Simple Linux Command learning notes, linux learning notes

Source: Internet
Author: User

Simple Linux Command learning notes, linux learning notes

1. View Processes

Ps-ef | grep keyword/* keyword is service name */

Netstat-unltp | grep keyword/* the keyword is the service name or port */

 

2. Killing Processes

Kill-9 process no./* exercise caution when performing operations */

 

 

3. view files by PAGE

Cat file name | less

Press enter,

Enter or press the next line.

[Top key] one line on the Internet

[Space key or PgDn] Flip down

[PgUp] Page up

[Q] exit to view

 

4. edit a file

Vi file name

[I] enters the editing status

[Esc] exit the editing status and can only be viewed

[: Q] exit the editing file and do not save it.

[: Q !] Force exit the edit file and do not save

[: Wq] Save and exit

[: Wq !] Force save and exit

 

5. Listen to files

Tail-f file name

[Ctrl + c] exit

 

6. View firewall policies

Iptables-L-n -- line-number/* display row number */

Iptables-L-n

Or cat/etc/sysconfig/iptables | less

If no iptables is found, install yum install iptables-services.

 

 

7. Set firewall policies

① Open ports to all addresses

Iptables-I INPUT-p tcp-m state -- state NEW-m tcp -- dport port number-j ACCEPT

/* The above commands are used temporarily, and will become invalid after Shutdown and restart */

Service iptables save/* Permanent storage */

② Prohibit access to a port from an IP address

Iptables-a input-s IP address to be disabled-p tcp -- dport port number-j DROP

③ Disable ping

Iptables-a input-p icmp-j DROP

④ Disable ping. You can ping other machines, but other machines cannot.

Iptables-a input-p 1 -- icmp-type 8-j DROP

⑤ Access from an IP address is not allowed

IP address-j DROP prohibited by iptables-a input-s

⑥ Delete firewall rules

Iptables-D type row number

 

8. compressed files

Tar-cvf test.tar test.txt/* package the test.txt file in the Directory into test.tar */

Tar-czf test.tar.gz test.txt/* package the test.txt file in the Directory into test.tar, and compress it with gzip, and name it test.tar.gz */

 

 

9. decompress the file

Tar-xvf test.tar/* decompress the tar package */

Tar-xzvf test.tar.gz/* decompress tar.gz */

 

Tar-xvf test.tar-C target address/* decompress the tar package to the specified directory */

 

 

10. Move files

Mv source file or source directory target file or target directory

 

 

11. Copy files

Cp source file target file


  12. Set Environment VariablesVi/etc/profile/* all global users */   13. Set auto-start upon startupVi/etc/rc. d/rc. local

 

 

14. Change the File Permission

Chmod 777 file/* readable and writable executable */

 

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.