MCQ

Linux MCQs – LINUX commands – 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. The find / -name '*' command will _________ ?

A List all files and directories recursively from the root /

B List a file named * that is located in the root /

C List all the files found in the root /

D List all the files and directories found in the root /

A
The following command :

$ find / -name ‘*’

Will list all files and directories recursively from the root /. We use the * character to say all files.

 

 

2. Which option of the “ls” command is used to display the inode number of a file?

A –l

B -o

C –a

D –i
 

 
D
The “ls” command with the option -i, lists the files and directories, with the inode number for each file and directory. For example:

$ ls -i

45963 Desktop   23925 Download          231258 prog.txt
45967 Documents 23945 Web               231335 profile.jpg
45964 Images    23909 bin   

 

 

3. Which command can be used to find the resource limit of a session?

A ulimit

B setrlimit

C getrlimit

D rlimit

A
The “ulimit” command allows you to display and set limits on a user’s resources. System resources are defined in a file called “/etc/security/limits.conf”. “ulimit” can then be used to display these settings. For example to display all your current settings, you can run the following command: “ulimit -a” :

$ ulimit -a

file size               (blocks, -f) unlimited
max memory size         (kbytes, -m) unlimited
stack size              (kbytes, -s) 1324
virtual memory          (kbytes, -v) unlimited

 

 

4. Which command is used to print a file ?

A ptr

B lpr

C print

D None of the above

B
The easiest way to print a file in Linux is to transfer a file with the “cat” command to the printing device, like this :

$ cat my_file.txt > /dev/lp0

 
Or with lpr command like this:

$ lpr my_file.txt

 

 

5. Which command is used to display the version of your system ?

A uname -r

B uname -t

C kernel

D uname -n
 

 
A
The “uname” command displays information about the software and hardware of your running Linux system, the -r option displays the version of your unix system, for example:

$ uname -r
3.4-32-generic

 

 

6. Which command is used to display the name of your operating system ?

A unix

B uname

C os

D kernel

B
The “uname” command displays information about the software and hardware of your Linux system. For example:

$ uname -a
Linux myserv 3.4-32-generic Lun Oct 13 12:31:48 2018 x86_64 GNU/Linux

(your system name, kernel version and date, platform type, and system type)

 

 

7. Which command is used to save a user connection session to a file ?

A script

B macro

C read

D None of the above

A
The “script” command records a shell session so that you can look at the output you saw at that time. For example :

$ script -c "ps ax" /tmp/all_processes.txt

This command writes the output of the “ps” command which will make it list all running processes on the system you have access to. The output will be written to the file “/tmp/all_processes.txt” and the last line of the file will record the date and time the command was executed.

 

 

8. Which command is used to change the I/O characteristics of the terminal?

A ctty

B ptty

C stty

D tty
 

 
C
The “stty” command is used to change the I/O characteristics of the terminal. For example to display all parameters use the following command:

$ stty -a

 

 

9. The following command :
$ mknod myfifo b 4 16

A Will create a device in block mode if the user is root

B Will create a block device for all users

C Create a FIFO if the user is not root

D None of the above

A
The “mknod” command is used to create character mode and block mode devices in /dev directory.

 

 

10. “dmesg” command

A Displays user logout and login attempts

B Display the syslog file for information messages

C Displays kernel log messages

D Displays the daemon’s log messages

C
The “dmesg” command allows you to control the kernel. For example, to list all the drivers loaded in the kernel run the following command:

# dmesg | more

 

 
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 *