Ubuntu/Linux tips (shell shortcut)

Source: Internet
Author: User
Tags clear screen

Collect common skills and notes.
Occasionally updated.

1. Shortcut Keys

Terminal shortcut:

CTRL + C: Stop Ctrl + Z: switch to the background Ctrl + D: cancel the current session Ctrl + W: Delete the command parameter Ctrl + u before the cursor: delete all characters before the cursor Ctrl + K: delete all characters after the cursor Ctrl + A: move the cursor to the beginning Ctrl + E: move the cursor to the end Ctrl + L: clear screen Ctrl + R: search history command

2. File Management

File Search:

$ Find. -Name "*. PY [CO] "# search by wildcard $ find. -iregex '. */index. * '# use a regular expression to search (including full Path Matching and case-sensitive RegEx) $ find. -type D # search directory type (Type F, d ...) $ find. -Type F-exec LS-l {}/; # Find and directly execute the command $ find. -Type F-Perm + 0100 | xargs LS-L # search for common files with execution permissions $ find. -Name "*. PY "| xargs grep-N main # search by content $ find. -Name "*. PY [CO] "| xargs Rm-RF # Delete $ find in batches. -Type F-size + 10 k | xargs LS-lH # files larger than 10 KB (unit: K, M, G, T, P ). $ Find. -Type F-mtime-2D | xargs LS-L # The modified file (unit: S, M, H, D, W) in the last two days. + 2d is not modified.

View n lines at the beginning/end of a file:

$ head -n 5 test.txt$ tail -n 5 test.txt

Display/display file content by page:

$ cat test.txt$ less test.txt

Refresh File Content Changes in real time (suitable for monitoring Log File changes and useful for debugging ):

$ tail -f test.txt$ less +F test.txt

View File Types:

$ file test.txt

3. System Management

The program runs in the background and does not close with the terminal session: nohup

$ nohup cat a.txt &$ nohup cat a.txt >/dev/null 2>&1 &

Terminate a process: Kill killall

$ kill 1267 1268 1269$ kill -INT 1267$ killall python$ killall -INT python

4. Network Management

Show Network Status: netstat

$ Netstat-LP # display listener $ netstat-LPN # display listener port $ netstat-T # display current connection

Dynamic viewing of website routes: MTR

$ mtr www.rainsts.net

DNS query: Dig

$ dig www.rainsts.net

IP Address Configuration: ifconfig

$ ifconfig$ ip a

Simple TCP listener and connection test tool (data can be sent in two directions): NC

$ Nc-l 8000 # listener $ NC localhost 8000 # Client

5. System Security

6. Compressed backup

Compressed/compressed: Tar

$ Tar CZF test.tar.gz./test $ tar CZF test.tar.gz a.txt B .txt c.txt # compress multiple paths $ tar TF test.tar.gz # view compressed Package content $ tar xf test.tar.gz-C ~ /Test # decompress the package to the specified directory

7. System Help

System Manual: Man

$ Man-K printf # Fuzzy search $ man-F printf # exact search

8. Related Software

Putty:

CTRL + S: block console output (for example, enter some sensitive information) Ctrl + Q: Restore console output
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.