In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "what is the use of alias command under Linux". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "what is the use of alias command under Linux" can help you solve the problem.
The alias command is an alias for setting instructions. Users can use alias to customize the alias of the directive. The syntax of the command is "alias [alias] = [instruction name]". If no parameters are added, all current alias settings will be listed.
In general, the alias command is suitable for the following scenarios:
Simplify excessively long and overly complex commands remember complex names commands that you use frequently to save time on how to create alias
For example, set an alias to list all files, including hidden files, alias la:
[root@server1 ~] # alias la='ls-al'
Execute the alias la and take a look:
[root@server1] # latotal 68drmuri XR Murray Murray. 3 root root 216May 25 13:13. Drwxr-xr-x. 19 root root 271 May 7 15:12.-rw-. 1 root root 1178 Dec 29 2019 anaconda-ks.cfg-rw-. 1 root root 14798 May 20 01:48 .bash _ history-rw-r--r--. 1 root root 18 May 11 2019 .bash _ logout-rw-r--r--. 1 root root 176 May 11 2019 .bash _ profile-rw-r--r--. 1 root root 17 May 11 2019. Bashrcdrwx-3 root root 17 Mar 11 11:17. Cache-rw-r--r--. 1 root root 100 May 11 2019. Cshrc-rw- 1 root root 64 May 25 13:13. Lesshst-rw-r--r-- 1 root root 234 May 19 09:52 sample.html-rw-r--r--. 1 root root 129 May 11 2019. Tcshrc-rw-r--r-- 1 root root 1178 May 19 09:32 test.txt-rw- 1 root root 15904 May 25 10:15 .viminfo
If you want to use it permanently, you can write the command to the ~ / .bashrc file.
[root@server1 ~] # echo "alias la='ls-al'" > > ~ / .bashrc how to list alias
Use the alias command to list all aliases that have been set on the system:
[root@server1 ~] # alias checks whether the command type is an alias
To check if the command is an alias, use the which command. The content shown in the following example is an alias.
[root@server1 ~] # which laalias la='ls-al'/usr/bin/ls how to delete alias
If you need to deactivate aliases, you can use the unalias command. For the changes to take effect permanently, you need to delete the corresponding alias from the ~ / .bashrc file.
[root@server1 ~] # unalias la uses alias for common commands
For frequently used commands, you can save more time by shortening them by using aliases. In the aliases shown below, we clear the screen with one letter, use ll to display the files in the directory, and view only the five files that were recently created or updated:
[root@server1 ~] # alias cantilever clear` [root@server1 ~] # alias ll='ls-al' [root@server1 ~] # alias new='ls-1tr | tail-5' use alias to change the behavior of a command
For example, if you want the ping command to request only four times, you can use this alias to ensure that it makes only four ping requests:
[root@server1 ~] # alias ping='ping-c 4' option to avoid long strings using alias
Aliases are useful for remembering longer command options. For example, to extract a file, you can use the following alias:
[root@server1 ~] # alias untar='tar-xvf' uses alias to view the history of commands
To view history using search terms:
[root@server1 ~] # alias rec='history | grep'
This shows the relevant records that are kept in the history, such as:
[root@server1 ~] # rec alias uses alias to search for related commands
To find a command related to a search term, use the apropos command, but this command is a bit unfamiliar, you can set an alias and use the following command:
[root@server1 ~] # alias? = "apropos"
What is the next use? Search for commands related to compress:
[root@server1] #? Compress shows your IP address [root@server1 ~] # alias myip='hostname-I 'about how to use the alias command under Linux. Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.