Linux - Shell startup script

About

The shell startup script is a script that launch automatically after a shell connection and permit to store permanently the values of environment variables.

You can found them in two directory:

  • in the home user (~) for a user scope
  • in the /etc/ directory for a system scope. The /etc/ files contains system wide environment stuff and startup programs. All customizations that you put in this file will apply for the entire environment variable on your system.

It's not the same depending of your shell type:

  • for a Bash shell:
~/.bash_profile
  • for a Bourne or Korn shell:
~/.profile
/etc/profile
  • for a C shell (csh):
~/.login
/etc/csh.login

To determine your type of shell, refer to this article : Linux - Shell

To get a complete view of all shell configuration files → Configuration files for shells

Articles Related

Script scope

User Script to modify
One user ~/.bash_profile
All users except root /etc/profile
root /root/.bash_profile

How changes can take effect immediately?

You can then make the changes to .bash_profile take effect immediately by typing the following command:

source .bash_profile
  • By adding paths to your .bash_profile, you can place utilities and programs in your path and be able to execute them without having to type ./ in front of the command.
  • the source command and the point '.' are similar:
source ./.bash_profile

is the same as

. ./.bash_profile

How to edit it ?

To edit the bash_profile :

  • change to your home directory (ie: /home/myname)
  • edit the file. Example with gedit.
gedit .bash_profile
PATH=$PATH:$HOME/bin:/usr/kerberos/sbin:/usr/local/sbin:/sbin:/usr/sbin:/root/bin:

Note the fullstop before 'bash'. This '.' makes it a hidden file

  • Bookmark "Linux - Shell startup script" at del.icio.us
  • Bookmark "Linux - Shell startup script" at Digg
  • Bookmark "Linux - Shell startup script" at Ask
  • Bookmark "Linux - Shell startup script" at Google
  • Bookmark "Linux - Shell startup script" at StumbleUpon
  • Bookmark "Linux - Shell startup script" at Technorati
  • Bookmark "Linux - Shell startup script" at Live Bookmarks
  • Bookmark "Linux - Shell startup script" at Yahoo! Myweb
  • Bookmark "Linux - Shell startup script" at Facebook
  • Bookmark "Linux - Shell startup script" at Yahoo! Bookmarks
  • Bookmark "Linux - Shell startup script" at Twitter
  • Bookmark "Linux - Shell startup script" at myAOL
 
linux/shell_startup_script.txt · Last modified: 2010/07/23 16:18 by gerardnico