[LINUX] About permissions

I've learned how to read permissions, so I'll take notes.

How to read permissions

First, ** owning user ** and ** group ** are set for files and directories, and access rights are expressed by 9 characters such as rw-r--r--.

First, create an appropriate file and check the permissions with the ls -l command.

$ touch index.html
$ ls -l
total 0
-rw-r--r--  1 user  staff  0 12 25 10:55 index.html

** user ** User who owns the file or directory ** staff ** Group that owns files and directories

It shows what you can do with this index.html file.

-rw-r--r--

The view is divided into 1: 3: 3: 3

- rw- r-- r--

** - Indicates the file type **

** rw- Access right of the owning user (user) ** ** r-- Access rights for owned group (staff) ** ** r-- Access rights of other users **

** File type **

Type meaning
- File
d directory
l Symbolic link

** How to read access rights **

mode Authority
r (read) Readable
w (write) Writable
x (execute) Executable

So the permissions on the index.html file are

-rw-r--r--  1 User  staff  0 12 25 10:55 index.html

** User ** is ** readable and writable ** ** staff ** can only be read ** ** Other users ** can only read **

Becomes

chmod command

rw-r--r-- This permission can be changed with the command chmod

rw- is user's ** u ** r-- is ** g ** of group r-- is another ** o ** All of this ** a ** of all

Can be handled with

For example, if you want to give all permissions to all users (user, group, other), write like this

$ chmod a=rwxrwxrwx index.html
$ ls -l
total 0
-rwxrwxrwx  1 user  staff  0 12 25 10:55 index.html

If you want to give g the authority rw o to rw

$ chmod g=rw,o=rw index.html
$ ls -l
total 0
-rwxrw-rw-  1 user  staff  0 12 25 10:55 index.html

You can also add or delete permissions with + or -

$ chmod g+x,o-w index.html
$ ls -l
total 0
-rwxrwxr--  1 user  staff  0 12 25 10:55 index.html

It can also be represented by numbers

mode Numbers
r 4
w 2
x 1

Access rights can be expressed by the sum of these numbers Example r + w + x = 7

mode Numbers
rwx 7
rw 6
r 4

For example, if you want to give the authority rwxrw-r--

$ chmod 764 index.html
$ ls -l
total 0
-rwxrw-r--  1 user  staff  0 12 25 10:55 index.html

When you want to make it rw-rw-r--

$ chmod 664 index.html
$ ls -l
total 0
-rw-rw-r--  1 kuzeginjirou  staff  0 12 25 10:55 index.html

Finally

I'm still studying, so I'd appreciate it if you could point out any corrections, etc. m (__) m

Recommended Posts

About permissions
About LangID
About virtiofs
About python-apt
About Permission
About sklearn.preprocessing.Imputer
About gunicorn
About requirements.txt
About locale
About Opencv ②
About axis = 0, axis = 1
About Opencv ③
About import
Linux permissions
About numpy
About pip
About Linux
About numpy.newaxis
About endian
About Linux
About import
About Opencv ①
About Linux
About Linux
About Linux ①
About cv2.imread
About _ and __
About wxPython
Finding out about file permissions and superuser
About python slices
About python comprehension
About Docker Volume
[Linux] About export
About reference type
About Twitter scraping
About the test
Learn about programming
About Flask customization
About variable scope. .. ..
About Python tqdm.
About python yield
Notes about with
About python, class
About Linear Models
About Go functions
About pandas describe
About Kivy root
About Firestore timeout
About python inheritance
About python, range ()
About Confusion Matrix
[Linux] About PATH
About python decorators
Linux (about groups)
Note about awk
About python reference
About Bitnami Autostart
About Python decorators
About Milkcocoa SDK
Notes about pytorch
[Python] About multi-process