COMP 3000 Lab 2 2012: Difference between revisions

From Soma-notes
Afry (talk | contribs)
Cdelahou (talk | contribs)
updated password
 
(6 intermediate revisions by 3 users not shown)
Line 18: Line 18:
You will need to do this assignment on an Ubuntu 12.04 machine that you have root access to.  Generally this will be a virtual machine.  In the labs, you can access pre-made Ubuntu virtual machines in VirtualBox.  Note that these are for other courses; we, however, can use them as well as we just need a standard Ubuntu install.
You will need to do this assignment on an Ubuntu 12.04 machine that you have root access to.  Generally this will be a virtual machine.  In the labs, you can access pre-made Ubuntu virtual machines in VirtualBox.  Note that these are for other courses; we, however, can use them as well as we just need a standard Ubuntu install.


To access the VMs open virtualbox, start menu, apps, virtualbox folder, virtualbox, it should be listed when you start the program.  You can use the following accounts. Note that only the '''admin''' account has root access.
To access the VMs open virtualbox, start menu, apps, virtualbox folder, virtualbox, it should be listed when you start the program.  You can use the following accounts for the COMP2401-2404 IMAGE only! Note that only the '''admin''' account has root access.
* Username: '''student'''  Password: ''tneduts!''
* Username: '''student'''  Password: ''tneduts!''
* Username: '''admin'''  Password: ''nimda1234!''
* Username: '''admin'''  Password: ''nimda!''
* Username: '''Starbuck'''  Password: ''harbinger''
* Username: '''Starbuck'''  Password: ''harbinger''


Line 26: Line 26:
# [2] How can you get a list of all of the processes running on the system from the command line?  Please give the command and required arguments, if any.
# [2] How can you get a list of all of the processes running on the system from the command line?  Please give the command and required arguments, if any.
# [10] What are five processes that are running on your system as non-regular users (i.e., as users other than the one you logged in as)?  What does each do, briefly?  Note: please exclude all processes enclosed in [], as those are built in to the kernel.
# [10] What are five processes that are running on your system as non-regular users (i.e., as users other than the one you logged in as)?  What does each do, briefly?  Note: please exclude all processes enclosed in [], as those are built in to the kernel.
# [1] How can I restart the graphical login screen on Ubuntu?  (Hint: use virtual terminals and Ctrl-Alt-F? combinations to access a terminal that is independent of the GUI.)
# [1] How can I restart the graphical login screen on Ubuntu?  (Hint: use virtual terminals and Ctrl-Alt-F? combinations to access a terminal that is independent of the GUI. Also, make sure you are aren't logged into a graphical session when you try this!)
# [2] What happens when you send a kill -9 signal to one of the <tt>getty</tt> processes that are running by default?  Why?
# [2] What happens when you send a kill -9 signal to one of the <tt>getty</tt> processes that are running by default?  Why?


Line 32: Line 32:
# [2] What starts the upstart daemon?  When is it started?
# [2] What starts the upstart daemon?  When is it started?
# [2] How would you "change the system runlevel" to reboot?  Shut down?
# [2] How would you "change the system runlevel" to reboot?  Shut down?
# [2] Look at the output of <tt>ls -l /etc/init/</tt>.  You will note <tt>-></tt> for many of the entries.  This arrow shows that those entries are symbolic links.  Where do most of these symbolic links point to?  Why?
# [2] Look at the output of <tt>ls -l /etc/init.d/</tt>.  You will note <tt>-></tt> for many of the entries.  This arrow shows that those entries are symbolic links.  Where do most of these symbolic links point to?  Why?
# [2] Install the <tt>openssh-server</tt> package in your virtual machine  from the command line.  What command(s) did you use?
# [2] Install the <tt>openssh-server</tt> package in your virtual machine  from the command line.  What command(s) did you use?
# [2] Note that <tt>sshd</tt> has separate entries in <tt>/etc/init</tt> and <tt>/etc/init.d</tt> differ.  Why do both exist (when most services have either one or the other)?
# [2] Note that <tt>sshd</tt> has separate entries in <tt>/etc/init</tt> and <tt>/etc/init.d</tt> differ.  Why do both exist (when most services have either one or the other)?
Line 40: Line 40:
# [1] What is plymouth?
# [1] What is plymouth?
# '''BONUS: ''' [5] Trace plymouth's behavior throughout the boot process.
# '''BONUS: ''' [5] Trace plymouth's behavior throughout the boot process.
==Answers==
Part A
# ps -aux<br/>ps -e<br/>Among others.
# cron - Cron is the time-based job scheduler.<br/>lightdm - Display manager. It also manages the X servers and facilitates remote logins using the XDMCP protocol.<br/>Network Manager - NetworkManager is a set of co-operative tools that make networking simple and straightforward. Whether WiFi, wired, 3G, or Bluetooth, NetworkManager allows you to quickly move from one network to another user/sbin/modemmanager.<br/>Upstart Socket Bridge - The  upstart-socket-bridge queries the Upstart init(8) daemon for all job configurations which start on or stop on the socket event. It  then waits  for  an incoming connection on each specified socket(7) and when detected emits the socket event (socket-event (7)), setting a number of environment variables for the job to query.<br/>acpid - The acpid process is designed to notify user-space programs of ACPI events.<br/>These are just some examples of acceptable answers.  There are others as well.
# Make sure you are not logged into xsession, then restart lightdm with sudo service lightdm restart
# It will automatically respawn itself.  There is a line in the tty script that instructs the process to automatically restart in the case of failure or termination of the process.
Part B
# The kernel starts the upstart daemon at system boot.
# To reboot use either telinit 6 or shutdown -r.  To shutdown use either telinit 0 or shutdown tool with -h option and a time.
# The links point to /lib/init/upstart-job.  Ubuntu is transitioning from SysVinit scripts to upstart scripts, these links are used to redirect to the upstart services.
# sudo apt-get install openssh-server.
# The init.d script is used only for chroot environments.  See lines 14-26 in init.d/ssh script.
# Can check syslog process to see which logs it directly writes too.  Some acceptable answers are:
## auth.log - CRON, lightdm, polkitd
## boot.log - modem-manager
## bootstrap.log - gpgv, dpkg
## dpkg.log - dpkg
## fontconfig.log - fontconfig
## kern.log - kernel
## pm-powersave.log - powerd
## pm-suspend.log - sleepd
## ufw.log - ufw
# test -x /usr/sbin/sshd || exit 0 - Check whether "/usr/sbin/sshd" exists and is executable and exit with status of 0 if not.  Used to verify SSHD is installed.<br/>( /usr/sbin/sshd -\? 2>&1 | grep -q OpenSSH ) 2>/dev/null || exit 0 - Runs SSH script with illegal option and pipes the output to grep to check for OpenSSH.  Rest is piped to /dev/null essentially discarding it.  This line checks to verify that the version of SSH installed is OpenSSH.  If not will exit with status of 0.
# test -x /usr/sbin/sshd || { stop; exit 0; }<br/>Does not have a check for OpenSSH.
# Plymouth is a bootsplash. It provides a graphical boot animation while the boot process takes place in the background.

Latest revision as of 16:54, 1 November 2012

Instructions

In this lab you will examine how Ubuntu Linux initializes itself.

You should expect to complete Part A in tutorial. You should submit the answers to both Part A and Part B, however, on Friday.

Indicate where you got the information to answer each question. This can be as simple as "the TA told me" or instead "I looked at chapter 7 in book X" or, just, "man page for ls". If you do not include such information, you'll automatically have 10 points deducted from your grade.

You should turn in Lab 2 by 10 PM on Friday, September 28 via cuLearn. Your answers should be in plain text (the true UNIX file format) or PDF. No other formats are acceptable (and will result in a zero grade until re-submitted in the correct format). This lab has 40 points in total (and 5 bonus points).

Resources

The Upstart cookbook covers most aspects of Upstart, the SystemV init script replacement used by Ubuntu. Also, you may want to look at the following commands: ps, top, gnome-system-monitor, service, kill, pstree, dpkg, apt-get

Running Ubuntu in Lab

You will need to do this assignment on an Ubuntu 12.04 machine that you have root access to. Generally this will be a virtual machine. In the labs, you can access pre-made Ubuntu virtual machines in VirtualBox. Note that these are for other courses; we, however, can use them as well as we just need a standard Ubuntu install.

To access the VMs open virtualbox, start menu, apps, virtualbox folder, virtualbox, it should be listed when you start the program. You can use the following accounts for the COMP2401-2404 IMAGE only! Note that only the admin account has root access.

  • Username: student Password: tneduts!
  • Username: admin Password: nimda!
  • Username: Starbuck Password: harbinger

Part A

  1. [2] How can you get a list of all of the processes running on the system from the command line? Please give the command and required arguments, if any.
  2. [10] What are five processes that are running on your system as non-regular users (i.e., as users other than the one you logged in as)? What does each do, briefly? Note: please exclude all processes enclosed in [], as those are built in to the kernel.
  3. [1] How can I restart the graphical login screen on Ubuntu? (Hint: use virtual terminals and Ctrl-Alt-F? combinations to access a terminal that is independent of the GUI. Also, make sure you are aren't logged into a graphical session when you try this!)
  4. [2] What happens when you send a kill -9 signal to one of the getty processes that are running by default? Why?

Part B

  1. [2] What starts the upstart daemon? When is it started?
  2. [2] How would you "change the system runlevel" to reboot? Shut down?
  3. [2] Look at the output of ls -l /etc/init.d/. You will note -> for many of the entries. This arrow shows that those entries are symbolic links. Where do most of these symbolic links point to? Why?
  4. [2] Install the openssh-server package in your virtual machine from the command line. What command(s) did you use?
  5. [2] Note that sshd has separate entries in /etc/init and /etc/init.d differ. Why do both exist (when most services have either one or the other)?
  6. [8] Log messages for the system are stored in /var/log. What are four log files that are present on your system? (Ignore the ones with numeric extensions, those are old versions.) What program wrote each of those files directly?
  7. [4] In /etc/init.d/ssh there are two lines near the beginning that end with output || exit 0 (should be lines 16 and 17). What do each of these lines do exactly? And what is there purpose?
  8. [2] What are the equivalent lines, if any, to these || exit 0 lines in /etc/init/ssh?
  9. [1] What is plymouth?
  10. BONUS: [5] Trace plymouth's behavior throughout the boot process.

Answers

Part A

  1. ps -aux
    ps -e
    Among others.
  2. cron - Cron is the time-based job scheduler.
    lightdm - Display manager. It also manages the X servers and facilitates remote logins using the XDMCP protocol.
    Network Manager - NetworkManager is a set of co-operative tools that make networking simple and straightforward. Whether WiFi, wired, 3G, or Bluetooth, NetworkManager allows you to quickly move from one network to another user/sbin/modemmanager.
    Upstart Socket Bridge - The upstart-socket-bridge queries the Upstart init(8) daemon for all job configurations which start on or stop on the socket event. It then waits for an incoming connection on each specified socket(7) and when detected emits the socket event (socket-event (7)), setting a number of environment variables for the job to query.
    acpid - The acpid process is designed to notify user-space programs of ACPI events.
    These are just some examples of acceptable answers. There are others as well.
  3. Make sure you are not logged into xsession, then restart lightdm with sudo service lightdm restart
  4. It will automatically respawn itself. There is a line in the tty script that instructs the process to automatically restart in the case of failure or termination of the process.

Part B

  1. The kernel starts the upstart daemon at system boot.
  2. To reboot use either telinit 6 or shutdown -r. To shutdown use either telinit 0 or shutdown tool with -h option and a time.
  3. The links point to /lib/init/upstart-job. Ubuntu is transitioning from SysVinit scripts to upstart scripts, these links are used to redirect to the upstart services.
  4. sudo apt-get install openssh-server.
  5. The init.d script is used only for chroot environments. See lines 14-26 in init.d/ssh script.
  6. Can check syslog process to see which logs it directly writes too. Some acceptable answers are:
    1. auth.log - CRON, lightdm, polkitd
    2. boot.log - modem-manager
    3. bootstrap.log - gpgv, dpkg
    4. dpkg.log - dpkg
    5. fontconfig.log - fontconfig
    6. kern.log - kernel
    7. pm-powersave.log - powerd
    8. pm-suspend.log - sleepd
    9. ufw.log - ufw
  7. test -x /usr/sbin/sshd || exit 0 - Check whether "/usr/sbin/sshd" exists and is executable and exit with status of 0 if not. Used to verify SSHD is installed.
    ( /usr/sbin/sshd -\? 2>&1 | grep -q OpenSSH ) 2>/dev/null || exit 0 - Runs SSH script with illegal option and pipes the output to grep to check for OpenSSH. Rest is piped to /dev/null essentially discarding it. This line checks to verify that the version of SSH installed is OpenSSH. If not will exit with status of 0.
  8. test -x /usr/sbin/sshd || { stop; exit 0; }
    Does not have a check for OpenSSH.
  9. Plymouth is a bootsplash. It provides a graphical boot animation while the boot process takes place in the background.