118 Notes Linux Command Chapter

Source: Internet
Author: User
Tags echo command

Linux Command Summary


1 mkdir Make Directorys example: Mkdir/data Create data directory at root/Bottom

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-6ab736b9b5cf9ccb.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

2.ls List Directory file example: LS/Reagan/directory directory and file.

-L (long) long format,-D (Directorys) view directory.


650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-d3c6fb58bffba58a.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-23ef45bc95778a60.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

3. Remark '/' this is called root.

CD Change Directory Example: CD/ETC is switching to etc inside.

The CD is followed by a relative path or absolute path, indicating access to the directory. If you do not want to follow anything, it will go into the current user's home directory.

Relative path concept: Start from the current directory instead of/start. Example: data/, Mnt/oldboy

Absolute path Concept: The directory from/start is called absolute path. Example:/data/, Mnt/oldboy

Linux absolute path: Cat/etc/sysconfig/network-scripts/ifcfg-eth0, the path from the root/start.

Relative path: A path that does not start with a/root and does not start at the beginning (/root).

4

PWD print (print) Work directory (directory)

Print working directory (show current path)

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-6cd260abc686b5ba.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

5

Touch create a file or update the timestamp of the file, if the file does not exist, create a new file, if the file exists, change the file access time Atime and other timestamp information.



(speak, answer questions, learn to give examples.) Let others understand. )

Question One (how do I create a/data file?)


650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-4aa6806710c46b9d.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

Mkdir/data or

CD/

Madir data

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-63d5bb9de47b74e8.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>


2. Create a file under/data oldboy.txt

Answer:

Command answer:

The first method:

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-cad8fd2f6b43729c.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

The second method:

Watch the word,

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-e2aec93a6d56f779.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

Small knowledge Point: How to create 1 to 10,000 folders in one second

Use

Touch stu{1..10000}

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-1da00f2b4f0db78b.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

3. Add the content "I am studying Linux" for the above oldboy.txt.

Answer:

(vi's basic editing method)

Execute VI oldboy.txt Enter VI editor (default command mode) Click A or I into the edit mode, tap the content I am studying Linux, and then press the EAC key on the keyboard to exit (and then enter the command mode), and finally knock: Wq (write quit).

You need to press A or I to enter the editor to insert (edit) the status.

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-28dd663a8ef8198f.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>


Press ESC to change to the command state when the edit is complete.


650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-59f2b96bd820910f.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

In the command state we usually use

: Wq (w indicates meaning of writing, q indicates meaning of exit)


Then we can use

Cat Oldboy.txt

To see the text we just wrote to Oldboy.txt.


650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-21ec1ea0e78f41aa.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

To learn how to make a picture, this is the best way to learn.

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-4aed097fe104802e.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

Teachers provide

What if you don't want to save it?

: Q (Exit does not save)

: q! (Forced exit)

Small knowledge:

VI equivalent to win Notepad, simple. Example: VI oldboy.txt

Vim Complex editor. Student movement must learn to use the editor, function complex, highlight, auto Indent (write

2. The second creates a Oldboy.txt method with (I am studying Linux).

Rm-f oldboy.txt (means delete this file) and then use

LS (view files in current directory)


650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-cc43252e3fa60335.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

It's simple.

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-b180b8aad70e4cc2.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

If the file exists, the file will be emptied of the existing content, put in front of my single quotation marks. (cover) This is more dangerous.


2. This is common in the enterprise: a single line of content is appended to the end of the file.

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-5e0922fae153f7c5.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

3. Special editing file method, use single quotation mark to append the contents of quotation mark through >> to/data/oldboy.txt through echo command, note: Append is increment, not overwrite.

The cat checks for additional results.

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-2e33621c9bd39f0a.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

Description here:

9

Echo is a common command to print out content, with ">" or ">>" to overwrite and append to the file, and this command can be mastered.

">" means to redirect, to be clear about all the previous data in the document,

">>" is appended to the content, only the required content is appended to the end of the file, and there is a more complex and less common command like printf.

Fahsarm

Write scripts commonly used, append multiple lines, the content is placed in the end of the file ...


Summarize:

VI: Text Editor

mkdir: Creating a Directory

LS: View current directory list ls-l (long list)

PWD: View current directory

Touch: Create Text

Cat: View Text

Echo ' * * * * ' >> append to Text

Echo ' * * * * * > Replace the original text content (no this will be created automatically)

Rm-f ****.txt Delete Text

Cat >>***.txt Append to Text

Cat >***.txt This can be written directly to the text, note: After the input is completed to the next line to press CTRL + C or ctrl+d to save the exit. I tried it several times before I knew it. I'm Comlrol on Mac OS (that's ctrl). Replace the original content (no text will be created automatically)

>****.txt will empty the contents of the file (because nothing in front of it can be written).

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-148b5ad3b67469f9.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

RM-RF * * * * (directory name) This is used to delete directories.

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/2776915-68bb626f9e568398.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "alt=" 1240 "/>

Special symbols:

> or 1> output redirection: The output from the previous input into the file behind, will erase the original contents of the file.

>> or 1>> Append output redirect: Append the front output to the rear end of the file, will not erase the original contents of the file.

0< or < input redirection: Input redirection is used to change the input of the command, followed by specifying the input, preceded by the file name.

0<< or << append input redirection: followed by a string that is used to denote "end of input". You can also use Ctrl+d (MAC with Conlrol+d).

2> Error Redirection: Entering the error message into a file behind it will delete the original contents of the file.

2>> wrong I append redirect: Appends the error message to the file in the back, does not delete the original content of the file.

Description

1. The direction of the arrows is the flow of data.

2. Number Description:

A. Standard input (stdin): code 0, using < or <<. Data flows from right to left.

B. Standard normal output (STDOUT): Code 1, using > or >>. Data flows from left to right.

C. Standard error Output (STDERR): Code 2, using 2> or 2>>.


This article from the "12125480" blog, reproduced please contact the author!

118 Notes Linux Command Chapter

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.