Today we continue to learn our instructions about Linux. There are many more instructions today than last time. Let’s start our study.
man manual
Let’s look at the title first. The first thing we think of about the manual is the search function of the manual. We all know that when we were in elementary school, if we encountered a word we didn’t know, we would read the pinyin of the word by consulting the dictionary. Of course We will also directly ask the teacher how to read. At this time, the teacher is like this man.
Our Linux also has its own manual, which we can use to check our daily instructions and some functions of the C language. Let's take a look together.
When we run man ls we will enter the manual.
We can look up the meaning of ls. When we want to exit, we only need to click Q on our keyboard to exit our manual. However, some people don't know what man is, so we can also look at it this way.
man man command to see our manual.
We can see these. What we will commonly use in the future is the 1 2 3 manual. When we use it, we point it in order. For example, we also have printf under Linux. Let’s take a look.
We can also use man printf.
We will come back to explain this later, but let’s take a look now.
man manual installation
Some cloud servers do not have man manuals, we only need to enter the command yum install -y man-pages
We must also switch to root before we can install it. Ordinary users cannot perform this command. Of course, we can also perform su privilege escalation on the command later. I will talk about it later. Here, you only need to switch to the root super user when installing. Just install it.
You can also try it after we install it.
I found that the man manual can also be used. The query is printf in C language. Why can the man manual also query C language? Because in fact, many of our Linux are written in C language.
man [options] command
We have also written this content, and then cat can print out the contents of our file. Let's first talk about how to use our cat command.
cat
: cat [ choice ][ text ]
So the usage of cp is
cp src dst
We said above that cp src dst can only operate on files. If we not only want to operate on files, we also have to operate on directories. We all know that to operate on directories, we can write cp -rf. The r here means recursive copy. , f is mandatory. Don’t ask me whether I want to copy it, just copy it. I’ll give it a try.
We also saw that it was copied successfully.
The cp command is used to copy files or directories. If two or more files or directories are specified at the same time, and the final destination is an existing directory, it will copy All files or directories specified previously are copied to this directory. If multiple files or directories are specified at the same time, and the final destination is not an existing directory, an error message will appear
Common selection :
Then we can use the mv command to cut files under Linux, let's take a look.
The above operation is to move our original directory a under 111 to lesson2, so the mv command is the following usage method.
mv [options] src dst
Of course, our mv can also be renamed, we can also take a look.
The following instructions are how to view the contents of the file.
We first need to create a large file. You can write the following code to create it. You can just copy and paste this code. We will talk about it later. Now you only need to understand that our code is to create 10,000 hellos. That's it.
cnt=1;while [ $cnt -le 10000 ]; do echo "Hello! $cnt"; let cnt++; done > large.txt
At this time we have a file called large.txt. Our current problem is how to check it. The cat we learned before will not work here because it can only print a full page, so it does not work. We will introduce a few new instructions here.
One is more
moer command
When we directly add more to our file, a whole page of hello is printed out, but we can only keep pressing Enter to query, and we can only query all the way down, not back, in case we use All of a sudden, if you press Enter too many times, you have to start over again, so this command is not very good. We also have more options, such as adding - number of lines to get to that line. Let’s take a look.
Click q to exit
This is the command that was just executed.
If there is more, there is less. Let’s take a look at less.
less command
less [参数] 文件
head指令 && tail指令
head
head [ 参数 ]... [ 文件]
tail指令
tail[ 必要参数 ][ 选择参数 ][ 文件 ]
今天的分享就到这里我们下次再见。