1 min read 275 words Updated May 09, 2026 Created May 09, 2026
#cli#linux

Bash

The infamous Bash shell (bourne again shell) is the typical default command shell on Linux systems.

You can read up on how bash works using man bash

A great online reference for the set options (i.e. Built-in) can be found at
https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html

Tips

Here is a tip. Bash will read different rc files on starting based on whether or not it is a "login" shell.

The difference is evident in the following example:

ssh host
(a login shell is created i.e. /bin/bash -l)
-vs-
ssh host "echo true"
(instead of executing a login shell the command echo true runs instead)

The first example (login shell) will read from /etc/profile then ~/.bash_profile for startup commands.

The second example will read from /etc/bash.bashrc then ~/.bashrc for startup commands.

weird, right?

So, long story short, I tend to put my commands in ~/.bashrc and source it from ~/.bash_profile

~$ cat ~/.bash\_profile

# Since .bashrc is not read when login over ssh we need this
if \[ -f ~/.bashrc \]; then
  . ~/.bashrc
fi

ssh-agent

To get ssh-agent started cleanly on login, use a stanza like this in your .bashrc

SSH_ENV="$HOME/.ssh/environment"

function start_agent {
     echo "Initialising new SSH agent..."
     /usr/bin/ssh-agent > "${SSH_ENV}"
     chmod 600 "${SSH_ENV}"
     . "${SSH_ENV}" > /dev/null
     /usr/bin/ssh-add;
}

# Source SSH settings, if applicable


if [ -f "${SSH_ENV}" ]; then
     . "${SSH_ENV}" > /dev/null
     
     ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
         start_agent;
     }
else
     start_agent;
fi

sh vs. bash vs. dash

You might think sh->bash but it (sometimes) links to dash. Be careful invoking /bin/sh in shell scripts that need bash functionality.