Take the MongoDB Run command as an example,/usr/local/webserver/mongodb/bin/mongo
1,linux adding directives to the environment variable path
Simply put, path is a string variable of a set of paths, and when you enter a command with no path, Linux looks for the command in the path of a path record. Some words are executed, and there is no hint that the command cannot be found. For example, in the root directory/below you can enter the command LS, in the/usr directory can also input LS, but in fact, ls command is not in this two directory, when you enter the LS command, Linux will go to/bin,/usr/bin,/sbin and other directories to look for the command. The path is a variable that defines the/bin:/sbin:/usr/bin and so on, where the colon is the separator between the directories. Add an instruction mode to the environment variable:
(1) Set path directly on the command line, this method is valid for the current method, shutdown or logoff after failure.
Path= $PATH:/usr/local/webserver/mongodb/bin
See if a directive joins an environment variable, using the Echo command.
Echo $PATH
(2) Add path to profile, this method is permanent for all users.
A) Open the profile file
Vim/etc/profile
b) Add the MONGO directive to the path of the profile file. Add ":/usr/local/webserver/mongo/bin" after path, = cannot have any spaces on either side of the equal sign.
Path= $PATH:/usr/local/webserver/mongo/bin
c) Execute the instructions so that the profile changes take effect immediately.
Source Profile
(3) Add path to the current profile, which is permanently valid for the current user. Similar to the second step, replace the profile with Bash_profile.
Vim ~/.bash_profile
Path= $PATH:/usr/local/webserver/mongo/bin
SOURCE ~/.bash_profile
2,linux add command to boot
Linux add instructions to boot or add environment variables