Summary of commonly used Linux commands for system operation and maintenance:
shutdown -h now or init 0: shut down the system
shutdown -r now or reboot: restart the system
logout: log out
Ctrl+C: exit the command line
date : display the system date
free -h : system memory and virtual memory usage
cat /proc/meminfog: View system memory details
cat /proc/meminfo |grep MemTotal: View memory size
cat /proc/cpuinfo: View CPU details
df -h: Display the disk space usage of the file system
fdisk -l |grep Disk: system disk size
top : Dynamically display the cpu and memory usage of the process, similar to the task manager
cd: Enter the specified path directory, you can directly enter all paths or a directory to enter
cd .. Return to the previous directory
pwd shows the current path
cd / back to the root directory
ls lists all files in the current folder
ls -a lists all files under the current file, including hidden files
tail -f file name: to view the last few lines of the file, you can add a number before f to return the last N lines of information
sz file name: put the file in the specified directory of the machine, generally used with xshell
du -sh : query the current directory folder size, you can also specify the path
du -sh filename: query file size
file folder name or file name: display file attributes
rm filename: delete file
rm -r directory or file name: delete the directory and the files under the directory
rm -rf directory or filename: force delete
cat filename: View file content
vim file name: open the file, enter i to enter edit mode, esc to exit to normal mode
:wq : save and exit
:q ! : exit without saving
tar cvf filename.tar or zip filename.zip or gzip filename.gz: compressed file
tar xvf filename.tar or zip filename.zip or gzip filename.gz
mv old file name new file name: change the old file name to the new file name, can also be used to move the file directory
kill -9 process id: forcefully kill the process
systemctl : view running services
service service name status : query service status
service service name start: start the service
service service name stop: stop the service
service service name restart: restart the service
lsof -i: port number: check the usage of the specified port number
netstat -tunlp: check the usage of all ports
netstat -tunlp | gep port number: check the usage of the specified port