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

What is the specific method of adding and deleting environment variables in Linux system?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article analyzes "what is the specific method of adding and deleting environment variables in Linux system". The content is detailed and easy to understand, "what are the specific methods of adding and deleting environmental variables in the Linux system?" interested friends can follow the editor's train of thought to read it slowly and deeply. I hope it will be helpful to everyone after reading. Let's follow the editor to learn more about "what is the specific method of adding and deleting Linux system environment variables".

Use the export command directly to view the PATH configuration, you can use the export command

Yao@ubuntu:~$ export declare-x HOME= "/ home/yao" declare-x LANG= "en_HK.UTF-8" declare-x LANGUAGE= "en_HK:en" declare-x LESSCLOSE= "/ usr/bin/lesspipe% s" declare-x LESSOPEN= "| / usr/bin/lesspipe% s" declare-x LOGNAME= "yao". Declare-x MAIL= "/ var/mail/yao" declare-x OLDPWD declare-x PATH= "/ usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin:/sbin" declare-x PWD= "/ home/yao" declare-x SHELL= "/ bin/bash" declare-x SHLVL= "1" declare-x TERM= "xterm-256color" declare-x USER= "yao" add path / sbin execution

Export PATH=$PATH:/sbin modifies the profile file vi / etc/profile to add it

Export PATH=$PATH:/sbin modifies the .bashrc file vi / root/.bashrc to add

Export PATH=$PATH:/sbin Note: $PATH:/sbin means to add the required path after the old path. If the file is modified to take effect immediately, you need to use the source command to source the file.

Delete a path straightforward method in PATH to directly override the PATH variable, you can first use the

Echo PATH displays the current PATH, copy

The clever method of export PATH= 's new path (remove the one to be deleted) I think the first method is a little too cumbersome, and for example, if you want to remove a path in the middle, you have to delete it and then copy it. You see a method introduced by the Great God using pipes and regular expressions.

Export PATH= `echo $PATH | sed-e's s/old word/new word/g':\ / root\ / bbb//g' `echo 's/old word/new word/g' to replace old word,new word with new word is deleted, / to be translated

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

On the Linux system environment variables to add and delete what is the specific method to share here, I hope that the above content can make you improve. If you want to learn more knowledge, please pay more attention to the editor's updates. Thank you for following the website!

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