Final exam exercises. May 11 2016. Time 12 noon -- 3 p.m.

The exercises are supposed to be done by each student solely on his/her desktop in the Linux lab, D-112. It is allowed to use lecture notes at http://linuxcourse.rutgers.edu and any printed material. Internet access during the exam will be allowed.
Number of exercises: 6. Each exercise has a maximum score.
You need to create a new file answers.txt in the home directory of user hostadm, where you will be writing answers to the exam exercises. Write your name and the desktop number in the file. When you finish with the exam answers, create directory FINAL, and copy answers.txt into directory FINAL.

Note: if you happen to need to install a software package, run
apt-get install package_name

1. VM deployment (max score 2)
Deploy virtual appliance final2016, available at http://192.168.5.240/coursefiles/final2016.tgz
Start final2016 VM. Specify the commands you used here.


Answer
A
wget http://engshare.rutgers.edu/KVM/final2016.tgz 
tar -zxvf final2016.tgz
cp final2016.xml /etc/libvirt/qemu
cp final2016.img /home/hostadm/KVM 
virsh define /etc/libvirt/qemu/final2016.xml
virsh start final2016


2. Port scan (max score 4)

Scan the TCP ports on final2016 VM from your desktop. Specify the command you use for the scan. What the TCP ports show up open?
Answer
First, figure out the IP address of final2016
grep final2016 /var/lib/libvirt/dnsmasq/default.leases 
Scan the host by using nmap on the IP address:
nmap -sT 192.168.122.42
Shows the following open TCP ports:
PORT     STATE SERVICE
22/tcp  open  ssh
389/tcp open  ldap



3. File consistency check (max score 4)

On final2016 VM, there are directories DATA_1, DATA_2, DATA_3 in home directory of user hostadm. Find the files in these directories that have been modified since the time when their tar archive has been created in file openmpi-1.8.tar.gz, located in home directory of user hostadm.

Answer
cd DATA_1
tar -zdf ../openmpi-1.8.tar.gz openmpi-1.8
openmpi-1.8/test/Makefile.in: Mod time differs
openmpi-1.8/test/Makefile.in: Size differs
openmpi-1.8/ompi/communicator/comm_init.c: Mod time differs
openmpi-1.8/ompi/communicator/comm_init.c: Size differs
cd DATA_2
tar -zdf ../openmpi-1.8.tar.gz openmpi-1.8
openmpi-1.8/contrib/platform/cray_xt3_romio: Uid differs
openmpi-1.8/contrib/platform/cray_xt3_romio: Gid differs
openmpi-1.8/contrib/platform/cray_xt3: Uid differs
openmpi-1.8/contrib/platform/cray_xt3: Gid differs
cd DATA_3
tar -zdf ../openmpi-1.8.tar.gz openmpi-1.8
None of the files appear modified in directory DATA_3


4. setuid/setgid executables (max score 4)

In home directory of user hostadm on final2016 VM, find setuid and setgid executable files. Specify the command you used and the path to the files.

Answer
find . -perm /u+s -ls

177432   32 -rwsr-xr-x   1 root     root        32464 Feb 16  2014 ./src/bin/newgrp
177431   48 -rwsr-xr-x   1 root     root        47032 Feb 16  2014 ./src/bin/passwd
find . -perm /g+s  -ls
177430   20 -rwxr-sr-x   1 root     tty         19024 Jun  3  2014 ./src/bin/wall
177434   16 -rwxr-sr-x   1 root     mail        14592 Dec  3  2012 ./src/bin/mail-lock



5. LDAP queries (max score 6)

There is LDAP server running on final2016 VM.
A) Find out the LDAP domain components and organizational units present in the LDAP database.
B) Find out the telephone number of 'Agent One' employee.
C) What is the Admin (Manager) password in the LDAP?
D) Add a new organizational unit, 'Production', into the LDAP database.

Answer
A
ldapsearch -x  -LL  -b '' -s base '(objectclass=*)' namingContexts
ldapsearch -x ou=*
dn:
namingContexts: dc=d112,dc=class

dn: ou=Research,dc=d112,dc=class
B
ldapsearch -x cn='Agent One'
...
telephoneNumber: 2234
...
C
grep rootpw /etc/ldap/slapd.conf
rootpw thisclass
D) Create ldif file, production.ldif:
dn: ou=Production,dc=d112,dc=class 
objectclass: organizationalUnit
ou: Production 
Add the content of the file into the LDAP:
ldapadd -x -D 'cn=Manager,dc=d112,dc=class' -W -f production.ldif
ldapsearch -x ou='Production'

6. HPC: Amdahl's law (max score 4)
Let's assume you have parallelized a code with MPI by 75%.
A) What is the maximum theoretical speedup you would expect from the parallel c ode?

B) What is the reasonable number of CPU cores you would request on a computational cluster to run the code ?
Hint: it would make sence getting the number of cores sufficient to speedup the code at 90% of the maximum theoretical limit.


Answer
A) By using Amdahl's law, we find that the maximum theoretical speedup of the code with S=0.25, P=0.75, and N=infinity, is 4.
B) Taking into account the value of the speedup, 90% of the theoretical limit, 3.6, we can express N from the Amdahl's law: 3.6 = 1 / (S + P/N) = 1 / (0.25 + 0.75 / N) , we find N = 0.75 / ( 1/3.6 - 0.25) = 27