View PATH: echo $ PATH and add mongodbserver as the column. Method 1: exportPATH =/usr/local/mongodb/bin: $ PATH // After configuration, you can view the configuration result through echo $ PATH. Effective method: effective immediately valid period: temporary change, only valid in the current terminal window, after the current window is closed, the original path configuration user restrictions will be restored: only for the current user
View PATH: echo $ PATH
Column to add mongodb server
Method 1:
Export PATH =/usr/local/mongodb/bin: $ PATH
// After configuration, you can view the configuration result through echo $ PATH.
Effective method: effective immediately
Validity period: temporary change. it can only be valid in the current terminal window. after the current window is closed, the original path configuration will be restored.
User restrictions: only for the current user
Method 2:
Modify the. bashrc file:
Vim ~ /. Bashrc
// Add the following to the last line:
Export PATH =/usr/local/mongodb/bin: $ PATH
Effective method: (two methods are available)
1. close the current terminal window and open a new terminal window to take effect.
2. enter "source ~ /. Bashrc "command, effective immediately
Validity period: permanently valid
User restrictions: only for the current user
Method 3:
Modify the profile file:
Vim/etc/profile
/Export PATH // find the row that sets PATH and add
Export PATH =/usr/local/mongodb/bin: $ PATH
Effective method: system restart
Validity period: permanently valid
User restrictions: for all users
Method 4:
Modify the environment file:
Vim/etc/environment
In PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: add ":/usr/local/mongodb/bin" to/usr/local/games"
Effective method: system restart
Validity period: permanently valid
User restrictions: for all users