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
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop




![Linux: Change the PATH [ Add New Directory ]](http://s13.cyberciti.org/images/shared/rp/3/19.jpg)







{ 4 comments… read them below or add one }
slight improvement:
path ()
{
local IFS=:
eval printf "%s\\\n" \$${1:-PATH}
}
accepts an optional argument that is the name of a path-like variable.
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?
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..
In below code:
Node=/liferay-portal-5.2.0/jboss-tomcat-4.2.3/server/node_portal
export jboss=$Node/../..
echo $jboss
Output :
/liferay-portal-5.2.0/jboss-tomcat-4.2.3/server/node_portal/../..
But I need Output as :
/liferay-portal-5.2.0/jboss-tomcat-4.2.3.
Please help me out in this.