Whats the profile file that is auto executed when I login


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Whats the profile file that is auto executed when I login
# 1  
Old 11-23-2016
Hammer & Screwdriver Whats the profile file that is auto executed when I login

Hi,

I dont find any .profile under my user home directory.

These are the only files i see in my home directory.

Code:
[root@mymac user1]# ls -laq
total 44
drwx------   4 user1 adm 4096 Nov 23 05:10 .
drwxr-xr-x. 12 root     root   4096 Nov 22 13:05 ..
-rw-r--r--   1 user1 adm   18 Nov 22 13:05 .bash_logout
-rw-r--r--   1 user1 adm  193 Nov 22 13:05 .bash_profile
-rw-r--r--   1 user1 adm  231 Nov 22 13:05 .bashrc
drwxr-xr-x   3 user1 adm   17 Nov 22 13:05 .cache
drwxr-xr-x   3 user1 adm   17 Nov 22 13:05 .config
-rw-------   1 user1 adm   46 Nov 22 13:05 .k5login
-rw-r--r--   1 user1  adm  172 Nov 22 13:05 .kshrc
-rw-------   1 user1 adm    8 Nov 23 07:36 .sh_history

Code:
uname -a
Linux mymac 3.10.0-327.36.1.el7.x86_64 #1 SMP Wed Aug 17 03:02:37 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux

Can you please tell me which is the file that gets executed first automatically as soon as i login to the machine using ssh / putty ?
# 2  
Old 11-23-2016
That highly depends on the shell that you use and which you fail to mention. Should that be bash, read man bash:


Quote:
INVOCATION
.
.
.
The following paragraphs describe how bash executes its startup files.
.
.
.
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.
.
.
.
When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist. This may be
inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc.

When bash is started non-interactively, to run a shell script, for example, it looks for the variable BASH_ENV in the environment, expands its value if it appears
there, and uses the expanded value as the name of a file to read and execute. Bash behaves as if the following command were executed:
if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
but the value of the PATH variable is not used to search for the filename.

If bash is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible, while conforming to the POSIX standard as well. When invoked as an interactive login shell, or a non-interactive shell with the --login option, it first attempts to read and execute commands from /etc/profile and ~/.profile, in that order. The --noprofile option may be used to inhibit this behavior. When invoked as an interactive shell with the name sh, bash looks for the variable ENV, expands its value if it is defined, and uses the expanded value as the name of a file to read and execute. Since a shell invoked as sh does not attempt to read and execute commands from any other startup files, the --rcfile option has no effect. A non-interactive shell invoked with the name sh does not attempt to read any other startup files. When invoked as sh, bash enters posix mode after the startup files are read.
.
.
.
Bash attempts to determine when it is being run with its standard input connected to a network connection, as when executed by the remote shell daemon, usually rshd, or the secure shell daemon sshd. If bash determines it is being run in this fashion, it reads and executes commands from ~/.bashrc and ~/.bashrc, if these files exist and are readable. It will not do this if invoked as sh. The --norc option may be used to inhibit this behavior, and the --rcfile option may be used to force another file to be read, but neither rshd nor sshd generally invoke the shell with those options or allow them to be specified.

Last edited by RudiC; 11-23-2016 at 10:10 AM..
# 3  
Old 11-23-2016
Quote:
Originally Posted by RudiC
That highly depends on the shell that you use and which you fail to mention. Should that be bash, read man bash:
Like i said in the op i jump from a different server onto this one using ssh.

Will the shell of the server i m jumping from also apply to this server i m login into ? If so, i m not using any shell explicitly ... so i believe it is C shell.

So, the question is what is the profile that will be executed if i m jumping from a different box which has C-shell.

Last edited by mohtashims; 11-23-2016 at 10:03 AM..
# 4  
Old 11-23-2016
man csh ?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Auto transfer all aliases from one profile to another

Hi, I login to Linux and Solaris server using my personal user account "ms1104" . I have several aliases set in my profile. Later i need to switch to another user account i.e. "wlsuser" and below is the command i use sudo -u wlsuser -s -H i do not have authority to modify the... (1 Reply)
Discussion started by: mohtashims
1 Replies

2. HP-UX

/etc/profile file not executed

Hi Experts, On one of hp-ux box I have writen the code to disable the direct login for some of the users in /etc/profile file. However when logging into terminal seems /etc/profile is not executed and users are still able to directly login into the terminal. Default shell for user is... (3 Replies)
Discussion started by: sai_2507
3 Replies

3. Shell Programming and Scripting

Users who desire to have their .profile executed must explicitly do so in the crontab entry. Why?

The .profile file should be read when the user logs in. So, there should be no need to execute .profile file again in a cron job (since the cron job is run after the user logs in). Doesn't the cron require login from the user. Then, from where does the cron execute? Please help!! (1 Reply)
Discussion started by: thulasidharan2k
1 Replies

4. Solaris

Auto login with SFTP

Hi All, How do you get around SFTP not having the 'cat' command to set up scripts to run cron jobs for passwords? I am use to the FTP allowing that, but we are converting to SFTP and need to be able to still run the same scripts in off hrs. Is there a way to still cat the password at the prompt... (14 Replies)
Discussion started by: wsiefkas
14 Replies

5. HP-UX

Auto X when Login

Hi All, We have some HP unix servers and sometimes we logon there thru a dedicated Windows server that has Reflection X on it in case we need X. In this case we always need to export DISPLAY=winservername:0.0 I want to automate this thing in .profile file. If e.g. $TERM = hpterm (thru... (2 Replies)
Discussion started by: BearCheese
2 Replies

6. Shell Programming and Scripting

Can I modify the .bashrc file instead of .profile file to customize my login?

Hello, I got this question which tells me to customize my login script. Some people in the forums suggested to modify the .profile file in my home directory. I did so, but none of my customizations show up when I open the terminal after. So, I tried to modify other files in my home directory,... (1 Reply)
Discussion started by: Hyunkel
1 Replies

7. UNIX for Dummies Questions & Answers

Auto Login

Hey all, I'm trying to configure a system so when it reboots it'll automatically log as a user I have selected. I've never done this nor' as I to sure on how to. This is teh best I have found on teh web and well I've changed a few things. but does anyone who has done this know if it'll work... (1 Reply)
Discussion started by: merlin
1 Replies

8. UNIX for Dummies Questions & Answers

why i have local.profile, local.cshrc,local.login instead of .profile, .login ?

Hello again ! Thanks for response of my first question. there is my second quesiton why i have local.profile instead of .profile file ? my all files in pwd shoes local. before any file. is anybody can tell me about that ? Thanks Abid Malik (5 Replies)
Discussion started by: abidmalik
5 Replies

9. UNIX for Dummies Questions & Answers

Auto login?

Ok I've lost myself and hit a brick wall. What I am trying to do is avoid the login screen when the machine is turned on. So no login screen is needed unless you turn the machine on and log out to login and change users. But as I said before I've hit a brick wall. I got not an idea of what I... (4 Replies)
Discussion started by: merlin
4 Replies
Login or Register to Ask a Question