4.6.1. Adding directories to PATH#
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
You can display the current value of
PATH using the
PATH and add a directory, you can follow the
steps below. This example adds
You will need to be careful while editing PATH.
You will also need to ensure that it includes
in the list. Otherwise, you will not be able to
access any commands!
$HOME/.bashrcin a text editor.
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=/home/user/.local/bin:$PATH export PATH
If a line with
PATHexists already in the file, update it instead.
Verify the change using
When you log in again or open a new terminal session,
/home/user/.local/bin will be
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.
mkdir "Sample Data"
To change into the
Sample Data directory, use:
cd "Sample Data"
Print current directory:
This would have been simpler if the directory name is
sample-data. You will not need to use quotes in that