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 like:- Top 40 Useful Linux Command Snippets
- Using Elasticsearch Ingest Pipeline to Copy Data from One Field to Another
- Top 10 Useful Windows Commands
- Essential Commands For Process Management in Kali Linux
- How To Install Python 2.7.18 From The Source
- How To Parse SSH Authentication Logs with Logstash
- A Comprehensive Guide to File System Commands in Linux
- Essential File Compression Commands in Linux
- Secure Shell (SSH) Protocol – A Comprehensive Guide
- Monitoring Active Connections in Kali Linux Using Netstat