≡ Menu

path settings

Linux: Change the PATH [ Add New Directory ]

How do I change the PATH settings under Linux operating systems and add a new directory to $PATH under bash shell?
[click to continue…]

How do I display my current path settings under Linux / FreeBSD / OpenBSD / NetBSD / Apple OS X / UNIX like operating systems using bash or ksh or csh / tcsh shell?
[click to continue…]

Ubuntu Set User Profile Under Bash Shell

How do I set user profile under bash shell running Ubuntu Linux operating systems?
[click to continue…]

How do I add a new path to $PATH variable under Linux and UNIX like operating system? What is my path, and how do I set or modify it using csh/tcsh or bash/ksh/sh shell?
[click to continue…]

Display or print UNIX / Linux path ~ $PATH variable

Q. How do I print current path settings under BASH shell? I’m using Debian Linux.

A. In UNIX / Linux file systems, the human-readable address of a resource is defined by PATH. On Unix / Linux like operating systems, (as well as on DOS / Windows and its descendants), PATH is an environment variable listing a set of paths to directories where executables may be found.

Display current PATH

Use echo command:
$ echo $PATH
Output:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games

Modify current PATH

Use export command to add /opt/games to PATH, enter:
export PATH=$PATH:/opt/games

To format your PATH variable for easy viewing, add following code to your bash startup file (such as ~/.bashrc or ~/.bash_profile) :

function path(){
    old=$IFS
    IFS=:
    printf "%s\n" $PATH
    IFS=$old
}

(Function credit: usenet archive)

Now just run path:
$ path
Output:

/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/bin/X11
/usr/games