MCQ

Linux MCQs – LINUX commands – Part 3

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 of the following commands will allow the user to search a file for a particular expression?

A ls

B find

C grep

D touch

C
grep command allows you to search and filter text using regular expressions.
Example : If we want to search for the word “string” in “prog.txt” file

$ grep "string" ~/prog.txt

 

 

2. Which option of “tar” command is used to list the contents of an archive?

A xvf

B cvf

C ovf

D tvf

D
The option -tvf of tar command is used to list the contents of a tar or tar.gz archive in Linux. For example :

$ tar -tvf myArchive.tar

 
Meaning of each letter :

  • t = table of contents
  • v = verbose
  • f = file

 

 

3. Which of the following commands can be used to change the default permissions for files and directories at creation time?

A umask

B chown

C chmod

D chgrp

A
“umask” is a command that determines the parameters of a mask, and it controls how file permissions are set for newly created files. For example, the following command:

$ umask u + w

This command sets the mask so that when a file is created, it has the permissions for the user to write.

 

 

4. “pwd” command displays _______ ?

A User’s password

B Contents of the password file

C The current working directory

D None of the above

C
The pwd command displays the current working directory.

 

 
 

5. Which of the following commands can be used to copy files to other systems?

A telnet

B ssh

C rsh

D ftp

D
FTP is the simplest file transfer protocol for exchanging files to and from a remote computer or network. Like Windows, the Linux and UNIX operating systems also have a built-in CLI that can be used as FTP clients to establish an FTP connection. Example of an ftp connection :

$ ftp 192.168.0.1
Name: anonymous
Password:
   230 Login successful.
Remote system type is UNIX.
   Using binary mode to transfer files.
   ftp> put file_name

We use the ‘put’ command to upload the file to other systems.

 

 

6. Which command is used to display all files, including hidden files in your directory and its subdirectories?

A ls –l

B ls –R

C ls –a

D ls –aR

D
$ ls –aR

This command allows to display all files, including hidden files in your directory and its subdirectories.

 

 

7. Which of these commands whose output contains the user ID?

A ls –l

B date

C help

D ls
 

 
A
$ ls -l

total 116
drwxr-xr-x. 3 root root  3036 Jul 21 02:20 Music
drwxr-xr-x. 4 root root  3036 Jul 21 02:20 Images
drwxr-xr-x. 4 root root  2036 Jul 11 02:20 Web
drwxr-xr-x. 4 root root  1036 Jul 11 02:20 bin
drwxr-xr-x. 4 root root  1036 Jul 11 02:20 Desktop

Allows to display all files, including hidden files in your directory and its subdirectories.

 

 

8. Which commands display information about the disk space used by each file?

A ls –l

B ls -la

C ls -a

D du

D
“du” command, is an abbreviation for “disk usage”, is used to estimate the use of file space. The “du” command can be used to track files and directories that consume an excessive amount of space on the hard disk. For example

$ du /home/my/test

32200    /home/my/test/play
1099     /home/my/test/system
23       /home/my/test/cours/java
59       /home/my/test/cours
410009   /home/my/test

 

 

9. Which commands to use to count the number of characters in a file ?

A grep

B wc

C count

D cut
 

 
B

The “wc” command, allows to count the number of characters in a file. The syntax of the command wc is as follow :

$ wc [options] file_name

 

 

10. Which commands to use to determine the path of an executable file?

A what

B wexec

C where

D which

D

“which” command is used to find the location of a program. The simplest form of the command is the following:

$ which <program_name>

 
For example, to find the location of your web browser such as Firefox, use the following command:

$ which firefox

 

 

 
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 *