UNIX Multiple Choice Questions – Shell
1. In Bourne shell, you have to EXPORT the declared environmental variables.
A. True
B. False
2. What does “../..” stand for ?
A. Current directory
B. Up one directory
C. Up two directories
D. None of Above
3. What does cd/ mean in UNIX?
A. Current directory
B. Root directory
C. Up one directory
D. None of the above
4. Which variable gives the exit status of the last command executed in the shell?
A. $*
B. $!
C. $?
D. $@
5. How will you assign the value of variable var2 to var1?
A. Var1=var2
B. $var1=$var2
C. Var1=$var2
D. $var1=var2
6. In UNIX, it is possible for more than one file descriptor to point to same file.
A. True
B. False
7. Which of these is true about assign a null value to the variable in bash?
A. A=””
B. A=
C. A=”
D. All of above
8. Command to change owner of the file in UNIX.
A. Chowner
B. Chown
C. Both
D. None
9. How many prompts are available in a UNIX system?
A. One
B. Two
C. Three
D. Zero
10. What is the purpose of the shell?
A. The shell keeps the end users from accessing the kernel for security reasons.
B. The shell protects the kernel from the shortcomings of the user.
C. The shell allows the user to do things that the kernel could not accommodate.
D. All of above
11. What is the command to find the differences in the lines containing “2011” between the files a1.txt and a2.txt
A. Grep 2011 | diff a1.txt a2.txt
B. Diff a1.txt a2.txt
C. Diff a1.txt a2.txt | grep 2011
D. None of above
12. What is the command to display environment variables?
A. DISPLAY ENV
B. PRINT ENV
C. DISPENV
D. PRINTENV
13. Output of the following: $ v= ‘ls’ $ echo $v
A. List all files
B. Ls
C. Error
14. Which one is not the environment variable?
A. PATH
B. RANDOM
C. READ
D. DISPLAY
15. Which part of UNIX is responsible for sending basic instructions to the computer’s processor?
A. Kernel
B. Shell
C. Both
16.To copy two files in a new files ?
cat file1 file 2 > file 3
17.To sort the records from large to small number and print the largest number ?
Option with Desc limit 1
18.Grep tata.*services$//multiple answer question
which has tata –service –may contain anything like consultancy , conference etc..
19.To remove a folder which have files
1.rm –rf
2.rmdir –l
3.rmdiv
4.rmAns:
20.Grep –v java// multiple answer question
options which doesn’t contain the java word in the line is the answer
21.S=0 {s=s+$2}
Avg of second column
Sum of second column
22.Unix command to remove duplicates in line ?
1.sort –u
2.sort unique
3.uniq
4.unique
23.What is output of below commands.. ?
grep –o cat animal.txtgrep ‘cat’ animal.txt
1.cat cat
2.Cat Cat
3.None cat
4.none of these
24.File and directory permission access will be done by which command … ?
chmod
25.On update cascade ensures what .. ?
1.Data integrity
2.Normalization
3.Materialized
4.All
26.String ‘llp’ file case insensitive.. ?
1.Grep –i‘llp’ file.txt
2.Grep –wi‘llp’ file.txt
3.Grep –w ‘llp’ file.txt
27.Compress file in unix.. ?
1.Compress
2.Comp
3.Zip
4.gzip
28.Pattern match at beginning of file ?
1.Pat^
2.Pat$
3.$pat
4.^pat
29.Length of longest file .. ?
1.Wc -cl
2.Wc –L <filename>
30.Sort file1| uniq–u
1.Sort the file name file 1 and diplaysdistinct lines
2.Find unique lines and sort
3.Command has syntax error
4.Sort the file and display duplicate lines
31.Query to delete primary key constraints .. ?
Drop
32.To print first line from file1.txt use,
1.echo $1 file1.txt
2.awk ‘NR==1’ file1.txt
3.head -1 file1.txt
4.sed -n ‘1p’ file1.txt
33.What is output of below command
awk’BEGIN{s=0 while(s<55){print s; ++s}}’
1. prints 0 to 54 number
2. prints 0 to 55 number
3. syntax error.
4. infinite loop
34.To count only words from which command is used ?
1.wc filename
2.wc -w filename
3.wc -word filename
35.S=S+$2.. ?
1.avg of second column
2.sum of second column
3.None
36._____displays all environment variables
1.environ
2.env
3.HOME
4.HOM
37.in order to determinvalue of a variable use the command?
1.echo
2.cat
3.ls
4.set
38.What is unix?
1.an operating system
2.programming language
3.software
4.editor
39.What are three main components of the Unix Architecture
1.kernel,data,PC
2.pcb,utilities,shell
3.shell,kernel,shared memory
4.kernel,shell,utilities
40.When a process finished its execution and exit status not received by the parent, the process state becomes…
1.new
2.stopped
3.orphan
4.Zombie