How to view and modify the environment variable PATH under linux

View PATH: echo $PATH
to add mongodb server as a column.
Modification method one:
export PATH=/usr/local/mongodb/bin:$PATH
//After configuration, you can view the configuration result through echo $PATH.
Effective method: effective immediately Effective
period: temporary change, only effective in the current terminal window, the original path configuration will be restored after the current window is closed
User limitation: only for the current user

Modification method 2:
By modifying the .bashrc file:
vim ~/.bashrc
// Add in the last line:
export PATH=/usr/local/mongodb/bin:$PATH
Effective method: (there are the following two)
1. Close the current terminal Window, reopen a new terminal window to take effect
2. Enter the "source ~/.bashrc" command to take effect immediately.
Validity period: Permanently valid
User limitation: Only for the current user

Modification method 3:
by modifying the profile file:
vim /etc/profile
/export PATH //Find the line that sets the PATH, and add
export PATH=/usr/local/mongodb/bin:$PATH
Effective method: system restart
Effective period: permanent effective
User limitations: for all users

Modification method 4:
by modifying the environment file:
vim /etc/environment
in PATH=``/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr Add ":/usr/local/mongodb/bin" to "/games:/usr/local/games"
Effective method: system restart
Validity period: permanent validity
User limitation: for all users

Guess you like

Origin blog.csdn.net/vcj1009784814/article/details/109025182