250+ TOP MCQs on Changing File Ownership and Permissions

Unix Questions and Answers for Experienced people on “Changing File Ownership and Permissions”.

1. While changing permissions in an absolute manner, we explicitly set all the nine bits irrespective of the previous permissions of the file.
a) True
b) False

Answer: a
Clarification: The expression used by chmod in an absolute manner is a string of three octal numbers (base 8). A set of 3 bits represent a single octal digit.
-> Read permission –4 (100 in octal)
-> Write permission –2(010 in octal)
-> Execute permission –1(001 in octal)
For each category, we add up these numbers. For example, if we have to set read and write permission then an octal number will be 110 (4+2).

2. What are the permission of file01 after executing this command?

a) rwxrwxrwx
b) rw-rw-rw
c) r–r–r–
d) r–r—-

Answer: a
Clarification: Since the octal number for the above command is 777 and we know that 7(111) represents all the three sets of permissions (read, write and execute) for a category of user. As we have 777, the file is readable, writable and executable by anyone.

3. A file named file01 should be readable, writable and executable only by the user(owner). Which one of the following set of command will be used?
a) chmod 700 file01
b) chmod 000 file01
c) chmod 477 file01
d) chmod 777 file01

Answer: a
Clarification: Since 7(111) represents read, write, execute permission. So 700 will represent read, write, execute permission only for the user (owner).

4. A file has a permission set as 000 i.e. — — —. Can the file be deleted?
a) Yes
b) No

  250+ TOP MCQs on Operator-Command Combinations and Answers

Answer: a
Clarification: The file having permission set as 000 is useless i.e. it is not readable, writable or executable. But we can delete the file using directory permissions. If the directory has write permission, we can easily add or remove a file from it.

5. A file has a permission set as 777 ie rwxrwxrwx but the directory permissions are 400. If the user tries to delete the file, will he be able to do it?
a) Yes
b) No

Answer: b
Clarification: Since we have only read permissions for the directory and the directory permissions do not allow us to add or remove a file from it we cannot delete a file no matter what is the permission set of that file.

6. Which command is used to change the ownership of a file?
a) chmod
b) change
c) ch
d) chown

Answer: d
Clarification: For changing the file ownership, we use the chown command. chown transfer the ownership of a file to another user. The command requires the user-ID (UID) of the recipient. To change the ownership of a file from user01 to user02, use the following commands:

1. Change your status to a super user.
2. # chown mash  file01            // # indicates another shell 
3. exit

7. Which option is used for the recursive functioning of chmod command?
a) -R
b) -r
c) -l
d) -i

Answer: a
Clarification: Like other UNIX commands, chmod can also descend a directory hierarchy and apply the expression to every file and subdirectories it finds. This is done using -R option. For example,

This command will make all files and subdirectories found in the tree walk executable by all users.

  250+ TOP MCQs on Process Basics and Answers

8. Which command is used to change the group owner of the file?
a) chown
b) ch
c) chgrp
d) chmod

Answer: c
Clarification: A user can change the group owner of a file but only to that group to which he belongs. A user can belong to more than one group and the one shown in /etc/psswd is the user’s main group.

9. A user can change the group ownership of a file to another group to which he does not belong.
a) True
b) False

Answer: b
Clarification: Group ownership can be changed only to that group to which the user also belongs otherwise a user cannot change the group ownership of a file to another group to which he does not belong.

10. Like chmod, chown and chgrp can also use ___ option.
a) -R
b) -r
c) -x
d) -i

Answer: a
Clarification: Like chmod, chown and chgrp use the -R option to perform their operations in a recursive manner.

11. UNIX allows the system administrator to use the only chown to change both owner and group.
a) True
b) False

Answer: a
Clarification: UNIX provides a special privilege for the system administrator to change both the owner and group using chown command only. The syntax requires two arguments to be separated by a (:). For example,

 
chown  abd:grp01  file01.txt     // ownership to abd, group to grp01

12. Which symbol is used to change permissions for hidden files?
a) .
b) &
c) $
d) *

Answer: a
Clarification: To change permissions for hidden files, use the (.) symbol with chmod command.

 
$ chmod 755  .    // works on hidden files

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top