Linux Operations Daily command Operations
1. Linux boot process
power on and bios on/off-boot lilo or grub-to-kernel boot (kernel boot)--Execute init (rc.sysinit, RC)--Mingetty (build terminal)--Shell
2, NIC binding multi-IP
Ifconfig eth0:1 192.168.1.99 netmask 255.255.255.0
3. Set up DNS, gateway
echo "NameServer 202.16.53.68" >>/etc/resolv.conf
Route add default GW 192.168.1.1
4, eject, recover the optical drive
Eject
Eject-t
5. Query yesterday's date with date
Date--date=yesterday
6, query file1 inside the line number of empty line
grep ^$ File
7. Query File1 the line ending with ABC
grep abc$ File1
8, print out the File1 file 1th to the third line
Sed-n ' 1,3p ' file1
Head-3 file1
9. Empty files
True > 1.txt
echo "" > 1.txt
> 1.txt
Cat/dev/null > 1.txt
10. Delete all empty directories
Find/data-type d-empty-exec rm-rf {} \;
11, Linux under the bulk delete empty files (size equals 0 files) method
Find/data-type f-size 0c-exec rm-rf {} \;
Find/data-type f-size 0c|xargs rm–f
12. Delete files from five days ago
Find/data-mtime +5-type f-exec rm-rf {} \;
13. Delete the duplicate parts of two files, print other
Cat 1.txt 3.txt |sort |uniq
14. Capturing the host name of the remote server
echo ' ssh $IP cat/etc/sysconfig/network|awk-f = '/hostname/{print $} '
15, real-time monitoring network card traffic (install iftop)
/usr/local/iftop/sbin/iftop-i Eth1-n
16. View the system version
Lsb_release-a
17, forced to kick out the landing user
Pkill-kill-t PTS/1
18, Tar add backup, restore
Tar-g KING-ZCVF kerry_full.tar.gz Kerry
Tar-g KING-ZCVF kerry_diff_1.tar.gz Kerry
Tar-g KING-ZCVF kerry_diff_2.tar.gz Kerry
TAR-ZXVF kerry_full.tar.gz
TAR-ZXVF kerry_diff_1.tar.gz
TAR-ZXVF kerry_diff_2.tar.gz
19, forwarding the local 80 port request to 8080 port, the current host external network IP is 202.96.85.46
-A prerouting-d 202.96.85.46-p tcp-m tcp--dport 80-j DNAT--to-destination 192.168.9.10:8080
20, in November, every day in the morning 6 to 12, every 2 hours to perform a/usr/bin/httpd.sh.
Crontab-e
0 6-12/2 */usr/bin/httpd.sh
21. View the process that occupies port 8080
NETSTAT-TNLP | grep 8080
lsof-i:8080
22, in the shell environment, how to see how long the remote Linux system has been running?
SSH [email protected] Monitored host IP "uptime"
23. View CPU Usage Commands
"" refreshes every 5 seconds with data on the right side of the CPU's occupancy rate
Vmstat 5
Top then press Shift+p to sort by process processor occupancy
Top
24. View memory Usage commands
"" View memory usage with the free command
Free-m
Top and then press Shift+m to sort by process memory usage
Top
25. View disk I/O
"" Use Iostat to see disk I/O for disk/DEV/SDC3, refreshed every two seconds
Iostat-d-X/DEV/SDC3 2
26. Repair File System
Fsck–yt ext3/
-t specifies the file system
-Y answer Yes to the problem found automatically
27. The read command automatically exits after 5 seconds
Read-t 5
28. What does GREP-E-P mean
-E,--EXTENDED-REGEXP uses extended regular expressions.
-p,--perl-regexp using Perl Regular expressions
29, vi Editor (related to modify, add, find)
Insert (insert) mode
I insert before cursor
I Insert the beginning of the cursor
A after the cursor is inserted
A Cursor Line End insertion
o Insert a row below the line where the cursor is inserted
O insert a row on the line where the cursor is inserted, beginning with
G moves to the beginning of the last line
NG moves to the beginning of the nth row
n+ down n lines, beginning of line
N-row, beginning
: The/str/moves from the current to the right to the place with Str
:? str? Move from current to left to a place with Str
: S/str1/str2/replaces the first str1 found with str2
: S/str2/str2/g replaces all str1 found in the current row with str2
: N1,n2s/str1/str2/g replaces all str1 found from N1 line to N2 line with STR2
: 1,.s/str1/str2/g replaces all str1 from line 1th to the current row with str2
:., $s/str1/str2/g replace all str1 from the current row to the last row with str2
30. Copying files between Linux servers
Copy local file 1.sh to the/data/directory of the remote 192.168.9.10 server
scp/etc/1.sh [Email protected]:/data/
Copy Remote 192.168.9.10 server/data/2.sh file to local/data/directory
SCP [email protected]:/data/2.sh/data/
31. Use the SED command to change the test on line 23rd of the Test.txt file to Tset.
Sed-i ' 23s/test/tset/' test.txt
Sed-i ' s/test/tset/' test.txt
32. Enable the history command to show the time
Export histtimeformat= "%F%T"
33, how to view the target host 192.168.0.1 open those ports
Nmap-ps 192.168.0.1
34. How to view network connection
Netstat-n | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, s[a]} '
35, how to view the current system used those library files
Ldconfig-v
36, how to view the driver version of the network card
Ethtool-i eth0
37. Use Tcpdump to monitor 80 ports of TCP for host 192.168.0.1
Tcpdump TCP Port host 192.168.0.1
38, how to see other users of the mailing list
Mial-u King
39, the large file for cutting
Split by 1000 lines per file
Split-l Httperr8007.log Httperr
Split according to 5m per file
Split-b 5m Httperr8007.log Httperr
40. Merging files
Remove the set of two files (duplicate lines retain only one copy)
Cat File1 File2 | Sort | Uniq
Remove the intersection of two files (Leave only files that exist in two files at the same time)
Cat File1 File2 | Sort | Uniq-d
Delete the intersection and leave the other rows
Cat File1 File2 | Sort | Uniq–u
41. Print the service running in text mode
Chkconfig--list|awk ' $5~/on/{print $1,$5} '
Linux Basic Operations Command