Linux entry-level operations commands

Source: Internet
Author: User
Tags parent directory

Create a Directory

mkdir Creating a Directory

Mkdir-p automatically create a parent directory even if the parent directory does not exist

View Catalog

LS view content in the specified directory

Ls-l displaying the details of a directory or file

View your current directory

Pwd

Switch directories

Cd

Create a file

Touch

Touch T1.txt T2.txt T3.txt can be created synchronously with multiple file names

Edit File

View Files

Cat view files all at once

More Paging View file contents

Less paging view file content, more features supported than more support back to see

Copy

Cp

CP Copy Object Copy destination

If the copy object already exists at the destination, then you can write \CP cancel the file already exists reminder, overwrite the original file directly

Shear

MV Cut Object Clipping destination

Delete

Rm

Rm-f force deletion of files without deleting confirmation

RM-FR Force Delete directory, do not prompt delete confirmation

Get the first n rows of a file

Head-n 10 getting the file 10 lines from the head

Tail-n 10 countdown from the tail gets the file 10 lines of content

Seq Build Queue

SEQ 100 generates a sequence of 1 to 100

Seq 10 20 generates a sequence of 10 to 20 steps of 1 10,11,12,13 .... 20

SEQ 10 2 20 generates a sequence of 10 to 20 steps of 2 10,12,14,16 .... 20

redirect

>

Redirect generated results to a place, usually a folder

For example, the above sequence can write the results directly to a file seq. 2 >test.txt

View aliases

Alias

You can alias the command to a long command, to simplify the command alias ipr= ' IP addr '

You can also de-name Unalias IPR

Find

Find finds out just a string display format

Find files with file names ending with. SH in the Oldboy directory Find/oldboy-type f-name ' *.sh ' got just the results.

Tail plus |xargs convert to real file object

Pipe character

| The left command result can be executed as a condition for the right command to start.

For example, there is a file with 50 lines, I need to see his 20 lines of 30 lines of content. So I can use head and tail at the same time.

Head-n-Ett.txt|tail-n 11, multiple-pipe-separated commands, ready to work from the back-to-back, when executed from the rear, in turn to increase efficiency and reduce waiting response time

Global substitution

Sed There are many places in your project where you need to modify the original file name, and this is the best time to use SED

Sed ' s## #g ' initial format, the middle three identical symbols can be arbitrary, the first two middle put the original name, and the last two symbols in the middle of the new names after the modification

Sed ' s#./hostlists.txt#. /idctest_iplist#g '

The Three Musketeers of Linux

grep is best at filtering

SED is best at replacing

Awk is best at fetching columns

Grep-v ' Oldboy ' test.txt filters all items that do not contain the Oldboy keyword

grep '-A ett.txt filters The contents of the file 20 and the previous 10 lines

grep '-B ' ett.txt filter the contents of the file 20 and after the 10 lines

grep '-C 5 ett.txt Filter the contents of the file 20 as well as the previous 5 lines and 5 lines after

Sed ' s#./hostlists.txt#. /idctest_iplist#g ' file suffix name is preceded by the back

awk ' nr>19 && nr<31 ' ett.txt filtering file contents with serial numbers greater than 19 and less than 30

awk ' {print $} ' test.txt print the contents of the third column of the file

Directory switching

CD/root directory

Cd. Current directory

Cd.. Top level directory of current directory

CD-The directory where you Last

Range

Create 100 Files Touch test{1..100}

Create three files Touch test{1,3,5}

Linux entry-level operations 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.