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
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- Perl sprintf: How do I use sprintf in a perl script?
- Environment variable changing on Linux/FreeBSD
- Shell command or script to write simple output on screen under Linux and UNIX
- FreeBSD Display Environment Settings
- How To Use Proxy Server To Access Internet at Shell Prompt With http_proxy Variable
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: bash_shell, echo_command, environment_variable, export_command, export_path, linux_file_systems, path_settings, printf_command



Recent Comments
Today ~ 1 Comment
Today ~ 3 Comments
Today ~ 57 Comments
Yesterday ~ 9 Comments
Yesterday ~ 7 Comments