Linux add instructions to boot or add environment variables

Source: Internet
Author: User
Tags echo command

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.