table of Contents
- System Management Services
- Document Management
- View Log
- Compression and decompression
- Disk and network management
- Firewall
- ftp operation
- Installation and management software
- other
System Management Services
systemctl
Output status of each service system:
systemctl list-units --type=service
View the running status of the service:
systemctl status firewalld
Close Services:
systemctl stop firewalld
Start the service:
systemctl start firewalld
Restart the services (regardless of the current service is started or shut down):
systemctl restart firewalld
Reload the configuration information without interrupting service:
systemctl reload firewalld
Prohibit service boot from the start:
systemctl disable firewalld
Set service boot from the start:
systemctl enable firewalld
Document Management
Find the file
(filename.txt file according to the following name lookup / directory)
find / -name filename.txt
View files, containing hidden files
ls -al
All files are listed in the current directory (/) under:
LS
ls -l /
Gets the current working directory where the absolute path
pwd
Change the current working directory: cd
cd /usr/local
Display or modify the system time and date; date
date '+%Y-%m-%d %H:%M:%S'
To set a user password: passwd
passwd root
Change the user identity (to switch to super user): su
su -username
Clears the screen information
clear
Display help information for the specified command: man
I ls
Discover what the system is run level: who
who -r
Displays the current user logged on to the system:
who -buT
Displays the system memory status (in MB): free
free -m
Dynamic Display System processes running: ps
ps -if
View sshd running dynamic process:
ps -ef | grep sshd
View real-time dynamic process, similar to Windows Task Manager
top
Create a directory
mkdir
Copy the file, including its subfolders to a custom directory
cp -r sourceFolder targetFolder
Delete the directory (this directory is an empty directory)
rmdir deleteEmptyFolder
Delete a file, including its subfolders
rm -rf deleteFile
Delete files: rm
rm text.txt
Moving Files
mv /temp/movefile /targetFolder
Move or overwrite the file: mv
mv oldNameFile.md newNameFile.md
Modify the file permissions (file.java rights -rwxrwxrwx, r for read, w for write, x for executable)
chmod 777 file.java
When the paging file is too long for the view file contents: more
page 10 line view boot.log file
more -c -10 /var/log/boot.log
View Linux boot log file and line number indicate: cat
cat -Ab /var/log/boot.log
Create a file text.txt: touch
touch text.txt
Start Vi editor
vi filename
1) to enter edit mode
shift+i
2) to exit edit mode
esc-->shift+:
3) Save and exit
wq
4) Force Quit
q
View Log
View the first 10 lines of the file
head -n 10 example.txt
10 lines to see the end of file
tail -n 10 example.txt
View the log file (this command will automatically display the new content, the screen only displays 10 lines of content (can be set))
tail -f exmaple.log
Log in search for the keyword
less server.log
1) If you want to start the search from the first log line
less server.log -> / search key -> n Find next - one> N Find
2) If you want to start from the last row of the log search
less server.log -> shitf + g ->? Next> N Find - Keyword Search -> Find Next on n
Compression and decompression
Decompression
unzip FileName.zip
compression:
ZIP -r filename.zip DirName
The archive / etc folder of files to the file etc.tar (not compressed): tar
tar -cvf /mydata/etc.tar / etc
File / etc are compressed with gzip folder to the etc.tar.gz:
tar -zcvf /mydata/etc.tar.gz /etc
With bzip2 compressed folder / etc to file /etc.tar.bz2:
tar -jcvf /mydata/etc.tar.bz2 / etc
Page View archive content (gzip):
tar -ztvf /mydata/etc.tar.gz |more -c -10
Unzip the file to the current directory (gzip):
tar -zxvf /mydata/etc.tar.gz
Disk and network management
View Disk Usage
df -h
View disk usage
free
Check disk space occupancy:
df -hT
dh
view the current files and directories under the share folder size:
du -h --max-depth=1 ./*
Displays the current status of network interfaces
ifconfig
View the current routing information: netstat
netstat -rn
View all active TCP connections:
netstat -an
View the system start listening service:
netstat -tulnp
View a port system monitoring services:
netstat -ntlp|grep 8080
View system resources in a connected state:
netstat -atunp
See if there is a certain process
ps -ef | grep java / pid
Download the file from the network
wget
Firewall
There are two Linux firewall software, ConterOS7.0 above using a firewall, ConterOS7.0 the following using iptables, this article will introduce the use of two firewall software.
Firewall
Open the firewall:
systemctl start firewalld
Turn off the firewall:
systemctl stop firewalld
Check firewall status:
systemctl status firewalld
Set boot:
systemctl enable firewalld
Disable boot:
systemctl disable firewalld
Restart the firewall:
firewall-cmd --reload
Open port (after modifying the firewall need to restart to take effect):
firewall-cmd --zone=public --add-port=8080/tcp --permanent
View open ports:
firewall-cmd --list-ports
Close port:
firewall-cmd --zone=public --remove-port=8080/tcp --permanent
Iptables
Installation
Because CenterOS7.0 or later and is not preinstalled Iptables, we need to install.
Turn off the firewall before installing the firewall
Installation iptables:
yum install iptables
Install iptables-services:
yum install iptables-services
Open the firewall:
systemctl start iptables.service
Turn off the firewall:
systemctl stop iptables.service
Check firewall status:
systemctl status iptables.service
Set boot:
systemctl enable iptables.service
Disable boot:
systemctl disable iptables.service
Check the filter table several chain rule (INPUT chain, we can see which ports are open):
iptables -L -n
Check the chain rule NAT table:
iptables -t nat -L -n
Clear all firewall rules:
iptables -F
iptables -X
iptables -Z
To add a rule in the INPUT chain (open port 8080):
iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
Find the line number where the rules:
iptables -L INPUT --line-numbers -n
According to the line number to delete filtering rules (closed 8080):
iptables -D INPUT 1
ftp operation
ftp ip
password password;
bin convert the file into a binary
get get the file name
Installation and management software
rpm
Install the package:
rpm -ivh nginx-1.12.2-2.el7.x86_64.rpm
Fuzzy Search packages:
RPM -qa | grep nginx
Exact Match packages:
RPM -qa nginx
Query Path installation packages:
rpm -ql nginx-1.12.2-2.el7.x86_64
View summary information package:
RPM -qi nginx 1.12.2-2.el7.x86_64
Verify that the package contents and the same installation file:
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
Install the package:
yum install nginx
Check the package can be updated:
yum check-update
Updates the specified package:
yum update nginx
Look for package information repository:
yum info nginx*
List all installed packages:
yum info installed
Lists the package name:
yum list nginx*
Fuzzy Search packages:
yum search nginx
other
Terminate the thread (the thread termination position number 19979 thread)
kill -9 19979
View the number of threads (for easy viewing program is wrong)
ps -Lf port number | wc -l
Check network connectivity
ping ip
See ip port connectivity check (connectivity firewall)
telnet ip port -> exit mode shift +] -> quit
Check local ip
ifconfig
View scheduler
crontab -l
Edit Scheduler
crontab -e
For more face through the development of small and skills are welcome to scan the QR code below, sustained attention!