Today, I was worried about the permission denied
problem while learning about automatic deployment, and I felt that I had little knowledge of authority systems, so I investigated it in detail as a review.
"Permission" means "permission or authority" in English, and "denied" means "denied in the past form of denial". In other words, permission denied
means something like" you are not authorized ".
And, the permission in programming is set with the information that defines the authority "who is allowed what kind of operation". This information is called permissions.
Run the ls command
with the-l option
.
Then, I think that the screen looks like this.
Terminal
$ ls -l
drwxr-xr-x. 20 root root 2077 July 5 14:34 bin/cat
"D" refers to a directory, rwx stands for r (read), w (write), and x (execute), and from the left, "owner," "group user," and "other user." Therefore, it is displayed as "rwxr-xr-x".
Specify the chmod command
. chmod is read as "change mode".
The format is as follows.
chmod <8-ary number> <filename>
meaning | Numbers |
---|---|
reading(r) | 4 |
writing(w) | 2 |
Run(x) | 1 |
As an example, you can change the permissions by entering the command as follows.
In this case, the part of chmod 755 file.txt
on the second line is hit.
Terminal
$ ls -l file.txt
-rw-r--r-- 1 takuya staff 0 Jul 12 18:58 file.txt
$ chmod 755 file.txt
$ ls -l file.txt
-rwxr-xr-x 1 takuya staff 0 Jul 12 18:58 file.txt*
In other words, "755" is "7 (4 + 2 + 1) 5 (4 + 1) 5 (4 + 1)", giving permissions to all users and "reading" to groups and their users. "And" execute "is given.
A superuser is a user with strong privileges who is allowed to perform all kinds of operations. Also known as the "root user" because the username is root. A superuser is a highly authorized user who is allowed to perform all operations and can change configuration files and install new applications, but it is usually risky because of the strong authority. It is important to log in as a general user, operate it, and work as a superuser only when necessary.
There are su command
and sudo command
as commands, but the difference is that after executing the su command
, you need to exit the superuser state with the ʻexit command. Also, the
sudo command executes commands on behalf of the root user, while the
su command` allows the root user to operate on behalf of the root user, so the root user password is required. I will.
Recommended Posts