Cílem cvičení jsou přístupová práva a jejich maska a
jejich praktické důsledky.
r/w/x
- základní práva
fray1:~alias p='stat -Lc "%A [%a] %U/%G %n"'
fray1:~p /etc/passwd
-rw-r--r-- [644] root/sys /etc/passwd
fray1:~head /etc/passwd
fray1:~>/etc/passwd
fray1:~/etc/passwd
fray1:~p /dev/null
crw-rw-rw- [666] root/sys /dev/null
fray1:~head /dev/null
fray1:~>/dev/null
fray1:~/dev/null
fray1:~p /bin/vimtutor
-r-xr-xr-x [555] root/bin /bin/vimtutor
fray1:~head /bin/vimtutor
fray1:~>/bin/vimtutor
fray1:~/bin/vimtutor
:q
fray1:~p /etc
drwxr-xr-x [755] root/sys /etc
fray1:~ls /etc
fray1:~touch /etc/foo
fray1:~cd /etc
fray1:~p /var/tmp
drwxrwxrwt [1777] root/sys /var/tmp
fray1:~ls /var/tmp
fray1:~touch /var/tmp/foo-$USER
fray1:~cd /var/tmp
fray1:~p /proc/$$
dr-x--x--x [511] barinkl/zam /proc/9530
fray1:~p /proc/1
dr-x--x--x [511] root/root /proc/1
fray1:~ls -l /proc/$$
fray1:~ls -l /proc/1
fray1:~ls -l /proc/$$/lwp/1
fray1:~ls -l /proc/1/lwp/1
fray1:~cd /home/courses/BIPS1/public/dirs
fray1:.../dirsls -l
fray1:.../dirsp no-w/{,remove.me}
dr-xr-xr-x [555] barinkl/bips1 no-w/
--w--w--w- [222] barinkl/bips1 no-w/remove.me
fray1:.../dirsrm no-w/remove.me
fray1:.../dirsp no-x
drw-rw-rw- [666] barinkl/bips1 no-x
fray1:.../dirsls no-x
fray1:.../dirsls -i no-x
fray1:.../dirsls -l no-x
fray1:.../dirshead no-x/file1
fray1:.../dirstouch no-x/foo
fray1:.../dirscd no-x
fray1:.../dirsp imaginary/{,r-only}
drwxrwxrwx [777] barinkl/bips1 imaginary/
-r--r--r-- [444] barinkl/bips1 imaginary/r-only
fray1:.../dirs>imaginary/r-only
fray1:.../dirscp imaginary/r-only imaginary/temp
fray1:.../dirsvim imaginary/temp
fray1:.../dirsmv imaginary/temp imaginary/r-only
fray1:.../dirschmod 444 imaginary/r-only
fray1:.../dirsp imaginary/r-only
-r--r--r-- [444] foo/bar imaginary/r-only
fray1:.../dirsp x-only
d--x--x--x [111] barinkl/bips1 x-only/
fray1:.../dirsls x-only/
fray1:.../dirsls x-only/dir[123]
fray1:.../dirsls x-only/dir{1,2,3}
fray1:.../dirscat x-only/file{1,2,3}
chmod práva soubor...
-R
fray1:~alias p='stat -Lc "%A [%a] %n"'
fray1:~touch file
fray1:~mkdir dir
fray1:~chmod 0 file; p file
fray1:~chmod 7 file; p file
fray1:~chmod 007 file; p file
fray1:~chmod 700 file; p file
fray1:~chmod 123 file; p file
fray1:.../dirscd
komu jak co
user + r
group - w
others = x
all X
u/g/o
fray1:~chmod a= file; p file
fray1:~chmod a+r,ug+w file; p file
fray1:~chmod g-wx,o= file; p file
fray1:~chmod go=u file; p file
fray1:~chmod a=,o+X file dir; p file dir
rw-rw-rw-
)rwxrwxrwx
)umask value | Security level | Effective permission (directory) |
---|---|---|
022 | Permissive | 755 rwx r-x r-x |
026 | Moderate | 751 rwx r-x --x |
027 | Moderate | 750 rwx r-x --- |
077 | Severe | 700 rwx --- --- |
Soubory Adresáře
6 6 6 7 7 7
----- ----- ----- ----- ----- -----
r w - r w - r w - r w x r w x r w x
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
0 2 6 = 0 2 6 Maska
----- ----- ----- ----- ----- -----
- - - - w - r w - - - - - w - r w -
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
6 4 0 7 5 1
===== ===== ===== ===== ===== =====
r w - r - - - - - r w x r - x - - x
fray1:~umask
fray1:~umask -S
fray1:~umask -S 123
u=rw,g=rx,o=r
fray1:~umask 27
fray1:~type umask
fray1:~grep umask /etc/profile
fray1:~chmod +x file; p file
fray1:~chmod = file dir; p file
fray1:~chmod =rwX file dir; p file dir
fray1:~umask -S
fray1:~chmod = file dir; p file dir
fray1:~chmod $(umask -S | tr x X) file dir; p file dir