WA7. System Security¶
Solution¶
1. Let’s learn a little bit about file permissions. Go to your home directory and run¶
$ ls –la
Take a screenshot.
On the left side of the output you see the following:
CS3307Unit7SS.JPG
rwx is for read, write, and exectute permissions, respectively.
2. Create an empty file called “A.txt”. Let’s look at the file permissions for “A.txt”¶
ls –l A.txt
What does the file permissions (the portion shown above) read for “A.txt”?
- According to the screenshot, the file permissions for A.txt is
-rw-rw-r--
which means the following:- The first character
-
means that the file is a regular file. - The later
rw-
means that the owner of the file has read and write permissions. - The later
rw-
means that the group of the file has read and write permissions. - The later
r--
means that all others have read permissions.
- The first character
3. Let’s add executable permissions to “A.txt” for our user.¶
chmod u+x A.txt
Now check the file permissions for “A.txt”. What does say for “A.txt”?
- According to the screenshot, the file permissions for A.txt is
-rwxrw-r--
which means the same as above, but the owner of the file has to execute permissions. These are the details of the file permissions:- The first character
-
means that the file is a regular file. - The later
rwx
means that the owner of the file has read, write, and execute permissions. - The later
rw-
means that the group of the file has read and write permissions. - The later
r--
means that all others have read permissions.
- The first character
4. Let’s remove group read permissions to “A.txt”.¶
chmod g-r A.txt
Now check the file permissions for “A.txt”. What does it say for “A.txt”?
- According to the screenshot, the file permissions for A.txt is
-rwx-w-r--
which means the same as above, but the group of the file has no read permissions. - The other permissions remain the same (including groups write and execute permissions).
- These are the details of the file permissions:
- The first character
-
means that the file is a regular file. - The later
rwx
means that the owner of the file has read, write, and execute permissions. - The later
-w-
means that the group of the file has only write permissions. - The later
r--
means that all others have read permissions.
- The first character
5. Sometimes it is easier to provide permissions for users, groups, and others all in one command. For this, we use octal values. This is the most common form for representing file permissions¶
-
The table below is according to (UoPeople, 2023):
6. Let’s give “A.txt” read and write permissions to everyone¶
chmod 666 A.txt
Now check the file permissions for A.txt. What does it say?
- According to the screenshot, the file permissions for A.txt is
-rw-rw-rw-
which means that all users, groups, and others have the same permissions which correspond to the value6
(read + write) in the octal value.
7. Let’s give the owner read, write, and execute permissions; give the group read and write permissions; and give all others read permissions for “A.txt”¶
chmod 764 A.txt
Now check the file permissions for “A.txt”. What does it say?
- According to the screenshot, the file permissions for A.txt is
-rwxrw-r--
which means: -
means that the file is a regular file.- the first
rwx
means that the owner of the file has read, write, and execute permissions. - The later
rw-
means that the group of the file has read and write permissions. - The later
r--
means that all others have read permissions.
References¶
- UoPeople (2023). CS3307 Unit 7: File Security. https://my.uopeople.edu/mod/workshop/view.php?id=336383