#! /usr/bin/perl
# This script is copyright to Ben Tasker and is licensed under the GNU GPL License.
# Please obtain a copy of the license from http://benscomputer.no-ip.org/GPL.txt
# You may freely use, modify and distribute this script so long as you give credit to the original
# author. If you make any modifications please append a comment to each of your lines with your name
# should you write a complete section then this section can be labelled as one.
# Thanks, enjoy using the script!
print "Welcome to the Benscomputer.no-ip.org Linux revision quiz \n";
print "\n \n Not all the resources are currently online, please feel free to use the quiz anyway \n";
print "\n Please Enter your name \n \n";
$name = <STDIN>;
print "\n Hello $name \n";
$X = 0;
$Y = 0;
@incorrect = ();
print "Your score is currently $X";
print "\n \n The first question is;" ;
print "\n \n Which of these is the correct command to delete a file? \n \n";
print "1) rm \n";
print "2) cp \n";
print "3) mv \n";
print "4) del \n \n";
$ans1 = <STDIN>;
$Y++;
print "\n";
if ($ans1 == 1) {
$X++;
$incorrect[1] = "Question 1: Correct!";
print "Correct, your score so far is $X \n";
} else {
$X--;
$incorrect[1] = "Question 1: Incorrect!";
print "Sorry, That is incorrect, your score so far is $X \n";
}
print "Please enter the command to change to /mnt/mp3/playlists \n";
$ans2 = <STDIN>;
$Y++;
$ans2a = "cd /mnt/mp3/playlists";
if ($ans2 eq $ans2a) {
$X++;
$incorrect[2] = "Question 2: Correct!";
print "Well done \n";
} else {
$X--;
$incorrect[2] = "Question 2: Incorrect!";
print "That is incorrect \n";
}
print "Your score so far is $X \n";
print "\n Question 3 \n";
print "Which command is most useful for investigating whether new hardware has been detected? \n \n";
print "1) cp \n";
print "2) dmesg \n";
print "3) mv \n";
print "4) echo \n";
print "5) export \n \n";
$ans3 = <STDIN>;
$Y++;
if ($ans3 == 2) {
$X++;
$incorrect[3] = "Question 3: Correct!";
print "Well done \n";
} else {
$X--;
$incorrect[3] = "Question 3: Incorrect!";
print "That is incorrect \n"
}
print "Your score so far is $X \n \n";
print "Which of the following is the correct command to start an apache init script? \n \n";
print "1) /etc/init.d/apache zap \n";
print "2) /etc/init/apache start \n";
print "3) /etc/init.d/apache start \n";
print "4) apache start \n \n";
$ans4 = <STDIN>;
$Y++;
if ($ans4 == 3) {
$X++;
$incorrect[4] = "Question 4: Correct!";
print "Well done \n";
} else {
$X--;
$incorrect[4] = "Question 4: Incorrect!";
print "That is incorrect \n"
}
$Z = $Y - $X;
print "Your score so far is $X which means you have got $Z questions wrong! \n \n";
print "Question 5: \n";
print "What is BASH? \n \n";
print "1) A party \n";
print "2) A rock \n";
print "3) A shell \n";
print "4) a command to copy \n \n";
$ans5 = <STDIN>;
$Y++;
if ($ans5 == 3) {
$X++;
$incorrect[5] = "Question 5: Correct!";
print "Well done \n";
} else {
$X--;
$incorrect[5] = "Question 5: Incorrect!";
print "That is incorrect \n"
}
print "\n \n Question 6";
print "\n \n What is Linux? \n \n";
print "1) An operating system \n";
print "2) An application \n";
print "3) Something only hippies like \n";
print "4) A kernel \n \n";
$ans6 = <STDIN>;
$Y++;
if ($ans6 == 4) {
$X++;
$incorrect[6] = "Question 6: Correct!";
print "Well done \n";
} else {
$X--;
$incorrect[6] = "Question 6: Incorrect!";
print "That is incorrect \n"
}
print "\n \n Question 7 \n \n";
print "Which command would you use to change the ownership of a file? \n \n";
print "1) chmod \n";
print "2) user \n";
print "3) su \n";
print "4) mkdir \n";
print "5) chown \n \n";
$ans7 = <STDIN>;
$Y++;
if ($ans7 == 5) {
$X++;
$incorrect[7] = "Question 7: Correct!";
print "Well done \n";
} else {
$X--;
$incorrect[7] = "Question 7: Incorrect!";
print "That is incorrect \n"
}
print "\n \n Question 8 \n \n";
print "Type in the command you would use to create /mnt/mp3/motorhead (assuming that /mnt/mp3 already exists \n \n";
$ans8 = <STDIN>;
$Y++;
if ($ans8 eq "mkdir /mnt/mp3/motorhead") {
$X++;
$incorrect[8] = "Question 8: Correct!";
print "Well done \n";
} else {
$X--;
$incorrect[8] = "Question 8: Incorrect!";
print "That is incorrect \n"
}
print "\n \n Question 9 (Almost there) \n \n";
print "Linus Torvalds created; \n \n";
print "1) MS Windows \n";
print "2) The FSF \n";
print "3) The GPL \n";
print "4) Linux \n";
print "5) OS/2 \n \n";
$ans9 = <STDIN>;
$Y++;
if ($ans9 == 4) {
$X++;
$incorrect[9] = "Question 9: Correct!";
print "Well done \n";
} else {
$X--;
$incorrect[9] = "Question 9: Incorrect!";
print "That is incorrect \n"
}
print "\n \n Question 10 \n \n";
print "Type in the command you would use to mount /mnt/mp3 (assuming an entry is present in /etc/fstab \n \n";
$ans10 = <STDIN>;
if ($ans10 eq "mount /mnt/mp3") {
$X++;
$incorrect[10] = "Question 10: Correct!";
print "Well done \n";
} else {
$X--;
$incorrect[10] = "Question 10: Incorrect!";
print "That is incorrect \n"
}

print "Your final score was $X \n";
print $incorrect[1];
print "\n $incorrect[2]";
print "\n $incorrect[3]";
print "\n $incorrect[4]";
print "\n $incorrect[5]";
print "\n $incorrect[6]";
print "\n $incorrect[7]";
print "\n $incorrect[8]";
print "\n $incorrect[9]";
print "\n $incorrect[10] \n \n";
if ($X == 10) {
print "Well done you";
} else {
if ($X > 7) {
print "Good, but perhaps you should re-read the materials";
} else {
if ($X > 5) {
print "You obviously have the basics, re-read and try again, don't give up!";
} else {
if ($X < 1) {
print "Try again!";
} else {
print "Perhaps a bit more practice";
}
}

}
}
print "\n";
