Chapter 1 - Advanced Shell Features
Chapter 1 - Advanced Shell Features
Code Meaning
\$ Show $ for ordinary user or # for root user
\u Show the user name
\h Show the host name
\W Show the working directory basename
History variables
• Several variables affect the way history is stored for the bash
shell:
Variable Effect
HISTFILESIZE Number of history entries to store in history file
HISTFILE Name of history file if different from ~/.bash_history
~/.bash_profile Each user has their own .bash_profile file in their home directory. The purpose for this file
is the same as the /etc/profile file, but having this file allows a user to customize the shell
to their own tastes. Normally used to create customized environment variables.
~./bashrc Each user has their own .bashrc file in their home directory. The purpose for this file is to
generate things that need to be created for each shell, such as local variables and
aliases.
/etc/bashrc This file may affect every user on the system. Only the administrator can modify this file.
Like the .bashrc file, the purpose for this file is to generate things that need to be created
for each shell, such as local variables and aliases.
Modifying Initialization Files
• Global initialization files are stored in • Local initialization files are stored in
the /etc/ directory and require the user's home directory ~, so a user
administrator privileges to modify may modify their own initialization
• A backup copy should be created files
before modifying any initialization file • Sourcing an initialization file executes
the file in the context of the user's
shell, and is a good way of testing.
• The command source and "." are
synonyms
Bash Exit Files
• Just as bash executes certain files when it starts up, bash will execute
certain files if they exist when you exit the shell
• If the .bash_logout file is located in the user's home directory, then it will be
executed upon logout
• The default ~/.bash_logout from CentOS 6.3 executes the clear command
to remove any text from the screen
• If the /etc/bash_logout file exists then it will also be executed upon logout
• The /etc/bash_logout file does not exist by default in CentOS 6.3