Unix Questions and Answers – General Purpose Commands – 1

This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “General Purpose Commands – 1”.

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

Answer: c
Explanation: 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.

$ echo hello
hello

advertisement
advertisement

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

Answer: a
Explanation: 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
View Answer

Answer: d
Explanation:

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
\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
View Answer

Answer: b
Explanation: 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.
advertisement

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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: b
Explanation: 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.
advertisement

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

Answer: b
Explanation: 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.

script   file_one

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

Answer: a
Explanation: 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  bob@saturn  (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
View Answer

Answer: d
Explanation: 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
View Answer

Answer: d
Explanation: 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
View Answer

Answer: a
Explanation: 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
View Answer

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

Sanfoundry Global Education & Learning Series – Unix.

To practice all areas of Unix, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.