1. Run the ls command
View files and folders visible in the current directory and their permissions. Common parameters are as follows: -l List view -al View all files and folders, including hidden files and foldersCopy the code
[root@qinshengfei bin]# ls --color displays in color
[root@qinshengfei bin]# ls -l List directory files in detail
[root@qinshengfei bin]# ls -a Displays all files, including hidden files
[root@qinshengfei bin]# ls-al list displays all files
[root@qinshengfei bin]# the ls - al | more will show directory content distribution
Copy the code
2, mkdir create folder
Common parameters: Direct folder nameCopy the code
[root@qinshengfei /home]# mkdir test
Copy the code
3. PWD Displays the current working directory
[root@qinshengfei bin]# pwd/usr/bin <== Displays the current working directoryCopy the code
4. CD Switch the directory
[root@qinshengfei /root]# cd .. <== Go back to the previous directory
[root@qinshengfei /]# CD <== go back to home
[root@qinshengfei root]# CD /usr/bin <== go to /usr/bin
Copy the code
5. Rmdir Deletes the specified directory
If the directory to be deleted contains files or folders that cannot be moved, you need to add the -rf parameter to force the deletion.Copy the code
[root@qinshengfei /root]# rmdir./test <== Delete directory
[root@qinshengfei /root]# rmdir./test2 -rf <== delete directories and subdirectories, files
Copy the code
6. Rm deletes the command file
[root@qinshengfei /root]# rm test
Copy the code
Cp means copy. For example, if we want to copy the.bashrc file to /home, we can:
[root@qinshengfei /root]# cp .bashrc /home
Copy the code
8. Mv Move files and folders
[root@qinshengfei /root]# mv test.txt /home
Copy the code
9. Cat prints the contents of the file on the console, for example, to print the mysql configuration file to the control
[root@qinshengfei /mysql.conf.d]# cat mysqld.cnf
Copy the code
10. Tail Displays file contents by line
[root@qinshengfei /mysql.conf.d]# tail -n 5 mysqld.cnf
Copy the code
11, less
The less command is used to view files. It's faster to use, and you won't inadvertently modify files. With fewer cursors, you can use the up and down arrow keys, the PgUp and PgDn keys, and the Home and End keys to scroll back and forth through the file. Press Q to exit less.Copy the code
[root@qinshengfei /mysql.conf.d]# less log.txt
Copy the code
12. Grep pipe to output the specified file content
Use ps - aux inquiry process, for example, we just need to know the tomcat is not running, you can use the pipeline instruction "|" to join the grep command operation at the same time.Copy the code
[root@qinshengfei /]# ps -aux|grep tomcat
Copy the code
13, find the file
[root@qinshengfei /]# find / -name bin
Copy the code
14. Tar -cvf compressed file
[root@qinshengfei /root]# tar -zcvf app.tar.gz app
Copy the code
15. Gzip compression
The compress command is similar to the compress command. Just zip the suffix.gz!Copy the code
[root@qinshengfei /root]# gzip -d xxxxx.gz
Copy the code
16. Unzip the decompressed file
[root@qinshengfei /root]Zip unzip a file called 'app.zip'
Copy the code
18. Exit Exit the login
[root@qinshengfei /root]# exit
Copy the code
19. Ping is the same as ping in Windows
[root@qinshengfei /root]# ping baidu.com
Copy the code
20. Telnet tests that the port on the target machine is open
[root@qinshengfei /root]# telnet 47.2.30.289 8080
Copy the code
21. Who Displays all the current users
[root@qinshengfei /root]# who
Copy the code
22. Su to switch users
[root@qinshengfei /root]# su qinshengfei
Copy the code
Uname Displays important information about the system, such as kernel name, host name, kernel version, processor type, etc. Use uname -a to view all information.
[root@qinshengfei /]# uname -aLinux qinshengfei 4.18.0-80.11.2. El8_0. X86_64#1 SMP Tue Sep 24 11:32:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[root@qinshengfei /]#
Copy the code
24, alias
Using the alias command, you can give a command or sequence of commands its own name. You can then enter your abbreviation, and the Shell will execute commands or sequences of commands for you.Copy the code
[root@qinshengfei /]# alias pf="ps -e | grep $1"
[root@qinshengfei /]# pf tomcat
Copy the code
25, chmod modify file and folder permissions command
0: No permission
1: Execute permission
2: Write permission
3: Write and execute permissions
4: Read permission
5: Read and execute permissions
6: Read and write permissions
7: Read, write and execute permissions
Copy the code
[root@qinshengfei /]# chmod 777 app-r <== -r
Copy the code
26 and chown
You can use chown to change the owner or group of a file, or both. Owner and group names must be provided, separated by: characters.Copy the code
[root@qinshengfei /]# chown dave:mary example.txt
Copy the code
27, curl
The curl command is a tool for retrieving information and files from a uniform resource Locator (URL) or Internet address.Copy the code
[root@qinshengfei /]# curl http://www.baidu.com index.html
Copy the code
28, echo
The echo command prints the text string to the terminal window. You can also print the string to a file.Copy the code
[root@qinshengfei /]# echo "hello world"
hello world
[root@qinshengfei /]#
Copy the code
29, free
The free command gives you a summary of your computer's memory usage. It does this for both main random access memory (RAM) and swap memory. The -h (human) option is used to provide human-friendly numbers and units. Without this option, numbers are in bytes.Copy the code
[root@qinshengfei /]# free
total used free shared buff/cache available
Mem: 8000348 1554508 4549432 576 1896408 6194856
Swap: 0 0 0
[root@qinshengfei /]#
Copy the code
30, the history,
The history command lists the previous commands you issued on the command line. You can repeat any command in history by typing an exclamation point! And command numbers in the history list.Copy the code
[root@qinshengfei /]#
[root@qinshengfei /]# history
1 yum install docker
2 yum install nginx
3 yum -y install docker-ce
Copy the code
31, kill
We’ll use the ps and grep tips from the section on alias commands above. We can search the shutter process and get its PID as follows:
[root@qinshengfei /]# ps -ef|grep nginx
root 31884 22980 0 16:19 pts/0 00:00:00 grep --color=auto nginx
root 32400 1 0 Feb18 ? 00:00:00 nginx: master process /usr/sbin/nginx
nginx 32401 32400 0 Feb18 ? 00:00:00 nginx: worker process
nginx 32402 32400 0 Feb18 ? 00:00:00 nginx: worker process
[root@qinshengfei /]# kill -9 32400
Copy the code
32 and passwd
The passwd command enables you to change the user password. Simply type passwd to change your own password.Copy the code
[root@qinshengfei /]# sudo passwd mary
Copy the code
33, SSH,
Use the SSH command to establish a connection to a remote Linux machine and log in to your account. To establish a connection, you must provide your user name and the IP address or domain name of the remote computer. In this example, user Mary logs in to the computer at 192.168.4.23. Once the connection is established, she will be asked to enter her password.Copy the code
[root@qinshengfei /]# ssh [email protected]
[email protected]'s password:
Copy the code
35. Df View the system disk usage
[root@qinshengfei /]# dfFilesystem 1K-blocks Used Available Use% Mounted on devtmpfs 3986836 0 3986836 0% /dev tmpfs 4000172 0 4000172 0% /dev/shm tmpfs 4000172 576 3999596 1% /run tmpfs 4000172 0 4000172 0% /sys/fs/cgroup /dev/vda1 52417516 4031296 48386220 8% / overlay 52417516 4031296 48386220 8% /var/lib/docker/overlay2/650e5470981551bdd57ee3f9da79da55ef5170d11017e282c318f801b5c5ac4b/merged tmpfs 800032 0 800032 0% /run/user/0 [root@qinshengfei /]#
Copy the code
36. Ps displays the system process
The ps command lists the processes that are running. Using ps without any options causes it to list the processes running in the current shell.Copy the code
[root@qinshengfei /]# ps
PID TTY TIME CMD
9191 pts/0 00:00:00 ps
16776 pts/0 00:00:00 bash
17212 pts/0 00:00:00 mysql
22980 pts/0 00:00:00 bash
23524 pts/0 00:00:44 java
[root@qinshengfei /]#
Copy the code
To query the keyword process, you can use the pipeline command.Copy the code
[root@qinshengfei /]# ps -ef|grep nginx
root 10377 22980 0 16:26 pts/0 00:00:00 grep --color=auto nginx
root 32400 1 0 Feb18 ? 00:00:00 nginx: master process /usr/sbin/nginx
nginx 32401 32400 0 Feb18 ? 00:00:00 nginx: worker process
nginx 32402 32400 0 Feb18 ? 00:00:00 nginx: worker process
[root@qinshengfei /]#
Copy the code
37. Top Displays system processes
[root@qinshengfei /]# top
Copy the code
38, Reboot the computer
[root@qinshengfei /]# reboot
Copy the code
39, shutdown
Using shutdown with no parameters will shut down the computer in one minute.
[root@qinshengfei /]# shutdown
Copy the code
Use the now parameter to power off immediatelyCopy the code
[root@qinshengfei /]# shutdown -h now
Copy the code
Restarting the system using -r has the same effect as restarting the system using reboot. Shutdown -r can be timedCopy the code
[root@qinshengfei /]# shutdown -r now
Copy the code
40, yum!
Commands for installing software in centosCopy the code
[root@qinshengfei /]# yum install nginx
Copy the code