Linux OS Shell Interview Preparation Guide

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 youre well-prepared for your Linux Shell interview. This resource is perfect for in-depth preparation and boosting your confidence.
Tweet Share WhatsApp

53 Linux Shell Questions and Answers:

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
Download PDFRead All Linux Shell Questions

2 :: 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

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

4 :: The expression expr -9 % 2 evaluates to:
a) 0
b) 1
c) -1
d) 2

c) -1

5 :: 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
Download PDFRead All Linux Shell Questions

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

7 :: 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

8 :: 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>

9 :: 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

10 :: 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)
Download PDFRead All Linux Shell Questions