Linux Shell Vim often uses commands, usage tips to summarize

Source: Internet
Author: User
Tags add numbers get ip

Objective

This article summarizes the actual development of their own regular use of commands, not regularly updated to facilitate their own and other people to consult.

If there are other use techniques to improve efficiency. Welcome message.

This address http://blog.csdn.net/never_cxb/article/details/47803991 reprint please indicate the source

Linux often uses commands basic
    • cd -Go back to the last working folder

    • export LANG=en_US, export settings for environment variables can also be used for child shells

    • ps -ef | grep nginxSearch. There's a pipe in here.

    • passwd rootChange Password

    • topMonitor CPU memory, etc.

    • $?The exit status of the last command run. Success is 0, unsuccessful is not 0

    • hostnameGet IP

LS frequently used in the number of parameters
  • -aList all (including hidden files, etc.):
  • -ltrAccording to the time ascending
  • -ltAccording to the time descending

  • Number of statistical files

    wc -lNumber of output file lines, i.e. number of files

    Ability to grep filter files by

    [Root@** _posts]#ls-ltotal156-rw-r--r--1Root root13607The -  -: -android-interview.md-rw-r--r--1Root root16287The -  -: -arrays-Sort. md-rw-r--r--1Root root2951The -  A:GenevaCommon-tools.md[root@** _posts]#ls| Wc-l3[Root@** _posts]#ls| Grep". MD"| Wc-l3
Find Files
    • locate
      Locate is based on the internal system table, fast, but may not update immediately
    • find . -name "*.sh" -or -name "*.c"
      Find instant lookup with relatively slow speed
Port Usage # #
    • netstat -tnpl | grep 12
    • kill -9 42312Kill the process,-9 means force kill
Sed use

There are many ways to use it.

‘$d‘ datafile#删除最后一行,其余的都被显示‘/my/d‘ datafile#删除包括my的行,其余的都被显示
Common ways to use the shell

$#Indicates the number of parameters received
$1Indicates the first few parameters

if  [ $#  -ne  4 ] Then  echo   "Usage:bash autofetch.sh <space > <windows/linux> <command> <number> " exit -1  fi  which=$1  Span class= "Hljs-keyword" >if  [$2  =  "Windows" ]then  machine=windowselif  [$2  =  "Linux" ]then  Machine=linuxfi   
Vim is often moved using the command direction
    • h, j, k, lMove left, bottom, top, right, respectively

      Add a number to these J-numbers, indicating the multiple of the move. For example, "10j" means moving down 10 rows

    • ^Move the cursor to the beginning of the line 0 (number 0) can also achieve the same function
      ^ is the first non-whitespace character to move to the beginning of the first line
      0 just move to the beginning of the line without distinguishing between whitespace or non-whitespace

    • $Move cursor to end of line

    • ggBack to the beginning of H the file and back to the top of the file

    • Gto the following
Copy and paste
    • ddDelete, preceded by a number indicating how many rows were deleted, for example 100DD
    • dwDelete a word
    • d$Delete the word to the end of this line
    • yyCopy
    • pPaste
      They all have the ability to add numbers to indicate how many lines of operation
Enter text
    • iInserts the current text position into the insert
    • aInsert append after the current text
    • oInsert Next line

    • wCursor to the beginning of the next word

    • eMove the cursor to the end of the next word
Find replacements
    • /stringFind
    • nFind the next matching
    • :set nuShow line Numbers
Save
    • :wqWrite and exit
    • :q!Force quit do not save changes
Online learning

Recommend an online learning vim site http://www.atool.org/vim.php

References

http://easwy.com/blog/archives/advanced-vim-skills-basic-move-method/

Linux Shell Vim often uses commands, usage tips to summarize

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.