1. The statement z = ‘expr 5 / 2′ would store
which of the following values in z?
Correct : C. 2
2. The expression expr -9 % 2 evaluates to:
Correct : C. -1
3. What is the output of the following program?b =
[ -n $b ]
echo $? [ -z $b ]
echo $?
Correct : C. 0 0
4. What is the output of the following program? [ -n $HOME ]
echo $?
[ -z $HOME ]
echo $?
Correct : A. 0 1
5. What is the output of the following program? x = 3; y = 5; z = 10;
if [( $x -eq 3 ) -a ( $y -eq 5 -o $z -eq 10 )] then
echo $x else
echo $y
fi
Correct : B. 3
6. What is the return value ($?) of this code:os = Unix
[$osName = UnixName] && exit 2 [${os}Name = UnixName] && exit 3
Correct : D. 3
7. What is the output of the following code: s=Unix
echo 1.$os 2."$os" 3.'$os' 4.$os
Correct : B. 1.unix 2.unix 3.$os 4.unix
8. which of these is NOT a valid variable in bash
Correct : D. some-var (some hyphen var)
9. What will be output of following command:$ echo "The process id is" $$$$
Correct : C. the process id is
<pid><pid>
10. What would be the current working directory at the end of the following command sequence? $ pwd
/home/user1/proj
$ cd src
$ cd generic
$ cd .
$ pwd
Correct : D. /home/user1/proj
/src/generic
11. How do you print the lines between 5 and 10, both inclusive
Correct : A. cat filename | head | tail 6
12. Create a new file “new.txt” that is a concatenation of “file1.txt” and “file2.txt”
Correct : B. cat file1.txt file2.txt
> new.txt
13. If a file with execute permissions set, but with unknown file format is executed
Correct : C. the current shell will try to execute it
14. Which of the following is true?
Correct : C. shell is a wrapper for all the commands and utilities
15. Which is true with regards to the shell prompt
Correct : C. the prompt can be customized (modified)
16. What is a shell in UNIX?
Correct : A. a program through which users can issue commands to unix
17. Which of the following represents an absolute path?
Correct : D. /usr/bin/cat
18. The user bhojas logged in and performed the following sequence of command. What will be the output of the last command? $ cd project/module1
$ pwd
Correct : A. /home/bhojas/project/m odule1
19. BASH shell stands for?
Correct : A. bourne-again shell
20. Which of the following files will not be displayed by the command cat re* ?
Correct : C. receipt
21. The redirection 2> abc implies
Correct : C. write standard error to abc
22. cmd 2>&1 > abc will
Correct : D. write standard output to abc & standard error to monitor
23. cmd > abc 2>&1 will
Correct : B. write standard output and standard error to abc
24. Which of these is the correct method for appending “foo” in /tmp/bar file?
Correct : B. echo foo >>
/tmp/bar
25. Syntax to suppress the display of command error to monitor?
Correct : D. command 2>
/dev/null
26. The following commands gives the output like this #cat file1 file2
#cat: file1: No such file or directory hello
If we execute the command “cat file1 file2 1>2 2>&1” the output would be
Correct : B. no output is displayed
27. cat < file1 >> file2 | file3
Correct : D. syntax error
28. Executing cat /etc/password > /dev/sda as superuser will
Correct : B. write data to the physical device sda
29. rom where would the read statement read if the following statements were executed? exec < file1 exec < file2 exec < file3 read line