Practice exam

Exam practice

This is a practice run for next weeks final exam for the Linux server course.

The idea is to choose one of the old exams and i chose this one.

Lamp stack

We need to create 7 users with their own public_html with an index file. Here are the users. Jorma wants a own domain named this we will make with an hostfile and sites-available .conf. Maija is the new sudo admin and as the boss she wants to choose her own username what will be maija.
Jorma Mähkylä jmahk gieP1ugh6eu
Pekka Hurme phurm engooR1ocha
Ronaldo Smith rsmit IeyiexeeP2a
Håkan Petersson hpete iereiteeH7E
Einari Mikkonen emikk queej8EvahY
Einari Vähäkäähkä evaha quab9Xayei3
Eija Vähäkäähkä eijav moJ4zoogiem
Maija Virtanen maija AhB4Oo2nohy sudo

First we will edit the skeleton folder which is the base to all newly created users. We can add the public_html folder with the index.php file already inside in to the skeleton so all users get it automatically. The web page of each user needs to display to current user so we need to make some kind of script for that. Lets try getting it with php so first install LAMP stack. As we did in the last time.
So here are the commands in order with only tiny descriptions what they do.

Update fresh Linux, install and configure Apache

sudo apt update && sudo apt upgrade -y
sudo apt install apache2 -y
echo "Default"|sudo tee /var/www/html/index.html
sudo a2enmod userdir
sudo systemctl restart apache2
cd; mkdir public_html; cd public_html
echo 'User created Apache works!'> index.php

Lets create the first user to test Apache for normal users.

sudo adduser jmahk
cd; cd public_html; echo 'Php works if it says four > <?php print(2+2+"\n\n"); ?>'> index.php

Now we know it works so lets put that inside the skeleton and add in the index.php this part so it will show “Welcome” and the current user name.

echo   get_current_user();

Now we can create all the other users too with the “sudo adduser” command and remember to give Maija sudo privliges. With typing

sudo adduser maija sudo

Firewall and python script

Now we enable and configure firewall

sudo ufw allow 22/tcp && sudo ufw allow 80/tcp && sudo ufw allow 443/tcp
sudo ufw enable && sudo ufw status


print “Welcome back!”

Adding host name for jorma

 cd /etc/apache2/sites-available/
sudoedit jorma.conf
sudo a2ensite jorma.conf

Copy this inside jorma.conf

<VirtualHost *:80>
    DocumentRoot /home/jmahk/public_html/index.php

Then we activate the site and edit the hosts file.

 sudo a2ensite jorma.conf
 systemctl reload apache2
 cd /etc/ ; sudoedit hosts

and add this 2 lines


Kurssiguru-coding meta packet

I tried to do it with this guide but was unsuccessful it gave me an error
dh_installchangelogs: warning: debian/changelog(l2): found end of file where expected first heading
dh_installchangelogs: error: fatal error occurred while parsing debian/changelog
debian/rules:20: recipe for target ‘binary-indep’ failed
make: *** [binary-indep] Error 255
Error in the build process: exit status 2


Course assignment
Chosen practice exam
My lamp stack blog.

Share this post

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on email

Leave a Reply

Your email address will not be published. Required fields are marked *