Summary of some useful Linux commands

Source: Internet
Author: User

some of the practical Linux Command Summary

1. Enable the Vim editor to automatically add line numbers when editing

echo "Set Nu" >>/etc/profile


2. Manually add line numbers in the Vim editor

When Vim is turned on, enter set nu in command line mode


3, when entering English words, the distance between each letter is very large

 
4, when reading text, print lines that begin with spaces and #
Cp /etc/profile /exercise/test.txt
egrep -v  "^$ |  ^# " test.txt

5, print nth row
head -100 | tail -1     Print line 100th
or head -n 100 | tail -n 1
history | head -100  | tail -1   the 100th line of the print history, or 100th history

6, find the 10 most recently modified files in the  /  directory
 ls  -1t / | head -n 10
 
 7, empty file Abc.txt
 echo > Abc.txt
  or Cat/dev/null > Abc.txt
 ,
 8, two useful Shortcuts
  (1), ESC +.   Indicates that the previous command is displayed in the command window (plus not counting the keys)
  (2), CD-      switch to the previous directory
 
 9, Sort by the 3rd column of the printed thing, And the previous 5 lines are displayed.
 cat-n/etc/passwd | sort-nk 3| head-n 5

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/91/AF/wKiom1j3apGQ0pYqAABLO19xuVE839.png "title=" Sort.png "width=" "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:700px;height:110px; "alt=" Wkiom1j3apgq0pyqaablo19xuve839.png "/>

"Cat-n to show line numbers, and after sorting by the 3rd column, the preceding line numbers also change"


10, add line number

(1), when opened with the Vim text editor, the method of displaying the line number:

In command-line mode: Set Nu

or echo ' Set Nu ' >>/ETC/VIMRC again Source/etc/profile

(2), when displaying a text document, precede the text document with the line number method:

Cat-n filename

or awk ' $0=nr ': ' $ ' filename

"Both just change the screen output and do not change the source file"

(3), add the source file inside the line number

cat-n filename > filename1

CP filename1 FileName

Note: The method is old and constantly updated


















This article is from the "12300166" blog, please be sure to keep this source http://12310166.blog.51cto.com/12300166/1917545

Summary of some useful Linux commands

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.