Linux Interview Questions

Want to become an expert in cracking Linux interview questions/Linux system administrator interview questions?

Start with practicing the questions below. Whether a question involves multiple choice or live coding, we will give you hints as you go and tell you if your answers are correct or incorrect.

After that, take our timed public Linux Interview Questions Test.

To use our service for testing candidates, buy a pack of candidates.


1. Cron
Linux Scheduling Public New

The output of crontab -l contains the following job definitions:

MAILTO=candidate@testdome.org,admin@testdome.org
0 0,12 1 */4 * df -h /

@hourly du -h / >> /var/log/disk_usage

0 6 1-12 * * /usr/bin/testdome_candidates

Select all the statements about the job definitions and schedules that are correct.

Easy  
5min
The df command is executed at midday and midnight on the first day of every 4th month.
The df command is executed 12 times, each hour, between midday and midnight on the 1st of April.
The MAILTO variable tells cron to email the output of df -h / to candidate@testdome.org and admin@testdome.org.
Every hour of every day the current disk usage is appended to the /var/log/disk_usage log file.
The /usr/bin/testdome_candidates binary is executed at 6:00am every day.
   

2. Elif
Linux Bash Public New

Select all the statements about the output of the following script that are correct.

#!/bin/bash
value=$1
if [ $value -eq 100 ]
then
    echo "value is eq 100"
elif [ $value -gt 100 ]
then
    echo "value is gt 100"
else
    case $value in
    [1-3]*) echo "value is between 1 and 39 (inclusive)" ;;
    [4-5]*) echo "value is between 40 and 59 (inclusive)" ;;
    9[1-8]) echo "value is between 91 and 98 (inclusive)" ;;
    99) echo "value is $value" ;;
    *) echo "value is unknown" ;;
    esac
fi
Easy 
5min
If the first argument of the script is 35 then 'value is unknown' echoed.
If the first argument of the script is 90 then 'value is unknown' echoed.
If the first argument of the script is 91 then 'value is between 91 and 98 (inclusive)' echoed.
If the first argument of the script is 99 then 'value is $value' echoed.
If the first argument of the script is 100 then 'value is eq 100' echoed.
   

3. Tar
Linux Bash Public New

Select all the commands that, when executed, would decompress and unpack the file file.tar.gz.

Hard  
2min
tar -czf file.tar.gz
gzip -dc file.tar.gz | tar -x
gzip -dc file.tar.gz > tar -x
tar -xf > gzip -dc file.tar.gz
tar -xzf file.tar.gz
   

4. Environment
Linux Bash Environmental Variable Public New

The PATH variable is set in /etc/environment: 

PATH="/usr/local/sbin:/usr/local/bin:/usr/games:/usr/local/games"

And updated in .bash_profile:

export PATH=/usr/temp:$PATH:/usr/local/apps

Select all of the statements are correct.

Hard 
3min
/usr/local/bin will be searched before /usr/games.
/usr/local/apps will be searched before /usr/local/sbin/.
If both /usr/local/apps and /usr/local/bin contain a binary with the same name, the version in /usr/local/apps will be executed. 
If the current directory contains a binary with the same name as one in /usr/local/sbin the version in the current directory will be executed.
The which command can be used to find binaries at locations within the PATH.
/usr/temp will only be searched during login shells, and will not be searched during interactive non-login shells. 
   

If you feel ready, take one of our timed public Linux Interview Questions tests:
Not exactly what you are looking for? Go to our For Jobseekers section.