LPI Linux Essentials 010 V1.6 - Chapter 14 Quiz
You want to set the sticky bit on an existing directory, subdir, without otherwise altering its permissions. To do so, you would type chmod _________________ subdir. A. o+t B. o+w C. a+t D. g+t E. a+w
A. To add a sticky bit to a directory you use the t character and add it to the owner permission set (o), so option A is correct. You add the sticky bit permissions to the owner, not the group, or all users, so options C and D are incorrect. The w character is used to assign write permissions, not the sticky bit, so options B and E are incorrect.
The ________________ option causes chown to change ownership on an entire directory tree. A. -L B. -R C. -H D. -P E. -f
B. The -R (or --recursive) option allows Linux to recursively change the ownership of a directory and all files and directories under it, so option B is correct. The -L option tells Linux to follow any symbolic links encountered in the directory, not recursively change the entire directory tree, so option A is incorrect. The -H option tells Linux to follow the symbolic link if it's listed as the command-line argument, not recursively change ownership in the entire directory; so option C is incorrect. The -P option tells Linux to not follow any symbolic links in the directory, not recursively change ownership in the directory tree, so option D is incorrect. The -f option tells Linux to suppress any error messages, not recursively change ownership on an entire directory tree, so option E is incorrect.
Typing ls -ld wonderjaye reveals a symbolic file mode of drwxr-xr-x. Which of the following are true? (Choose all that apply.) A. wonderjaye is a symbolic link. B. wonderjaye is an executable program. C. wonderjaye is a directory. D. wonderjaye may be read by all users of the system. E. wonderjaye may be written by any member of the file's group.
C, D. The d at the start of the symbolic file mode indicates that wonderjaye is a directory. The first set of permissions (rwx) indicate the directory owner has read, write, and execute permissions on the directory. The second and third sets of permissions (r-x and r-x) indicate that the directory's primary group and all others have read and execute permissions on the directory. Thus, options C and D are correct. A leading l character would indicate the file is a symbolic link, so option A is incorrect. A leading dash would indicate the object is a file, but since the leading character is a d option B is incorrect. For members of the group to have write permissions to the directory, the second set of permissions must include the w character, which it doesn't, so option E is incorrect.
The three-character symbolic string ___________________ represents read and execute permission but no write permission. A. -wx B. --x C. r-x D. rw- E. rwx
C. Symbolic permissions are indicated by the three-character string rwx. If a permission is not present, the character is replaced by a dash, so to remove write permissions you would use the character set r-x, making option C correct. The -wx symbol indicates write and execute permissions, so option A is incorrect. The --x symbol indicates no read and write permissions, only execute permissions, so option B is incorrect. The rw- symbol indicates read and write permissions but no execute permission, making option D incorrect. The rwx symbol indicates read, write, and execute permissions, so option E is incorrect.
What command would you type (as root) to change the ownership of somefile.txt from ralph to tony? A. chown ralph:tony somefile.txt B. chmod somefile.txt tony C. chown somefile.txt tony D. chown tony somefile.txt E. chmod tony somefile.txt
D. The chown command changes the owner assigned to a file. You list the new file owner first, then the filename, making option D correct. You can't change file ownership using the chmod command, making options B and E incorrect. The new file owner must be listed first by itself, making options A and C incorrect.
The chmod symbolic representation ____________ allows all users execute access to a file without affecting other permissions. A. u+x B. u-x C. g+x D. a-x E. a+x
E. The chmod command uses the character a to represent permissions assigned to all users. To add a permission, you use the plus sign (+), and to represent execute permissions you use the x character. Thus, option E is correct. The u+x symbol assigns execute permissions to only the user, not all users, so option A is incorrect. The u-x symbol removes execute permissions from the user and doesn't change the permissions for everyone else, so option B is incorrect. The g+x symbol adds execute permissions to the group but not for all users, so option C is incorrect. The a-x symbol removes execute permission for all users—it does not add it—so option D is incorrect.
Which of the following commands can you use to change a file's group? A. groupadd B. groupmod C. chmod D. ls E. chown
E. The chown command allows you to change both the file's owner and group, so option E is correct. The groupadd command allows you to add a new group to the system, not change the group assigned to a file, so option A is incorrect. The groupmod command allows you to modify details of a group definition, not change the group assigned to a file, so option B is incorrect. The chmod command allows you to change the permissions assigned to a file, not the file's primary group, so option C is incorrect. The ls command allows you to display the file owner, group, and permissions using the -l option, but it doesn't allow you to change the file's group, so option D is incorrect.
True or false: Only root can use the chmod command.
False. The chmod command allows users to change the permissions assigned to a file or directory. Any user can change the permissions of files and directories that the user owns; therefore, any user can use the chmod command.
True or false: Only root can change a file's ownership with chown.
True. An ordinary user can use chown to change a file's group to another group the user belongs to, but ordinary users can't change the ownership of a file—only the root user can do that.
True or false: A file with permissions of 755 can be read by any user on the computer, assuming all users can read the directory in which it resides.
True. The octal mode permission 755 represents the symbolic mode -rwxr-xr-x. The third set of permission characters indicates the permissions for all users on the system, so all users have read permission on the file.