Linux+ User and Group Permissions Flashcards
6 cards from real Linux practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 Linux+ User and Group Permissions flashcards as text
A user named 'alex' is a member of the 'developers' and 'qa' groups. A system administrator needs to add 'alex' to the 'sysadmins' group without removing them from their existing groups. Which of the following commands will accomplish this?
Answer: usermod -aG sysadmins alex
The `usermod` command modifies a user account. The `-G` option specifies the supplementary groups. Crucially, the `-a` (append) option must be used with `-G` to add the user to the new group without removing them from their current supplementary groups. Using `-G` alone would replace the user's current group list with the new one.
A directory named '/data/shared' is used by the 'editors' group for collaborative work. What is the effect of setting the SetGID (SGID) bit on this directory?
Answer: All new files and subdirectories created within '/data/shared' will inherit the group ownership of the directory ('editors').
When the SetGID bit is set on a directory, it forces all new files and subdirectories created within that directory to inherit the group ownership of the parent directory. This is extremely useful for shared directories, as it ensures that new files automatically belong to the correct group ('editors' in this case) for collaboration, rather than the primary group of the user who created them.
Which of the following `chmod` commands will set the permissions on a file named `report.txt` to: owner can read and write, group can read only, and others can read only?
Answer: chmod 644 report.txt
Permissions are calculated using octal values: read (4), write (2), and execute (1). For the owner (read+write): 4+2=6. For the group (read-only): 4. For others (read-only): 4. Combining these gives the octal value 644.
A system administrator needs to change the ownership of a file named `config.bak` from the user `root` to the user `jdoe` and also change its group ownership to `admins`. Which command achieves this in a single operation?
Answer: chown jdoe:admins config.bak
The `chown` command is used to change the owner and/or group of a file. The syntax `chown user:group filename` allows for changing both the user and group ownership simultaneously. `chmod` changes permissions, not ownership, and `chgrp` only changes the group.
The `/tmp` directory on a Linux system has the sticky bit set. A user, 'emma', creates a file `/tmp/emma_file`. Another user, 'liam', who has write permissions to the `/tmp` directory, attempts to delete this file. What will be the outcome?
Answer: Liam will not be able to delete the file because he is not the file owner.
The sticky bit, when set on a directory, restricts file deletion. Even if a user has write permissions on the directory, they can only delete or rename files that they own. Since 'liam' does not own '/tmp/emma_file', he cannot delete it. Only the file owner ('emma') or the root user can delete it.
A system administrator sets the umask to `0027` for a user. What will the default permissions be for a newly created directory by this user?
Answer: 750 (rwxr-x---)
The umask value is subtracted from the default base permissions to determine the permissions of new files and directories. For directories, the base permission is `777`. Subtracting the umask (`027`) from the base (`777`) results in `750`. (7-0=7, 7-2=5, 7-7=0). This translates to `rwxr-x---`.