- Command to list services that start on startup?
- 9 Answers 9
- Upstart
- System V
- SystemD
- How to list services in Linux using the command-line
- BitLaunch
- BitLaunch
- How to list services in Linux
- Listing services with systemctl
- Types of Virtual Machines & Virtualization Technology
- How to install Yarn, the node.js package manager
- How can I see all services in Ubuntu?
- How to list all services in Ubuntu?
- List all services using the systemctl command
- How to list systemd unit files?
- How to list systemd service unit files using states?
- List all active or running services
- List all excited services
- List all stopped or dead services
- Managing systemd services using systemctl
- View service status using systemctl command
- More commands to list services in Ubuntu
- Use of pstree command
- List firewall services
- List top control groups with resource utilization
- Conclusion
- About the author
- Samreena Aslam
Command to list services that start on startup?
Is there a command to list services that run on startup? I imagine it would involve parsing /etc/init.d/ , and the various /etc/rc.* directories.
9 Answers 9
The quick answer is: It depends on your init system.
The long answer is: For current versions of Ubuntu, you probably have a mix of Upstart, and SystemV. Newer versions of Ubuntu after 15.04 «Vivid Vervet» (and other Linux distros like RHEL/CentOS 7) are moving to use SystemD.
Upstart
To list all Upstart services and run initctl show-config on them, this one-liner may be helpful:
sudo initctl list | awk '< print $1 >' | xargs -n1 initctl show-config
System V
# for init scripts: ls /etc/init.d/ # for runlevel symlinks: ls /etc/rc*.d/
SystemD
sudo systemctl --all list-unit-files --type=service
ls /lib/systemd/system/*.service /etc/systemd/system/*.service
service —status-all does NOT show whether services are enabled to start on boot, at least not on Ubuntu 16. It shows whether services are currently running or not.
I had to sudo service —status-all to get all of the services to show up. A few were hidden when I only ran service —status-all on a non-root account.
@Phlucious : Thanks for mentioning that. I assumed it was well known that these commands are usually run as root ( systemctl , service , initctl . ) as they are usually considered system administration commands.
You can simply use the initctl list shell command to list the contents of /etc/init rather than the suggested dbus-send command.
systemctl list-units --type=service
Since Ubuntu 16.04, initctl has been replaced by systemd (source, in French).
The /etc/init.d and /etc/rc.* directories have been superseded by the ‘ upstart ‘ init tool. Although scripts in these directories will be executed as expected, the new method for running things on init is defined by files in /etc/init/
You can list all of the upstart jobs with by querying upstart over dbus:
dbus-send --print-reply --system --dest=com.ubuntu.Upstart \ /com/ubuntu/Upstart com.ubuntu.Upstart0_6.GetAllJobs
You may have to change 0_6 to reflect the version of upstart you have. This command works on my lucid install.
How to list services in Linux using the command-line
Listing services in Linux is a key part of server management. Here’s how to do so on Ubuntu, Debian, CentOS, and Fedora.
BitLaunch
BitLaunch
Performing basic functions in the command-line can be challenging if you’re used to the GUI-based workflow of Windows or Linux desktops. A particular hurdle is working out how to get a list of running services when you cannot lean on hotkeys such as Ctrl + Shift + Esc or Ctrl + Alt + Del.
Listing services in Linux is a key part of server management. It allows you to check whether necessary services are running correctly or whether something is running that shouldn’t. Fortunately, there are several ways to list services in Linux, though the commands can vary depending on the distribution. In this blog, we’ll cover listing services on the most popular ones: Ubuntu, Debian, CentOS, and Fedora.
How to list services in Linux
Linux has multiple easy ways to list services, with the most obvious being the service command. This command should work on all distros that support System V init scripts.
This will list all services, whether they’re running or not, with a + next to the ones that are. You can also filter out services that are running using grep :
And the ones that aren’t by changing that + to a — :
You can find the status of a particular service by typing service status . For example, service ssh status will return:
ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2022-12-19 08:21:39 UTC; 24h ago
Listing services with systemctl
Many will prefer to use the systemctl command over service because it shows more information and outputs in a tabular format. It also works on all of the Linux distributions mentioned. The list-units option will list all services, regardless of whether they are active or not.
systemctl list-units --type=service
systemctl list-units —type=service —all , meanwhile, shows services that are active or have failed.
You can filter those to only active service by using:
systemctl list-units -a --state=active
systemctl list-units -a --state=inactive
Want to list only running services? Use this instead:
systemctl list-units --type=service --state=running
If you want to see the services that have failed (for troubleshooting purposes), you can use the —state option:
systemctl list-units --state=failed
Types of Virtual Machines & Virtualization Technology
The different types of virtual machines fall into two categories: process virtual machines and virtual system machines. Here’s how they differ, and where KVMs come into the picture.
How to install Yarn, the node.js package manager
Yarn’s release marked a major step forward for package management in node.js, delivering features we now take for granted such as deterministic sub-dependency resolution and an offline cache. While
How can I see all services in Ubuntu?
System services are the processes or system programs known as ‘daemons’ that continuously run in the background. These services wait for client requests and are responsible for how the system works and how it communicates with other programs. When working in a Linux environment, including Ubuntu, you can easily manage all system services (start, stop, restart, enable at system boot, etc.) through a service manager. Most of the modern Linux distributions, such as Ubuntu, now use a process manager known as ‘systemd’. The systemd is a service manager in the Ubuntu system and used to replace the ‘init’ process. The systemd services manager is controlled by the primary command-line tool ‘systemctl’ command.
We will show you the various techniques in this tutorial related to listing or viewing all services in the Ubuntu 20.04 system.
How to list all services in Ubuntu?
Various services are running in the background of your Ubuntu Linux distribution. While working as a system administrator, you must know how to view all services, including system services such as (login, process management, syslog, cron jobs). You must have the knowledge to view all network services (remote login, web hosting, file transfer, DNS and DHCP, etc.) using the systemctl command and other ways you can control or manage all Linux services. We will also discuss this in this article.
List all services using the systemctl command
When the systemctl command is used without any arguments, in this case, it displays the list of loaded systemd units, including services either these are active or not.
The following command will also display all services unit files:
In the output, the details about UNIT, LOAD, ACTIVE, SUB, and service Description displays in the form of columns as follows:
- UNIT This column shows the corresponding details about the systemd unit name.
- LOAD The column displays the information about the unit, either currently loaded in the memory or not.
- Active This column shows whether the systemd unit is active or not.
- SUB This column shows the running state of the systemd unit.
- DESCRIPTION This column displays the short details about the unit.
How to list systemd unit files?
The below-mentioned will show the all available systemd unit files rather than their type and running status info:
Use the grep command in case you are searching for a specific unit file. For example, the below command will search for an apache2 unit file:
If you want to search for a specific unit file, you can also perform this action using the grep command.
For example, we want to search an apache2 service unit file by using the grep command as follows:
The above command will retrieve all unit files related to the apache2 service that you can see in the following screenshot:
How to list systemd service unit files using states?
The following systemctl command will show you the information about all enabled systemd unit files on Ubuntu 20.04 system:
To display all disabled systemd unit files, run the below-mentioned command:
The services that are enabled on your system automatically start on system reboot.
List all active or running services
Using the ‘systemctl’ command, you can filter active or running services from the all services list as follows:
List all excited services
By running the below-given command, you can easily list all services with the excited state:
List all stopped or dead services
With the help of the following command, you can easily list all disabled services on the terminal window:
Managing systemd services using systemctl
The systemctl is the most commonly used command to manage the systemd unit files and services in Ubuntu 20.04 distribution. Users can enable, disable, start and stop services using the following commands respectively.
$ sudo systemctl enable service-name
$ sudo systemctl disable service_name
$ sudo systemctl start service_name
$ sudo systemctl disable service-name
Using the above commands, you can control each service state based on your requirements.
View service status using systemctl command
To view the detailed information about a particular service, use the below-mentioned command:
For example, we want to check the complete status of the ‘ssh’ service. In this case, by running the following command, you can display the complete status of the ssh service as follows:
More commands to list services in Ubuntu
Use of pstree command
Using the ‘pstree’ command, you can list all running Ubuntu services in the form of the tree structure as follows:
List firewall services
By running the following command, the user can easily list firewall services and ports:
List top control groups with resource utilization
The ‘systemd-cgtop’ command is used to display the top control groups by their resource utilization as follows:
The previous Ubuntu distributions use the ‘service’ command to list all system services as follows:
You can also view all services by directly listing the /etc/init.d directory in older Ubuntu systems as follows:
Conclusion
We learned how to list all services in Ubuntu 20.04 system using the systemctl command. We have also experienced various commands that are also helpful in listing all Ubuntu services. Most of the commands, like the service command, are obsolete now. In the latest Ubuntu distribution, system administrators use ‘systemctl’ to get the details about all systemd services. The systemctl command also offers advanced features and is quite more useful as compared to the other service listing commands.
About the author
Samreena Aslam
Samreena Aslam holds a master’s degree in Software Engineering. Currently, she’s working as a Freelancer & Technical writer. She’s a Linux enthusiast and has written various articles on Computer programming, different Linux flavors including Ubuntu, Debian, CentOS, and Mint.