Startup scripts
Jump to navigation
Jump to search
← The tilde expansion • Home • Using aliases →
If you'd like to set the bash environment variables permanently, add your settings to the initialization file located in the home directory of your account $HOME/.bash_profile.
Script Execution Order
- /etc/profile - It contains Linux system wide environment and startup programs. This file runs first when a user logs in to the system. This file also act as a system-wide profile file for the bash shell.
- /etc/profile.d - /etc/profile calls /etc/profile.d/. It is a directory and all scripts in this directory are called by /etc/profile using a for loop. This file runs second when a user logs in.
- ~/.bash_profile or $HOME/.bash_profile - Finally, the file ~/.bash_profile is called in the users home directory ($HOME). This file runs third when a user logs in. This file calls ~/.bashrc in the users home directory.
Please note that each script can add or undo changes made in previously called script. For example, the PS1 variable is set in the /etc/profile, but it can be modified in the ~/.bash_profile or ~/.bashrc file.
Usage
- Use above files to customize your environment.
- Typical examples:
- Set PATH and PS1 (shell prompt) variables.
- Set default printer via PRINTER variable.
- Set default text editor via EDITOR variable.
- Set default pager via PAGER variable.
- Set default umask (file mode creation mask).
- Override and remove unwanted settings such as variables or aliases (undo changes).
- Set up environment.
- Set up aliases.
- Set up functions.
How do I view dot (.) files?
Type the following command in your $HOME directory:
ls -a
OR
ls -A | less
Sample outputs:
.bash_logout .bash_profile .bashrc domain-check-2.txt .mozilla safe s.img test12 test1.csv .zshrc
To view contains of the file, enter:
cat .bash_profile
OR
cat $HOME/.bash_profile
OR
cat ~/.bash_profile
See also