Ravi, you need bash Beginner's Guide or Advanced Bash Scripting Guide found on
www.tldp.org
To run anything at log-in, edit your .bash_profile file found your home directory (the one that you are placed in when you log-in to your Unix/Linux system). Check it by issuing this command:
or
You should see files ending in "profile" beginning with ".". It could be .profile or .bash_profile or .sh_profile. Usually, it is your "profile" file that is executed whenever your log-in to your system. Similarly there is a .logout file whose function should be obvious now.
So, add this line at the end of your .profile file:
Code:
echo "Hello, ${USER}!"
and add these lines at the end of your .logout file:
Code:
echo "Bye, ${USER}!"
read -p "Press enter to log out..."
You can actually do more than that. Just keep your codes in a separate script file and then call it from within any of the above files:
A Note on the Variable: We
enclose the variable's name with
curly braces in case any other character or word is adjacent to it so that it is separately taken as a variable and not as a part of the other word. In the above case, we have separated the variable's name from the exclamation mark.
To check your home directory issue this command at the Command Prompt / Shell Prompt:
To directly get into your home directory, do this:
Yes, no
argument is supplied this time. $HOME is taken by default.