PATH is an environment variable that is a list of directories that the operating system looks in to find commands issued by the user. For example, when you type ls to list files, you are actually executing /bin/ls because the /bin directory is in your path by default. There may be times when you will want to add a new location to PATH, whether temporarily or permanently.
The PATH environment variable
When you type a command, the system searches in all the directories listed in the PATH environment variable. Many executable files, for instance, are stored in /usr/bin, which is one of the locations specified by default in MX Linux and most other Linux distros. The others are /bin, /usr/local/bin, /usr/games and /usr/local/games.
To see which directories are specified on your system, open a terminal and type:
If you need to add a different directory, then you have two choices: 1) create a new path, or 2) make a symlink between the directory and one of the existing path locations.
To add a new path to a directory, open a terminal and type
PATH=$PATH:/path/to/new/directory export PATH
This change is temporary, and only commands typed in this particular terminal window are affected. For permanent change, add these commands to your ~/.bashrc file (if it doesn’t exist, use Leafpad or another text editor to create it).
For more complicated situations, see link below.
To display location of user paths:
cat /etc/profile |grep -i "PATH"
Root and regular users have different locations that can be specified as follows:
if [ "`id -u`" -eq 0 ]; then PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" else PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games" fi
An UID of 0 is the root user therefore the first PATH that matches UID = 0 is the path for the root user and the PATH in ELSE is for everyone else / regular users. The overriding user preference file is ~/.profile. There you can put your own PATH= for each user. This also can be overridden / added to via bashrc (/etc/bash.bashrc original / ~/.bashrc user preference).