Linux Operations Common commands

Source: Internet
Author: User

1. Linux boot process

Power-on and BIOS-on-boot, bootloader lilo or grub--> kernel boot (kernel boot)--Execute init (rc.sysinit, RC)--Mingetty (set up terminal)--& Gt 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-most CPU occupancy
# Vmstat 5

Top then press Shift+p to sort by process processor occupancy
# Top
24. View memory Usage commands
Use the free command to view memory usage
# 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 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].168.9.10:/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 are retained only one copy)
# Cat File1 File2 | Sort | Uniq

Remove the intersection of two files (leaving only files that exist in two files)
# 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} '
42. Delete the 0-byte file
# Find-type F-size 0-exec rm-rf {};
43, view the process, by memory from large to small arrangement
# PS-E-O "%c:%p:%z:%a" |sort-k5-nr
44. View the number of concurrent requests for HTTP and their TCP connection status
# Netstat-n | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, s[a]} '
45. Get the IP address
# ifconfig eth0|sed-n ' 2p ' |awk ' {print $} ' |cut-c 6-30

The Perl implementation obtains the IP address:
# Ifconfig-a | Perl-ne ' if (m/^s*inet (?: Addr:)? ( [D.] +). *?cast/) {print QQ ($1n); exit 0;} '
46. Get Memory Size
# free-m |grep "Mem" | awk ' {print $} '
47. View the number of CPU cores
# Cat/proc/cpuinfo |GREP-C Processor
48. View disk Usage
# df-h
49. See how many php-cgi processes are active
# NETSTAT-ANP | grep php-cgi | grep ^tcp | Wc-l
50. View hardware manufacturer
# dmidecode-s System-product-name

Original link: https://www.douban.com/note/526768245/

Linux Operations Common commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.