Linux finishing operation and maintenance of common script

1 , to find the current occupancy 0 byte file and delete directory 

Find. / F -type -size 0 -exec RM - RF} {\; # This command is not an operation byte 0 of the root of the file 

2 , It is displayed by the system process memory footprint size the 

PS -e -o "% C:% P:% Z:% A" | Sort -k5- NR    

. 3 , the system will display the process by the CPU usage are sized 

PS -e -o "% C:% P:% Z:% A" | Sort - NR 

. 4 , in a document match and replace the contents of a row 

Sed -i '/ Root / S / NO / Yes' / etc / SSH / the sshd_config to # match to Root, and then replace this line is no yes 

5 , show all run level 3 and start-up services 

LS /etc/rc3.d/S* | Cut -c 15 -     the beginning of S is the # rc3.d run level 3's services, and with a cut behind the interception of the contents of the first 15 characters 

6 , to obtain the IP address of the network card eth0  

method 1: ifconfig   | Grep 'inet addr:' | grep -v ' 127.0 . 0.1 ' | Cut -d: -f2 | awk '{$ Print . 1 }' 

Method 2: the ifconfig eth0 | grep "inet addr:" | awk '{$ Print 2 } '| Cut -c 6 - 7 , 80-port TCP packet capture tools to analyze the data flow 
tcpdump -c 10000 -i eth0 -n dst port 80 8 , inquiry yesterday's date 
dATE -date = yesterday 9 , remove all empty directories 
find / data -type d -empty -exec rm -rf {}; # best not / execute this command directory 10 , 5 days before the deleted file 
Find / Data -mtime + . 5 -type F -exec RM - RF { }; 11













Forced end user kicked 

the pkill -KILL -t PTS / . 1 

12 is forward the request from the port 80 to port 8080 

iptables -A the PREROUTING -m -p TCP TCP -dport80 Where do you want -j DNAT -to- 127.0 . 0.1 : 8080 

13 , transfer files between linux server 

scp ~ / test.txtroot @ 192.168 . 0.10 : / data / # test.txt will spread to remote hosts personal home directory under / the Data directory of 

14 , split large files 

split the -l 1000 the message.log the Message # 1000 lines per file to split 

split - b the message.log the Message # 5m 5M to split each file

 

Guess you like

Origin www.cnblogs.com/ada54410017/p/11222190.html