Unix/Linux Commands and Shell Scripting

Test your knowledge of Unix/Linux commands, file permissions, and shell scripting including loops, variables, command history, and text processing.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

A user types history command and gets the following output
141 cd .tcs
142 ll tcs.lst
143 pwd
144 vi tcs.lst
145 ll -lrt | awk '{ print $NF }'
146 echo "Test"
147 ps -ef | grep lsnr
148 grep a *
149 ls
150 echo $PWD

Refering to the scenario above, which one of the following is not a method for recovering the pwd command

  1. r 143
  2. fc -e -r p
  3. fc -e 143
  4. r -8
Question 2 Multiple Choice (Single Answer)

Consider the script
let i=2
while (( i <= ($l - 1) )); do
if (( ($l % i ) == 0 )); then
print $i $l $?
break;
fi
let i=i+1
done

What is the program all about and what are the possible outputs?

  1. checks prime number; returns one when not prime and zero when prime
  2. checks prime number; returns none when not prime and zero when prime
  3. checks prime number; returns zero when not prime and one when prime
  4. checks prime number; returns zero when not prime and none when prime
Question 3 Multiple Choice (Single Answer)

"A user types history command and gets the following output 141 cd .tcs 142 ll tcs.lst 143 pwd 144 vi tcs.lst 145 ll -lrt | awk '{ print $NF }' 146 echo ""Test"" 147 ps -ef | grep lsnr 148 grep a * 149 ls 150 echo $PWD Refering to the scenario above, which one of the following is not a method for recovering the pwd command"

  1. r 143
  2. fc -e -r p
  3. fc -e 143
  4. r -8
Question 4 Multiple Choice (Single Answer)

Consider the script "beach.sh" for i in $1; do if (( ${#i} > 4 )); then print -n "#$i " fi done beach.sh "On the beach at night, stands a child with her father" What is the output of this script?

  1. #On the beach at night, stands a child with her father
  2. #On #the #at #a #with #her
  3. #beac #nigh #stan #chil #fath
  4. #beach #night, #stands #child #father
Question 5 Multiple Choice (Single Answer)

Which of the following command sets the previously undefined variable x to 40?

  1. typset x=32+8
  2. set x=32+8
  3. let x=32+8
  4. x=32+8
Question 6 Multiple Choice (Single Answer)

Consider the script let i=2 while (( i <= ($l - 1) )); do if (( ($l % i ) == 0 )); then print $? break; fi let i=i+1 done What is the program all about and what are the possible outputs

  1. checks prime number; returns one when not prime and zero when prime
  2. checks prime number; returns none when not prime and zero when prime
  3. checks prime number; returns zero when not prime and one when prime
  4. checks prime number; returns zero when not prime and none when prime
Question 7 Multiple Choice (Single Answer)

Which one of the following command shows the last 50 commands the user has entered.

  1. fc -l 50
  2. fc -l -50
  3. history 50
  4. history $$
Question 8 Multiple Choice (Single Answer)

Which one of the following is the syntax for a pattern that matches the null string or a filename beginning with a or A

  1. ?([A-a].*)
  2. ?([aA]*)
  3. ?([aA].*)
  4. ?([aA]$)
Question 9 Multiple Choice (Single Answer)

Consider the following case echo * We know that the output will be the list of all the files in current directory or equivalent to ls output. Which of the following command gives the ouput as * for the above script.

  1. set -t
  2. set -m
  3. set -f
  4. set -l
Question 10 Multiple Choice (Single Answer)

#! /bin/ksh for i in 1 2 3 4 ......... 50 # loop from 1 to 50 do let i=i+1 done echo $i What is the output of the above script.

  1. 2450
  2. 1275
  3. 1225
  4. 2550
Question 11 Multiple Choice (Single Answer)

Crown margin mode can be done using which command?

  1. nroff
  2. mm
  3. tbl
  4. fmt
Question 12 Multiple Choice (Single Answer)

Which key allows to append the script in next line

  1. back slash
  2. Single quote
  3. full stop (dot)
  4. frontslash
Question 13 Multiple Choice (Single Answer)

Command to set the default file permssions of a user

  1. default
  2. set
  3. umask
  4. mask
Question 14 Multiple Choice (Single Answer)

What is the default configuration for regular files?

  1. --xr--r--
  2. rw-r--r--
  3. r--r--r--
  4. rwxr--r--
Question 15 Multiple Choice (Single Answer)

Command that is used to find text matches from a file?

  1. find
  2. match
  3. grep
  4. use
Question 16 Multiple Choice (Single Answer)

Command to find out what kind of a Unix system you are on ?

  1. ipaddress
  2. uname
  3. ip
  4. sysip
Question 17 Multiple Choice (Single Answer)

Command to find how long a user is logged in ?

  1. network
  2. finger
  3. nstat
  4. nw
Question 18 Multiple Choice (Single Answer)

Command to check connections with a remote host

  1. show
  2. iproute
  3. ping
  4. table
Question 19 Multiple Choice (Single Answer)

Command to view the beginning of multiple files ?

  1. top|more
  2. begin|more
  3. head|multiple
  4. head|more
Question 20 Multiple Choice (Single Answer)

The numeric permission "400" stands for?

  1. read by anybody
  2. read by other
  3. read by owner
  4. read by group