M01: Introduction to Operating Systems
TU1: Installing, configuring and exploiting a computer system
ASIX1
Practical Exercise 9: Managing services 07-02-14

Practical Exercise 9:  Managing services

GENERAL CONDITIONS
1- Deadline: 21-02-2014.
2- Send your report as a PDF file attached to an e-mail with the following specifications:
     a) E-mail address:
cf(at)collados.org or jordi.binefa(at)fje.edu depending who is your teacher
     b) File Name:

        b.1)
ASIX1 (Catalan): asix1_surname_name_m01tu01pr9.pdf
        b2.) DAW1 (English): daw1_surname_name_m01tu01pr9.pdf     
     c)
Subject:
        
c.1) ASIX1 (Catalan): asix1_surname_name_m01tu01pr9
         c.2)
DAW1 (English): daw1_surname_name_m01tu01pr9
3- Make this report individually.
4- Left, right, top and bottom margins: 2cm.
5- Character format: a) Font:Times New Roman (or Liberation Serif), b) Size: 10, c) Questions typeface: Bold, d) Answers typeface: Regular
6- Page numbering on footer bar

1- What is a server program?
A server is a computer program running in a computer that provides services to other computer programs (the clients)  running in the same computer or in other computers connected through the network.
Usually, a server is a program that awaits a request from a client programs in the same or other computers. When a request is received from a client, the server program will fulfill the task requested by the client.
The most of the times a server is a daemon, therefore it is a process running continuosly that has been  initialized at system startup and then wait in the background until their service is required.

Typical servers are:
  1. Apache: It is a Web server. A client (firefox, chrome,....) can gain access to a web pages stored in the computer where Apache is running
  2. Mysql: It is Database server. A client can gain access to a database stored in the computer where MySQL is running.
  3. Postfix: It is a Mail server. A client can send e-mails through Postfix or receive e-mails stored in the computer where Postfix is running
  4. Pulseaudio: It is a sound server for Linux. A client can gain access to the sound hardware in the computer where Pulseaudio is running.
  5. CUPS: Local and network printer server for Linux.
2- service
A command-line utility that can report or change the status of any of the system services (a service is provided by a server program).
This command should be run as a root user.The following options are available:
a) start --> Starting a service. Example: service  apache2 start
b) stop --> Stopping a service. Example: service  apache2 stop
c)
restart --> Restarting a service. The service will be stopped and started, its service file configuration will be read again, and its PID will be changed. Example: service apache2 restart.
d)
status --> Displaying a service status (is stopped or started). Example: service apache2 status

3- Listing services running in your system
a) ls  /etc/rc2.d/S* --> This command shows services which start during the computer boot process if your system runlevel is 2. You should check your runlevel running: runlevel. If your runlevel were any other number, 5 for instance, you would have to run: 
ls  /etc/rc5.d/S*.  Depending on your system runlevel, a different set of services will be run during the boot process.
b) netstat  -atupn --> This command shows network services running in your system just now. This command should be run as a root user.
c) service  --status-all --> It shows a list of service running in your system. Only services with +  are running properly in your system. Services with  - are not running in your system. The current status is no available for services with ?.
This command should be run as a root user.

4- Adding o removing a service during the system boot process
a) If you want to totally remove a service during the system boot process you have to run the following command:

update-rc.d   -f   service_name   remove

For intance, if you want to remove apache2 during the system boot process you have to run the following command:

update-rc.d   -f   apache2   remove

a) If you want to add  a service during the system boot process you have to run the following command:

update-rc.d   service_name   defaults

For intance, if you want to add apache2 during the system boot process you have to run the following command:

update-rc.d   apache2   defaults

PRACTICAL EXERCISE

1- Find out the following features of  apache2 and cups, using the GNOME System Monitor: a) PID, b) owner, c) status and d) command-line.
2- Using a command-line tool, find out if ssh is runnig or stopped. Take note of its PID and who its owner is.
3-
Using a command-line tool, stop the ssh service. Check if that service has been stopped using a command-line tool.
4- Using a command-line tool, start the ssh service. Check if that service is running again using a command-line tool. Check its PID. Any change?.
5- Using a command-line tool, restart the ssh service. Using a command-line tool, check if that service is running. Check its PID. Any change?.
6- Check the status of all your system network services. Could you tell me if apache2, ssh and cups ares network services?. Why?
7- Check the status of apache2, cups and ssh using netstat and one single command  (*1).
8- Check the running level of your system. Show services which start during the computer boot process.
9- Remove apache2 and ssh as services started by the computer during the boot process. Reboot your system and check that both services are not running.
10- Add apache2 and ssh as services started by the computer during the boot process. Reboot your system and check that both services are running.

(*1) --> Help:  grep -E '(cups|ssh|apache)'.