Abstract
Developers must have Linux common commands, master these commands absolutely enough, based on CenterOS7.6.
System Service Management
systemctl
- Output the status of each service in the system:
systemctl list-units --type=service
Copy the code
- View the running status of the service:
systemctl status firewalld
Copy the code
- Service shutdown:
systemctl stop firewalld
Copy the code
- Start the service:
systemctl start firewalld
Copy the code
- Restarting the service (whether the current service is up or down) :
systemctl restart firewalld
Copy the code
- Reload configuration information without interrupting service:
systemctl reload firewalld
Copy the code
- Forbid automatic startup of services upon startup:
systemctl disable firewalld
Copy the code
- Set service startup:
systemctl enable firewalld
Copy the code
File management
ls
List all files under the current directory (/) :
ls -l /
Copy the code
pwd
Gets the absolute path to the current working directory
cd
Change the current working directory:
cd /usr/local
Copy the code
date
Display or modify system time and date;
date '+%Y-%m-%d %H:%M:%S'
Copy the code
passwd
Used to set user password:
passwd root
Copy the code
su
Change user identity (switch to superuser) :
su -
Copy the code
clear
Clear screen information
man
Displays help information about the specified command:
man ls
Copy the code
who
- Query the operating level of the system:
who -r
Copy the code
- Display the current users logged into the system:
who -buT
Copy the code
free
Display system memory status (in MB) :
free -m
Copy the code
ps
Displays the running status of system processes:
ps -ef
Copy the code
View the running status of the SSHD process:
ps -ef | grep sshd
Copy the code
top
View live active processes, similar to Windows task Manager
mkdir
Create a directory
more
Page View when a file is too long 10 lines per page View the boot.log file
more -c -10 /var/log/boot.log
Copy the code
cat
View the Linux startup log file file with the line number:
cat -Ab /var/log/boot.log
Copy the code
touch
Create text.txt file:
touch text.txt
Copy the code
rm
- Delete file:
rm text.txt
Copy the code
- Forcibly delete a directory and its subdirectories:
rm -rf testdir/
Copy the code
cp
Copy the test1 directory to the test2 directory
cp -r /mydata/tes1 /mydata/test2
Copy the code
mv
To move or overwrite a file:
mv text.txt text2.txt
Copy the code
Compression and decompression
tar
- Archive files from the /etc folder into the /etc/tar file (which does not compress) :
tar -cvf /mydata/etc.tar /etc
Copy the code
- Use gzip to compress files in /etc to /etc/tar. gz:
tar -zcvf /mydata/etc.tar.gz /etc
Copy the code
- Use bzip2 to compress /etc into /etc/tar. bz2:
tar -jcvf /mydata/etc.tar.bz2 /etc
Copy the code
- Paging to view the contents of the compressed package (gzip) :
tar -ztvf /mydata/etc.tar.gz |more -c -10
Copy the code
- Unzip files to current directory (gzip) :
tar -zxvf /mydata/etc.tar.gz
Copy the code
Disk and network management
df
Viewing disk space usage:
df -hT
Copy the code
dh
Check the size of files and folders in the current directory:
du -h --max-depth=1 ./*
Copy the code
ifconfig
Displays the status of the current network interface
netstat
- View the current route information:
netstat -rn
Copy the code
- To view all valid TCP connections:
netstat -an
Copy the code
- To view the listening service enabled in the system:
netstat -tulnp
Copy the code
- View information about connected system resources:
netstat -atunp
Copy the code
wget
Download files from the network
Software installation and management
rpm
- The installation package is RPM -ivh nginx-1.12.2-2.el7.x86_64. RPM
- Fuzzy search package: RPM – qa | grep nginx
- Exact find package: RPM -qa nginx
- To query the installation path of the software package, run RPM -ql nginx-1.12.2-2.el7.x86_64
- View the general information about the software package: RPM -qi nginx-1.12.2-2.el7.x86_64
- Verify that the software package is the same as the installation file: RPM -v nginx-1.12.2-2.el7.x86_64
- Update package RPM -uvh nginx-1.12.2-2.el7.x86_64
- To delete the software package, run RPM -e nginx-1.12.2-2.el7.x86_64
yum
- Yum install nginx
- Check packages that can be updated: yum check-update
- Yum update nginx
- Find package information in the repository: yum info nginx*
- Yum Info Installed lists all packages installed: yum Info Installed
- Yum list nginx* yum list nginx*
- Yum Search Nginx
The public,
Mall project full set of learning tutorials serialized, attention to the public number the first time access.