Operating System MCQs with Answers
Practice important Operating System MCQs with answers and explanations.
Chapter: 10
Q241:
In the following command: "command < input-file", which file is used for input redirection?
A. keyboard
B. output-file
C. input-file
D. error-file
Correct Answer:
C
Chapter: 10
Q242:
What happens when you try to write to a FIFO that no process has opened for reading?
A. The process is suspended
B. A SIGPIPE signal is sent
C. The process terminates
D. An EOF is sent
Correct Answer:
B
Chapter: 10
Q243:
What system call is used to create FIFOs in UNIX/Linux?
A. mknod()
B. mkfifo()
C. open()
D. read()
Correct Answer:
B
Chapter: 10
Q244:
Which of the following is a feature of named pipes (FIFOs)?
A. Temporary and used between related processes
B. Created only with the open() system call
C. Can be used between unrelated processes
D. Requires a C library call to open
Correct Answer:
C
Chapter: 10
Q245:
What does the ‘1>’ operator do in UNIX/Linux?
A. Redirects error messages to a file
B. Redirects standard output to a file
C. Redirects input to a file
D. Redirects standard error to a file
Correct Answer:
B
Chapter: 10
Q246:
Which command is used to create a FIFO in UNIX/Linux?
A. mknod
B. ls
C. mkfifo
D. fifo
Correct Answer:
C
Chapter: 10
Q247:
In the following command, what happens: "command 2> error-file"?
A. The command's output is saved to error-file
B. The command’s error messages are saved to error-file
C. The command’s standard input is saved to error-file
D. The command reads input from error-file
Correct Answer:
B
Chapter: 10
Q248:
What does the mknod() system call do?
A. Creates a FIFO
B. Creates a file in the filesystem
C. Executes a command
D. Closes a file
Correct Answer:
B
Chapter: 10
Q249:
Which of the following is an example of error redirection in UNIX/Linux?
A. $ cat > output.txt
B. $ ls 2> error.log
C. $ find < input.txt
D. $ grep > output.txt
Correct Answer:
B
Chapter: 10
Q250:
FIFOs in UNIX/Linux are typically used for communication between:
A. Related processes only
B. Unrelated processes only
C. Any processes
D. Processes on different systems
Correct Answer:
B
Chapter: 10
Q251:
Which of the following can be used to detach stdout from the display screen in UNIX/Linux?
A. command < input-file
B. command > output-file
C. command 2> error-file
D. command | output-file
Correct Answer:
B
Chapter: 10
Q252:
When a process writes to a FIFO and no process is reading from it, what signal is sent?
A. SIGPIPE
B. SIGTERM
C. SIGKILL
D. SIGINT
Correct Answer:
A
Chapter: 10
Q253:
In which situation would the ‘mkfifo’ command fail?
A. When creating a FIFO with a valid path
B. When the destination directory is read-only
C. When the file permissions are correct
D. When the FIFO is empty
Correct Answer:
B
Chapter: 10
Q254:
A FIFO can be used for communication between:
A. Only processes on the same machine
B. Only processes in the same directory
C. Any processes regardless of relationship
D. Only related processes
Correct Answer:
C
Chapter: 10
Q255:
Which command can be used to create a FIFO from the command line in UNIX/Linux?
A. mknod
B. grep
C. mkfifo
D. cat
Correct Answer:
C
Chapter: 10
Q256:
In a UNIX/Linux shell, what happens when a command writes to a FIFO that no process has opened for reading?
A. It waits for input
B. An EOF is sent
C. A SIGPIPE signal is sent
D. The process is suspended
Correct Answer:
C
Chapter: 10
Q257:
Which of the following is not a valid redirection operator in UNIX/Linux?
A. <
B. >
C. 2>
D. |
Correct Answer:
C
Chapter: 10
Q258:
Which system call is used to create a special file or FIFO in UNIX/Linux?
A. mknod()
B. mkfifo()
C. pipe()
D. open()
Correct Answer:
A
Chapter: 10
Q259:
In UNIX/Linux, what is the default mode of operation when opening a FIFO?
A. Non-blocking I/O
B. Blocking I/O
C. Immediate I/O
D. Asynchronous I/O
Correct Answer:
B
Chapter: 10
Q260:
What is the purpose of using FIFOs in client-server applications in UNIX/Linux?
A. For fast file transfers
B. For inter-process communication
C. To manage file permissions
D. To create files with special permissions
Correct Answer:
B