4.6. Notes#

4.6.1. Adding directories to PATH#

The PATH variable stores the list of directories that will be searched to locate commands you type. If you have a command that is stored in a directory that is not on this list, you will need to add it to PATH.

You can display the current value of PATH using the echo command:

echo $PATH



To modify PATH and add a directory, you can follow the steps below. This example adds /home/user/.local/bin to PATH.


You will need to be careful while editing PATH.

You will also need to ensure that it includes $PATH in the list. Otherwise, you will not be able to access any commands!

  1. Open $HOME/.bashrc in a text editor.

  2. Add the following lines at the end of the file. Add the directory you wish to add separated by a colon. The list should end in $PATH.

    export PATH


    If a line with PATH exists already in the file, update it instead.

  3. Verify the change using echo:

    echo $PATH



When you log in again or open a new terminal session, commands in /home/user/.local/bin will be accessible.

4.6.2. Dealing with spaces in file names#

When you create a new file or directory, it is a good idea to not use spaces in the file or directory name. This is especially useful while working with these files or directories in the command-line. Instead, you can use an underscore (_) or hyphen (-) to separate words in file names.

If you do have to work with file or directory names containing spaces, you can use quotes around the file or directory name.

For example:

mkdir "Sample Data"

To change into the Sample Data directory, use:

cd "Sample Data"

Print current directory:



/home/user/Sample Data

This would have been simpler if the directory name is sample-data. You will not need to use quotes in that case.