MCQ

Linux MCQs – File Access Rights and Permissions – Part 2

Multiple choice questions and answers (MCQs) on Linux focuses on “Managing of users accounts and groups” to prepare for exams, interviews, and certifications, such as Redhat exam, CompTIA exam, Ubuntu / SuSE certification, LPI certification exam. These MCQs will easily prepare anyone to pass their Linux test.
 

1. Which command is used to assign read-write permission to the file owner?

A chmod a+r myfile

B chmod o+r myfile

C chmod u=rw myfile

D chmod og-r myfile
 

 
C
“chmod” is an abbreviation of change mode is a command that can change the access permissions of files and directories. The permissions are filtered by the umask.

 

 

2. The following command:
$ chmod 4777 c.out

A will set the SUID bit of c.out file

B will only set the SUID bit of c.out file if the command is submitted by the root user

C invalid command

D will put the sticky bit of c.out file

A
SUID (Set owner User ID) is defined to give temporary rights to a user to run a program or file with the permissions of the owner of the file rather than the actual user.

 

 

4. The -rwxr-xr-t permissions represented by the following octal value.

A 0777

B 1755

C 1754

D 2754

B
The sticky bit ($ chmod +t file-name) was introduced for use with executables to allow to an operating system to keep the program’s text segment in swap space after the process has finished. It was a performance feature designed to speed up program execution. The sticky bit is most commonly used on directories where it allows files or directories to be moved or deleted only by the owner of that object, the owner of the directory or the root superuser. To define the sticky bit on a file, the octal value is 1000 and the symbolic value is “t”.
String notation:

$ chmod o+t file1.txt

 
Numeric notation:

$ chmod 1755 file1.txt

 
The sticky bit has no effect if other does not have execution permissions. The sticky bit is represented with a lowercase “t” in the output of ls. In cases where it has no effect, it is represented by a capital “T”.

$ ls -l file1

-rwxr-xr-t 1 user1 user1 0 2018-10-29 21:41 file1

 

 

5. The following command :
$ chmod o-w myfile

A defines the write permission for “others”.

B defines the write permission for “owner”.

C deletes the write permission for “others”.

D deletes write permissions

C

 

 
 

6. Which of these commands will set the permissions on the file “myfile”: read and write for the owner(user), read for the group and nothing for others?

A $ chmod 046 myfile

B $ chmod 640 myfile

C $ chmod 310 myfile

D $ chmod rw rw myfile

B
  • r = permission to read
  • w = permission to write
  • x = permission to run
  • – = 0 permission

With r=4 / w=2 / x=1

$ chmod 640 myfile
$ ls -l myfile

-rw-r----- 1 user1 user1 0 2018-10-29 21:41 myfile

 

 

7. If you are a root user, how can you enable execution only for the owner of the file “myfile”?

A $ chmod +x myfile

B $ chmod u+x myfile

C $ chmod a+x myfile

D $ chmod U+X myfile

B
u+x grants the execution right to the file owner.

 

 

8. What does the following command “chmod + t”?

A wrong syntax

B defines the EUID

C defines the EGID

D set up the sticky bit

D

 

 

9. A user executes the following command :
$ chmod + x myfile.txt
Which of the following statements is true for the output of this command?

A The command results in an execution permission being added to the user who executed this command

B The command results in the execution permission being added for the owner of the file

C The command causes an error because the file is not an executable file

D The command results in the execution permission being added for all (user, group and others)

D

 

 
 

10. Which of the umask command parameters grant the right to run the newly created regular files by default?

A 222

B 111

C 000

D None of the above

D

umask by default is 022 so

  • permissions for newly created directories: rwxr-xr-x.
  • permissions for newly created files: -rw-r-r–.

By default, the execution permission is disabled for regular files.

 

 
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

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