Linux OS Shell Interview Questions And Answers
Download Linux Shell Interview Questions and Answers PDF
Prepare comprehensively for your Linux Shell interview with our extensive list of 53 questions. These questions will test your expertise and readiness for any Linux Shell interview scenario. Ideal for candidates of all levels, this collection is a must-have for your study plan. Download the free PDF now to get all 53 questions and ensure you're well-prepared for your Linux Shell interview. This resource is perfect for in-depth preparation and boosting your confidence.
53 Linux Shell Questions and Answers:
Linux Shell Job Interview Questions Table of Contents:
1 :: The statement z = 'expr 5 / 2′ would store which of the following values in z?
a) 0
b) 1
c) 2
d) 2.5
e) 3
c) 2
Read More2 :: What is the output of the following program?
[ -n $HOME ]
echo $?
[ -z $HOME ]
echo $?
a) 0
1
b) 1
0
c) 0
0
d) 1
1
a) 0
1
Read More1
3 :: 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
a) 1
b) 3
c) 5
d) Error
b) 3
Read More5 :: What is the output of the following program?
b =
[ -n $b ]
echo $?
[ -z $b ]
echo $?
a) 1
1
b) 2
2
c) 0
0
d) 0
1
c) 0
0
Read More0
6 :: What is the output of the following code:
os=Unix
echo 1.$os 2."$os" 3.'$os' 4.$os
a) 1.Unix 2.Unix 3.Unix 4.Unix
b) 1.Unix 2.Unix 3.$os 4.Unix
c) 1.Unix 2.Unix 3.Unix 4.$os
d) 1.Unix 2.$os 3.$os 4.$os
b) 1.Unix 2.Unix 3.$os 4.Unix
Read More7 :: Create a new file "new.txt" that is a concatenation of "file1.txt" and "file2.txt"?
a) cp file.txt file2.txt new.txt
b) cat file1.txt file2.txt > new.txt
c) mv file[12].txt new.txt
d) ls file1.txt file2.txt | new.txt
b) cat file1.txt file2.txt > new.txt
Read More8 :: What will be output of following command:
$ echo "The process id is" $$$$
a) The process id is $$
b) The process id is $<pid>$<pid>
c) The process id is <pid><pid>
d) The process id is $$$$
c) The process id is <pid><pid>
Read More9 :: What is the return value ($?) of this code:
os = Unix
[$osName = UnixName] && exit 2
[${os}Name = UnixName] && exit 3
a) 0
b) 1
c) 2
d) 3
d) 3
Read More10 :: Which of these is not a valid variable in bash:
a) __ (double underscore)
b) _1var (underscore 1 var )
c) _var_ (underscore var underscore)
d) some-var (some hyphen var)
d) some-var (some hyphen var)
Read More11 :: How do you print the lines between 5 and 10, both inclusive?
a) cat filename | head | tail -6
b) cat filename | head | tail -5
c) cat filename | tail +5 | head
d) cat filename | tail -5 | head -10
a) cat filename | head | tail -6
Read More12 :: 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
a) /home/user1/proj
b) /home/user1/proj/src
c) /home/user1
d) /home/user1/proj/src/generic
d) /home/user1/proj/src/generic
Read More13 :: Tell me which of the following commands allows definition and assignment of environment variables under bash:
a) env
b) export
c) environ
d) setenviron
a) env
Read More14 :: How to feed standard output of one command to standard input of another in a single shell session?
a) IO redirection can be used
b) Named pipes can be used
c) The pipe operator provided by the shell can be used
d) It can not be done
c) The pipe operator provided by the shell can be used
Read More15 :: The redirection 2> abc implies:
a) Write file 2 to file abc
b) Write standard output to abc
c) Write standard error to abc
d) none of the mentioned
c) Write standard error to abc
Read More16 :: cmd > abc 2>&1 will:
a) Write file2 to file1
b) Write standard output and standard error to abc
c) Write standard error to abc
d) Write standard output to abc & standard error to monitor
b) Write standard output and standard error to abc
Read More17 :: cmd 2>&1 > abc will:
a) Write file2 to file1
b) Write standard output and standard error to abc
c) Write standard error to abc
d) Write standard output to abc & standard error to monitor
d) Write standard output to abc & standard error to monitor
Read More18 :: 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
a) cat: file1: No such file or directory hello
b) No output is displayed
c) Cat: 1>2: No such file or directory
d) hello
b) No output is displayed
Read More19 :: From where would the read statement read if the following statements were executed?
exec < file1
exec < file2
exec < file3
read line
a) It would read all the files
b) It would not read any files
c) It would read all the files in reverse order
d) It would read only file3
b) It would not read any files
Read More20 :: Which of these is the correct method for appending "foo" in /tmp/bar file?
a) echo foo > /tmp/bar
b) echo foo >> /tmp/bar
c) echo foo | /tmp/var
d) /tmp/bar < echo foo
b) echo foo >> /tmp/bar
Read More21 :: cat < file1 >> file2 | file3:
a) file1 content will be appended to file2 and finally stored in file3
b) file1 content will be appended to file2 and file3 will be ignored
c) file2 and file3 will have same content
d) syntax error
d) syntax error
Read More22 :: Executing cat /etc/password > /dev/sda as superuser will:
a) Write data into a regular file called /dev/sda
b) Write data to the physical device sda
c) Create a temporary file /dev/sda and write data to it
d) None of the above
b) Write data to the physical device sda
Read More23 :: Which variable is used to display number of arguments specified in command line:
a) $0
b) $#
c) $*
d) $?
b) $#
Read More25 :: Syntax to suppress the display of command error to monitor?
a) command > &2
b) command 2> &1
c) command 2> &2
d) command 2> /dev/null
d) command 2> /dev/null
Read More