Preface: As a back-end developer, how can you not order Linux commands? Summarized a set of very practical Linux commands (based on CentOS 7.6), I hope it will help you! You can also join the group 1106675687 to talk about technical bragging. There will be a lottery to send professional books several times a week. The prizes are not very valuable, but you can come to win a lottery [doge]. They lack practical project experience and want to switch to programming. Friends look here >>> C/C++Linux server development/backend architect .
1. System Service Management
systemctl
systemctl命令是 service和 chkconfig命令的组合体,可用于管理系统。
Output the status of each service in the system:
systemctl list-units --type=service
View the running status of the service:
systemctl status firewalld
Close service:
systemctl stop firewalld
Start the service:
systemctl start firewalld
Restart the service (regardless of whether the current service is started or closed):
systemctl restart firewalld
Reload configuration information without interrupting service:
systemctl reload firewalld
Forbid the service to start automatically after booting:
systemctl disable firewalld
Set the service to start automatically after booting:
systemctl enable firewalld
2. File management
ls
lists all files in the specified directory, lists files in the / directory:
ls -l /
pwd
gets the absolute path of the current working directory:
cd
changes the current working directory:
cd /usr/local
date
display or modify the system time and date;
date '+%Y-%m-%d %H:%M:%S'
passwd is
used to set the user password:
passwd root
su to
change user identity (switch to super user):
su -
clear is
used to clear screen information
man
displays help information for the specified command:
man ls
Who
queries the operating level of the system:
who -r
Display the users currently logged in to the system:
who -buT
free
displays the system memory status (in MB):
free -m
ps
shows the running dynamics of system processes:
ps -ef
View the running dynamics of the sshd process:
ps -ef | grep sshd
Have you seen this and won’t you join the group 1106675687 to learn? ? ?
top
view the real-time active process, similar to the task manager of Windows.
mkdir
creates a directory:
more is
used to view files by page, for example, view the boot.log file with 10 lines per page:
more -c -10 /var/log/boot.log
cat is
used to view files, such as viewing Linux startup log files, and marking the line number:
cat -Ab /var/log/boot.log
touch is
used to create files, for example to create a text.txt file:
touch text.txt
rm
delete files:
rm text.txt
Forcibly delete a directory and its subdirectories:
rm -rf testdir/
cp is
used to copy files, for example, copy the test1 directory to the test2 directory
cp -r /mydata/tes1 /mydata/test2
mv is
used to move or overwrite files:
mv text.txt text2.txt
Three, compression and decompression
tar
archives the files in the /etc folder to the file etc.tar (and will not compress):
tar -cvf /mydata/etc.tar /etc
Use gzip to compress the files in the folder /etc to the file etc.tar.gz:
tar -zcvf /mydata/etc.tar.gz /etc
Use bzip2 to compress the folder /etc to the file /etc.tar.bz2:
tar -jcvf /mydata/etc.tar.bz2 /etc
View the contents of the compressed package by page (gzip):
tar -ztvf /mydata/etc.tar.gz |more -c -10
Unzip the file to the current directory (gzip):
tar -zxvf /mydata/etc.tar.gz
Unzip the file to the specified directory (gzip):
tar -zxvf /mydata/etc.tar.gz -C /mydata/etc
Fourth, disk and network management
df
view disk space usage:
df -hT
dh
view the size of files and folders in the current directory:
du -h --max-depth=1 ./*
ifconfig
displays the current network interface status:
netstat
View current routing information:
netstat -rn
View all valid TCP connections:
netstat -an
View the monitoring services started in the system:
netstat -tulnp
View system resource information in a connected state:
netstat -atunp
wget
downloads files from the network
Five, file upload and download
Install the upload and download tool lrzsz;
yum install -y lrzsz
To upload a file, enter the following command XShell will pop up a file upload box;
rz
Download the file, enter the following command XShell will pop up the file save box;
sz fileName
6. Software installation and management
rpm
RPM是 Red-Hat Package Manager的缩写,一种Linux下通用的软件包管理方式,可用于安装和管理
.rpm结尾的软件包。
Install the package:
rpm -ivh nginx-1.12.2-2.el7.x86_64.rpm
Fuzzy search package:
rpm -qa | grep nginx
Find packages precisely:
rpm -qa nginx
Query the installation path of the software package:
rpm -ql nginx-1.12.2-2.el7.x86_64
View the summary information of the package:
rpm -qi nginx-1.12.2-2.el7.x86_64
Verify that the contents of the software package are consistent with the installation files
rpm -V nginx-1.12.2-2.el7.x86_64
Update package:
rpm -Uvh nginx-1.12.2-2.el7.x86_64
Remove the package:
rpm -e nginx-1.12.2-2.el7.x86_64
Yum
Yum is the abbreviation of Yellow dog Updater, Modified. It can automatically download and install RPM packages online, automatically handle dependencies, and install all dependent packages at once, which is very convenient!
Install the package:
yum install nginx
Check the packages that can be updated:
yum check-update
Update the specified package:
yum update nginx
Find package information in the resource library:
yum info nginx*
List all installed packages:
yum info installed
List the package names:
yum list nginx*
Fuzzy search package:
yum search nginx