Linux Common commands

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.