For the Unix and Linux beginners: How to display the common PATH-like environment variables

A regular Linux and Unix user should know how to use the PATH, CDPATH, MANPATH and HOME environment variables, in the bash shell.

With the PATH and the CDPATH set in the right way, you can easily use your commands and scripts.

Display the PATH and CDPATH with echo, like any other variable:

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

$ echo $CDPATH
/home/razvan/scripts:/home/razvan/work

The MANPATH is used by the Linux and Unix manual (man).

Display the MANPATH:

$ manpath -g
/usr/man:/usr/share/man:/usr/local/man:/usr/local/share/man:/usr/X11R6/man:/opt/man

The HOME is not PATH-like, but it is often used in shell scripts, and it is the same as tilde ~, expanding in the user’s homedir.

$ echo $HOME
/home/razvan

You can see a list of the most common PATH-like variables here.

Tagged with: , , , , , , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Subscribe

  

Subscribe to get the latest Linux news and how to guides directly on your e-mail!