In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to manage the environment of Shell". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to manage the environment of Shell.
Alias
An alias is a shortcut to a command. It is useful to create shortcuts for long commands that need to be executed frequently but take a long time to enter. The syntax is:
$alias yourAlias='complex command with arguments'
They are not always used to shorten long commands. The important thing is that you use them for tasks you often perform. Possible examples:
$alias dnfUpgrade='dnf-y upgrade'
In this way, in order to upgrade the system, I just need to enter dnfUpgrade instead of entering the full dnf command.
The problem with setting an alias in a terminal is that once the terminal session is closed, the alias is lost. To set them, use a resource file.
Resource file
Resource files (that is, rc files) are configuration files that are loaded at the beginning of a session or process (when each user opens a new terminal window or starts a new program such as vim). For ZSH, the resource file is .zshrc, and for bash, it is .bashrc.
To make aliases * aliases, you can put them in the resource file. You can use the text editor of your choice to edit the resource file. Vim is used here:
$vim $HOME/.zshrc
Or for bash:
$vim $HOME/.bashrc
Note that the location of the resource file is specified relative to the home directory. This is the location where ZSH (or bash) looks for the file by default for each user.
Another way is to put your configuration in any other file and read it:
$source / path/to/your/rc/file
Similarly, reading it directly in a session will only apply it to the session, so to make it * *, add the source command to the resource file. The advantage of putting a file in a different location is that you can read it at any time. This is useful in a shared environment.
Environment variable
Environment variables are values that are assigned a specific name, and you can call them in scripts and commands. They start with the dollar sign ($). The most common of these is $HOME, which points to the home directory.
As the name implies, environmental variables are part of your environment. Set the variable using the following syntax:
$http_proxy= "http://your.proxy"
To make it an environment variable, export it using the following command:
$export $http_proxy
To view all environment variables that are currently set, use the env command:
$env
This command outputs all variables available in the session. To demonstrate how to use them in commands, try running the following echo command:
$echo $PWD/home/fedora$ echo $USERfedora
Variable expansion occurs here, where the values stored in the variables are used in the command.
Another useful variable is $PATH, which defines the directory where shell looks for binaries.
$PATH variable
There are many directories or folders that are important to the operating system (how they are called in a graphical environment). Some directories are set to hold binaries that can be used directly in shell. These directories are defined in the $PATH variable.
$echo $PATH/usr/lib64/qt-3.3/bin:/usr/share/Modules/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/usr/libexec/sdcc:/usr/libexec/sdcc:/usr/bin:/bin:/sbin:/usr/sbin:/opt/FortiClient
This is helpful when you want to access your binaries (or scripts) in shell.
At this point, I believe you have a deeper understanding of "how to manage the environment of Shell". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.