Linux Command Line Tips __linux

Source: Internet
Author: User
Tags ssh ssh port

Turn from: http://cloud.csdn.net/a/20120321/313378.html


I'll share some tips on how to learn the Linux command line and hopefully it will help. If you encounter unfamiliar commands in this article, you can type the following command in the terminal to ask for help.

Mans <command>

Where there ' s a shell, there ' a way.

Linux Primer Prerequisites for bash: there's no need to delve into the proving Bash manual and learn from Man bash. Understand VI: You may use Emacs or eclipse in your work, but VI is irreplaceable. Learn about SSH: Learn the basics of password-free authentication. Bash Job Management Basics: Use &, Ctrl-c, FG, BG, ctrl-z, Jobs, and kill. File management commands: such as hard links and soft links, permissions, and so on. Network Management commands: such as ifconfig. How to use regular expressions, how to use grep, sed, and so on. Learn to use Apt-get and Yum management packages.

Increase your daily productivity in bash, you can use the Ctrl+r command to search the command line history. In bash, you can use Ctrl+w to delete the last word and use Ctrl+u to delete the entire row. Use the CD-command to return to the previous working directory, using the CD. command returns the upper directory. Learn how to use Xargs:

$ find. -name *.py | Xargs grep some_function $ cat Hosts | xargs-i{} ssh root@{} Hostnamex View the process tree using the pstree-p command. Understand the different signals. For example, use Kill-stop [PID] to terminate a process. A detailed list of signals can be viewed in Man 7 signal. If you want to keep the process running in the background forever, you can use the Nohup and disown commands. Use the NETSTAT-LNTP command to view the listening process and refer to the lsof command. Use Subshells to group commands in a bash script:
#do Something in current dir (Cd/some/other/dir Other-command) #continue in original dir string trim (trimming Strings): ${ Var%suffix} and ${var#prefix}. For example, if Var=foo.pdf then echo ${var%.pdf}.txt prints "foo.txt". The output of the command can be used as a file. For example, compare local and remote/etc/hosts files:
Diff/etc/hosts < (SSH somehost cat/etc/hosts) understands "here documents" in bash. Understand standard output and standard error redirection. Understand the ASCII code table. You can run the man ASCII command as a reference in the terminal. When working remotely through SSH, you can save a reply using screen or Dtach. For web developers, curl, wget, and other commands are very useful. Convert an HTML page to a text file:
Lynx-dump-stdin if you want to master the Xml,xmlstarlet command is a very good tool. Learn about SSH port mappings. Use the Alt+shift+3 shortcut key to add a comment "#" before a row.

Data Processing understands the sort and uniq commands. Learn about the cut, paste, and join commands. Learn how to make intersection, set, and difference sets for text files:

Cat A B | Sort | Uniq > C # c is a union B cat a B | Sort | uniq-d > C # c is a intersect B cat a b b | Sort | Uniq-u > C # c is set difference A–b a summary of the second column of the text file, the following code is more refined, faster (3 times times) than the same Python code:
awk ' {x + + $} end {print X} ' understands string and grep commands. File Segmentation: Understanding Split (split by size) and Csplit (split by match) command.

System Diagnostics uses the Iostat, netstat, top, and Dstat commands to view the status of disks, processors, and networks.

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.