250+ TOP MCQs on General Purpose Commands and Answers

Unix Multiple Choice Questions on “General Purpose Commands”.

1. echo command is used for _________
a) displaying errors
b) displaying operating system details
c) displaying diagnostic messages
d) displaying date and time

Answer: c
Clarification: echo command is generally used for displaying diagnostic messages on to the terminal or to issue prompt for reading the user input. All shells now have echo built in i.e. it is an internal command.

2. What are escape sequences?
a) special characters beginning with a (backslash)
b) special commands
c) special utilities
d) a sequence of characters

Answer: a
Clarification: An escape sequence is generally a two character string which begins with a . The role of escape sequences is that they change the state of computer or the peripheral devices attached to it, For example, n is an escape sequence which implies a new line character.

3. Which of the following is not a valid escape sequence in UNIX?
a) n
b) t
c) v
d) d

Answer: d
Clarification:

n denotes a new line character
t denotes a space tab while 
v denotes a vertical tab.

4. Which command is used as an alternative to echo command?
a) ls
b) printf
c) wc
d) ps

Answer: b
Clarification: printf command is available on most UNIX systems and it behaves much like a substitution for echo command. It supports many of the formats which are used by C’s printf function. printf is also an external command.

5. For what purpose bc command is used?
a) as a calculator
b) as an editor
c) as a process table viewer
d) for copying files

Answer: a
Clarification: bc command is used for invoking calculator on UNIX system. It comes with a wide library for performing calculations. The power of this tool can be derived from the fact, that it can perform calculations up to and above 900 digits!

6. script command is used for___________
a) recording history
b) recording our session
c) recording passwords
d) recording scripts

Answer: b
Clarification: script command is basically used for recording our login session in a file. All the keystrokes, output, error messages that are encountered while our session will be stored in a file which we can view later. The name of the file in which the session is stored is typescript.

7. Which of the following is a valid option with script command?
a) -b
b) -a
c) -d
d) -x

Answer: b
Clarification: script command overwrites any previous typescript that may exist. -a option allows us to append our session to the existing typescript file without overwriting to it.
For example, script -a
We can also record our session to a different log file by using the following command.

8. mailx command is used for sending and receiving emails.
a) True
b) False

Answer: a
Clarification: Since UNIX is a multiuser system, so communication between systems seems to be natural and important. For this purpose mailx command is used. Through mailx command, we can send and receive emails to different users on same host network or different network. The addressing scheme uses a combination of username and machine name. For example,

mailx  bob  (bob is on same host)
mailx  [email protected]  (bob is on networked host saturn)

9. Which of the following function cannot be performed by mailx command?
a) sending and receiving emails
b) reply to the sender
c) forward, delete and print mails
d) un-send mails

Answer: d
Clarification: mailx command can perform various functions apart from sending and receiving emails such as replying to the sender and all recipients, forward it to others, save it to a different folder, delete it, print it. To view received emails, simply type mailx command and hit enter.

10. Which of the following is not an internal command used by mailx?
a) N
b) d
c) q
d) a

Answer: d
Clarification: There are various internal commands used by mailx each of which performs a specified task.

N , prints the message numbered N
d , deletes the current message( if N is not specified along with it)
q , quits the mailx  program

11. -h option is used with who command for what purpose?
a) display output with header information
b) display output with a more detailed version
c) display output with trailer information
d) display output in columnar form

Answer: a
Clarification: While most UNIX commands have a feature to avoid cluttering the display with display information, who command does have a header option( -H ). This option prints the column headers also.

$ who  -H
NAME              LINE	      TIME	             PID
Abd	           pts/12     Aug 12  17:51	     11040
Mash	           pts/14     Aug 12  17:57          11045

12. Two or more users can have same login name in the output of who command.
a) True
b) False

Answer: a
Clarification: Yes, UNIX provides us a feature that two users can login with the same username at the same time on the same network host.

Leave a Reply

Your email address will not be published. Required fields are marked *