What is File permissions?
On Linux and similar systems, the setting for each file and directory that decides whether read (r), write (w) and execute (x) are allowed for the owner (user), the group and others. ls -l shows it as rwxr-xr--, and chmod also expresses it in octal such as 754 (the sum of r = 4, w = 2, x = 1). The permissions of newly created files are decided by the umask. root (the superuser) can generally read and write files regardless of these restrictions.
Japanese name: パーミッション
File permissions appears in 6 practice questions across 1 topic, including Linux and Command-Line Basics.
Field: Linux and Command-Line Basics
Reading the notation
Of the first 10 characters of ls -l, the first is the file type (- for a regular file, d for a directory, l for a symbolic link), and each following group of three is the permission of the owner, the group and others. In octal each digit is the sum of r = 4, w = 2 and x = 1, so rwxr-xr-- is 754 and rw-r--r-- is 644. Besides specifying numbers, as in chmod 754 file, symbols can change only part of it, as in chmod g+w file or chmod o-r file.
Directory permissions
For a directory, r is permission to read the list of names in it, w to create and delete files in it, and x to enter it and reach files by name. So whether a file can be deleted is decided not by the file itself but by the w and x of the directory. A directory that anyone can write to, such as /tmp, is given the sticky bit (t) so that people cannot delete other people's files.
Special bits and umask
There is setuid, which runs a program with the owner's privileges (s in the owner's x position), setgid, which runs it with the group's privileges, and the sticky bit mentioned above, expressed in octal as the 4000, 2000 and 1000 places. New files are created from 666 and directories from 777 with the umask bits removed, so with umask 022 files become 644 and directories 755.
FAQ
Does chmod 777 solve the problem?
"Permission denied" may disappear, but anyone can then modify or run the file, and other users or programs may change its contents. The basic approach is to first check which users need to do which operations, match the owner and group with chown and chgrp, and grant only the permissions needed.
How can I let only my team members read files on a shared server?
Create a group for the team, add the members, set the group of the files and directories to that group, and give the group r (r and x for directories) and others nothing (for example 640 for files and 750 for directories). To set permissions finely per person, ACLs (setfacl, getfacl) can also be used.