Linux Command Line skills

Source: Internet
Author: User
Tags ssh port

Http://cloud.csdn.net/a/20120321/313378.html

I will share with you some tips on how to learn Linux Command lines, hoping to help you. If you encounter unfamiliar commands in this article, you can enter the following command on the terminal for help.

 
 
  1. Man <command> 

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

 Essential for getting started with Linux

  • Understanding Bash: there is no need to study the lengthy bash user manual. You can use man Bash to learn.
  • Understand VI: You may use Emacs or eclipse at work, but VI is irreplaceable.
  • SSH: learn the basics of password-free authentication.
  • Basic bash Job Management Knowledge: such as use &, Ctrl-C, FG, BG, Ctrl-Z, jobs, and kill.
  • File Management commands: such as hard links, soft links, and permissions.
  • Network management commands, such as ifconfig.
  • How to use regular expressions and grep and sed.
  • Learn how to use apt-Get and Yum management software packages.

Improve Daily Work Efficiency

  • In Bash, you can use the CTRL + R command to search for command line history records.
  • In Bash, you can use Ctrl + W to delete the last word and CTRL + u to delete the entire line.
  • Use the CD-command to return the previous working directory, and use the CD .. command to return to the upper directory.
  • Learn how to use xargs:
 
 
  1. $ find . -name *.py | xargs grep some_function  
  2. $ cat hosts | xargs -I{} ssh root@{} hostnameX 
  • Run the pstree-p command to view the process tree.
  • Understand different signals. For example, kill-stop [pid] is used to terminate a process. The detailed signal list can be viewed in MAN 7 signal.
  • If you want the process to run in the background forever, you can use the nohup and disown commands.
  • Run the netstat-lntp command to view the listening process and refer to the lsof command.
  • Use subshells In the bash script to group commands:
 
 
  1. #do something in current dir  
  2. (cd /some/other/dir; other-command)  
  3. #continue in original dir 
  • String trim (trimming strings): $ {var % suffix} and $ {var # prefix }. For example, if var?foo=then echo =#var=.pdf.txt .txt prints "foo.txt ".
  • Command output can be used as a file. For example, compare local and remote/etc/hosts files:
 
 
  1. diff /etc/hosts <(ssh somehost cat /etc/hosts) 
  • Learn about "Here documents" in bash ".
  • Learn about standard output and standard error redirection.
  • Learn about ASCII code tables. You can run the man ASCII command on the terminal as a reference.
  • When working remotely through SSH, you can use screen or dtach to save the session.
  • For Web developers, commands such as curl and wget are very useful.
  • Convert HTML pages into text files:
 
 
  1. lynx -dump -stdin 
  • The xmlstarlet command is a good tool for understanding XML.
  • Understand ssh port ing.
  • You can use the Alt + Shift + 3 shortcut to add the comment "#" before the row.

Data Processing

  • Understand sort and uniq commands.
  • Understand cut, paste, and join commands.
  • Learn how to intersection, combine, and set text files:
 
 
  1. cat a b | sort | uniq > c # c is a union b  
  2. cat a b | sort | uniq -d > c # c is a intersect b  
  3. cat a b b | sort | uniq -u > c # c is set difference a – b 
  • Abstract The second column of a text file. The following code is more refined and fast (3 times) than the same Python code ):
 
 
  1. awk '{ x += $2 } END { print x }' 
  • Understand the string and grep commands.
  • File segmentation: Understand the commands of Split (split by size) and csplit (split by matching.

System diagnostics

  • Use iostat, netstat, top, and dstat commands to view the status of disks, processors, and networks.
  • Use commands such as free and vmstat to check the system memory status.
  • Use MTR network diagnostic tools.
  • Use iftop, nethogs, and other tools to view the process and bandwidth occupied by the bandwidth.
  • Use the AB tool to quickly understand the performance of web servers.
  • Use Wireshark and tshark commands to diagnose complex networks.
  • Learn how to use strace and diagnose running processes. This is very helpful for analyzing the cause of program running errors.
  • Run the LDD command to view shared library files.
  • Learn how to use GDB to connect to a running process and trace the stack.
  • Knowledge about/proc is very important.
  • How can I diagnose an error? The SAR command is a good choice for collecting, storing, and reporting system information.

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.