Unix Questions and Answers – Changing File Ownership and Permissions – 1

This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Changing File Ownership and Permissions – 1”.

1. Which command is used to change the permissions of a file?
a) chmod
b) ch
c) chown
d) chgrp
View Answer

Answer: a
Explanation: The chmod (change mode) command is used to change the permissions of files. This command can only be run by the owner of the file or by the super user.

2. chmod command can take multiple filenames as arguments.
a) True
b) False
View Answer

Answer: a
Explanation: We can change permissions of multiple files by using chmod command once. To change permissions of multiple files simultaneously just use the chmod command with multiple filenames as arguments.

3. chmod command can be used in ____ ways.
a) 3
b) 2
c) 5
d) 0
View Answer

Answer: b
Explanation: chmod command can be used in two manners i.e. relative (changes are specified to the current permissions) and absolute (final permissions are specified).
advertisement
advertisement

4. The expression used with chmod command to change permissions in a relative manner contains ____ components.
a) 5
b) 2
c) 4
d) 3
View Answer

Answer: d
Explanation: chmod command takes an expression as its arguments which comprises of some letters and symbols. The expression comprises three components:-
-> User category (user, group, others)
-> The operation to be performed (assign or remove a permission)
-> Type of permission (read, write, execute).

5. Which of the following characters specify the user and group category?
a) ‘u’ and ‘g’
b) ‘g’ and ‘o’
c) ‘us’ and ‘gr’
d) ‘u’ and ‘o’
View Answer

Answer: a
Explanation: Each character specifies a particular category of users as follows:
‘u’ stands for a user,
‘g’ for ‘group’
‘o’ for ‘others’.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. Which of the following symbol is used with chmod to assign permission to a file?
a) –
b) /
c) +
d) *
View Answer

Answer: c
Explanation: To assign and remove permissions from a file, (+) and (-) symbols are used respectively.
‘+’ symbol will assign a permission
‘-‘ symbol will remove a permission

7. To assign execute permission to the user (owner) for a file named file01.txt, which of the following command will be used?
a) chmod u+r file01.txt
b) chmod u+w file01.txt
c) chmod u-x file01.txt
d) chmod u+x file01.txt
View Answer

Answer: d
Explanation: To assign execute permission to the user, above command is stated as follows:

advertisement
 u    -  for specifying the category of user.
 +    - for assigning permission.
 x    - to specify execute permission.

advertisement

8. What does the following command do?

     $ chmod ugo +w  file01.txt

a) assign write permission to users, group and others
b) assign write permission to the user (owner) only
c) assign write permission to group and others
d) command not executable
View Answer

Answer: a
Explanation: The string ugo combines all the three categories –user, group and others while (+) is used to assign the permission. ‘w’ specifies the write operation.

9. Which character is used to replace ‘ugo’ string in chmod command?
a) a
b) v
c) x
d) o
View Answer

Answer: a
Explanation: UNIX offers a shorthand symbol ‘a’ (all) that acts as a synonym for the ‘ugo’ string which represents all the categories of users.

$ chmod a+w  file01		// assign write permission to user, group and others.

10. To remove write permission from group and others, which one of the following commands will be used?
a) chmod go+w file01
b) chmod go-w file01
c) chmod ug-w file01
d) chmod a-w file01
View Answer

Answer: b
Explanation: To remove a certain permission from a category of users we use (-) symbol. So above command will remove write permission from group and others.

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.