Significance of PATH variable in Linux

It defines the order of directories which the computer will search for programs to execute. This is important when you have installed a program in a non-standard place, or when multiple versions of a program with the same name exist. For example, suppose you have two different versions of Git installed on your machine in /usr/bin/git and /usr/local/bin/git . If you don’t specify the full pathname on the command line and simply type in git , the OS uses the PATH to determine which one you mean.

$ echo $PATH

PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

This is a colon-delimited list of directory names. It means the OS will search directories for programs in the following precedence order:

• /usr/local/sbin

• /usr/local/bin

• /usr/sbin

• /usr/bin

• /sbin

• /bin

 

Note: This will be the default path in all the system.

Reason:

 

/bin This is used for trivial binaries used in the very early boot stage or ones that you need to have available in booting single-user mode
/sbin Same, but for scripts with superuser (root) privileges required.
/usr/bin Same as first, but for general system-wide binaries.
/usr/sbin Same as above, but for scripts with superuser (root) privileges required.
/usr/local/bin system-wide available scripts
/usr/local/sbin Same as above with super user privileges.

 

/usr/local   – Tertiary hierarchy for local data, specific to this host.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s