Page Body


The Command Prompt

The command line prompt is represented by the # or $ symbol. A command with a # means that you must run it as the root user. A command with a $ or no symbol for the prompt means that you can run the command as a non-root user.

To help distinguish between commands and command output, multi-line code block commands will contain a symbol for the command line prompt, when necessary. To distinguish between command line commands and internal program commands (e.g., a command used within a program like vim), a symbol will be used for the command line prompt, as well.

When copying commands, do not include the command line prompt symbol.


Code samples may contain phrases with the word example in them. These phrases are placeholders for command arguments. You will need to replace these phrases with the actual values you would like to use as arguments for the commands.

Running Bash Scripts

If you see a bash script on this site that you want to utilize, copy the script content and save it to a text file on your system. Saving scripts to a Scripts directory in your user's home directory is a common practice, but you should choose what works best for you. To view your user's home directory, run the following command:

echo "${HOME}"

${HOME} is a variable that will expand to your user's home directory before the command executes.

The script file name can be arbitrary, but it is probably best to select something that reflects the script's purpose and is easy to remember. Give the script file name a .bash extension.

To ensure that you can easily run the script by entering its file name at the command prompt, you will need to make the script file executable. You can do this with the chmod command. For example, if the script is called example.bash and is stored in a Scripts directory within your home directory, you can make the script executable by running:

chmod 700 "${HOME}/Scripts/example.bash"

Also, you will need to make sure that the location of your Scripts directory is a part of your shell's PATH variable. You can see the current value of your shell's PATH the same way you viewed your system's home directory, e.g., echo "${PATH}".

${PATH} is a variable that contains the colon-delimited list of directories that your shell uses to search for programs/scripts.

Often, the PATH variable is defined via the .profile file in your user's home directory. You can add your Scripts directory to PATH by appending a line that redefines the PATH variable to the .profile file. For example:

$ {
  echo ''
  echo '# Set PATH variable with custom locations'
  echo 'export PATH="${PATH}:${HOME}/Scripts"'
} >> "${HOME}/.profile"

Finally, reload the .profile file into your shell's current configuration with the source command:

source "${HOME}/.profile"

Now, you should be able to run the script above at the command line by entering example.bash, regardless of where you are in your system's file system hierarchy.