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.
Questions
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
- r 143
- fc -e -r p
- fc -e 143
- r -8
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?
- checks prime number; returns one when not prime and zero when prime
- checks prime number; returns none when not prime and zero when prime
- checks prime number; returns zero when not prime and one when prime
- checks prime number; returns zero when not prime and none when prime
"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"
- r 143
- fc -e -r p
- fc -e 143
- r -8
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?
- #On the beach at night, stands a child with her father
- #On #the #at #a #with #her
- #beac #nigh #stan #chil #fath
- #beach #night, #stands #child #father
Which of the following command sets the previously undefined variable x to 40?
- typset x=32+8
- set x=32+8
- let x=32+8
- x=32+8
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
- checks prime number; returns one when not prime and zero when prime
- checks prime number; returns none when not prime and zero when prime
- checks prime number; returns zero when not prime and one when prime
- checks prime number; returns zero when not prime and none when prime
Which one of the following command shows the last 50 commands the user has entered.
- fc -l 50
- fc -l -50
- history 50
- history $$
Which one of the following is the syntax for a pattern that matches the null string or a filename beginning with a or A
- ?([A-a].*)
- ?([aA]*)
- ?([aA].*)
- ?([aA]$)
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.
- set -t
- set -m
- set -f
- set -l
#! /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.
- 2450
- 1275
- 1225
- 2550
Crown margin mode can be done using which command?
- nroff
- mm
- tbl
- fmt
Which key allows to append the script in next line
- back slash
- Single quote
- full stop (dot)
- frontslash
Command to set the default file permssions of a user
- default
- set
- umask
- mask
What is the default configuration for regular files?
- --xr--r--
- rw-r--r--
- r--r--r--
- rwxr--r--
Command that is used to find text matches from a file?
- find
- match
- grep
- use
Command to find out what kind of a Unix system you are on ?
- ipaddress
- uname
- ip
- sysip
Command to find how long a user is logged in ?
- network
- finger
- nstat
- nw
Command to check connections with a remote host
- show
- iproute
- ping
- table
Command to view the beginning of multiple files ?
- top|more
- begin|more
- head|multiple
- head|more
The numeric permission "400" stands for?
- read by anybody
- read by other
- read by owner
- read by group