Skip to content

Commit 45fc269

Browse files
authored
Merge pull request #8 from elenammul/patch-4
Exercise.004.solutions
2 parents 2d6af7e + 6ca86ec commit 45fc269

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Exercise 004 - Playing with file permissions - Solutions
2+
3+
1) Create a file called testfile1 in your home dir
4+
5+
[mmul@localhost ~]$ mkdir /tmp/scratch
6+
[mmul@localhost ~]$ cd /tmp/scratch/
7+
[mmul@localhost scratch]$ touch testfile1
8+
9+
2) Check permissions, remove all permission on the file except for owner
10+
11+
[mmul@localhost scratch]$ ls -l
12+
-rw-rw-r-- 1 mmul mmul 0 Dec 2 16:33 testfile1
13+
14+
[mmul@localhost scratch]$ chmod 0600 testfile1
15+
16+
[mmul@localhost ~]$ ls -l
17+
-rw------- 2 mmul mmul 60 Dec 2 16:33 testfile1
18+
19+
3) Switching account and trying to remove file testfile1
20+
21+
[mmul@localhost scratch]$ su - mmul2
22+
23+
[mmul@localhost scratch]$ cd /tmp/scratch
24+
25+
[mmul2@localhost scratch]$ rm testfile1
26+
rm: remove write-protected regular empty file 'testfile1'? y
27+
rm: cannot remove 'testfile1': Permission denied
28+
29+
4) Re-assign permissions
30+
31+
[mmul@localhost scratch]$ chmod 0777 testfile1
32+
33+
[mmul@localhost scratch]$ ls -l
34+
-rwxrwxrwx 1 mmul mmul 0 Dec 2 16:41 testfile1
35+
36+
5) Trying to remove again
37+
38+
[mmul2@localhost scratch]$ ls -l
39+
-rwxrwxrwx 1 mmul mmul 0 Dec 2 16:41 testfile1
40+
41+
[mmul2@localhost scratch]$ rm testfile1
42+
rm: cannot remove 'testfile1': Permission denied
43+
44+
6) Check /tmp permissions
45+
46+
[mmul2@localhost scratch]$ ls -ld /tmp/
47+
drwxrwxrwt 34 root root 1720 Dec 2 17:00 /tmp/
48+
49+
/tmp has the sticky bit enabled! This means that, despite the full access,
50+
we cannot remove testfile1 because mmul2 is not the owner.

0 commit comments

Comments
 (0)