0% found this document useful (0 votes)
132 views12 pages

UNIX Command MCQs

This document contains 37 multiple choice questions about Linux commands and utilities. The questions cover topics such as grep, sort, head, cp, chmod, rmdir, cut, wc, touch, ls, od, vi editor commands, ps, wall, rm, and file. For each question there are 4 possible answers and the correct answer is indicated. The questions are numbered and separated by horizontal lines, with the answer and an attribution to the website study2online.com below each question.

Uploaded by

Bilal Hassan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views12 pages

UNIX Command MCQs

This document contains 37 multiple choice questions about Linux commands and utilities. The questions cover topics such as grep, sort, head, cp, chmod, rmdir, cut, wc, touch, ls, od, vi editor commands, ps, wall, rm, and file. For each question there are 4 possible answers and the correct answer is indicated. The questions are numbered and separated by horizontal lines, with the answer and an attribution to the website study2online.com below each question.

Uploaded by

Bilal Hassan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MCQ

1. Which symbol will be used with grep command to match the pattern pat at the beginning of
a line?
A) ^pat
B) $pat
C) pat$
D) pat^
Answer : A
______________________________________________________________________www.[Link]

2. Which command is used to sort the lines of data in a file in reverse order
A) sort
B) sh
C) st
D) sort -r
Answer : D
______________________________________________________________________www.[Link]

3. Which command is used to display the top of the file?


A) cat
B) head
C) more
D) grep
Answer : B
______________________________________________________________________www.[Link]

4. Which command is used to copy all files having the string chap and any two characters after
that to the progs directory?
A) cp chap?? progs
B) cp chap* progs
C) cp chap[12] /progs/*.*
D) cp chap?? /progs/*
Answer : A
______________________________________________________________________www.[Link]

5. Which command is used to change protection mode of files starting with the string emp and

Page 1/12 Visit our site: [Link]


MCQ

ending with 1,2, or 3?


A) chmod u+x emp[1-3]
B) chmod 777 emp*
C) chmod u+r ??? emp
D) chmod 222 emp?
Answer : A
______________________________________________________________________www.[Link]

6. Which command is used to remove a directory?


A) rd
B) rmdir
C) dldir
D) rdir
Answer : B
______________________________________________________________________www.[Link]

7. Which of the following keys is used to replace a single character with new text?
A) S
B) s
C) r
D) C
Answer : B
______________________________________________________________________www.[Link]

8. Which command is used to extract specific columns from the file?


A) cat
B) cut
C) grep
D) paste
Answer : B
______________________________________________________________________www.[Link]

9. Which command sends the word count of the file infile to the newfile.
A) wc infile >newfile
B) wc newfile
C) wc infile - newfile

Page 2/12 Visit our site: [Link]


MCQ

D) wc infile | newfile
Answer : A
______________________________________________________________________www.[Link]

10. Which command is used to remove the read permission of the file 'note' from both the
group and others?
A) chmod go+r note
B) chmod go+rw note
C) chmod go-x note
D) chmod go-r note
Answer : D
______________________________________________________________________www.[Link]

11. Which of the following commands is used to display the directory attributes rather than its
contents?
A) ls -l -d
B) ls -l
C) ls -x
D) ls -F
Answer : A
______________________________________________________________________www.[Link]

12. Which of the following files will displayed by this command cat *ch*
A) patch
B) catch
C) .ch
D) All of the above
Answer : D
______________________________________________________________________www.[Link]

13. The Octal number to be given alogn with chmod command to make a file readable,
writable and executable to the owner, readable and executable to group and others is:
A) 0
B) 755
C) 744

Page 3/12 Visit our site: [Link]


MCQ

D) 555
Answer : B
______________________________________________________________________www.[Link]

14. If you are to use [Control-c] as the interrupt key instead of [Del], then you will have to use
A) tty ^c
B) stty intr ^c
C) stty echoe
D) stty echo ^a
Answer : B
______________________________________________________________________www.[Link]

15. Which of the following is not a communication command.


A) write
B) mesg
C) mail
D) grep
Answer : D
______________________________________________________________________www.[Link]

16. Which of the following keys is used to move the cursor to the end of the paragraph.
A) }
B) {
C) |
D) $
Answer : A
______________________________________________________________________www.[Link]

17. Which command is used to concatenate all files beginning with the string 'emp' and
followed by a non-numeric characters?
A) cat emp[!0-9]
B) more [emp][!0-9]
C) cat emp[x-z]
D) cat emp[a-z]
Answer : A

Page 4/12 Visit our site: [Link]


MCQ

______________________________________________________________________www.[Link]

18. The command which transcribes the standard input to the standard output and also makes a
copy of the same in a file is
A) tee
B) tr
C) sort
D) grep
Answer : A
______________________________________________________________________www.[Link]

19. Which command is used to remove a file?


A) remove
B) rm
C) mv
D) del
Answer : B
______________________________________________________________________www.[Link]

20. Which symbol is used to separate more than one command in the same command line?
A) $
B) #
C) :
D) ;
Answer : D
______________________________________________________________________www.[Link]

21. The agency that sits between the user and the UNIX system is called the
A) logic
B) profile
C) shell
D) erxc
Answer : C
______________________________________________________________________www.[Link]

22. Which of the following commands is used to update access and modification times of a

Page 5/12 Visit our site: [Link]


MCQ

file?
A) grep
B) wc
C) touch
D) cat
Answer : C
______________________________________________________________________www.[Link]

23. Which command is used to count just the number of characters in a file?
A) wc - 1
B) wc -c
C) wc -w
D) wc -r
Answer : B
______________________________________________________________________www.[Link]

24. Which of the following commands is used to list contents of directories?


A) ls
B) lp
C) dir
D) tar
Answer : A
______________________________________________________________________www.[Link]

25. Which command is used to display a file contents in octal form?


A) cd
B) od
C) of
D) oct
Answer : B
______________________________________________________________________www.[Link]

26. Which command will be used with vi editor to insert text to left of cursor?
A) s
B) S
C) a

Page 6/12 Visit our site: [Link]


MCQ

D) i
Answer : D
______________________________________________________________________www.[Link]

27. In vi editor, forward search is performed using the command.


A) :pat
B) ?pat
C) /pat
D) All of the above
Answer : C
______________________________________________________________________www.[Link]

28. Which of the following special shell variables is used to process number of the last
background job?
A) $!
B) $#
C) $0
D) $*
Answer : A
______________________________________________________________________www.[Link]

29. Which option will be used with ps command to slow the entire command line of the
process being run?
A) -4
B) #NAME?
C) -1
D) -2
Answer : B
______________________________________________________________________www.[Link]

30. Which of the following command addresses all users who are currently hooked on?
A) write
B) mail
C) wall
D) mesg

Page 7/12 Visit our site: [Link]


MCQ

Answer : C
______________________________________________________________________www.[Link]

31. Which option is used with rm command to make the command prompt the user with each
filename and a ?, before acting on it
A) -r
B) #NAME?
C) #NAME?
D) -1
Answer : C
______________________________________________________________________www.[Link]

32. Which of the following directories contain all the Alias created by a user, including his
login directory?
A) /tmp
B) /etc
C) /usr
D) /dev
Answer : C
______________________________________________________________________www.[Link]

33. Which of the following commands is used to obtain a list of all files by modification time?
A) ls -1
B) ls -t
C) ls -i
D) ls -R
Answer : B
______________________________________________________________________www.[Link]

34. The % key allows you


A) to move the cursor to a matching delimiter, when a delimiters a parenthesis, a bracket, or a
brace.
B) to move the cursor to the upperleft corner of the screen
C) to move the cursor backward to the beginning of a word
D) to move the cursor to the first column in the current line

Page 8/12 Visit our site: [Link]


MCQ

Answer : A
______________________________________________________________________www.[Link]

35. Which command is used to display the characteristics of a process?


A) pid
B) du
C) ps
D) au
Answer : C
______________________________________________________________________www.[Link]

36. Which of the following commands is used to identify the type of file by context?
A) ls
B) cat
C) file
D) more
Answer : C
______________________________________________________________________www.[Link]

37. The field separator in cut command is specified with


A) #NAME?
B) #NAME?
C) -r option
D) #NAME?
Answer : B
______________________________________________________________________www.[Link]

38. Which of the following options will be used to display number of blocks used by a file?
A) -c
B) #NAME?
C) #NAME?
D) #NAME?
Answer : D
______________________________________________________________________www.[Link]

39. Which command is used to make all files and sub-directories in the directory (progs)

Page 9/12 Visit our site: [Link]


MCQ

executable by all users?


A) chmod -R a+x progs
B) chmod -R 222 progs
C) chmod -1 a+x progs
D) chmod -x a+x progs
Answer : A
______________________________________________________________________www.[Link]

40. Which command is used to display and create files?


A) cat
B) vi
C) ed
D) lyrix
Answer : A
______________________________________________________________________www.[Link]

41. The second set of the three permissions (r-) indicates that
A) group has read permission only
B) other has read permission only
C) owner has read permission only
D) group has write permission only
Answer : A
______________________________________________________________________www.[Link]

42. Which column contains all details of the permissions of a file when you issue the ls -l
command?
A) second
B) fourth
C) third
D) first
Answer : D
______________________________________________________________________www.[Link]

43. Which of the following commands is used to display your working directory?
A) dir
B) prompt $p$g

Page 10/12 Visit our site: [Link]


MCQ

C) pwd
D) path
Answer : C
______________________________________________________________________www.[Link]

44. While working with mail command, which command is used to save mail in a separate
file?
A) s
B) r
C) w
D) d
Answer : A
______________________________________________________________________www.[Link]

45. The command used to compare the files is known as


A) comp
B) cmp
C) do
D) ccp
Answer : B
______________________________________________________________________www.[Link]

46. Which command is used to terminate a process?


A) shutdown
B) haltsys
C) cancel
D) kill
Answer : D
______________________________________________________________________www.[Link]

47. The cp command uses:


A) standard input file
B) standard output file
C) both input and output file
D) neither standard input nor standard output file
Answer : D

Page 11/12 Visit our site: [Link]


MCQ

______________________________________________________________________www.[Link]

48. Which of the following files contains information related to password aging?
A) Shadow
B) password
C) profile
D) All the three
Answer : B
______________________________________________________________________www.[Link]

49. Which command will be used with vi editor to replace text from cursor to right?
A) r
B) R
C) s
D) S
Answer : B
______________________________________________________________________www.[Link]

50. Which of the following commands is used to rename a file?


A) rename
B) remove
C) mv
D) ren
Answer : C
______________________________________________________________________www.[Link]

Page 12/12 Visit our site: [Link]

You might also like