MCQ

Linux MCQs – Multiple Choice Questions and Answers – Process management

Multiple choice questions and answers (MCQs) on Linux focuses on “Process management” 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. What command is used to bring the background process to the foreground?

A bg

B fg

C background

D forground

B
The “fg” command is used to bring back a stopped or background process by executing it in the foreground. The syntax is as follows:

$ fg [ %job_id ]

 

 

2. How to run a background process?

A |

B &

C *

D ?

B
To run a process in the background use the character “&”, example:

$ vlc &

In this case, the vlc process goes into the background and you can continue to use the terminal. You have the command prompt again. The sign “&” at the end of the command means: run this command in the background.

 

 

3. If a program running in the background tries to read from STDIN

A Its execution is suspended

B STDIN is made available to him

C It completes its task

D None of the above

A
Background processes cannot read from the terminal. If they try, they are suspended by a SIGTTIN (teletype input) signal. The reason for this feature is that if multiple processes tried to read from the terminal, each character would essentially go randomly to one of the processes, which is not useful behavior. Thus, the foreground process gets the input and the background processes do not. If sudo tries to read from the terminal, to ask for your password, it is suspended. You must run sudo in the foreground, then switch to the background.

 

 

4. We can get information about a process in the current shell by using ____?

A kill

B ps

C fg

D bg

B
The “ps” command generates a list of running processes on your computer. Example:

[root@stackhowto ~]# ps
  PID TTY          TIME CMD
69521 pts/0    00:00:00 bash
99301 pts/0    00:00:00 ps

 

 

5. Which command can be executed by a user who is already logged in to the system, in order to change to the root user?

A user

B chroot

C su

D root

C
To switch to the root user, the user need to run the “sudo” command as follows:

$ sudo su

 

 

6. What signal is sent by the “kill -9” command?

A TERM

B STOP

C KILL

D INT

C
The kill command sends a defined signal to a process identified by a (PID):

$ kill - <signal> <pid>

Of course, we can only kill processes that we own, whereas root can kill all processes.
 
The signals that “kill” can send are listed in the man page (man kill). The signal can be represented by its name or by its PID. If no signal is specified, the default signal is 15 resp. So the “TERM” signal is used.
 
TERM (15): this will terminate a process, i.e. it executes a shutdown routine correctly.
 
KILL (9): applications are stopped and killed immediately (which could result in data loss)

 

 

7. When a child process terminates before the parent process closes, which of the following is true?

A The child process becomes an orphan

B The parent process disappears

C if the parent process does not support SIGCHLD, the child process becomes a zombie

D None of the above

C
When a child process stops or terminates, SIGCHLD is sent to the parent process. The default response to the signal is to ignore it. The signal can be intercepted and the exit status of the child process can be obtained by immediately calling wait(2) and wait3(3C). This will remove zombie process entries as quickly as possible.

 

 

8. Which of the following values for the STAT column of the “ps” command is not true?

A Status R means Running

B Status S means Sleeping

C Status E means Exited

D Status Z means Zombie

C
The process states indicated by “ps” command are:

  • D : uninterrupted sleep (usually an I/O)
  • R : running or executable (in the execution queue)
  • S : interruptible sleep (waiting for an event to be completed)
  • T : stopped, either by a control signal from the Job
  • W : paging
  • X : dead (should never be seen)
  • Z : (“zombie”) process, ended without the parent process being aware of it.

 

 

9. We can change the priority of a running process using?

A nice

B renice

C the priority cannot be changed for a running process

D only the superuser can change the priority

B
Every running process in Unix has a priority. You can change the priority of a process by using the “nice” and “renice” utilities. The “nice” command will start a process with a user-defined schedule priority. The “renice” command will change the scheduling priority of a running process.

 

 

10. The signal sent to a process when the “Ctrl-C” key is pressed is ______

A KILL

B INT

C TERM

D TSTP

B
The INT signal is sent to a process via a terminal when a user wishes to interrupt the process. This signal is usually started by pressing Ctrl-C, but on some systems “delete” or “break” button can trigger this signal.

 

 

11. A user issues the following sequence of commands:
$ c.out
$ bash
$ c.out
If the user kills the bash process, then which of the following statements is true?

A The second “c.out” process is also completed

B The second “c.out” process becomes an orphan process

C The first “c.out” process becomes a zombie process

D The init process becomes the parent of the second “c.out” process

D
When a process dies, its children are adopted by init, so you’ll see a lot of processes with parent 1 on a typical system.

 

 

12. “nohup” command is used for ____?

A automatically hang up the process after disconnection

B keep the process after logging out

C create a backgroung process

D manually hang up the process after disconnection

B
“nohup” command allows you to start a process that remains active even after the user who initiated the process has logged out.

 

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 *