My experiment Linux - Chapter 6 (file permissions and directory configuration)

Chapter 6

1. users and groups

File access can access the identity of the three categories

  1. owner
  2. group
  3. others

Accounts recorded in the / etc / passwd file
password in / etc / shadow file
user group names recorded in the / etc / group file

2. Linux file permissions concept

2.1 Linux file attributes

Here Insert Picture Description
ls command to display the name of a file and related properties.
To Hide file when the file beginning.
The first column represents the file type the letters of permission.
File size capacity, the default unit is B

Terminal command line can not display Chinese, if you want to set the system default language, set the file / etc / sysconfig / i18n.

Note: This only applies to CentOS 5,6. In CentOS 8 has no such files, as opposed to, you can set the system default language by modifying the file /etc/locale.config

For a directory, have both r and x permissions of people to enter; w have permission to write.

2.1 change file attributes and permissions

command effect
chgrp Change the user group
chown Changing Ownership
chmod Change permissions

Note: We use the cp command to copy the file to someone else, the file attributes and permissions will be copied together. So if you want others to use our copy of the file, you also need to change the file attributes and permissions
Note: When we use these three commands folder will not have folder files from the effect. If you want to simultaneously change the folder properties and permissions in the file, add -Rthe option to perform recursive folder.

When using the chmod command, you can use two methods: digital change and letter changes .

  1. Digital Law
letter Digital representation
r 4
w 2
x 1

Experimental Procedure:
Here Insert Picture Description
2. letter method

experiment:
Here Insert Picture Description

Permissions meaning 2.2 files and directories

2.2.1 r rights

In the first drawing under the root user to set permissions:
Here Insert Picture Description
then switch a regular user testing:
Here Insert Picture Description
Use ls can see the file name, but did not know the property with ll file.
The strange thing is, you can not use the cat command to get the echo file.
Use the vi command to open the file, you can not see the contents of the documents can not be edited:
Here Insert Picture Description
cd command can not be used:
Here Insert Picture Description

2.2.2 w permissions

The following diagram first to set permissions on the root user:
Here Insert Picture Description
and then switch to test an ordinary user:
LS, LL, CAT can not be used:
Here Insert Picture Description
the use of echo redirect files can not be changed:
Here Insert Picture Description
the same, using the vi command to open a file, you can not see the file content can not be edited:
Here Insert Picture Description
cd command can not be used:
Here Insert Picture Description

2.2.2 x permissions

In the first drawing under the root user to set permissions:
Here Insert Picture Description
Anyway, root can always execute an executable file:
Here Insert Picture Description
and then switch to test an ordinary user:
Here Insert Picture Description
LS, LL, CAT command can not be used.
cd command can be used.
Executable files can not be used!

2.2.2 rx folder permissions, file permissions x

The following diagram first to set permissions on the root user:
Here Insert Picture Description
not, who can tell me why testdir up and down the folder permission settings are not the same?

An ordinary user and then switch to test:
Here Insert Picture Description
the executable file can not be executed.

2.2.2 rx folder permissions, file permissions rx

In the first case the root user to set permissions FIG:
Here Insert Picture Description
before switching a normal user test:
Here Insert Picture Description
may be performed.

As can be seen, in order to execute executable file, folder and file permissions should rx.

2.2.2 Folder rwx permissions, file no authority

However, if a user has rwx permissions to the folder, while he had no permission to file in this folder, although the user can not view, modify, and execute the file, but the user but can remove it.
It's like I've got a stone, although I do nothing on this stone, but throw it out, I can still do.

3. Directory Configuration

This chapter also describes the FHS standard directory configuration, but some directory changes, I change I found listed here.

3.1 / bin, / lib, / lib64, / sbin directory

CentOS 6 Screenshot:
Here Insert Picture Description
CentOS 8 shots:
Here Insert Picture Descriptionthe map can be seen, these files in the root directory folder has become symbolic links.

3.2 /etc/init.d directory

6 CentOS:
Here Insert Picture Description
CentOS 8:
Here Insert Picture DescriptionSince the time of the revision CentOS 7, this folder has been moved empty.
This is the README information in the figure above:
Here Insert Picture Description

3.3 / selinux directory

6 CentOS:
Here Insert Picture Description
CentOS 8:
Here Insert Picture DescriptionCentOS 8 simply do not have this directory, the directory does not know where to run?

3.4 CentOS View

View Which Linux distribution using standard.
6 CentOS:
Here Insert Picture Description
CentOS 8 did not have the command. . .

Published 12 original articles · won praise 2 · Views 518

Guess you like

Origin blog.csdn.net/qq_45582319/article/details/104293277