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 processnetstat -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 Services
  • stopStopping system Services
  • restartRestart the service
  • reloadReload the service (reload the configuration and the service will not break)
  • statusService status
  • enableSet the service startup
  • disableDisable service startup
  • Example:
    • systemctl stop firewalldDisabling the Firewall
    • systemctl status firewalldChecking the Firewall Status
    • systemctl start firewalldStart the firewall
    • systemctl 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 confirmation
  • yum update packageNameUsed to update the specified package
  • yum 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

  1. 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
  2. Run the yum source update command
    • yum clean allClear the stale cache of YUM
    • yum makecache