This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “File Ownership and Permissions”.
1. A file can be recognized as an ordinary file or directory by ____ symbol.
Explanation: When ls command is used with -l option its displays attributes of a file in the multi-columnar form. The first column defines the file types and permissions associated with a file. If the permissions are preceded by a (-), then it is an ordinary file otherwise it is a directory.
2. How many types of permissions a file has in UNIX?
Explanation: In UNIX system, a file can have three types of permissions -read, write and execute. Read permission means that the file is readable. Write permission means that the file can be edited while executing permission (for a directory) means that we can “pass through” the directory file for searching subdirectories.
3. Permissions of a file are represented by which of the following characters?
Explanation: A file can have three types of permissions; read, write and execute which is represented by characters r, w and x respectively.
4. A file named abd.txt has the following set of permissions
All the three operations i.e read, write and execute can be performed on the file by file owner, group owner and others.
Explanation: UNIX provides a three tired file protection system that determines the file access rights i.e. the permissions are dived into three groups as
r w x r w x r w x
The first group has all the three permissions i.e. file is readable, writable and executable by the file owner.
The second group also has all the three permissions i.e. file is readable, writable and executable by the group owner.
The third group also has all the three permissions i.e. file is readable, writable and executable by others who are neither a part of the group nor they are an owner of the file.
Normally this set of permissions is too dangerous!
5. Which of the following symbol is used to indicate the absence of a permission of a file?
Explanation: ( – ) is used to indicate the absence of a single or set of permissions of a file. For example, if a file has all the three permissions for owner but is only readable by group members and others, then the set of permissions would be,
rwx r-- r--
6. When we create a file, we are the owner of a file.
Explanation: In most cases, the user which creates the file is regarded as owner of the file. The owner of the file can create, delete or edit the file or he can change the permissions associated with it.
7. What is group ownership?
a) group of users who can access the file
b) group of users who can create the file
c) group of users who can edit the file
d) group of users who can delete the file
Explanation: When the system administrator creates a user account, he assigns the user two parameters; UID (user ID) and GID (group ID). Group id denotes the group to which the user belongs.
In simple words, group ownership defines the group to which the file is accessible.
8. A file has permissions as rwx r– —. A user other than the owner cannot edit the file.
Explanation: Since the second and third group of permissions of a file are r– and — respectively. So the file is only readable and that too, only by the members of the group to which the file belongs.
9. If a file is read protected, we can write to the file.
Explanation: If a file is not readable then it is obvious that we cannot write anything to the file. To write anything to a file it should be readable first. But if a file is writable then we can read the file easily but the reverse is not true.
10. The write permission for a directory determines that ____________
a) we can write to a directory file
b) we can read the directory file
c) we can execute the directory file
d) we can add or remove files to it
Explanation: The write permission of a directory does not imply that we can write to the directory. Only kernel is allowed to do that. It simply means that we can create or remove files from the directory.
11. If the file is write-protected and the directory has to write permission then we cannot delete the file.
Explanation: The term ‘write-protected’ has a limited meaning in the UNIX file system. A file which is write protected cannot be written, but it can be removed if the directory has to write permission.
12. What is execute permission?
a) permission to execute the file
b) permission to delete the file
c) permission to rename the file
d) permission to search or navigate through the directory
Explanation: Executing a directory does not make any sense, execute permission simply means that a user can “pass through” the directory while searching for subdirectories. When we use pathname with any command we should have execute permission for each of the directories involved in the complete pathname. For example,
cd users/users06/abd/dir01/file01.txt // all directories should have execute permission.
13. Which of the following is default permission set for ordinary files?
Explanation: The default permission set for an ordinary file is rw-rw-rw i.e. it is readable and writable by owner, group member and others.
14. Which of the following is default permission set for directories?
Explanation: The default permission set for an ordinary file is rwxrwxrwx i.e. it is readable, writable, executable by owner, group members and others.
15. A file owner does not have a permission to edit the file but the group to which the file owner belong do have the permission to edit it. Can owner edit the file?
c) Cannot be defined
d) Error will be encountered
Explanation: The file owner cannot edit the file because the owner’s permission overrides the group’s permission. In other words, the priority of owner’s permission is greater than group’s permission.
Sanfoundry Global Education & Learning Series – Unix.
To practice all areas of Unix, here is complete set of 1000+ Multiple Choice Questions and Answers.