In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "what are the common commands of Shell scripts that are easy to use". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and go deep into it slowly to study and learn "what are the common commands of Shell scripts that are easy to use" together!
1. List all catalog usage and sort by size.
The code is as follows:
ls|xargs du -h|sort -rn
#Do not recursively use du -sh for child directories
2. View files exclude #switches and blank lines for viewing profiles.
The code is as follows:
egrep -v "^#|^$" filename
sed '/#.*$/ d; /^ *$/d'
3. Delete spaces and blank lines.
The code is as follows:
sed '/^$/d' filename #Delete blank lines
sed 's/ //g' filename
sed 's/[[:space:]]//g' filename
4. Delete comments after #.
The code is as follows:
sed -i 's/#.*$// g' filename
5. Kick out the logged in user and use who to view the terminal.
The code is as follows:
pkill -KILL -t pts/0
6. Delete empty files.
The code is as follows:
find / -type f -size 0 -exec rm -rf {} \;
7. Find process pid and kill.
The code is as follows:
pgrep nginx|xargs kill
pidof nginx|xargs kill
8. Get the current IP address, powerful awk, one command to get it.
The code is as follows:
ifconfig |awk -F"[ ]+|[:]" 'NR==2 {print $4}'
9. View wtmp logs in text mode
The code is as follows:
utmpdump /var/log/wtmp
10. List processes sorted by memory size
The code is as follows:
ps aux --sort=rss |sort -k 6 -rn
11. Simple web server lists the current directory file, port 8000:
The code is as follows:
python -m SimpleHTTPServer
12. Change user password by pipeline input:
The code is as follows:
echo "password" |passwd -stdin root
12. Generate SSH certificate and copy to remote server:
The code is as follows:
ssh-keygen -y -f ~/.ssh/id_rsa && cat ~/.ssh/id_rsa.pub | ssh root@host "cat - >> ~/.ssh/authorized_keys"
13. Create a new folder under shell and enter, add bashrc as follows:
The code is as follows:
mkcd ( ){
mkdir $1
cd $1
}
14. Quickly backup files to another server via SSH:
The code is as follows:
tar zcvf - back/ | ssh root@www.yisu.com tar xzf - -C /root/back/
15. Download the whole site with wget:
The code is as follows:
wget -r -p -np -k https://www.yisu.com
#r recursive p download all files np not download parent k convert relative link
Kill the entire process tree:
The code is as follows:
pstree -ap 10277|grep -oP '[0-9]{4,6}'|xargs kill -9
17. Generate random characters:
The code is as follows:
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
18. Use awk to export the last column of non-empty data:
The code is as follows:
awk -F "|" '{if($NF!= "") print $NF}'
19. Find data that is larger than a few digits per row:
The code is as follows:
awk -F '' '{if(NF>6) print $0}'
20. Get HTML page text content:
The code is as follows:
lynx -dump www.yisu.com #URL containing page
w3m -no-cookie -dump www.yisu.com
links -dump www.yisu.com #Poor support for Chinese content
21. Port redirection:
The code is as follows:
socat TCP4-LISTEN:1234,reuseaddr,fork, TCP4:www.baidu.com:80
22. Insert before or after the line:
The code is as follows:
sed 'p;s/^.*$/--------/ ' file
awk '{print $0;print "-------"}' file
23. Insert at the beginning or end of a line:
The code is as follows:
sed 's/^/new/g' file
sed 's/$/new/g' file
24. Word for word:
The code is as follows:
awk -F "" '{for(i=1;i
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.