Important Basic Arithmetic Interview Questions
Q – 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
Ans- d) to exit the current shell
Q – 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
Ans- a) prints the current mask using symbolic notation
Q – 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
Ans- a) reads lines of standard input and assigns each to the element of an indexed array
Q – 4 Which option of the kill command sends the given signal name to the specified process?
a) -l
b) -n
c) -s
d) -a
Ans- c) -s
Q – 5 Which command removes a directory from directory stack?
a) dirs
b) popd
c) pushd
d) rm
Ans- b) popd
Q – 6 Which command puts a script to sleep untill a signal is recieved?
a) sleep
b) suspend
c) disown
d) break
Ans- b) suspend
Q – 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
Ans- c) both (a) and (b)
Q – 8 Which command identifies the resource of a command?
a) type
b) typeset
c) select
d) source
Ans- a) type
Q – 9 Which command wait for the specified process to complete and return the exit status?
a) sleep
b) wait
c) delay
d) stop
Ans- b) wait
Q – 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
Ans- b) times
Q – 11 Which command terminates a running process by name of the process?
a) kill
b) pkill
c) killall
d) none of the mentioned
Ans- c) killall
Q – 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
Ans- b) stop background jobs if they try to send output to the terminal
Q – 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
Ans- a) terminate the job whose command line starts with s
Q – 14 Which command brings a background job into the foreground?
a) fg
b) bg
c) jobs %1
d) none of the mentioned
Ans- a) fg
Q – 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)
Ans- b) stops the process running in the shell
Q – 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
Ans- b) a unique number, assigned to each job in shell
Q – 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
Ans- a) jobs
Q – 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
Ans- a) it is the ability to stop and resume any process running in shell at a later point
Q – 19 Which command is used to re-execute the previous command?
a) !!
b) !cat
c) !3
d) !$
Ans- a) !!
Q – 20 Fc stands for
a) find command
b) fix command
c) both (a) and (b)
d) none of the mentioned
Ans- c) both (a) and (b)
Q – 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
Ans- d) -P
Q – 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
Ans- a) compgen
Q – 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
Ans- a) exec
Q – 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
Ans- c) program will generate an error message
Q – 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
Ans- a) ‘globalguideline’ will print 4 times
Q – 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
Ans- a) ‘ggl’ will print 3 times
Q – 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
Ans- a) by entering “hello”
Q – 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
Ans- d) all of the mentioned
Q – 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
Ans- a) It is greater than 1000
Q – 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
Ans- a) builtin
Q – 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
Ans- d) all of the mentioned
Q – 32 Which command concatenate the specified argument into a single command, then execute the command?
a) fc
b) eval
c) exec
d) getopts
Ans- b) eval
Q – 33 Which command can create environment variable?
a) export
b) set
c) read
d) none of the mentioned
Ans- a) export
Q – 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
Ans- b) disables the specified built-in command
Q – 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
Ans- b) removes all running jobs
Q – 36 Which command prints the directory stack?
a) cd
b) dirs
c) popd
d) pushd
Ans- b) dirs
Q – 37 Which statement resumes the next iteration of a for, while, select, or until loop?
a) continue
b) break
c) complete
d) command
Ans- a) continue
Q – 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
Ans- c) full list of all commands
Q – 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
Ans- d) all of the mentioned
Q – 40 Which command sets up shorthand for command or command line?
a) set
b) alias
c) new
d) echo
Ans- b) alias
Q – 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
Ans- a) 14
The operators in decreasing order of precedence are ++, **, *, +.
Q – 42 What is the output of this program?
#!/bin/bash
a=10
b=$(( $a<0&&$a echo $b
exit 0
a) 10
b) 0
c) 1
Ans- b) 0
The condition ‘$a<0’ is false so logical and operator provides the output 0.
Q – 43 What is the output of this program?
#!/bin/bash
a=10
b=$(( $a<0?10:$a echo $b
exit 0
a) 10
b) 20
c) 1
d) 0
Ans- c) 1
Q – 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
Ans- b) 22
Q – 45 What is the output of this program?
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
Ans- b) 16
Q – 46Â Which built-in command performs integer arithmetic in bash shell?
a) let
b) get
c) set
d) none of the mentioned
Ans- a) let