The PATH variable is an environment variable in Linux that holds a list of directories where the system searches for files. When a command is entered in the terminal, the system scans these directories in the order they are listed, attempting to locate the corresponding file.
To view your current PATH configuration, simply open a terminal and type:
echo $PATH
This command will display a colon-separated list of directories.
Modifying the PATH Variable:
1. Temporary Modification:
- You can temporarily modify the PATH variable for your current session using the
exportcommand. For example:bashCopy codeexport PATH=$PATH:/path/to/your/directoryThis appends the specified directory to the existing PATH.
2. Permanent Modification:
- For a permanent change, you can add the export statement to your shell configuration file (e.g.,
.bashrcfor Bash) echo 'export PATH=$PATH:/path/to/your/directory' >> ~/.bashrc- Remember to restart your terminal or use the
sourcecommand to apply the changes.