How to set environment variables under Linux

Source: Internet
Author: User

If you install a software, after installation, enter the command, prompt "command not found", which involves the environment variable path problem. The path setting is a component of the custom environment variable under Linux.

Each user in Linux has a dedicated runtime environment, which is defined as a set of environment variables that users can customize to their own environment. The environment is closely related to the shell, and the user logs into the system and starts a shell, typically Bash,bash has two system-level profiles,/ETC/BASHRC and/etc/profile.

1, ECHO displays environment variables.

Echo $HOME #环境变量一般是大写

2,export Setting an environment variable

Export Myname=cmiao #这个环境变量是暂时的, after you launch the shell, it disappears.

3, modify an environment variable

Myname=miaoc

4, Show all environment variables

Env

5, use the SET command to display all locally defined shell variables.

Set

6, use unset to clear environment variables

Unset MYNAME

7. Modify environment variables by modifying the environment variable definition file

In your own home directory, execute VI. bash_profile

For example, edit your path declaration, path= $PAEH:<path1>:<path2>:<path3>:<path4> each path with: Separate, save and close.

Executes the source. Bash_profile

Use the Echo $PATH to view the current search path. As long as your command is in this path, it can be searched.

Variables modified by modifying the configuration file are permanent, while the variables declared with export are temporary and expire when the shell is closed.

Modify/etc/profile, Source/etc/profile. Valid for all users.

Modify. Bash_profile in the personal directory is valid only for the current user.

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.