Modify environment variable path in Linux

Source: Internet
Author: User

The value of path is a series of directories that Linux searches for when you run a program. You can see the value of path with the following command.

$ echo $PATH

For example, in a host, the user Yogin path value is:

/opt/kde/bin:/usr/local/bin:/bin:/usr/bin:/usr/x11r6/bin:/home/yogin/bin

where ":" is the separator. So, a list of directories above can be considered as the directory listing below.

/opt/kde/bin
/usr/local/bin
/bin:/usr/bin
/usr/X11R6/bin
/home/yogin/bin

Also, in the host, the path value for user root is:

/opt/kde/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/x11r6/bin:/root/bin

To modify the PATH value for all users, you can edit the/etc/profile file as root and modify the line that contains "path=".

For example, you can use the Pico Editor to open/etc/profile files.

$ pico-w/etc/profile

Pico is a text editor, and the-w option turns off long line wrapping functionality.

The new value for path will not take effect until the user registers again. If you only want to modify a user's path value, you should edit the. bash-profile file in the user's home directory.

If you want to add the current directory to the path, the. When you join the path, the path is set as follows:

Path= "$PATH:/usr/x11r6/bin:."

Export PATH

Note: After modifying the path value or any environment variable, export it with export and the new path value will not take effect.

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.