1. Review the Process
Ps-ef | grep keyword/* keyword for service name */
NETSTAT-UNLTP | grep keyword/* keyword is a service name or a port */
2. Kill the Process
KILL-9 Process Number/* Operation be cautious */
3. Paging to view files
Cat file name | Less
Enter
"Enter or down" line down a row
"Up key" online line
"Spacebar or PGDN" page Down
"PgUp" Page Up
"Q" Exit view
4. Edit the file
VI File name
"I" enters edit state
"ESC" exits the edit state and can only view
": Q" Exit edit file, do not save
": q!" Force exit Edit file, do not save
": Wq" Save and exit
": wq!" Force save and exit
5. Listening files
Tail-f file name
"Ctrl + C" exit
6. View Firewall Policy
IPTABLES-L-N--line-number/* Displays line numbers */
Iptables-l-N
or Cat/etc/sysconfig/iptables | Less
If you do not find iptables install it, yum installs iptables-services
7. Set Firewall Policy
① open ports for all addresses
Iptables-i input-p tcp-m State--state new-m TCP--dport port number-j ACCEPT
/* The above command function is temporary, the shutdown after the restart is invalid */
Service Iptables Save/* Permanently saved */
② disable access to a port for an IP
Iptables-a input-s to disallow ip-p TCP--dport port number-j DROP
③ Disabling ping
Iptables-a input-p icmp-j DROP
④ disables ping and can ping other machines, but other machines cannot ping the machine
Iptables-a input-p 1--icmp-type 8-j DROP
⑤ does not allow access to an IP address
Iptables-a input-s Forbidden Ip-j DROP
⑥ Removing firewall rules
Iptables-d Type line number
8. Compress files
TAR-CVF Test.tar test.txt/* Package test.txt files in the directory into test.tar*/
TAR-CZF test.tar.gz test.txt/* Package test.txt files in the directory into Test.tar and compress them in gzip, named test.tar.gz*/
9. Unzip the file
TAR-XVF Test.tar/* Unzip the TAR package */
TAR-XZVF test.tar.gz/* Unzip tar.gz*/
TAR-XVF test.tar-c Destination Address/* Unzip the TAR package to the specified directory */
10. Moving Files
MV source file or source directory destination file or destination directory
11. Copy Files
CP Source File Destination file
12. Setting Environment VariablesVi/etc/profile/* Global All Users */
13. Set the boot startVi/etc/rc.d/rc.local
14. Change file ownership
chmod 777 File/* Readable and writable executable */
Linux Common commands