Unix Questions and Answers – File Ownership and Permissions

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.
a) $
b) –
c) *
d) /
View Answer

Answer: b
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?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: c
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?
a) r,w,x
b) e,w,x
c) x,w,e
d) e,x,w
View Answer

Answer: a
Explanation: A file can have three types of permissions; read, write and execute which is represented by characters r, w and x respectively.
advertisement
advertisement

4. A file named abd.txt has the following set of permissions

 -rwxrwxrwx

All the three operations i.e read, write and execute can be performed on the file by file owner, group owner and others.
a) True
b) False
View Answer

Answer: a
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

Note: Join free Sanfoundry classes at Telegram or Youtube
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!

advertisement

5. Which of the following symbol is used to indicate the absence of a permission of a file?
a) $
b) &
c) +
d) –
View Answer

Answer: d
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,

advertisement
rwx  r--  r--

6. When we create a file, we are the owner of a file.
a) True
b) False
View Answer

Answer: a
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
View Answer

Answer: a
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.
a) True
b) False
View Answer

Answer: a
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.
a) True
b) False
View Answer

Answer: b
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
View Answer

Answer: d
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.
a) True
b) False
View Answer

Answer: b
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
View Answer

Answer: d
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?
a) rw-rw-rw-
b) rwxrwxrwx
c) r–r–r–
d) rw-rw-rwx
View Answer

Answer: a
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?
a) rw-rw-rw-
b) rwxrwxrwx
c) r–r–r–
d) rw-rw-rwx
View Answer

Answer: b
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?
a) Yes
b) No
c) Cannot be defined
d) Error will be encountered
View Answer

Answer: b
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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.