Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to modify the environment variable PATH in Linux system

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to modify the environment variable PATH in the Linux system, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

To check the user's environment variables, run the following command in user mode:

$echo $PATH

/ usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/sbin:/sbin:/home/xmodulo/bin

Or run:

$env | grep PATH

PATH=/usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/sbin:/sbin:/home/xmodulo/bin

If your command does not exist in any of the above directories, shell will throw an error message: "command not found".

If you want to add another directory (for example: / usr/local/bin) to your PATH variable, you can use the following commands.

Modify the PATH environment variable for a specific user

If you only want to temporarily add a new directory (e.g. / usr/local/bin) to the user's default search path in the current login session, you only need to enter the following command.

$PATH=$PATH:/usr/local/bin

Check to see if PATH has been updated:

$echo $PATH

/ usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/sbin:/sbin:/home/xmodulo/bin:/usr/local/bin

The updated PATH will remain valid for the current session. However, the changes will expire in the new session.

If you want to change the PATH variable permanently, open ~ / .bashrc (or ~ / .bash_profile) with an editor, and then add the following line at the end.

Export PATH=$PATH:/usr/local/bin

Then run the following line of permanent activation changes:

$source ~ / .bashrc (or source ~ / .bash_profile)

Change system-level environment variables

If you want to permanently add / usr/local/bin to the system-level PATH variable, edit / etc/profile as follows.

$sudo vi / etc/profile

Export PATH=$PATH:/usr/local/bin

When you log back in, the updated environment variables will take effect.

The above is how to modify the environment variable PATH in the Linux system. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report