BASH - Shell
Overview
The BASH (Bash, bash) or Bourne-Again SHell is the default shell on ARCC HPC resources. The bash shell is very robust, well documented, and full-featured. Bash can be a little uneasy for those unfamiliar with the shell. This page contains some external links and quick information for the ARCC HPC installed versions such as startup files and basic features. ARCC recommends the use of bash as that is the default shell across many Linux, BSD, and macOS systems. For detailed information, consult the man page for the bash command.
Startup / Exit Files
The bash shell has access to many startup files, but only some are read based on the method that the terminal is invoked. Prefixes below with a ~ represent the $HOME directory.
File | Order | Which Shell Type | Notes |
---|---|---|---|
~/.bash_profile | 1 | Interactive login shell | Red Hat Note |
~/.bash_login | 2 | Interactive login shell | Doesn't exists usually |
~/.profile | 3 | Interactive login shell | More used when sh invoked |
~/.bashrc | 1 | Interactive shell | Red Hat Note |
Red Hat Note - Red Hat implementation: ~/.bash_profile sources ~/.bashrc which then sources /etc/bashrc. From this logic, it is wise to make edits to the ~/.bashrc file and make sure to not remove the portion that sources the /etc/bashrc.
Environment Variables
Environment variables contain information about your login session, stored for the system shell to use when executing commands. They exist whether you're using Linux, Mac, or Windows. Many of these variables are set by default during installation or user creation.
Aliases
A Bash alias is essentially nothing more than a keyboard shortcut, an abbreviation, a means of avoiding typing a long command sequence. If, for example, we include alias lm="ls -l | more" in the ~/.bashrc
file, then each lm
[1] typed at the command-line will automatically be replaced by a ls -l | more. This can save a great deal of typing at the command-line and avoid having to remember complex combinations of commands and options. Setting alias rm="rm -i" (interactive mode delete) may save a good deal of grief, since it can prevent inadvertently deleting important files.