Linux file permissions
(Dateirechte)
Everything is a file !
[admin123@debian11 file_permissions]$ ls
directory1 file1
[admin123@debian11 file_permissions]$ ls -l
insgesamt 4
drwxr-xr-x 2 admin123 admin123 4096 4. Jun 10:19 directory1
-rw-rw-r-- 1 admin123 admin123 0 4. Jun 09:44 file1
[admin123@debian11 file_permissions]$ ls -la
insgesamt 12
drwxr-xr-x
8 admin123 admin123 4096 5. Jun 09:41
.
<- this is a file
drwxr-xr-x 4 root
root 4096 20. Apr 13:43
..
<- this is a file
drwxr-xr-x 2 admin123 admin123 4096 4. Jun 10:19 directory1 <- this is a file
-rw-r--r-- 1 admin123 admin123
0 4. Jun 09:44
file1
<- this is a file
|
|
|
|
|
|
|
|
|
|
|
|
|
file
|
|
|
|
| date and time
|
|
|
| size
|
|
| group, who owns the file
|
| user, who owns the
file
|
hard links to a file
file permissions
file and directory permissions
files have permissions and directories have permissions.
X-rwx-rwx-rwx
| | | |
| | | others permissions
| | group permisions
| owner permissions
filetype: d=directory, l=link,
read (r)
=> 100 => 4
write (w) =>
010 => 2
execute (x) => 001
=> 1
421 --- read, write,
execute
0 --- no
permission
1 --x
execute
2 -w-
write
3 -wx
write and execute
4 r--
read
5 r-x
read and execute
6 rw-
read and write
7 rwx read, write and execute
umask
For a new file the umask is subtracted from 0777 for directories
and 0666 from files.
The default mask for non-root users is 002,
the default mask for root is 022.
new files for non-root: 0664 (0666 - 002)
new directories for non-root: 0775 (0777 - 002)
new files for root: 0644 (0666 - 022)
new directories for root: 0775 (0777 - 022)
SUID = Setuid = user id bit = rws rwx rwx
SGID = Setgid = group id bit = rwx rws
rwx
Sticky Bit
= rwx rwx rwt
commands
ls - list
directory
contents
man ls
chmod - change file mode bits man chmod
chown - change file owner an group man chown
chgrp - change group ownership man chgrp
touch - create file or change timestamps man touch
changing permissions:
chmod:
chmod u=rwx,g=rx,o=rx <file> ≙ chmod 755 <file> ≙
chmod u+rwx,g+rx,o+rx <file>