MCQ

Linux MCQs – File Management – Part 1

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 change file and directory permissions?

A mv

B chgrp

C chmod

D set

C
“chmod” is a command that allows you to change the access permissions to objects in the file system (files and directories). The request is filtered by the umask. The name is an abbreviation of “change mode”.

 

 

2. Where can I find the printer device? In _______ directory.

A /etc

B /dev

C /lib

D /printer
 

 
B
The /dev directory contains special device files for all devices. These device files are created during installation.

 

 

3. Which of the following statements is true?

A The $cp command will keep the file metadata

B The $sort command sorts by default in numerical order

C The $mv command will keep the file metadata

D The $ps command will display the file system usage

C
The $mv command does not copy any file contents, but only the file system metadata about the file based on its name and location, while the $cp command creates a separate copy of the file, which takes much longer because it has to read the first file completely and write its contents to another file.

The $sort command is used to sort a file, organizing the records in a particular order. By default, the sort command sorts the file assuming the contents are in ASCII. By using options in the sort command, it can also be used to sort numerically.

The $ps command in Linux allows you to display the processes running on the system. It provides a snapshot of the current processes with detailed information such as user ID, CPU usage, memory usage, command name, etc..

 

 

4. Which UNIX command is used to update the modification time of a file?

A time

B modify

C cat

D touch

D
The “touch” command changes some dates for each file argument. By default, the “touch” command sets the last modification date and the last access date of the file.

 

 

5. How many links are created when we create a directory?

A 1

B 2

C 3

D 4
 

 
B
In the Unix file system there are two entries in each directory: The dot (.) pointing to the directory itself and the colon (..) pointing to its parent. This made it easy to browse the file system, both for applications and for the operating system itself.

Thus, each directory has a number of links of 2+n, where n is the number of subdirectories.

 

 

6. A user creates a link to “file1” with the following command:
$ ln -s file1 link
Which of the following statements is not true when listing the details of the link created?

A file1 and link have the same inode numbers

B The number of links for file1 is displayed as 1

C The number of links for file1 is displayed as 2

D The number of links for file2 is displayed as 2

B
Symbolic links are created with the “ln” command. For example, the following command creates a symbolic link named “link1” to a file named “file1”, both are in the current directory.

$ ln -s file1 link

 
When listing the details with the “ls” command:

$ ls -l file1 link1

-rw-r--r--   1  alex  gralex  0 Mar  7 22:01 file1
lrwxr-xr-x   1  alex  gralex  5 Mar  7 22:01 link1 -> file1

 

 

 

7. There are two physical links to “file1” which are “p1” and “p2” and one symbolic link “s1”. What happens if we delete “file1”?

A We will still be able to access the file with p1 and p2 but not with sl

B We will not be able to access the file with p1 and p2 but with sl

C We can access the file with any p1, p2 and sl

D We will not be able to access the file with p1, p2 and sl

A
A physical link acts as a mirror copy of the original file. These links share the same inodes. Changes made to the original file will be reflected in the other. When you delete the physical link, nothing will happen in the other file.

A symbolic link is a real link to the original file. These links will have a different Inodes value. The symbolic link points to the original file. Therefore, if the original file is deleted, the symbolic link fails. If you delete the symbolic link, the original file will not be affected. The reason is that the inode of the file or directory is different.

 

 

8. If two files are on the same partition and point to the same inode, they are called ______

A Symbolic links

B Physical links

C Alias

D Special files
 

 
B
A physical link acts as a mirror copy of the original file. These links share the same inodes. Changes made to the original file will be reflected in the other. When you delete the physical link, nothing will happen in the other file.

 

 

9. Delete a symbolic link meaning that ________

A Delete the destination file

B Removes both the symbolic link and the destination file

C Removes only the symbolic link

D the destination backup is automatically created

C
If a symbolic link is deleted, its target remains intact. If a symbolic link points to a target and that target is later moved, renamed, or deleted, the symbolic link is not automatically updated or deleted, but continues to exist and still points to the old target, now a nonexistent location or file. Symbolic links pointing to moved or non-existent targets are sometimes called broken, orphaned or dead links.

 

 

10. Creation of physical links pointing to partitions ____

A is only allowed to the root user

B can be done by any user

C the effects are not specified

D is not allowed

D
A physical link is the file system representation of a file by which multiple paths refer to a single file on the same partition or volume.

 

 
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 *