Detailed text view commands commonly used in CentOS


Key words: 1. Common text viewing commands – – – 2. Types of files and basic permissions

1. Common text viewing commands

Let’s show the commands one by one, and then introduce cat – — more – — less – — head – — tail.

Usually I use cat more when I actually use it. Used to it…. Look at the picture


More has the advantage of displaying what you want to see per cent

Use less keyboard shortcuts to help you achieve, you want to complete the adjustment! (You can actually do it yourself)

Turn up and down the letter J K

G Jump End

G arrives at the head of the line

The space bar is also very useful!!

So head and tail.

At the same time, you can specify how many lines to display (you can see the difference by comparing the content shown in the cat above)



A last line displaying the text of a file or a first line displaying the text of a file

Write it down as head-n/etc/passwd | | tail-n/etc/passwd (-n stands for numbers)

!!!! Just add numbers!!!!

2. Types of files and basic permissions

Everyone remembers the commands when learning ls. In order to see the details of the file, they use ls-l or ll.


Look at such a large section, don’t rush to slow down!

Let’s look at it separately.-

This one represents the file type

– Ordinary documents

D directory file

Link file

B block equipment

S socket

C character device

P Pipeline File

You can judge the file type based on this after knowing such a long period of time.

So rw-r–r — not to mention first, but later.

This one appeared after CentOS 6. It has something to do with selinux. Some of them are followed by + this is the problem of acl.

Looking back, two roots represent the owner: the owner group and another user.

So far, OK can finally tell you rw-r-r.

RW – is the owner root privilege; R — is the group privilege; R — is the privilege of other users

Meaning of the expression r. W. x

R – Read permissions

W – – Write permission

X – Implementation


Drwxr-xr-x 10 root 4096 December 26 09:49 source 1

– rw-r–r–1 root 1161 December 2609:49 search.php.2

Look at Example 1 and explain what x says above is execution permission.

X. Usually it can be said to be execution rights (some ordinary files are also available). For directories,’x’is very important. He decides whether we can enter directories (cd).

Next, the number 4096 in eg:1 — represents the size of the file

Following the figures, December 2609:49 represents the latest revision time of the document.

And then there’s the filename.

——- Let’s talk about drwxr-xr-x. The number 2 after drwxr-xr-x. That’s inode. You can see the inode number with ls-i

The numerical meaning is (several files use the same inode node number)

Now that r-read w-write x-execute is said, these permissions can be changed, the command is Chmod

How to change the expression of the question??????

I want to change the 1.txt I created myself.

The default permission of directory 755 is (rwxr-xr-x)

File default permission 644 is (rw-r–r–)

So the default 644 (rw-r–r–) conversion I created for 1.txt is (4+2–4–4) = 644.

I want to change my 1.txt permission to 666 to see the picture (see my arrow)


Look at another one about directories.


I added a parameter – R, which can recursively modify the permissions of the entire directory when using the directory!! Just look at my picture.

Then we go on to introduce the owner and ownership group.

File owners and ownership groups can also be modified using the chown command

Also using the test1 file, I also built two users test1 and test2 to talk with pictures.


The previous owner ownership groups of directory test1 were root, and the owner was modified to test1.

Change ownership group


I want to change back???? Keep looking at the pictures and talking.