Common Linux Commands
CD directory switch, can be followed by a relative path, can be followed by an absolute path
Mkdir To create a directory, you can create only one level of directories. You can follow the command -p to create multi-level directories
Ls displays the files contained in the current directory and their subdirectories.
- -a: displays files in all directories, including hidden files
- -l Displays information in a list
- -h Displays the file size in the unit of K,m, and G
- -t Sorts files by generation date
Netstat: displays the network status.
- -a Displays all connected sockets
- -n Directly uses the IP address instead of the DNS server
- -p Displays the program id and program that is using the Socket
- Use pipes to query the specified process
netstat -anp 3306 | grep 3306To query process 3306, run the following commandkill PIDKilling the specified process
Tar compressed files or directories to generate compressed files. Decompress the compressed file
- options
- -z Uses gzip compression. Compressed files are named.tar.gz or TGZ
- -x Decompresses files
- -v Displays files during compression
- -f specifies the compressed file name. This option must be placed after other options
- -c < Destination directory > Specifies the decompression directory
Gz file under /opt to the /usr/local directory: tar -zxvf /opt/gitblit-1.9.1.tar.gz -c /usr/local
Systemctl System control, equivalent to service
startStarting system ServicesstopStopping system ServicesrestartRestart the servicereloadReload the service (reload the configuration and the service will not break)statusService statusenableSet the service startupdisableDisable service startup- Example:
systemctl stop firewalldDisabling the Firewallsystemctl status firewalldChecking the Firewall Statussystemctl start firewalldStart the firewallsystemctl enable firewalldFirewall startup
The yum(Yellow Dog Updater,Modified) command automatically downloads and installs RPM packages from a specified server based on the RPM command. It automatically handles dependencies and installs all dependent software packages at one time without downloading and installing them again.
yum -y install packageNameInstallation package: -y indicates no confirmationyum update packageNameUsed to update the specified packageyum remove packageNameRemoving a specified package
Useradd User account [-d < Login directory >] [-s]
Yum source set
The default yum command source is Apache and the network speed is slow. You can configure the yum command source as an Intranet mirror by editing the /etc/yom.repos. d/ centos-base. repo file
- Wget downloads the repo file and changes the file name to centos-base. repo:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/Cent7OS-163.repo - Run the yum source update command
yum clean allClear the stale cache of YUMyum makecache