1) The User interacts with the Unix system or applications using _____ a) Hardware b) Shell c) Device drivers d) Compiler Answer: b) Shell 2) Select the features of an Unix Shell a) Unix Shell is a command interpreter b) Unix shell scripts can help in automation c) Like any programming languages, Unix shell supports variables, conditional statements, functions, array etc. d) All of the above Answer: d) All of the above 3) Will the following script produce errors? #!/bin/ksh until=1 while [$until=1] do echo "skfsi" done a) Yes b) No Answer: a) Yes They have error coz script shld be while [ $until=1 ] i.e with spaces near the bracket 4) Which of the following is valid syntax for UNIX commands? a) Command name followed by arguments b) Command name followed by options c) Command name, followed by options, followed by arguments d) all of the above Answer: d) all of the above 5) Which of the following command is used to select first 5 lines from a file? a) head o5 filename b) head +5 filename c) head 5 filename d) head -5 filename Answer: d) head -5 filename 6) What will be the output of the following shell scripts snippet? (Here - represents assignment operator) #!/bin/bash n-"Test" echo $n "$n"1 $n1 a) Test n1 1 b) Test $n1 n1 c) Test Test1 d) Test Test1 Test1 Answer: c) Test Test1 7) Which of the commands provides information on UNIX documentation? a) man b) whatis c) apropos d) All of the above Answer: d) man 8) The User executes the following commands: $ export VAR1=Wipro $ echo $VAR1 Wipro $ /bin/bash $ echo $VAR1 xxxxx $ export VAR1=India $ exit $ echo $VAR1 yyyyy In the above, what would be printed in place of xxxxx and yyyyy? a) NULL, Wipro b) Wipro, India c) Wipro, Wipro d) Wipro, NULL Answer: Wipro, Wipro 9) Which of the following shell variables is used to set the secondary prompt? Note: Seondary prompt is also known as Continuation Interactive prompt a) $PROMPT b) $PS2 c) $INS d) $HOME Answer: b) $PS2 10) What will be the output of the following shell script snippet? (Here = represents assignemnt Operator) n="Test" echo $n "$n"1 '$n'1 a) Test Test1 $n1 b) Test $n1 n1 c) Test n1 1 d) Test Test1 Test1 Answer: a) Test Test1 $n1 11) Which of the following is true about environment variables? a) Environment variables can be set and must be exported to be available globally b) They can be listed using the printerv command c) An environment variable defined in child shell will not be available in the parent shell d) All of the above Answer: All of the above 12) The exit status of the typical Unix command will usually have a value of ? a) 0 if successful and non-zero on failure b) Non zero if successful and 0 on failure c) 1 if successful and -1 on failure d) -1 if successful and 1 on failure Answer: a) 0 if successful and Non-zero on failure 13) Consider the following shell program if [ $# -eq 0 ] then echo "Usage: give multiple integers" exit 1 fi output=0 Until [ $# -eq 0 ] do output='expr $output + $1' shift done echo $output What will be the output of the above program when inputs are given as: program 16 23 44 70 0 50 a) 16 b) 50 c) 203 Answer: c) 203 (Addition of all the arguments) 14) What is the command used to allow the members of your working group to write to Wipro.file without impacting the permissions of non-group users? a) chmod +w Wipro.file b) chmod u+x Wipro.file c) chmod g|w Wipro.file d) chmod g+w Wipro.file Answer: d) chmod g+w Wipro.file 15) The Current directory is /home/user1/mydir. if the following commands are executed on the shell, what will be the output? pwd=`pwd` cd .. echo `pwd` $pwd a) /home/user1 /home/user1/mydir b) /home/user1/mydir /home/user1/mydir c) pwd /home/user1 d) /home/user1/mydir /home/user1 Answer: a) /home/user1 /home/user1/mydir 16) What is the output of command "cd/" in Unix a) It will change to user directory b) It will change to root directory c) It will change to device directory d) It will change to etc directory Answer: b) It will change to root directory 17) What is the output of following command basename /usr/bin/wipro/wipro.txt a) /usr/bin/wipro b) /usr/ c) wipro.txt d) None of the above Answer: c) wipro.txt 18) The exit status of the last command executed is referred by the shell variable a) $! b) $" c) $& d) $? Answer: d) $? 19) Command used to list all the shell variables a) act b) disp c) print d) none of the above Answer: a) act 20) What kill$! will do? kill the last processed nbr 21) chown command is used for? 22) Foo${newvar} BAR - What is the output if newvar=wipro 23) What command is used to read the content of the file? a) cat b) fetch c) both d) display 24) Filename ends with $$ represents? 6) How the path will be specified in environment file? a) look b) manpath c) Path d) dir Answer: ? -- getting lot of question on the above. http://www.grymoire.com/Unix/Permissions.html -------------- Ashmita: 1) Asuming the command line arguments to be first second third, what would be the output of the following script #!/bin/ksh while [ $# -gt 0 ] do last="$@" shift done echo $last a)  ,first second third b) first second c) first d) third Answer: d) third 2) what will be the output of the following script snippet? (( 6>9 )) echo "$?" a) 0 b) 1 c) 127 d) Error Answer: b) 1 3) All Unix command invoked by user are interpreted by a) Hardware b) Shell c) Device Drivers d) Compiler Answer: b) Shell 4) $# is a built-in shell variable that holds a) exit status of the last command executed b) number of command line args c) name of the shell script d) None of the above Answer: b) number of command line args 5) What value does $# have?. if the shell script called "testscript" is executed as $ ./testscript arg1 arg2 a) testscript  arg1  arg2 2) arg1 arg2 c) 2 d) 3 Answer: c) 2 6) What will be the statement to print only the 7th line from a file using head and tail commands a) head -7 |tail -7 filename b) tail -7 filename c) head -7 filename|tail -1 Answer: head -7 filename|tail -1 1) cat file1 file2 - displays content of both file1 and file2 2) df command - Disk Free 3) du command - shows the disk usage of the files and directories 4) KILL$!: answer covered above 5) $! 6) $# - aruguments one two three "four and five". How many no of arguments . Answer: 4 7) foo(((5+3*2) - 4)+1). What is $#? 8) Case Syntax 9) x=c; y=c; echo $$x $$$y What is printed if the current PID is 1234 a) 1234x 1234y b) xc c) 1234x 1234c d) $x $$y Answer: 1234x 1234c 10) Which command is used to know if the process is running a) ps b) ls c) awk answer: ps 12) exp var= ( This is Unix Unix assessment ) $ echo ${myvar[3]} Answer: 13) echo `set r w x`; IFS="-"; echo "$*" a)rwx b)r w x c)r-w-x Answer: 14) Which options can be used in chmod a) + or - or = b) * c) d) 15) What will be the ouptput of the below program, echo "Process Killed" kill $$ echo "Process not killed" a) First echo will be printed b) second echo statement will be printed c) both the echo statement will be printed d) none of the above Answer: Both the echo statement will be printed 16) How to perform addition of numbers. parameters passed as 3 and 4 a) a = $3 + $4 b) a = 3 + 4 c) a = `expr $1 + $2` Answer: c) a = `expr $1 + $2` 17) Terminal command a) $PATH b) $TERM c) $TERMINAL d) $CMD Answer: $TERM ------------------------------------------------------------------------------------------------- 1) CHOWNER with * gives 2) echo 'set r w x: IFS='-'; echo "$*"' 3) $ Temp="wipro". If you need this variable to be assigned with the value, u will? ($ and then space) a) set --- something like this 4) Test command is used to compare a) Strings b) Numerics c) State of file d) All 5) unset is used as a) unset a=10 b) unset a c) unset var a d) unset $a Answer: d) unset $a unset is used to delete the variables during program execution 6) What will :$((cnt=cnt+1)) do? 7) If ls > /tmp/xx.$$ , then $$ takes a) pid b) No. of arguement c) Login d) Name Answer: pid -------------------------------------- Variable Description $0 The filename of the current script. $n These variables correspond to the arguments with which a script was invoked. Here n is a positive decimal number corresponding to the position of an argument (the first argument is $1, the second argument is $2, and so on). $# The number of arguments supplied to a script. $* All the arguments are double quoted. If a script receives two arguments, $* is equivalent to $1 $2. $@ All the arguments are individually double quoted. If a script receives two arguments, $@ is equivalent to $1 $2. $? The exit status of the last command executed. $$ The process number of the current shell. For shell scripts, this is the process ID under which they are executing. $! The process number of the last background command. ----------------------------------- List of Commands cat - display or concatenate files cd - change directory chmod - change the permissions on a file or directory cp - copy a file date - display the current date and time diff - display differences between text files file - determine the type of a file find - find files of a specified name or type ftp - file transfer program grep - searches files for a specified string or expression gzip - compress a file help - display information about bash builtin commands info - read online documentation kill - kill a process lpr - print out a file ls - list names of files in a directory man - display an on-line manual page mkdir - make a directory more - scan through a text file page by page mv - move or rename files or directories nice - change the priority at which a job is being run passwd - change your password ps - list processes pwd - display the name of your current directory quota - disk quota and usage rm - remove files or directories rmdir - remove a directory sort - sort and collate lines ssh - secure remote access tar - create and use archives of files apropos - Locate commands by keyword lookup du - Disk Usage df - Disk Free ------------------------------- Environment Variables: Variable Description DISPLAY - Contains the identifier for the display that X11 programs should use by default. HOME - Indicates the home directory of the current user: the default argument for the cd built-in command. IFS - Indicates the Internal Field Separator that is used by the parser for word splitting after expansion. LANG - LANG expands to the default system locale; LC_ALL can be used to override this. For example, if its value is pt_BR, then the language is set to (Brazilian) Portuguese and the locale to Brazil. LD_LIBRARY_PATH - On many Unix systems with a dynamic linker, contains a colon-separated list of directories that the dynamic linker should search for shared objects when building a process image after exec, before searching in any other directories. PATH - Indicates search path for commands. It is a colon-separated list of directories in which the shell looks for commands. PWD - Indicates the current working directory as set by the cd command. RANDOM - Generates a random integer between 0 and 32,767 each time it is referenced. SHLVL - Increments by one each time an instance of bash is started. This variable is useful for determining whether the built-in exit command ends the current session. TERM - Refers to the display type TZ - Refers to Time zone. It can take values like GMT, AST, etc. -----------------------------