Home > System Tutorial > LINUX > Detailed explanation of commonly used text viewing commands under CentOS

Detailed explanation of commonly used text viewing commands under CentOS

WBOY
Release: 2024-01-09 19:13:57
forward
530 people have browsed it

Keywords: 1. Commonly used text viewing commands-------2. File types and basic permissions

1. Commonly used text viewing commands

Show the commands one by one, and then introduce cat---- more----- less -----head----- tail

I usually use cat more often in actual use. got used to. . . . Look at the picture

Detailed explanation of commonly used text viewing commands under CentOS

The benefit of more is that you can display the content you want to see based on %

What is more free to use is less. Various shortcut keys help you realize the adjustments you want to complete! (You can do it yourself)

Letter j k page up and down

G Jump to the end of the line

g reaches the beginning of the line

The space bar is also very useful! !

Let’s do head and tail like this. They display the output results in reverse. One displays the first ten lines of the text (head) and the other displays the ten lines after the text.

You can specify how many lines to display at the same time (compare the cat display content in the picture above, you can find the difference)

Detailed explanation of commonly used text viewing commands under CentOS

Detailed explanation of commonly used text viewing commands under CentOS

One displays the last line of the file text and the other displays the first line

Write it completely: head -n /etc/passwd || tail -n /etc/passwd (-n represents a number)

! ! ! ! Just add the numbers and that’s it! ! ! !

2. File types and basic permissions

Everyone remembers the command when learning ls. In order to see the detailed information of the file, you will use ls -l or ll

Detailed explanation of commonly used text viewing commands under CentOS

Looking at such a long paragraph, don’t be impatient and tell me slowly!

I marked the previous one -rw-r--r--. Let’s look at it separately. Let’s look at it first -

This bit represents the file type

- Ordinary file

d directory file

l Link file

b Block device

s socket

c character device

p Pipeline file

Knowing such a large section, we can judge the file type based on this in the future

Then rw-r--r-- I won’t talk about it now, I’ll talk about it later.

Centos 6 and later this . is related to selinux, and some are followed by this. This is an acl problem. Just know it.

Then looking back, the two roots represent the owner: owning group and another user

----- ok now I can finally tell you rw-r--r--.

rw- is the owner root permission r-- is the permission of the owning group r-- is the permission of other users

r w x The meaning of expression

r----Read permission

w---Write permission

x----Execute

eg:

DRWXR-XR-X 10 Root Root 4096 09:49 Source 1

-rw-R-R-1 Root Root 1161 December 26 09:49 Search.php 2

Look at Example 1 and explain x. It is said above that it is execution permission

x It can usually be said to be execution permission (some ordinary files also have it). For directories, ‘x’ is very important. It determines whether we can enter the directory (cd)

More forward, the number 4096 in eg:1 ----represents the size of the file

The number behind the number December 26 09:49 represents the latest modification time of the file

After that is the file name

--------Let's talk about drwxr-xr-x. The number 2 behind it is inode. Use ls -i to see the inode number

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

Now that we have mentioned r-read w-write x-execute, that means these permissions can be changed, the command is chmod

How to change the problem? How to express it? ? ? ? ?

---Only one kind of digital representation is in the permissions r=4 w=2 x=1 I want to change the 1.txt I created myself. So do it like this

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

The default file permissions are 644, which is (rw-r--r--)

So the default 644 (rw-r--r--) of the 1.txt I created is (4 2--4--4)=644

I want to change the permissions of my 1.txt to 666. See the picture (see the arrow I marked)

Detailed explanation of commonly used text viewing commands under CentOS

Let’s take another look at the directory

Detailed explanation of commonly used text viewing commands under CentOS

I added a parameter -R so that when used in a directory, the permissions in the entire directory can be modified recursively! ! Just look at my pictures. .

Then we continue to introduce the owner and the owning group

The owner and ownership group of the file can also be modified using the chown command

I also use the test1 file. I also created 2 users test1 and test2. Look at the pictures and talk.

Detailed explanation of commonly used text viewing commands under CentOS

The previous owners and groups of directory test1 were all root. First, the owner was changed to test1.

Change owning group

Detailed explanation of commonly used text viewing commands under CentOS

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

Detailed explanation of commonly used text viewing commands under CentOS

The above is the detailed content of Detailed explanation of commonly used text viewing commands under CentOS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jb51.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template