1. The 'logout' built in command is used to:
a) shutdown the computer
b) logoff of the computer
c) logout the current user
d) to exit the current shell

d) to exit the current shell

2. The command 'umask -S'
a) prints the current mask using symbolic notation
b) prints the current mask using octal numbers
c) sets the mask to 000
d) sets the mask to 777

a) prints the current mask using symbolic notation

3. The 'mapfile' command:
a) reads lines of standard input and assigns each to the element of an indexed array
b) reads lines of standard output file
c) reads lines of standard error file
d) none of the mentioned

a) reads lines of standard input and assigns each to the element of an indexed array

4. Which option of the kill command sends the given signal name to the specified process?
a) -l
b) -n
c) -s
d) -a

c) -s

5. Which command removes a directory from directory stack?
a) dirs
b) popd
c) pushd
d) rm

b) popd

6. Which command puts a script to sleep untill a signal is recieved?
a) sleep
b) suspend
c) disown
d) break

b) suspend

7. The command 'ulimit'
a) set a limit on specified resource for system users
b) set/show process resource limit
c) both (a) and (b)
d) none of the mentioned

c) both (a) and (b)

8. Which command identifies the resource of a command?
a) type
b) typeset
c) select
d) source

a) type

9. Which command wait for the specified process to complete and return the exit status?
a) sleep
b) wait
c) delay
d) stop

b) wait

10. Which command prints the accumulated user and system times for processes run from the shell?
a) time
b) times
c) both (a) and (b)
d) none of the mentioned

b) times

Download Interview PDF

11. Which command terminates a running process by name of the process?
a) kill
b) pkill
c) killall
d) none of the mentioned

c) killall

12. 'stty tostop' command will:
a) stop all jobs running in the shell
b) stop background jobs if they try to send output to the terminal
c) this is not a valid command
d) none of the mentioned

b) stop background jobs if they try to send output to the terminal

13. 'kill %s' command will:
a) terminate the job whose command line starts with s
b) terminate the last job
c) terminate the first job
d) none of the mentioned

a) terminate the job whose command line starts with s

14. Which command brings a background job into the foreground?
a) fg
b) bg
c) jobs %1
d) none of the mentioned

a) fg
Explanation:
bg command brings a foreground job into the background.

15. Ctrl-Z key combination:
a) generates a SIGINT signal
b) stops the process running in the shell
c) kills the process running in the shell
d) both (a) and (c)

b) stops the process running in the shell
Explanation:
Ctrl-Z key combination generates a SIGTSTP signal and stops the process running in the shell.

16. What is job number?
a) same as PID
b) a unique number, assigned to each job in shell
c) both (a) and (b)
d) none of the mentioned

b) a unique number, assigned to each job in shell

17. Which command allows to view the current jobs being handled by the shell?
a) jobs
b) view
c) show
d) none of the mentioned

a) jobs

18. Which one of the following is not correct about job control in bash shell?
a) it is the ability to stop and resume any process running in shell at a later point
b) user employs this facility via an interactive interface supplied by the kernel's terminal driver and bash
c) it is the ability to create any process
d) none of the mentioned

a) it is the ability to stop and resume any process running in shell at a later point

19. Which command is used to re-execute the previous command?
a) !!
b) !cat
c) !3
d) !$

a) !!
Explanation:'!cat' will re-execute the last cat command, '!3′ will re-execute the third last command and '!$' will execute the last argument of previous command.

20. Fc stands for
a) find command
b) fix command
c) both (a) and (b)
d) none of the mentioned

c) both (a) and (b)
Explanation:'fc -l' is used to list history of commands and 'fc -e' to edit them and 'history' command also provides the histroy of commands.

21. Which option of the command 'cd' use the actual filesystem path for cd.. and the value of pwd?
a) -l
b) -L
c) -p
d) -P

d) -P

22. Which command generates possible completions for string according to the and write it to standard output?
a) compgen
b) complete
c) continue
d) none of the mentioned

a) compgen

23. Which command executes 'command' in place of the current process instead of creating a new process?
a) exec
b) command
c) trap
d) none of the mentioned

a) exec

24. 5. After running this program, as you press 's', what will be the output of the program?
#!/bin/bash
echo "press 's' to print interviewquestionsanswers"
read var
if $var=s
then
echo "interviewquestionsanswers"
else
echo "You did not press s"
fi
exit 0
a) interviewquestionsanswers
b) You did not press s
c) program will generate an error message
d) none of the mentioned

c) program will generate an error message

25. After running this program, as your press 4, what will be the output of the program?
#!/bin/bash
echo "How many times you want to print 'globalguideline'"
read value
for ((i=0;i<$value;i++))
do
echo "globalguideline";
done
exit 0
a) 'globalguideline' will print 4 times
b) 'globalguideline' will print 3 times
c) 'globalguideline' will print 5 times
d) program will generate an error message

a) 'globalguideline' will print 4 times

Download Interview PDF

26. What is the output of this program?
#!/bin/bash
for i in 2 3 7
do
echo "ggl"
done
exit 0
a) 'ggl' will print 3 times
b) nothing will print
c) program will generate an error message
d) none of the mentioned

a) 'ggl' will print 3 times

27. How can you come out of the loop in this program?
#!/bin/bash
read x
while [ $x != "hello" ]
do
echo "Try to come out of the loop"
read x
done
echo "Welcome"
exit 0
a) by entering "hello"
b) by entering anything except "hello"
c) it is not possible
d) none of the mentioned

a) by entering "hello"

28. What is the output of this program?
#!/bin/bash
echo "Which file do you want to check"
read x
until [ -e $x ]
do
echo "The file does not exist. Do you want to create? y/n"
read a
if [ $a = y ]; then
touch $x
echo "Your file has been created successfully."
fi
done
echo "The file is present in this directory"
exit 0

a) it checks the existance of your entered file in the present working directory
b) it creates the file if file does not exists
c) program runs untill you create the file
d) all of the mentioned

d) all of the mentioned

29. After running this program, if you enter 1000, then what will be the output of the program?
#!/bin/bash
echo "Please enter a number"
read a
if [ $a -lt 100 ]; then
echo "It is less than 100";
elif [ $a -lt 1000 ]; then
echo "It is less than 1000"
else
echo "It is greater than 1000"
fi
exit 0
a) It is greater than 1000
b) It is less then 1000
c) It is equal to 1000
d) none of then mentioned

a) It is greater than 1000

30. Which command runs the shell built-in command 'command' with the given argument?
a) builtin
b) caller
c) there is no command present for this purpose
d) none of the mentioned

a) builtin

31. The command 'hash':
a) manages a internal hash table
b) find and remember the full path name of the specified command
c) displays used command names and the number of hits
d) all of the mentioned

d) all of the mentioned

32. Which command concatenate the specified argument into a single command, then execute the command?
a) fc
b) eval
c) exec
d) getopts

b) eval

33. Which command can create environment variable?
a) export
b) set
c) read
d) none of the mentioned

a) export

34. The command 'enable -n ':
a) enables the specified built-in command
b) disables the specified built-in command
c) print the status of the command
d) none of the mentioned

b) disables the specified built-in command

35. The command 'disown -r':
a) removes all jobs
b) removes all running jobs
c) marks jobs to not receive SIGNUP when bash exits
d) marks all jobs

b) removes all running jobs

36. Which command prints the directory stack?
a) cd
b) dirs
c) popd
d) pushd

b) dirs

37. Which statement resumes the next iteration of a for, while, select, or until loop?
a) continue
b) break
c) complete
d) command

a) continue

38. The command 'compgen -c' shows:
a) all variable names
b) all system wide aliases
c) full list of all commands
d) none of the mentioned

c) full list of all commands

39. What is the function of bind command in bash shell?
a) defining new macros
b) defining new key bindings for existing commands
c) dumping the installed key bindings
d) all of the mentioned

d) all of the mentioned

40. Which command sets up shorthand for command or command line?
a) set
b) alias
c) new
d) echo

b) alias

Download Interview PDF

41. What is the output of this program?
#!/bin/bash
a=1; b=2; c=3
d=$(( ++a**b*c++ + a ))
echo $d
exit 0

a) 14
b) 12
c) program will generate an error message
d) none of the mentioned

a) 14
The operators in decreasing order of precedence are ++, **, *, +.

42. What is the output of this program?
#!/bin/bash
a=10
b=$(( $a<0&&$a<100 ))
echo $b
exit 0
a) 10
b) 0
c) 1

b) 0
The condition '$a<0' is false so logical and operator provides the output 0.

43. What is the output of this program?
#!/bin/bash
a=10
b=$(( $a<0?10:$a<100 ))
echo $b
exit 0
a) 10
b) 20
c) 1
d) 0

c) 1
Firstly the '$a<0' condition has been checked. Because it is false hence the right hand side condition of the colon (:) has been checked and this is true so program output is 1.

44. What is the output of this program?
#!/bin/bash
a=10; b=20
c=$((++a))
let a=c+a
echo $a
exit 0
a) 21
b) 22
c) program will generate an error message
d) none of the above

b) 22

45. What is the output of this program?
If:
1) #!/bin/bash
2) a=2
3) b=4
4) let c=a**b
5) echo $c
6) exit 0

Options:
a) 8
b) 16
c) 32
d) none of the mentioned

b) 16

Explanation:
'**' is the exponentation operator in bash shell.
Output:
root@ubuntu:/home/google#./test.sh
16
root@ubuntu:/home/google#

46. Which one of the following is not a valid operator in bash shell?
a) ||
b) ~
c) =<<
d) -=

c) =<<

47. Which one of the following is bit-wise 'exclusive or' operator?
a) ^=
b) |=
c) !=
d) none of the mentioned

a) ^=

48. If a and b are 2 variables then the meaning of a<<=b is:
a) b = a << b
b) a = a << b
c) b = b << a
d) a = a << b

b) a = a << b

49. Which expression use the value of the enclosed arithmetic expression?
a) $(())
b) $()
c) ${}
d) $[]

a) $(())

50. Which built-in command performs integer arithmetic in bash shell?
a) let
b) get
c) set
d) none of the mentioned

a) let