Midterm exam exercises. March 27 2008. Time 3:20 p.m. -- 4:40 p.m.

The exercises are supposed to be done by each student solely on his/her desktop station in the Unisys lab, D-112. It is allowed to use lecture notes at http://linuxcourse.rutgers.edu as well as any printed material. Internet access during the exam will be restricted to the web site only.
Number of exercises: 8. Each exercise has a maximum score.
In directory /root, you need to create a new file answers.txt, where you will be writing answers to the exam exercises.

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

1. Processes (max score 3)
On a multi-user system, everything runs very slow because application 'ansys' is utilizing most of the CPU and memory resources on the system. How can you make the process, 'ansys', to run at the lowest priority without restarting it?

-- ANSWER:
Figure out the PID or process 'ansys':
by running command top or ps -ef | grep ansys
Re-nice the process to the lowest priority, 19
renice 19 PID
Note, the priority levels run from -20 (the highest) to 19 (the lowest)

2. Debian packages (max score 6)
Specify the commands you use to find the answers in A and B below.
A) What package does system executable file /bin/ls belong to?
What version of the package is installed on your system?

B) Download file namdlib_0-0_i386.deb from the web server:
http://linuxcourse.rutgers.edu/namdlib_0-0_i386.deb

What is this package for?
What files does it contain?
Install the package on your system.
Verify the package installation.
Remove the package from your system.

-- ANSWER:
A) dpkg -S /bin/ls gives coreutils
dpkg -l 'coreutils' gives 5.97-5.3
B) wget http://linuxcourse.rutgers.edu/namdlib_0-0_i386.deb
dpkg -I namdlib_0-0_i386.deb gives "NAMD libraries. Package built for the Midterm exam exercises."
dpkg -c namdlib_0-0_i386.deb shows the files contained in the package.
Package nstallation and removal can be done as follows:
dpkg -i namdlib_0-0_i386.deb
dpkg -l namdlib
dpkg --purge namdlib 

3. MAC address (max score 4)
What is the MAC address of host 192.168.5.55?
What is the MAC address of host 128.6.236.16?
Specify the commands you use to determine them and explain why they did or didn't work in your case.
-- ANSWER:
Host 192.168.5.55 is located on your local subnet, therefore, you can identify its MAC address from the ARP table. After pinging 192.168.5.55, then running command arp
ping 192.168.5.55
arp -a
we get the MAC address, 00:B0:D0:20:37:3B, for the host.
You can't determine the MAC address of host 128.6.236.16 since it is not located on your subnet and, therefore, doesn't respond to the ARP requests from your desktop.

4. Subnets (max score 5)
How many IP addresses are available in subnet
172.16.4.128 / 255.255.255.192 ?
Can the gateway for the subnet have IP = 172.16.4.192 ?

-- ANSWER:
By running ipcalc, you can see that the number of available hosts is 62; the maximum IP is 172.16.4.190 and broadcast address is 172.16.4.191, so 172.16.4.192 is beyond the scope of the subnet, and, therefore, can not be a gateway IP address.

5. File permissions (max score 4)
Suppose you have downloaded script script.sh into your home directory. When you tried running it, you get an error:
-bash: ./script.sh: Permission denied
What is the problem with the script and how can you fix it?

-- ANSWER:
Check the permission the script has by running:
ls -l
If the executable flag, x, is not set, make the script executable:
chmod u+x script.sh

6. LDAP (max score 7)
The LDAP directory tree is defined by the following distinguished names
dn: dc=tools, dc=net
dn: cn=Manager, dc=tools, dc=net
dn: ou=Research, dc=tools, dc=net 
dn: ou=Support, dc=tools, dc=net 
dn: cn=John Smith, ou=Support, dc=tools, dc=net
dn: cn=Mike Willson, ou=Research, dc=tools, dc=net 
A) Create a simple LDIF file, dir.ldif, for this directory.
B) How to add this data to LDAP?
-- ANSWER:
A)
# Root node
dn: dc=tools, dc=net
objectclass: organization
objectclass: dcObject
o: tools.net 
dc: tools.net 

# The Super-User's node
dn: cn=Manager, dc=tools, dc=net
objectclass: organizationalRole
cn: Manager

# Research branch
dn: ou=Research, dc=tools, dc=net
objectclass: organizationalUnit
ou: Research

# Support branch
dn: ou=Support, dc=tools, dc=net
objectclass: organizationalUnit
ou: Support

# A leaf node
dn: cn=John Smith, ou=Support, dc=tools, dc=net
objectclass: person
cn: John Smith
sn: Smith

# A leaf node
dn: cn=Mike Willson, ou=Research, dc=tools, dc=net 
objectclass: person
cn: Mike Willson
sn: Willson

B) ldapadd -x -D 'cn=Manager,dc=tools,dc=net' -W -f dir.ldif

7. User accounts, groups, file ownership (max score 5)
Create a new group, midterm, with GID=700.
Create a new account, midterm, with UID=700, GID=700, user home directory, and login shell /bin/bash
Copy file answers.txt into the home directory of user midterm.
Assign it the ownership of user and group midterm.

-- ANSWER:
groupadd -g 700 midterm
useradd -u 700 -g 700 -m -s /bin/bash  midterm
passwd midterm
cp /root/answers.txt /home/midterm
chown midterm:midterm /home/midterm/answers.txt

8. NFS exports (max score 5)
Make the home directory of user midterm available via NFS to host 192.168.5.250.
Note, only host 192.168.5.250 should be able to mount the directory and with non writeble privileges.

-- ANSWER:
edit file /etc/exports:
/home/midterm 192.168.5.250(ro)
If portmap and nfs daemons are running, execute
exportfs -ra
Otherwise, start the services:
/etc/init.d/portmap start
/etc/init.d/nfs-kernel-server start