Centos Bash Shell Scripts

From rbachwiki
Revision as of 20:44, 7 March 2019 by Bacchas (talk | contribs)
Jump to navigation Jump to search

List Environment Variables

set
# you can | to grep to filter
or
env

Environmental Files

Files that execute each time a user logs in to bash shell

/etc/profile 
/etc/bashrc 
~/.bashrc 
~/.bash_profile 
~/.bash_login 
~/.profile

The BASH runtime configuration files (/etc/bashrc and ~/.bashrc) are typically used to set aliases and variables that must be present in the BASH shell. They are executed immediately after a new login as well as when a new BASH shell is created after login. The /etc/bashrc file contains aliases and variables for all users on the system, whereas the ~/.bashrc file contains aliases and variables for a specific user.
The other environment files are only executed after a new login. The /etc/profile file is exe- cuted after login for all users on the system and sets most environment variables, such as HOME and PATH. After /etc/profile finishes executing, the home directory of the user is searched for the hidden environment files. bash_profile, .bash_login, and .profile. If these files exist, the first one found is executed; as a result, only one of these files is typically used. These hidden environment files allow a user to set customized variables independent of BASH shells used by other users on the system; any values assigned to variables in these files override those set in /etc/profile, /etc/bashrc, and ~/.bashrc due to the order of execution

Structure of a bash Script

#!/bin/bash
Escape Sequence