Explore key concepts of Linux file permissions and ownership with this quiz designed to reinforce your understanding of permission symbols, access types, and command usage. Perfect for those aiming to improve their grasp on managing files and directories securely within the Linux ecosystem.
In the permission string '-rwxr-xr--', which permissions are granted to the group that owns the file?
Explanation: ‘-rwxr-xr--’ gives the group read (r) and execute (x) permission, but not write. The first set after the dash is for the owner, the second set is for the group, and the last set is for others. 'Read and write' is incorrect because 'w' (write) is missing for the group. 'Write and execute' does not include read permission, and 'Read, write, and execute' gives more permissions than are assigned to the group.
Which numeric value represents the permissions 'rw-r--r--' for a file in Linux?
Explanation: The permission ‘rw-r--r--’ translates to 6 for the owner (read+write), 4 for the group (read), and 4 for others (read), resulting in 644. '655' is not a standard permission set, '755' gives execute permissions not present here, and '600' lacks group and others read permissions. Therefore, only 644 matches the given string accurately.
Which command below correctly changes the owner of 'file.txt' to user 'alex' without altering the group?
Explanation: The correct command is 'chown alex file.txt', which sets the owner to 'alex' and leaves the group unchanged. 'chmod' is for modifying file permissions, not ownership. 'chown :alex file.txt' changes only the group, and 'chmod :alex file.txt' is not syntactically meaningful. Thus, only the first option achieves the desired result.
On a shared directory '/public', applying the sticky bit will result in what behavior for regular users?
Explanation: Setting the sticky bit on a directory ensures users can only remove or rename files they own, even if they have write permissions for the directory. Allowing all users to delete any file would be insecure. Only the directory owner having delete rights is not accurate, and write access is not lost—users retain write abilities subject to permissions. The sticky bit specifically restricts deletion based on ownership.
If a user’s umask is set to 027, which default permission will a new file have when created?
Explanation: A umask of 027 removes group write and all permissions for others from the default 666 (for files), resulting in 640 (rw-r-----). '750' is a typical result for a directory with umask 027, not a file. '777' and '755' both provide execute permissions, which aren’t given to new files by default. Only '640' correctly reflects the default permissions after applying umask 027.