Linux provides a large number of commands that can be used to efficiently perform a large amount of work, such as disk operations, file access, directory operations, process management, file permissions, and so on. Therefore, working on a Linux system requires the use of system-supplied commands.
Character matching
- * represents any string
- ? Represents a character
- [ABCD ...] Represents the selection of characters from inside
- [1-9] [A-z] denotes range
- [!ABCD] represents other than these strings
redirect
- LS-L/tmp >/TMP.MSG no longer screen display, but input to/tmp.msg this file
- Date >>/tep.msg >> indicates append at end
- grep 127 </etc/hosts input redirection
- Cp-r/usr/backup/usr.bak 2>/bak.error Error Output redirection
Pipe: Input of one command into another command
Command link character
- Ls-l/etc/hosts;ls-l/etc/host; Commands are executed sequentially
- sudo service apache2 Stop&&sudo service apache2 start before command execution succeeds before executing the following command
- Service Apache2 Restart | | sudo service apache2 Restart after the previous command failed, the following command was executed
Command substitution
- Ls-l ' which touch ' takes the input of which touch as a parameter of ls-l
Directory and file management commands
- ls -ald /root display/root All files
- pwd display current directory
- touch TEST.C&NB sp; Create a new file test.c
- mkdir test Create a new directory test
- cp test.c /root& nbsp; copy test.c to/root
- cp -r test /root & nbsp Copy the test folder to the/root
- mv test.c /root move test.c to/root
- mv test.c /ro ot/test2.c moves and renames the
- rm -rf /mydir does not ask for y/n, forcibly deletes/ Mydir directory and inside file
- cat Myfile View file
- more Myfile Paging view file contents, Spaces: Next page, enter: Next line, Q: Exit
- Tail-num Log.txt Real-time view of the file before the NUM line content
- ln source.txt /var/source.txt Create a hard link (equivalent to copy + Live Update)
- LN-S&N Bsp source.txt /var/source.txt Create a soft connection (equivalent to a shortcut)
- sudo chmod-r 777/sh
Compression and decompression
- gzip-d file: Compressed to. gz file, directory not supported, source file not preserved,-D is uncompressed
- Bzip2-k file: Compressed to. bz2 file, its compression ratio is very alarming, K will retain the source file.
- Bunzip2. bz2 file: Extract. bz2 file.
- TAR-ZXVF aa.tar.gz extract to current folder
- TAR-ZCVF aa.tar.gz/etc/aa.txt compressed file, remember file with full path
- Zip services.zip/etc/services Compressed file
- Zip test.zip/test Compressed Directory zip is a source file that retains compression.
- Uzip Compressed file: Extract files;
File permissions
- chmod [-r] 777/var/home/www change file/directory permissions-R is recursive
- Chown Caokaiyan/var/home/www/aa.txt Change file owner
- CHGRP [-R] Admin/var/home/www/aa.txt change all groups of files
User Management
- Useradd Caokaiyan Add a user to the system
- passwd Caokaiyan set a secret for the user
- SU switches to root user
- sudo ordinary users to use the root user rights operation, generally in the Debian series Linux only
- Logout Logout Login
File Search
- Which LS navigates to the absolute path of the LS command; provides command alias information
- Whereis LS navigates to the absolute path of the LS command; provides help documentation information
- FIND/ETC host searches/etc for files with host names
- Locate host based on the Linux built-in file database to find files with host names, generally before looking for updatedb, update the built-in database
- File files: Determining the type of files
Network communication Command
- ping + IP address/url: Send a packet to see if you can get the package back
- Ping your own machine IP address: If you can, explain your network settings is no problem!
- Ping 127.0.0.1 (loopback address): Detection of their own machine installed TIP/IP protocol?
- Ping + 6000 www.baidu.com: Send a packet of 6000 block size to test network connection delay
- IFCONFIG-A: View the network card information; eth0 is the first network card lo is the loopback network card;
- NETSTAT-ANP: Monitor network status, port number, which process is listening to this port Ah, and so on!
- Traceroute + domain/HOST IP: Tracking routing
- Route-n: Display native routing table
Shutdown
- shutdown-h [now/wait Time]
- shutdown-r [now/wait time] reboot
- Reboot fast reboot (skip sync data sync process)
- Init 0 shutdown
- Init 6 reboot
- Halt system Downtime
View hard disk Partitions
- fdisk-l [/dev/had] hard disk partitioning
- Use of df-h hard disk partitions
- Du-sh/root View all directory sizes under/root
- Linux version number used by uname-a
Linux Environment configuration
- Locale View the current language environment
- Lang=zh_cn. UTF-8 set the current language, LANG is an environment variable
- You can use configuration environment variables without having to modify the corresponding configuration file
- ENV lists all the environment variables
- Date shows current time
- Cal Displays the current calendar
Process Management
- PS aux view all running processes
- PS E
- Kill 8024 kills the process by PID
- Kill-9 8935 forced Kill process
- Killall 8323 kills it and its child processes
- Top real-time monitoring process
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.