Mastering Linux
< Previous Solution - Home - Next Solution >
student@vm01:~$ mkdir ~/permissions
myfile.txt
under ~permissions
.student@vm01:~$ touch ~/permissions/myfile.txt
/var/log/waagent.log
. Then copy this file to your permissions directory. Who is the new owner of this file now?student@vm01:~$ ls -l /var/log/waagent.log
-rw-r--r-- 1 root root 192274 Apr 11 17:07 /var/log/waagent.log
student@vm01:~$ cp /var/log/waagent.log ~/permissions/
student@vm01:~$ ls -ls ~/permissions/
-rw-r--r-- 1 student student 0 Apr 8 14:55 myfile.txt
-rw-r--r-- 1 student student 195022 Apr 11 19:51 waagent.log
rootfile.txt
in the /home/student/permissions
directory.student@vm01:~$ sudo su
root@vm01:/# touch /home/student/permissions/rootfile
root@vm01:/# exit
student@vm01:~$ ls -l ~/permissions
total 4
-rw-rw-r-- 1 student student 0 Apr 8 14:55 myfile.txt
-rw-r--r-- 1 root root 0 Apr 8 14:58 rootfile
-rw-r--r-- 1 student student 195022 Apr 11 19:51 waagent.log
/home/student/permissions
to yourself (student).student@vm01:~$ chown student ~/permissions/*
chown: changing ownership of '/home/student/permissions/rootfile': Operation not permitted
Note you cannot become owner of the file that belongs to root.
~
, and others can only readstudent@vm01:~$ find ~ -type d -exec chmod 755 {} \;
student@vm01:~$ find ~ -type f -exec chmod 644 {} \;
chmod: changing permissions of '/home/student/permissions/rootfile': Operation not permitted
Note you cannot change permissions of the file that belongs to root.