In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to check the commands commonly used in Linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Check your own most frequently used commands on Linux
In Linux, the history file ~ / .bash_history records all the commands you have entered in the terminal, so we can use this file to find the commands you use most frequently.
The specific practices are as follows:
$history | awk'{print $2}'| sort | uniq-c | sort-nr | head-5
The results of the above command will show the five commands that users use most frequently on Linux.
The output is as follows:
153 sudo 118 ls 33 cd 30 ssh 29 git
The result is very refreshing and intuitive!
So, do you know the specific function of each part of the above command? Now, let's explain it in detail.
First, let's look at the output of the history command:
Alvin@alvin-pc:~$ history 743 sudo apt-get update 744 sudo apt-get upgrade 745 ls 747 ls 748 git status
This is the result seen on Ubuntu. If you see it on other platforms, such as CentOS, the result will be a different situation, and the corresponding command will need to be changed slightly.
Awk'{print $2} 'prints the second column string from the history file without displaying command options and arguments
Sort arranges all lines alphabetically
Uniq-c deletes duplicate rows and counts them
Sort-nr sorts in reverse according to the statistics returned by the uniq command
Tip: you can use ExplainShell to find a functional description of each option in the command.
As you can see from the results, sudo is the most frequently used command for current users, using it 153 times.
The display of the result is in descending order, and if you want it to be displayed in ascending order, you need to use the following command:
$history | awk {'print $2'} | sort | uniq-c | sort-n | tail-N5
You can compare them with the previous command to see their differences.
The output is as follows:
29 git 30 ssh 33 cd 118 ls 153 sudo
If you do not want to limit the number of results, simply delete the last part of the above command.
$history | awk'{print $2}'| sort | uniq-c | sort-nr article on "how to view commands commonly used in Linux" ends here. I hope the above content can be helpful to you so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.