Shell Basics and usage tips (Tools + Common bash commands to accelerate operations)

Source: Internet
Author: User
Tags aliases

shell scripting Introduction and common Tools
    • Shell Script
      • Shell script: is actually a batch script in Windows, multiple shell command collections that can be executed at once. Scripts on Linux can be implemented in a number of languages, and the bash shell is a relatively simple one, and the higher-order can be used in other scripting languages, such as Python.
      • Shell scripts are very powerful in managing the system and can even use the shell to implement Web-managed Linux features with PHP: You can write a Web page (example: PHP-based) to manage the system, including viewing deleted users, configuring the network, sending mail, rebooting the system, One-click Backup, one click to build the server.

    • Build an efficient Shell scripting development environment (PUTTY+WINSCP+SUBLIME)
      • Knock command directly with Putty, in order to avoid moving in the virtual machine to move, the mouse recognition affects the speed.
      • If the development script suggests using Winscp+sublime to implement script development. Sublime development of HTML or scripts are very fast, you can learn about sublime, known as the industry's development artifact, the complete function is very powerful.
frequently used bash commands to speed up operations
  • TAB Auto Completion: Very useful
  • Command History history:history/! (Number of command lines) or Yes! Match character
      • (! VI invokes the last command in history that begins with VI)
      • (! 5 will call the fifth command in history)
  • Command aliases
      • (alias lists the current aliases)
      • (alias alias = ' Linux command ')
      • (Unalias alias, alias cancellation)
      • (Persistent command aliases need to be changed under the user root directory (/ROOT/.BASHRC). bashrc file)
  • Output redirection (the result of the command is not displayed on the screen, but the reality is in a specific area)
      • Commands > redirected files, overlay redirection (ifconfig eth0 > Test.txt: Enter the case of the eth0 NIC into the Test.txt file in the current directory)
      • Command >> redirect file, append redirect (ifconfig eth0>> test.txt: Input the eth0 nic into the Test.txt file in the current directory)
      • Command 2> redirect file (AAAA 2>test.txt: input error command into Test.txt, no write number defaults to 1>, indicates the correct result is written to the file. If 2> is specifically indicated, the error result is written to test.txt)
      • Command &> redirect files (bash test.sh &> all.txt, redirect both the correct script and incorrect results to the all.sh file)
      • Append Redirect to append the wrong result along the 1 channel to the Test.txt file (bash test.txt 1>>all.txt 2>&1)
  • Pipe Operation (|, the left output as the right input)
      • Using the pipeline to view mem memory (Eg:free-m|grep-i mem)
      • | Pipelines can be used multiple times in one command (eg: View available memory Free-m|grep-i Mem|awk ' {print $4} ')

Shell Basics and usage tips (Tools + Common bash commands to accelerate operations)

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.