5.3 Managing File Permissions and Ownership
Understanding and manipulating file permissions and ownership settings
Practice Exam Questions 2
Question 1:
What are the two modes for describing permissions when using the "chmod" command?
A) Absolute mode and symbolic mode
B) Numeric mode and symbolic mode
C) Octal mode and symbolic mode
D) Absolute mode and numeric mode
--------------------------
Answer 1 Below:
--------------------------
/* --------------------- */
Details:
The two modes for describing permissions when using the "chmod" command are numeric mode and symbolic mode.
Explanation:
Numeric mode allows setting permissions using a numerical value, such as 660, which represents the permissions in octal form. Symbolic mode allows adding or revoking permissions individually, using symbols like + and - along with letters like r, w, and x. System administrators should be familiar with both modes to adapt to different scenarios and requirements.
Answer 1: B) Numeric mode and symbolic mode
Question 2:
What does the command "chmod ug+rw-x,o-rwx text.txt" do?
A) Adds read and write permissions for the owner and group, and removes all permissions for others on the file "text.txt"
B) Adds execute permission for the owner and group, and removes read, write, and execute permissions for others on the file "text.txt"
C) Adds read and write permissions for the owner and group, and removes execute permissions for others on the file "text.txt"
D) Adds read, write, and execute permissions for the owner and group, and removes read, write, and execute permissions for others on the file "text.txt"
--------------------------
Answer 2 Below:
--------------------------
/* --------------------- */
Details:
The command "chmod ug+rw-x,o-rwx text.txt" adds read and write permissions for the owner and group, and removes all permissions for others on the file "text.txt".
Explanation:
The symbolic mode allows for fine-grained control over permissions. In this scenario, "ug+rw-x" adds read and write permissions for the user (owner) and group, while removing execute permissions. "o-rwx" removes all permissions for others (everyone else). Understanding symbolic mode helps system administrators precisely define file permissions according to specific access requirements.
Answer 2:
A) Adds read and write permissions for the owner and group, and removes
all permissions for others on the file "text.txt"
Question 3:
What is the equivalent command to "chmod ug+rw-x,o-rwx text.txt" using numeric mode?
A) chmod 460 text.txt
B) chmod 770 text.txt
C) chmod 640 text.txt
D) chmod 750 text.txt
--------------------------
Answer 3 Below:
--------------------------
/* --------------------- */
Details:
The command "chmod 640 text.txt" is the equivalent command to "chmod ug+rw-x,o-rwx text.txt" using numeric mode.
Explanation:
In numeric mode, permissions are represented using octal values. The digits represent permissions for the owner, group, and others, respectively. In this case, "640" translates to read and write permissions for the owner, read permissions for the group, and no permissions for others. Understanding numeric mode enables system administrators to quickly set permissions using a concise numerical representation
Answer 3: C) chmod 640 text.txt
Question 4:
What does the command "ls -ld Another_Directory/" display?
A) The detailed information of the directory "Another_Directory" itself.
B) The contents of the directory "Another_Directory" including hidden files.
C) The permissions and ownership of the directory "Another_Directory."
D) The permissions, ownership, and size of the directory "Another_Directory."
--------------------------
Answer 4 Below:
--------------------------
/* --------------------- */
Details:
The command "ls -ld Another_Directory/" displays the permissions and ownership of the directory "Another_Directory."
Explanation:
The "ls" command is used to list files and directories in Linux. The "-l" option displays detailed information, and the "-d" option restricts the listing to the directory itself instead of its contents. By using "ls -ld Another_Directory/", you can obtain the permissions and ownership details of the specified directory. This information is valuable for system administrators to understand and manage file permissions and ownership settings effectively.
Answer 4: C) The permissions and ownership of the directory "Another_Directory."
Question 5:
What does the command "chmod g+w text.txt" do?
A) Grants write permission to the owner of the file "text.txt."
B) Grants write permission to the group owning the file "text.txt."
C) Revokes read permission for the group owning the file "text.txt."
D) Revokes write permission for the owner of the file "text.txt."
--------------------------
Answer 5 Below:
--------------------------
/* --------------------- */
Details:
The command "chmod g+w text.txt" grants write permission to the group owning the file "text.txt."
Explanation:
In symbolic mode, the command begins with the target (in this case, "g" for the group), followed by the action to be taken (in this case, "+" to grant), and the permission to be modified (in this case, "w" for write). By using "g+w," the write permission is added to the group for the specified file. This allows members of the group to write to the file while preserving the existing permissions for other users.
Answer 5: B) Grants write permission to the group owning the file "text.txt."
Question 6:
What does the command "chmod u-r text.txt" do?
A) Grants read permission to the owner of the file "text.txt."
B) Grants write permission to the owner of the file "text.txt."
C) Revokes read permission for the owner of the file "text.txt."
D) Revokes write permission for the group owning the file "text.txt."
--------------------------
Answer 6 Below:
--------------------------
/* --------------------- */
Details:
The command "chmod u-r text.txt" revokes read permission for the owner of the file "text.txt."
Explanation:
In symbolic mode, the command starts with the target (in this case, "u" for the user/owner), followed by the action to be taken (in this case, "-" to revoke), and the permission to be modified (in this case, "r" for read). By using "u-r," the read permission is removed from the owner of the specified file. This means the owner will no longer be able to read the contents of the file.
Answer 6: C) Revokes read permission for the owner of the file "text.txt."
Question 7:
What does the command "chmod a=rw- text.txt" do?
A) Grants read and write permission to the owner of the file "text.txt."
B) Grants read and write permission to the group owning the file "text.txt."
C) Grants read and write permission to all users for the file "text.txt."
D) Revokes read and write permission for all users for the file "text.txt."
--------------------------
Answer 7 Below:
--------------------------
/* --------------------- */
Details:
The command "chmod a=rw- text.txt" grants read and write permission to all users for the file "text.txt."
Explanation:
In symbolic mode, the command begins with "a" to indicate all users, followed by "=" to set the permissions, and "rw-" to specify read and write permissions. By using "a=rw-," the read and write permissions are set to the specified file for all users. This means that the owner, group, and other users will have the ability to read and write to the file.
Answer 7: C) Grants read and write permission to all users for the file "text.txt."
Question 8:
What does the command "chmod u+rwx,g-x text.txt" do?
A) Grants read, write, and execute permission to the owner of the file "text.txt."
B) Grants execute permission to the owner and revokes execute permission for the group for the file "text.txt."
C) Grants read, write, and execute permission to the group owning the file "text.txt."
D) Grants read, write, and execute permission to all users for the file "text.txt."
--------------------------
Answer 8 Below:
--------------------------
/* --------------------- */
Details:
The command "chmod u+rwx,g-x text.txt" grants read, write, and execute permission to the owner of the file "text.txt."
Explanation:
In symbolic mode, the command starts with the target "u" for the user/owner, followed by "+" to grant permissions, and "rwx" to specify read, write, and execute permissions. Additionally, "g-x" is used to revoke execute permission for the group. By using "u+rwx,g-x," the owner is granted read, write, and execute permissions, while the execute permission for the group is revoked.
Answer 8: A) Grants read, write, and execute permission to the owner of the file "text.txt."
Question 9:
What does the command "chmod -R u+rwx Another_Directory/" do?
A) Grants read, write, and execute permission to the owner of the directory "Another_Directory" and its subdirectories.
B) Revokes read, write, and execute permission for the owner of the directory "Another_Directory" and its subdirectories.
C) Grants read, write, and execute permission to all users for the directory "Another_Directory" and its subdirectories.
D) Revokes read, write, and execute permission for all users for the directory "Another_Directory" and its subdirectories.
--------------------------
Answer 9 Below:
--------------------------
/* --------------------- */
Details:
The command "chmod -R u+rwx Another_Directory/" grants read, write, and execute permission to the owner of the directory "Another_Directory" and its subdirectories.
Explanation:
The "-R" option is used to perform a recursive operation, meaning that the specified permissions will be applied not only to the directory "Another_Directory" but also to all its subdirectories and files. By using "u+rwx," the owner is granted read, write, and execute permissions for the specified directory and its contents.
Answer 9: A) Grants read, write, and execute permission to the owner of the directory "Another_Directory" and its subdirectories.
Question 10:
Which mode offers fine-grained control and allows you to add or revoke a single permission without modifying others on the set?
A) Numeric mode
B) Symbolic mode
C) Recursive mode
D) Targeted mode
--------------------------
Answer 10 Below:
--------------------------
/* --------------------- */
Details:
Symbolic mode offers fine-grained control and allows you to add or revoke a single permission without modifying others on the set.
Explanation:
Symbolic mode allows you to specify the target (user, group, others, or all), the action (grant, revoke, or set), and the permission (read, write, or execute) separately. This enables you to modify specific permissions without affecting the rest. It offers flexibility and precision in managing file permissions.
Answer 10: B) Symbolic mode
Question 11:
What should you consider before using the "-R" switch with the "chmod" command?
A) It modifies permissions only for the owner of the file.
B) It modifies permissions only for the group owning the file.
C) It modifies permissions for all files inside a directory and its subdirectories.
D) It modifies permissions for all users on the system.
--------------------------
Answer 11 Below:
--------------------------
/* --------------------- */
Details:
The "-R" switch with the "chmod" command modifies permissions for all files inside a directory and its subdirectories.
Explanation:
The "-R" (recursive) option is used with the "chmod" command to apply the specified permissions not only to the directory itself but also to all files and subdirectories within it. It allows for bulk modification of permissions within a directory hierarchy. However, caution must be exercised when using this option to avoid unintentionally changing permissions on files and directories that should not be modified.
Answer 11: C) It modifies permissions for all files inside a directory and its subdirectories.