How do I change the PATH settings under Linux operating systems and add a new directory to $PATH under bash shell?
You can change your PATH by editing your ~/.bash_profile file or ~/.profile file under Linux operating systems for your own login session. Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following commands to edit ~/.bash_profile file:
vi ~/.bash_profile
To add /opt/apps and $HOME/bin/ directories to your PATH, append or modify the line starting with PATH:
export PATH=$PATH:/opt/apps:$HOME/bin
The ":" act as a separator to represent a list of directories. Save and close the file. Logout and login back to see your new path settings:
echo $PATH
Change the PATH For All Users On Linux
You can change the PATH for all users on the Linux system by editing the file /etc/profile file, enter:
# vi /etc/profile
To add /opt/apps directory to your PATH, append or modify the line starting with PATH as follows:
export PATH=$PATH:/opt/apps
Save and close the file.
- 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












{ 1 comment… read it below or add one }
No need to logout and login to check the details. `source ~/.bash_profile` and try `echo $PATH`