
In Ubuntu, services refer to background processes that run on a system, even when no user is logged in. Some examples of commonly used services in Ubuntu include:
- Apache Web Server
- SSH
- MySQL/MariaDB
- CUPS (Print server)
- Samba (File sharing)
- Postfix (Mail server)
- NTP (Network Time Protocol)
You can manage these services using the systemctl command, which allows you to start, stop, restart, enable, or disable a service.
To list all services unit files execute the bellow command from your terminal:
Command: systemctl list-units –all –type=service –no-pager
The following command will display all available systemd unit files regardless of their state and type:
Command: systemctl list-unit-files –no-pager
You can also use grep command in case you are searching for a specific unit file.
Command: systemctl list-unit-files –no-pager | grep apache2
The systemctl command can be used to list all active running services:
Command: systemctl list-units –all –type=service –no-pager | grep running
To display all exited service execute:
Command: systemctl list-units –all –type=service –no-pager | grep exited
Furthermore, to show all stopped/dead systemd services execute:
Command: systemctl list-units –all –type=service –no-pager | grep dead
The following systemctl command will list all enabled services:
Command: systemctl list-unit-files | grep enabled
On the other hand to list all disabled services execute:
Command: systemctl list-unit-files | grep disabled
Use the systemctl command to set the service state as enabled or disabled. For example the following command will enable the Apache2 service to start during the system boot startup:
Command: systemctl enable apache2
And to disable the apache2 service, you can type:
Command: systemctl disable apache2
To manage services in Ubuntu, you can use the systemctl command, which is part of the systemd system and service manager. This tool provides a convenient way to manage system services, including starting, stopping, restarting, enabling, and disabling them.
Here are some common tasks you can perform using systemctl:
- Start a service: sudo systemctl start [service-name]
- Stop a service: sudo systemctl stop [service-name]
- Restart a service: sudo systemctl restart [service-name]
- Enable a service to start automatically at boot: sudo systemctl enable [service-name]
- Disable a service from starting automatically at boot: sudo systemctl disable [service-name]
- Check the status of a service: sudo systemctl status [service-name]
You can find a list of all available services on your system by using the systemctl list-units command. This will display a list of all units, including services, sockets, devices, etc. To view only the services, you can use the following command: systemctl list-units –type=service.
You may also read:
- How To Check Which Apps are Sending Information
- How To Use chattr Command in Linux
- [Two Methods] Force Linux User to Change Password at Next Login
- How To Install The WinDbg Windows Debugging Tool
- Getting Started with Apache Solr on Ubuntu
- Understanding OpenSSL Commands – A Comprehensive Guide
- How To Check SSL Certificate Expiry Date from Certificate File
- How To Install Apache Tomcat on Ubuntu 22.04 LTS
- How To Compress Files Faster Using Pigz on Ubuntu Linux
- A Step-by-Step Guide to Setting up Nginx and SSL with Certbot