Monday, January 11, 2016

How to check status of services on Lubuntu


Your computer, which runs lubuntu, might have several services running in the background, for example your computer is running ssh server, apache/nginx web server, mysql server, FTP server, etc. 

The questions is how to check the status of these services whether it's active or not? for example, i want to know about ssh server on my computer, how do i know the ssh server on my computer is up and running?

On lubuntu, there is a tool that specially design for this purpose, on lubuntu/ubuntu we can use tool called 'service'. This tool comes with lubuntu installation, so you can use it right away.

It needs to be run under root permission, otherwise it won't work. And service is not just for checking status, but also can start, stop, and restart the services.

Okay, let's try it, open your terminal/console/command line (press CTRL + ALT + T), and then type the following command:

sudo service --status-all

That command will list all available services on your computer, with [+] means active service, [-] means inactive/stopped service, and [?] means service without status command.

kernelpanic@kernelpanic:~$ sudo service --status-all
[sudo] password for kernelpanic: 
 [ - ]  alsa-utils
 [ - ]  anacron
 [ + ]  apache2
 [ + ]  apparmor
 [ + ]  apport
 [ + ]  bluetooth
 [ - ]  bootmisc.sh
 [ - ]  checkfs.sh
 [ - ]  checkroot-bootclean.sh
 [ - ]  checkroot.sh
 [ - ]  console-setup
 [ + ]  cron
 [ - ]  cups
 [ + ]  dbus
 [ - ]  dns-clean
 [ + ]  grub-common
 [ - ]  hostname.sh
 [ - ]  hwclock.sh
 [ + ]  irqbalance
 [ - ]  killprocs
 [ + ]  kmod
 [ + ]  lightdm
 [ - ]  lvm2
 [ - ]  mountall-bootclean.sh
 [ - ]  mountall.sh
 [ - ]  mountdevsubfs.sh
 [ - ]  mountkernfs.sh
 [ - ]  mountnfs-bootclean.sh
 [ - ]  mountnfs.sh
 [ + ]  network-manager
 [ + ]  networking
 [ + ]  ntp
 [ + ]  ondemand
 [ - ]  pppd-dns
 [ + ]  procps
 [ + ]  rc.local
 [ + ]  resolvconf
 [ - ]  rsync
 [ + ]  rsyslog
 [ - ]  sendsigs
 [ + ]  udev
 [ + ]  ufw
 [ - ]  umountfs
 [ - ]  umountnfs.sh
 [ - ]  umountroot
 [ - ]  unattended-upgrades
 [ + ]  urandom
 [ - ]  uuidd
 [ + ]  vsftpd
 [ + ]  whoopsie
 [ - ]  x11-common

You can also check individual status of each service with more detail status of the service. As long as you know the name of the service it will works.

sudo service [name-of-the-service] status

example:

sudo service apache2 status
sudo service vsftpd status
sudo service lightdm status
sudo service mysqld status


Restarting the service

The service command can also be use to restart service, all you need to do is specify the service name you want to restart and add --full-restart parameter.

sudo service [name-of-the-service] --full-restart

example:

sudo service apache2 --full-restart
sudo service mysqld --full-restart
sudo service vsftpd --full-restart

(warning don't try this command, it will restart your desktop!!)
sudo service lightdm --full-restart

The --full-restart is actually do two things, first stopping the service and then start the service again, so we can also do this manually for all services, like this:

sudo service apache2 start
sudo service apache2 stop
sudo service apache2 restart

You can do the same thing with other services, just replace 'apache2' with any service you want, it should work.



~ cheers ~

No comments:

Post a Comment