Display or print UNIX / Linux path ~ $PATH variable

I am a new Linux or Unix system user and I am using a Debian Linux VPS. How do I print current path settings under BASH or sh or ksh shell?

In Linux or Unix-like file systems, the human-readable address of a resource is defined by PATH shell variable. 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 executable may be found. This page explains how to print path variable using various commands under Linux and Unix-like systems.
Tutorial details
Difficulty level Easy
Root privileges No
Requirements Linux, Unix, or macOS terminal app
Est. reading time 2 minutes

Display current PATH in Linux

Use the echo command as follows:
echo "$PATH"
Here is my settings from Debian Linux system:


You can use the printf command as well to show the current PATH settings:
$ printf "%s\n" $PATH
Here is my settings from macOS/macOS X Unix desktop:


To get human-readable format, try the echo command with Bash parameter substitution:
echo "${PATH//:/$'\n'}"


What is a PATH in Linux or Unix?

A PATH is nothing but the search path for commands. It is a colon-separated list of directories in which the shell looks for commands.

How to modify current PATH

Use the 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(){
    printf "%s\n" $PATH

Now just run path:
$ path
Here is what I see on CentOS/RHEL/Fedora Linux:


Another option is to run the following command:
echo "$PATH" | tr ":" "\n" | nl

Fig.01: Printing $PATH on Linux or Unix-like system

Summing up

The default shell path ($PATH variable) is system-dependent, and is set by the administrator who installs bash or ksh or any other shell. However, developers and other Linux and Unix system users can set up their own path using the export command under bash/sh/ksh.

Setting up PATH permanently

Users can edit the ~/.bashrc or ~~/.bash_profile or ~/.profile to set up their path as follows for bash:

# set up dart lang path #
echo 'export PATH="$PATH:/usr/local/dart/bin"' >> ~/.bash_profile

Printing PATH in Linux or Unix

Now run:
echo "$PATH"
printf "%s\n", $PATH

How to Checking Path in Unix and Linux

We explained how to print PATH variable on Linux, macOS, and Unix-like systems using command-line. Please see your shell man page/documentation by using the man command:
man bash
man ksh
man sh
man tcsh
help export

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 10 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
10 comments… add one
  • anon Oct 31, 2010 @ 2:50

    slight improvement:

    path ()
    local IFS=:
    eval printf "%s\\\n" \$${1:-PATH}

    accepts an optional argument that is the name of a path-like variable.

    • Pekka R Mar 6, 2014 @ 12:25

      I did not get either of those path() working. I assume my version of unix does not recognize IFS when applying printf. But this works:

      echo $PATH | sed 's/\:/\n/g' | sort

      • Dan R Aug 5, 2014 @ 21:08

        Thanks for that, Pekka. I started using zsh, which has the same problem you described. The original solution works wonderfully in bash, but yours works in zsh.

      • Joe Sep 2, 2016 @ 15:42

        Ugghh curly quotes. Could not copy and paste.

        I am using Zshell, Prezto, OSX. The sed command replaces the : with an n

        To get one path per line I used:

        echo “${PATH//:/$’\n’}”

  • Jamal A Talla Nov 21, 2010 @ 10:11

    Hello Sir;
    I am trying to run a program on a cluster and every time I run the program I have this message: mpiexec was unable to launch the specified application as it could not find an executable. ”
    so I am suggesting that the program is not recognize the mpixec path. so I need to add the MPI path in my working directory.
    my question is how to set this up?

  • ana Nov 12, 2011 @ 16:09

    hola necesito decargar un editor ok lo descargo en superusuario y cuando esta descargando me dice q no puede continuar … me aparece esto : dpkg: aviso: `ldconfig’ no se ha encontrado en el PATH o no es ejecutable.
    dpkg: aviso: `start-stop-daemon’ no se ha encontrado en el PATH o no es ejecutable.
    dpkg: error: 2 expected programs not found in PATH or not executable.
    Note: root’s PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin.
    E: Sub-process /usr/bin/dpkg returned an error code (2)
    Un paquete no se pudo instalar. Tratando de recuperarlo:
    dpkg: aviso: `ldconfig’ no se ha encontrado en el PATH o no es ejecutable.
    dpkg: aviso: `start-stop-daemon’ no se ha encontrado en el PATH o no es ejecutable.
    dpkg: error: 2 expected programs not found in PATH or not executable.
    Note: root’s PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin.
    help me..

  • Kapil May 8, 2012 @ 14:52

    In below code:
    export jboss=$Node/../..
    echo $jboss

    Output :


    But I need Output as :


    Please help me out in this.

  • Elaine Oct 21, 2016 @ 11:24

    How can I make PATH easily to view when I just execute the script? Thanks

  • Peter Jun 17, 2021 @ 22:17

    You can search/replace within variables as you expand them.
    The following replaces ‘:’ with newlines while expanding $PATH, so it’s done without using external commands:

    echo "${PATH//:/$'\n'}"

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum