[Reading memo] Linux standard textbook (Chapter 7-8)

Introduction

We will output a summary of reading the "Linux Standard Textbook (PDF)" about Linux, which beginners should understand above all. This time, Chapters 7 and 8 in the latter half.

It takes a lot of time to write each command one by one, so when it comes time to use it, I mainly extract the one that says "The specific method is written here!". Please note.

Chapter 7 Manager's work

-To use Linux, you need a user account, but you can use groups to bundle multiple users. -By properly setting groups and users, ** files, directories, arbitrary programs, shell scripts, etc. can be given permission to browse and edit only those who need them **. -Commands marked with # can only be executed with root privileges, and those marked with $ can also be executed with user privileges.

Create / modify / delete users / create / delete groups, etc.

-In addition to the users prepared from the time of installation, the administrator can define users as needed. However, the command in the link does not seem to be applied on Mac **.

There are many things you can do for each, so refer to the article below.

[Useradd] command-create a new user

[Usermod] command-change user account information

[Userdel] command-delete user

[Group add] command-create a new group

[Groupmod] command-change group ID and name

[Groupdel] command-delete a group

@markIT's Linux search display screen

password

-To use the user's authority, authenticate using the user name and password. The command to register / change the user password is possible with passwd [user name]. -Shadow file: The user's password is saved in the shadow file (/ etc / shadow) instead of the password file. The contents of one user (one line) registered in the shadow file looks like this.

account:password:last_changed:may_be_changed:warned:expires:disabled:reserved
item Contents
account User's name
password Encrypted password
last_changed Days from January 1, 1970 to the date the password was last updated
may_be_changed Number of days before the password can be changed
must_be_changed Number of days before you have to change your password
warned The number of days a user will be warned before the password expires
expires The number of days before your password expires and your account becomes unusable
disabled Days from January 1, 1970 until the account becomes unavailable
reserved Reserved field

Available users and groups

-Advantages of creating a group: You can set the access rights of directories on the system to create a directory that can be accessed only by users who belong to a specific group, or only users who belong to a specific group can become root users. It is possible to operate such as. -Root user: A special user who can change system settings, install or delete programs, and create / delete users without usage restrictions.

su command

The su command is a command that allows a user who is already logged in as another user to temporarily become another user.

su
su - [User]
option
su - (Or su- root): Become the root user
su -user Can be the specified user

sudo command

-You can execute commands with superuser (root) privileges without switching the user to root with the su command.

Chapter 8 User Authority and Access Rights

File owner and owning group

-The user ID and group ID of the file creator become the owner and owning group of the file. The owner can be changed with the chown command, and the owning group can be changed with the chgrp command.

chown user[.group]directory
chown user[.group]File
chgrp group directory
chgrp group file
* To change, you need to be the root user

Files and permissions

-Files can have permissions set at three levels: the user who owns the file, the user who excludes the file owner from the file ownership group, and other users. -The file has three permissions, ** ① read ② write ③ execute **, for each of the three levels divided by the user. -The ls -l command can be used to display the file mode. For example, like this.

$ ls -l
drwxr-xr-x@ 2 user  staff   64  7 30 09:46 test
drwxr-xr-x@ 4 user  staff  128  7 26 15:38 method
drwxr-xr-x@ 7 user  staff  224  7 29 21:37 practice
drwxr-xr-x@ 4 user  staff  128  7 24 15:52 Iterative processing

-The meanings of file types r, w, and x are as follows.

item Contents
r Read
w writing
x Run or move directory
rwx All three are possible

To change the access right, follow the steps below.

chmod mode[,mode]...directory
chmod mode[,mode]...File
chmod octal notation mode directory
chmod octadecimal mode file

For other details, share this article because it was concrete and easy to understand.

chmod? chown? File permission system summary for those who do not understand well

File creation mode

-When a new file is created, the file is created with permissions such as 644 or 664, which are the permissions specified for each USER. By using the umask command, it is possible to restrict the creation of files with the specified permissions.

umask [Eighth mode mask value]

-Permissions are set in the form of file mode. Details are linked below

What is Linux file mode? And how to change

What are "file mode" and "permission" in Linux? 【Beginners】

Reference material

[Useradd] command-create a new user

[Usermod] command-change user account information

[Userdel] command-delete user

[Group add] command-create a new group

[Groupmod] command-change group ID and name

[Groupdel] command-delete a group

@markIT's Linux search display screen

chmod? chown? File permission system summary for those who do not understand well

What is Linux file mode? And how to change

What are "file mode" and "permission" in Linux? 【Beginners】

Recommended Posts

[Reading memo] Linux standard textbook (Chapter 7-8)
[Reading memo] Linux standard textbook (Chapter 1 to Chapter 6)
Linux standard textbook memo 1
Linux standard textbook memo 3
Linux standard textbook memo 1 part 2
Linux standard textbook memo part 6
Linux standard textbook
Linux standard textbook (ver3.0.2) I tried Chapter 1
Linux standard textbook part 5
Linux standard textbook part 4
I read "Linux standard textbook"!
Building Linux From Scratch 10.0
Best 3 from the impressions of reading a new shell programming textbook
[Reading memo] Linux standard textbook (Chapter 7-8)
Linux x memo
linux (ubuntu) memo
Linux # Command Memo 1
Image reading memo
[For memo] Linux Part 2
NTP configuration memo on Linux
Linux tar xz command memo
New Linux textbook (study notes)
[For AtCoder] Standard input memo
Contents of reading VBA x Python fastest work technique Memo chapter1