|~~#~~|whoami| |~~#~~|groups| |:::|id| |~~#~~|id| |:::|getent passwd //your_username// \\ # uid is the third, and gid the fourth field| |~~#~~|w -n| |~~#~~|last -wn 10 \\ # displays 10 last logons| |~~#~~|last root| |~~#~~|last --present '2023-03-03 13:30'| |~~#~~|write //username// \\ //message// \\ //Ctrl+d//| |~~#~~|su \\ exit \\ # lub //Ctrl+d// \\ su user//5// \\ exit| |~~#~~|ls -ld ~ ~/.ssh ~/.bash_history /etc/passwd /etc/shadow /tmp /usr/bin/passwd /usr/bin/write| |:::|stat ~ ~/.ssh ~/.bash_history /etc/passwd /etc/shadow /tmp /usr/bin/passwd /usr/bin/write| |:::|# the exercise shows examples of real-world permission usage; ponder why such permissions are set| |~~#~~|ls -l /var/run /dev/sda /dev/nvme0n1 /dev/null /run/initctl /run/rpcbind.sock| |:::|stat /var/run /dev/sda /dev/nvme0n1 /dev/null /run/initctl /run/rpcbind.sock| |:::|# the exercise shows the possible file types (apart from an ordinary file and a directory)| |~~#~~|fortune > file1 \\ chmod go-r file1 \\ su user//2// \\ cat file1 \\ exit \\ su user//3// \\ cat file1 \\ exit | |:::|fortune > file1 \\ chmod go-r file1 \\ su user//2// -c "cat file1" \\ su user//3// -c "cat file1"| |~~#~~|fortune > file2 \\ chmod 640 file2 \\ # verify as above| |~~#~~|fortune > file3 \\ chmod o-r file3 \\ # alternatively: chmod u=rw,g=r,o= file3| |~~#~~|chgrp left file3| |~~#~~|fortune > file4 \\ chmod 604 file4 \\ # verify as in 31| |~~#~~|mkdir dir1 \\ fortune > dir1/a \\ chmod -x dir1 \\ ls dir1 \\ cd dir1 \\ cat dir1/a | |~~#~~|chmod u=rwx,go=rx dir1 \\ su user//2// \\ cat dir1/a \\ ls dir1 \\ exit \\ chmod go-r dir1 \\ # repeat cat and ls as user//2// | |~~#~~|mkdir dir2 \\ cd dir2 \\ touch a b \\ chmod go-r b \\ su user//2// \\ rm a \\ rm b \\ exit| |~~#~~|cd ~/dir2 \\ su user//2// \\ mkdir d1 d2 \\ touch d2/f \\ exit \\ rm -r d1 \\ rm -r d2| |~~#~~|cd ~/dir2 \\ mv d2 foo \\ mv foo ~ \\ cd .. \\ mkdir dir3 \\ mv dir2 dir3 | |~~#~~|mkdir dir4 \\ fortune > file5 \\ fortune > dir4/f \\ chmod -R 0 dir4 file5 \\ su \\ cat file5 \\ cd dir4 \\ cat f \\ exit| |~~#~~|su \\ chown user//2// file1 \\ chown :www-data file2 \\ exit| |~~#~~|stat /var/log/wtmp \\ # take notice of the last access date which might precede last modify date| |~~#~~|touch ~| |~~#~~|touch -d '13:30 PDT Saturday month ago' //file//| ~~META: language = en ~~