2024 Midterm exam exercises Q-and-A.#

June 26 2024. Time 6:00 p.m. – 9:00 p.m.

Number of exercises: 4. Each exercise has a maximum score.

In home directory of user hostadm, you need to create a new subdirectory, MIDTERM and a file within it, answers.txt, where you will be writing answers to the exam exercises.

In the file, first, put your name, then proceed with answering to the questions below.


1. VM deployment in KVM (max score 4)#

A) Create a new VMs, midterm2024, by cloning kvm1.

B) Set hostname to IP address resolution for midterm2024 on your VD desktop.

Make sure you can ping midterm2024 from the desktop.

Answer:

A)

virt-clone -o kvm1 -n midterm2024 -f KVM/midterm2024.qcow2

B) On midterm2024:

ip a

On the desktop, edit file /etc/hosts and add:

/etc/hosts

192.168.122.26 midterm2024

Check if we can ping midterm2024 from the desktop:

ping -c 3 midterm2024

2. Command find (max score 6)#

On midterm2024 VM, download tgz file e2fsprogs-1.47.1.tar.gz from
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/snapshot/e2fsprogs-1.47.1.tar.gz

Untar the archive.

A) Find all files with file name types.h.

B) How many files with extension c are in the archive?

C) Find the largest file in the archive.

  • What is the file name?

  • What is the file size?

Answer:

A)

find e2fsprogs-1.47.1/ -name types.h

output:

e2fsprogs-1.47.1/include/nonunix/linux/types.h
e2fsprogs-1.47.1/include/nonunix/asm/types.h
e2fsprogs-1.47.1/include/mingw/sys/types.h
e2fsprogs-1.47.1/include/mingw/linux/types.h

B)

find  e2fsprogs-1.47.1/ -name "*.c" | wc -l

Output:

    326

C)

find  e2fsprogs-1.47.1/ -size  +1M

Output:

e2fsprogs-1.47.1/tests/f_many_subdirs/image.gz
e2fsprogs-1.47.1/tests/f_bad_local_jnl/image

Then

find  e2fsprogs-1.47.1/ -size  +4M
ls -l e2fsprogs-1.47.1/tests/f_bad_local_jnl/image

File name: image Size: 8388608 bytes or ~8 Mbytes


3. Commands scp and rsync (max score 4)#

Transfer directory e2fsprogs-1.47.1/include/nonunix from midterm2024 VM into directory MIDTERM on the VD desktop by using 2 methods:

A) command scp.

B) command rsync.

Answer:

On the desktop:

A) Recursive scp for the directory:

scp -r midterm2024:e2fsprogs-1.47.1/include/nonunix .

B) rsync:

rsync -avz midterm2024:e2fsprogs-1.47.1/include/nonunix .

4. Service start/stop, configuration, permissions, command wget (max score 6)#

On midterm2024 VM, install web server lighttpd by using apt install.

A) Check lighttpd service status and stop the service.

B) By using an editor, replace the service configuration file content in /etc/lighttpd/lighttpd.conf with the following:

new lighttpd.conf:

server.modules = (
        "mod_indexfile",
        "mod_access",
        "mod_alias",
        "mod_redirect",
        "mod_dirlisting",
        "mod_staticfile",
)
dir-listing.activate        = "enable"

#server.document-root        = "/var/www/html"
server.document-root        = "/home/hostadm"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80

#https://redmine.lighttpd.net/projects/lighttpd/wiki/Server_feature-flagsDetails
server.feature-flags       += ("server.h2proto" => "enable")
server.feature-flags       += ("server.h2c"     => "enable")
server.feature-flags       += ("server.graceful-shutdown-timeout" => 5)
#server.feature-flags       += ("server.graceful-restart-bg" => "enable")

index-file.names            = ( "index.php", "index.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

C) Set readable and executable permission for all users on directory /home/hostadm.

D) Start lighttpd service.

E) On the desktop, download file e2fsprogs-1.47.1/README into MIDTERM directory from midterm2024 VM by using wget command.

Hint: in wget use HTTP connection to the VM, http://midterm2024

F) On the desktop, download directory e2fsprogs-1.47.1/include/nonunix into MIDTERM directory from midterm2024 VM by using wget command.

Answer:

sudo -s
apt install lighttpd

A)

systemctl status lighttpd
systemctl stop lighttpd

B)

nano /etc/lighttpd/lighttpd.conf
  • Remove all the lines in the file.

  • Copy/paste the content from the box.

  • Save the updated file

C)

chmod a+rw /home/hostadm

D)

systemctl start lighttpd

E)

wget http://midterm2024/e2fsprogs-1.47.1/README

F) To fetch a directory via wget, use –recursive or -r, -l1 recursive depth not to fetch the parent other subdirectories, -nH no host directory to create:

wget --recursive -l1 -nH  http://midterm2024/e2fsprogs-1.47.1/include/nonunix