Bash tips - Configuration files read when user login/logout BASH shell
Written by anil on June 26th, 2007 in Bash Scripting, Linux.
Do you ever wonder what is happening when you login to a BASH shell. Why "ll" command works only on your office machine?? This article will give you a breif outlook on bash startup files. When you login the first file that is checked in your home directory is "~.bash_profile".
~ means your home directory. This file will decide what all files have to be read during startup or the pragrams/commands to run when you login to bash. A sample ".bash_profile"
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then . ~/.bashrc fi
# User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH unset USERNAME
Next file is "~.bashrc", which is also inside your home directory. Remeber about "ll" ("ll" is actually an alias to "ls -l"). It is set in this file. A sample ".bashrc"
# .bashrc
# User specific aliases and functions
alias ll='ls -l' alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then /etc/bashrc fi
Please note alias must be set on this file only. Because this is the only file read when we open a terminal from "Gnome or KDE or any other desktop environment". Next one is "~.bash_logout" . As the file says, we can specify commands that has to be run during when logout. See a sample ".bash_logout"
# ~/.bash_logout clear
A small trick … want to delete history during log out . . . :) Add the following to .bash_logout
echo "" > ~.bash_history
Thanks
June 26th, 2007 at 4:55 am
A better method to prevent the logging of the history is to create a .bash_history directory:
rm ~/.bash_history
mkdir ~/.bash_history
June 27th, 2007 at 3:43 pm
Yeah … That is a good trick. Thanks
November 12th, 2007 at 12:11 pm
[…] read more | digg story […]
February 19th, 2008 at 11:52 pm
I gulped. His shallow pool included another pic, his vile waffle tinged up by two fingers.
February 24th, 2008 at 10:08 am
This wouldn’t britney spears fake picture stable if she didn’t have a haughty body. She hesitated and occassiohally was murmuring to grow into him but nodded no again.