Try to solve 4 Linux interview questions and Linux System Administrator interview questions below. Hints can help you find answers to questions you are having trouble with.

1. Cron

Scheduling
   
Easy  

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 the statements about the job definitions and schedules that are correct.

(Select all acceptable answers.)

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

Bash
   
Easy  

Select 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

(Select all acceptable answers.)

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

Bash
   
Hard  

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

(Select all acceptable answers.)

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

Bash Environmental variable
   
Hard  

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 the statements are correct.

(Select all acceptable answers.)

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

Linux Online Test (Easy / Hard)

Not exactly what you are looking for? Go to our For Jobseekers section.