I. Catalogue INTRODUCTION
/boot storage kernel, file storage point required for system startup
/bin stores all common commands that users can perform
/dev Interface Device
/etc about system settings and management files
Home directory for all ordinary users
/sbin Hosting administrative commands with root user rights
/usr Store other programs
/var storage system frequently-changed files
Second, port
HTTP TCP-HTTPS TCP 443 DNS TCP/UDP-DHCP UDP 67
DDH TVP telnet tcp at FTP TCP 21:20
Samba-client UDP 137:138 samba-server TCP 139:445
RSYNCD tcp/udp 873 rpc-bind TCP 111 NFS TCP 2049
TFTP server UDP, MySQL TCP 3306 SMTP TCP 25
Squid tcp 3128 nginx TCP PHP-FPM TCP 9000 tomcat TCP 8080
Three. command [...] Represents an option
Uname-r viewing the kernel version Cat/proc/cpuinfo viewing CPU information
Cat/proc/meminfo view memory clear clear screen or ctrl+l
Shutdown-h now immediately shuts down or power off
Shutdown-r now restarts or reboot
Tab completion command or path ctrl+u delete cursor before ctrl+k delete cursor
CTRL + C cancel command man + command word view manual
Whereis + Find path
PWD View current directory (print working directory)
CD Switch working directory (change direcotory)
CD./ start CD with current directory. / start with the parent directory of the current directory
CD ~/* starting with the current user host Directory
CD-Returns the last CD-Executing directory CD ~ Switch to the current host directory
LS list displays directory contents (list)
ls [option] "File or directory"
Option-L long format display-a show all hidden files-a show all but do not include hidden-h more humanized display size default to byte-R recursive display--color with color distinction (dark blue directory white general file green executable xxx device file red zip file-D only display attribute)
File or directory not clear can be used with wildcards: "? "Match an unknown character" * "matches any number of characters in the file name and can also be applied to other commands in the shell environment
Alias aliases
Alias + Command aliases = Original Command example: Alias + mls = ' Ls-alh '
Du statistics directory and Space usage of files (disk usage)
Du [-a|h|s options] File or directory-a statistics path all files-h in KB statistics-s only counts the total space of each parameter
mkdir Create directory folder (make directory) mkdir [-p] Directory name-p once create multiple directory nesting example: Mkdir-p/a/b/c/d create four consecutive
Touch filename Creation File Create multiple examples with spaces: Touch 1 2 3
ln creates a link file (link) similar to the shortcut ln [-s] source file path destination path soft link for directory or file, but source file cannot be deleted
CP Copy (copy) CP [option] source file or directory destination file or directory
Option-F force replication does not interact with-I alert user Interactive-p keeps source file property time constant
-r Copy directory must be added
RM Delete directory or file (remove) RM [-r|i|f] File and directory usage same as CP
MV Move file or directory (move) MV source file or directory destination file or directory if moving in the same directory is equivalent to renaming
which + command find the path to the command echo $ variable name display variable
Find finds files or directories find [Look in] "options" "File or directory name"
Option-name Search by file name you can use the wildcard character-size to find-user according to the file's main search-type by file type lookup (normal file f directory D device file b character device file C) to achieve multiple search criteria:-A and, and two conditions are true; O or only one condition is true.
Cases:
Find/-name "res*.conf" under "/" The name is the file or directory that begins with res. conf End
Find/-type D finds all directories under "/"
Find/-size +1024k-a-name "Lmlinuz" under "/" Look for size more than 1024KB and named Lmlinuz
System Service Control: Service Name control type
Control types include: Start start stop stop restart restart reload Reload Refresh Status View status Example: Service httpd start start httpd services
You can also start directly using the service startup script
View current operating level: RunLevel
Toggle RunLevel: Init + "0-6" 3 command line mode 5 Desktop mode
NTSYSV Interactive centralized configuration of various system service states NTSYSV--level run Level * Indicates a startup null representation does not start
Chkconfig set a service run level start state chkconfig--level [0-6] Service name On|off
Example: Chkconfig--level httpd on at level 3.5 auto-start
Chkconfig--list Service Name to view the startup status of the service at each level
"|" Pipe character The result of the preceding command is used after the symbol
">" redirect output to where
Man ls |wc-l >/123.txt view the LS command manual and count how many rows of redirects are saved to/123.txt
Directory and file management commands:
CAT displays and connects the contents of a file and can also view multiple files separated by a space
Example: Cat/etc/sysconfig/network-scripts/ifcfg-eth0/proc/version view eth0 NIC and system kernel information
More and less paging view file contents More file press ENTER key down SPACEBAR turn one screen B key up one screen Q exit
Head and tail View the beginning or end of a file part of the head view file at the beginning tail view file end
Head or Tail-n file-n indicates how many line examples are displayed: head-10/httpd.conf view the first 10 lines of the httpd.conf file
Tail-f file dynamic display file for real-time monitoring file changes can be used to view log file example: tail-f/var/log/messages Dynamic View public log file
WC statistics file Word, number of rows, etc. information without options default statistics three information
WC [Options] File
Options:-C Statistics File bytes-L Statistics File Lines-W statistics file number of words, separated by a space
Example: wc-l/etc/passwd Statistics System How many users (/etc/passwd one behavior one user information)
grep retrieves and filters file contents
grep [Options] ..... "Find criteria" target file option:-I lookup ignores case-V reverse lookup result inversion
Find criteria: You can use key strings, or you can use complex expression examples: "^word" means "word$" beginning with word means "^$" at the end of word for blank lines
Example: Grep-v "^#"/etc/yum.conf |grep-v "^$" filter out comment lines and blank lines in the file
Backing up and recovering documents:
Gzip and gunzip compression unpack the suffix named ". Gz"
Compression format: gzip [options] File option: 9 increase compression ratio, save space
Example: gzip-9 mkfile High Compressed file Mkfile
Decompression format: gzip [options] file or gunzip file option:-D
bZIP and bunzip compression unpack the suffix named ". bz2"
Usage similar to gzip and gunzip
The TAR command archives directories and files, and typically compresses files as they are archived to save file disk space. When using the tar command, you can omit the "-" before the option, and the archive solution is universal
Make archive file format: tar [options] .... Archive and file compression names source files or directories that need to be archived
Option:-C create. Tar format package file-F use archive file-j call bzip2 to compress or decompress-p package preserves file and directory permissions----Keep files and directories absolute path-t list view files in Package-V Output details-X unpack. Tar format package files -Z Call the GZIP program to compress or unzip the directory that is released when the decompression is specified
Example: Backing up a directory to generate 1.tar.gz archive compression package, viewing details when compressing
Tar zcvf 1.tar.gz/etc
To make a format. tar.bz2 Format Archive Package, change-Z to-j option
Recovering data from an archive file
tar [options] ... Archive and Compress file names [-C target directory]
Unzip 1.tar.gz compress package to/
Tar zxf 1.tar.gz-c/
Unzip the format. tar.bz2 Format Archive Tarball, change-Z to-j option
VI text Editor, the enhanced version of Vim for VI, extends the use of many functions
Format: Vim file
There are three different modes of operation in the VI editing interface:
Command mode: The VI editor is launched into this mode, find, copy and paste, delete and other operations
Input mode: As the name implies to modify the file, add new content
Last-line mode: Save exit, replace character, will appear ":"
Mode switch:
Command mode-----> Input mode
A: Insert content after the cursor
A: Insert content at the end of the line where the cursor is located
I: inserting content at cursor position
I: Insert content at the beginning of the line where the cursor is located
o: Insert a new line after the cursor line
O: Insert a new row before the line where the cursor is located
Input mode-----> Command mode ESC key
Command mode-----> last-line mode ":" Key
Last-line mode-----> Command mode ESC key
Command mode shortcut keys:
PageDown or ctrl+f down a full page
PageUp or ctrl+b down a full page
Home key or ^ key, number 0 key to quickly jump to the beginning of the bank
End key or key to quickly jump the cursor to the end of the line
1G or GG jumps to the first line of the file contents
G Jump to the last line of the file content
#G可跳转到文件中的第 # line (#为数字)
X key or del key to delete a single character at the cursor
DD Delete Row, #dd删除从光标起开始的 # line contents
d^ Delete all characters from the current cursor to the beginning of the line
d$ Delete all characters from the current cursor to the end of the line
yy copies the current whole line, #yy复制从光标起开始的 # line contents
p after pasting to the cursor position, p is pasted before the cursor position
/find the characters in the current file,
Last-line mode command:
Set NU display line number set Nonu do not display line numbers
Linux common commands, a little summary