[LINUX] Finding out about file permissions and superuser

I was ignorant about Linux file permissions and permissions, so I looked it up.

Introduction

Files handled by Linux are owned by everything from files created by yourself to libraries provided by the system to execution commands. The owner of the file can freely set the access right to the file.

Confirm file owner

$ ls -l /bin/cat
-rwxr-xr-x  1 root(File owner)  wheel(The group to which the file belongs)  23648  9 21  2018 /bin/cat

group

A group is a group of users.

By assigning multiple administrator users to a group called wheel that manages the system and giving permission to the wheel group, it is possible to give the same authority to multiple users who have the same role.

About users

File permissions

In each file, information that defines the authority *** "Allow anyone to perform what kind of operation" *** is set.

-rwxr-xr-x(File type and file permissions) 1 root(File owner)  wheel(The group to which the file belongs)  23648  9 21  2018 /bin/cat

About file type

*-: Normal file

File permissions

The permissions of the files displayed by rwxr-xr-x are in one block for every three, which means permissions for" owner "," group ", and" other users ", respectively. Symbols such as r, w, and x mean operations on allowed files. There are three types of operations: "read", "write", and "execute". If not allowed, - will be displayed.

-rwxr-xr-x 1 root  wheel  23648  9 21  2018 /bin/cat

Description of the above file permissions

Owner

rwx →" Read "" Write "" Execute "is allowed

wheel group user

r-x →" Read "and" Execute "are allowed

Other users

r-x →" Read "and" Execute "are allowed

chmod command

A command to set file and directory permissions. The chmod command has a symbol mode specification and a numerical mode setting.

How to specify the user in symbol mode

How to use in symbol mode

Added write permission for owner

$ chmod u+w file.txt



 Remove write permission for group

#### **`$ chmod g-w file.txt`**
```txt


 Make other users' permissions read only

#### **`$ chmod o=r file.txt`**
```txt


#### User specification method in numerical mode

 Permission numbers in numeric mode

 * r (read): 4
 * w (write): 2
 * x (execute): 1

#### How to use in numerical mode

 Specify the permissions of file.txt to `rwxr-xr-x`

#### **`$ chmod 755 file.txt`**
```txt


## Superuser
 Special user with administrator privileges

 Normally, it is common to log in as a general user, operate it, and work as a super user only when necessary.

### su command
 Command to temporarily become another user

 The su command can be any user, but this command is mainly used to become superuser. For security reasons, Linux does not allow you to log in directly as a superuser. First, you need to log in as a general user and become a super user with the su command.

### sudo command
 Run the command as another user. If no user is specified, it will be executed as superuser.

## Summary
 Somehow I was using the chmod command and the sudo command, so I learned.


Recommended Posts

Finding out about file permissions and superuser
Linux file and directory permissions
About permissions
About _ and __
About Class and Instance
Find out about SVM
About cumprod and cummax
About cross-validation and F-number