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 add PATH environment variables under Linux

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly shows you "how to add PATH environment variables under Linux", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to add PATH environment variables under Linux" this article.

The function of the PATH environment variable is to specify the command search path. When executing commands such as javac to compile the java program under the I command line, it will look in the path specified by the PATH variable to see if the corresponding command program can be found. We need to add the bin directory under the jdk installation directory to the existing PATH variable. The bin directory contains frequently used executable files such as javac/java/javadoc wait. After setting the PATH variable, you can execute tools such as javac/java in any directory.

When you execute a command under the linux command line, first make sure that the command exists, if so, but still prompt when entering the command: command not found

At this point, check the setting of the PATH environment variable and whether the current command exists in the PATH environment variable.

# View PATH:echo $PATH

For example, the command composr is / usr/loca/bin

But when executing, the hint is:

-bash: composr: command not found

At this time, through echo $PATH, it is found that composer is not set in the PATH environment variable. At this time, you need to add the path where composer is located to PATH.

Therefore, you need to modify the PATH environment variable, as follows:

Method 1: after export PATH=/usr/local/bin:$PATH# is configured, you can view the configuration result through echo $PATH. # effective method: effective immediately # validity period: temporary changes can only be effective in the current terminal window. After the current window is closed, it will restore the existing path configuration # user limitations: only for the current user method 2: by modifying the .bashrc file: vim ~ / .bashrc # add on the last line: export PATH=/usr/local/bin:$PATH# effective method: (there are two following) # 1, close the current terminal window Re-open a new terminal window to take effect # 2. Enter the "source ~ / .bashrc" command Effective immediately # validity period: permanent validity # user limitation: method 3 for current users only: # by modifying profile file: vim / etc/profileexport PATH=/usr/local/bin:$PATH# effective method: system restart # validity period: permanent validity # user limitation: method 4 for all users: # by modifying environment file: vim / etc/environment in PATH= "/ usr/local/sbin:/usr/sbin:/usr/ Add ": / usr/local/bin" to bin:/sbin:/bin # effective method: system restart # validity period: permanent validity # user limitation: for all users, the above is all the contents of the article "how to add PATH environment variables under Linux" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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

Development

Wechat

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

12
Report