Linux instructions (2) + complete mind map + real picture examples + in-depth details + easy to understand suggestions for collection


introduction

        The learning of commands is a long process, because in general, in order to reduce the resource consumption of refreshing the graphical interface on the background server, it is presented in the form of a command line. For this, we must master the commands of Linux. Today we continue to learn more instructions following the instructions in the previous chapter.

Not much to say, fasten your seat belt and start the car (it is recommended to watch on the computer).


Attachment: red, the part is the key part; the blue color is the part that needs to be memorized (not rote memorization, knock more); black bold or other colors are the secondary key points; black is the description need


mind Mapping:

 

If you want XMind mind map, you can private message


Table of contents

1.man

2. cp command

3. mv command

4.cat

5.more

6.less

7.head

8.tail        


1.man

Knowledge points:

Function: Linux commands have a lot of additional instructions, we can't remember all of them , so you can get help by checking the online manual. The command to access the Linux man page is man

Basic syntax: man + the command you want to view

Practice using:

 When you enter the above command, some English explanations of this command will pop up.

 Press q to quit

We can also check the man

It is divided into manuals in man, with 9 manuals, mainly the first 3

Basic commands, system calls, library functions,

So if you want to check some library functions, you can

If an error will be reported at this time, first use yum install man-pages under the root user to install the man manual

In addition, for man, he will start looking for manual 1 first, and if there is no manual, he will continue to search for manuals later


2. cp command

Before learning the cp command, let's roughly learn two auxiliary learning commands

  1. cat : view the contents of a normal file .
  2.  echo :

    1. Echo is followed by a string,  and the string is printed directly on the screen

    2. If you add > at the end, it can be written to the file ( redirection : at this time , the target file will be cleared first, and then overwritten and printed ; if you don’t want to clear it, we can use >> two greater than symbols to perform additional redirection , among which echo will wrap automatically, if you want not to wrap, you can use printf , if the redirected file does not exist, a new file will be automatically generated).

Knowledge points:

The function of cp: copy files or directories

Syntax: cp source file/directory target file/directory

detail:

Additional instructions:

-r : Recursive processing, note that we need to add -r when copying a directory

 -i : user will be asked when overwriting files

-f : Force copy, regardless of whether there is a directory/file with the same name (a file with the same name cannot exist in a directory)

At this time, regardless of whether it will be overwritten or not, it will be directly overwritten


Practice using:

At this time, copy the contents of the test directory to the l1 directory with cp test/* l1


3. mv command

Knowledge points:

The mv command is the abbreviation of move, which can be used to move files (cut) or rename files (move (rename) files). It is a commonly used command in the Linux system and is often used to back up files or directories.

All mv actions are cut and rename

detail:

For mv, its functions for files and directories are basically the same, but note that:

When a directory already exists , if you want to move and rename it to the existing directory , the existing directory will not be overwritten at this time, but the directory to be moved will be placed in the existing directory go


Practice using:

Renaming of mv:

  1. Rename the file directly

cut of mv

  1. Cut and rename, where ../ represents the cut position test2 represents the renamed name 
  2. Cut but not rename, where test/ indicates that the copied position is not followed by the renamed name, so the name is still test2

But actually renaming is the same as cutting

where: rename mv t3 T3 == cut mv t3 ./T3


Additional knowledge points:

  1. ctrl c : Stop the program/instruction exception/or it can be used when you don’t want to use this instruction, you can directly add ctrl+c at the end of the instruction and it will automatically jump to the next paragraph
  2. In fact, each instruction is an executable program , generally speaking, the green mark is an executable program

    We can even put our own executable program mv into it, so that it can be used as an instruction (but it is not recommended because it is easy to forget after a while)

  3. In our computer world, all software, tools, and instructions are executable programs

  4. alias can modify/add some instructions to change the meaning of the instruction and reduce ls -l to ll

  5. Everything is a file under Linux : monitors, keyboards...they are actually files too

 


4.cat

Knowledge points:

Syntax: cat [option] [file]
Function:
view the content of the target file

detail:

Additional instructions:

  1. When using cat alone, it will print out what you input directly
  2.  -n : add line numbers to the file content 
  3. -b : Add line numbers to non-blank lines
  4. -s : Do not output multiple blank lines (only output one blank line when there are consecutive blank lines) 

5.more

Knowledge points:

Syntax: more [option] [file]
Function: more command, the function is similar to cat
, but for cat, when he reads the file, he starts to read it directly from the end . When there are many lines in a file, it is not easy to go Turn up (there are 10,000 lines, when you need to find the 1000th line), so cat is only suitable for reading small files, while the more command is from top to bottom, and you can also specify the start.

detail:

  1. Press q to exit more
  2. press enter to scroll down
  3. /n You can search directly (n is the number of lines from the beginning)

 Additional instructions:

-n : Number all lines of output, and specify which line to stop at

details as follows:

Input: more -1000 t   (-1000 starts from 1000, t indicates the file to open)

Note: When you specify the header as -1000, it should be noted that if you use /n, the first layer starts at 1000, and you need -1000 to be the same as the number of layers you want.


6.less

Knowledge points:

Compared with more, more cannot be turned up , so we don’t actually use it often, and less can be used  to view the file content by pressing the up and down keys, so we generally use less

detail:

  1. You can also search backwards by / 
  2. You can also use ? to search for numbers marked to include (?9)
  3. press q to quit

7.head

Knowledge points:

Syntax: head -n file, get the first n lines of the file, if not written, get the first 10 lines by default


8.tail        

Knowledge points:

tail is used in the same way as head, except that the number of lines extracted is counted from the tail at this time

practise:

When we want to get line 1000 ~ 1020 by using only head and tail

If the conventional method, it is necessary to create a temporary file first (first use head to get the first 1020 and put them in the temporary file, and then get the last 21 through tail to view)

At this time , it can be done through the pipeline . At this time, there is no need to create a temporary file, because for the pipeline, it will output the left side to the pipeline file, and then use the right side in the pipeline file. At this time, the pipeline file is A memory-level file always exists, and we don't need to create a new file on disk.

In fact, the concept of pipelines is very similar to that in reality. Like our natural gas pipelines, one side transmits natural gas into the pipeline (output), and during the transmission process, the pipeline becomes a temporary storage container, and the other side needs to receive ( enter)


This chapter is over. To predict what will happen next, let's wait for the next chapter to break it down.

If you have any questions, welcome to discuss!

If you think this article is helpful to you, please like it!

Continuously update a large number of Linux detailed content, pay attention early and don't get lost.

Guess you like

Origin blog.csdn.net/ZYK069/article/details/130648952