- How to List All Running Services Under Systemd in Linux
- Listing Running Services Under SystemD in Linux
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- Which services are running on linux
- Check the service status
- Start the service
- Use netstat to find port conflicts
- Check xinetd status
- Check logs
- Next steps
- Share this information:
- How to check all running services in Linux
- Method-1: Listing Linux Running Services with service command
- Method-1(a): How to check running services in System V (SysV) init System
- Method-1(b): How to check running services in Linux with pstree command
- Method-2: How to check running services in systemd system using the systemctl command
- Method-2(a): Listing Linux services with pstree command
- Method-2(b): Listing Linux Services with chkservice command
- Conclusion
- How to check running process in Linux using command line
- Check running process in Linux
- How to manage processes from the Linux terminal
- Linux pgrep command
- Linux top command
- Linux htop command to check running process in Linux
- Linux kill command
- Linux pkill command
- Linux killall command
- Linux nice and renice command
How to List All Running Services Under Systemd in Linux
A Linux systems provide a variety of system services (such as process management, login, syslog, cron, etc.) and network services (such as remote login, e-mail, printers, web hosting, data storage, file transfer, domain name resolution (using DNS), dynamic IP address assignment (using DHCP), and much more).
Technically, a service is a process or group of processes (commonly known as daemons) running continuously in the background, waiting for requests to come in (especially from clients).
Linux supports different ways to manage (start, stop, restart, enable auto-start at system boot, etc.) services, typically through a process or service manager. Most if not all modern Linux distributions now use the same process manager: systemd.
Systemd is a system and service manager for Linux; a drop-in replacement for the init process, which is compatible with SysV and LSB init scripts and the systemctl command is the primary tool to manage systemd.
In this guide, we will demonstrate how to list all running services under systemd in Linux.
Listing Running Services Under SystemD in Linux
When you run the systemctl command without any arguments, it will display a list of all loaded systemd units (read the systemd documentation for more information about systemd units) including services, showing their status (whether active or not).
To list all loaded services on your system (whether active; running, exited or failed, use the list-units subcommand and —type switch with a value of service.
List All Services Under Systemd
And to list all loaded but active services, both running and those that have exited, you can add the —state option with a value of active, as follows.
List All Active Running Services in Systemd
But to get a quick glance of all running services (i.e all loaded and actively running services), run the following command.
List Running Services in Systemd
If you frequently use the previous command, you can create an alias command in your
/.bashrc file as shown, to easily invoke it.
Then add the following line under the list of aliases as shown in the screenshot.
Create a Alias for Long Command
Save the changes in the file and close it. And from now onwards, use the “running_services” command to view a list of all loaded, actively running services on your server.
View All Running Services
Besides, an important aspect of services is the port they use. To determine the port a daemon process is listening on, you can use the netstat or ss tools as shown.
Where the flag -l means print all listening sockets, -t displays all TCP connections, -u shows all UDP connections, -n means print numeric port numbers (instead of application names) and -p means show application name.
The fifth column shows the socket: Local Address:Port. In this case, the process zabbix_agentd is listening on port 10050.
Determine Process Port
Also, if your server has a firewall service running, which controls how to block or allow traffic to or from selected services or ports, you can list services or ports that have been opened in the firewall, using the firewall-cmd or ufw command (depending on the Linux distributions you are using) as shown.
List Open Services and Ports on Firewall
That’s all for now! In this guide, we demonstrated how to view running services under systemd in Linux. We also covered how to check the port a service is listening on and how to view services or ports opened in the system firewall. Do you have any additions to make or questions? If yes, reach us using the comment form below.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
Which services are running on linux
Last updated on: 2019-12-20
Authored by: Rackspace Support
When you need to troubleshoot a network service, the first step is to ensure that the service is running.
If the service has an initialization (init) script installed, you can use the service command to start, stop, and check the status of the service. This command references a service by using its init script, which is stored in the /etc/init.d directory for Debian®-based distributions and the etc/rc.d/init.d directory for Red Hat®-based distributions.
If you don’t know the name that the system uses for a service, check either of the preceding directories by using the ls command followed by the directory name. Some names vary depending on your distribution. For example, Apache® is httpd on CentOS® and apache2 on the Ubuntu® operating system.
Note: Many newer Linux® distributions use systemd instead of netstat to check services. If you’re using systemd , replace all service commands with systemct1 . For more information about systemct1 commands, see the Fedora™ SysVinit to Systemd Cheatsheet.
Check the service status
A service can have any of the following statuses:
- start : The service has started.
- stop : The service has stopped running.
- restart : The service is rebooting and will start after the process is complete.
The following example shows how to check the status of httpd on CentOS by using the service command:
Start the service
If a service isn’t running, you can use the service command to start it. The following example starts the httpd service:
If the application can’t be started, the system reports the failure and usually displays a message that indicates the cause of the problem.
Use netstat to find port conflicts
In the preceding example, httpd can’t be started because something is already listening on the port. To find out what’s listening, you can run the netstat command.
Run the following command to display a list of listening programs and the ports that they’re using:
The output shows that the nc program (which appears in the Program name column) is listening on port 80 (which appears in the Local Address column). Stopping this program should enable httpd to be started.
Note: For more information about the netstat command, see Check listening ports with netstat.
Check xinetd status
If the service isn’t running, it might be because a super-server such as an Extended Internet Service Daemon ( xinetd ) is being used to launch the program when a connection is received. If this is the case, starting the service might have resolved the issue. Run the following command to verify that the issue is resolved:
Check logs
If you can’t start your service, review your logs to see if they contain information about the issue.
Next steps
After you’re sure that the application is running, check the server resources to verify how much your application is consuming.
Share this information:
©2020 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
Источник
How to check all running services in Linux
There are many ways as well as tools to check and list all running services in Linux.
Most Linux administrators typically use ‘service service_name status’ or ‘/etc/init.d/service_name status’ for the System V (SysV) init system, and ‘systemctl status service_name’ for the systemd systems for a specific service.
The above commands show whether the particular service is running on the server or not. These are frequently used commands by every Linux administrator.
If you are new to the environment and want to know what services are running on the system, continue to read.
The following commands lists all the services running on the system and give you an idea of what purpose the system is being used for. Also, it provides an opportunity to disable certain services that are not used on the system.
‘init’ (short for initialization) is the first process started during booting of the computer system. init is a daemon process that continues running until the system is shut down.
We recommend reading the following articles related to this topic.
Many init systems have been developed for Linux, but the following are the three most familiar and commonly used init systems.
- System V (Sys V) is the older init system
- Upstart is an event-based replacement for the traditional init system
- systemd is the new init system, that was adopted by most of the latest Linux distributions
Method-1: Listing Linux Running Services with service command
To display the status of all available services at once in the System V (SysV) init system, run the service command with the —status-all option:
If you have multiple services, use file display commands (like less or more) for page-wise viewing. The following command will show the below information in the output.
- Running services and their associated PID
- Stopped services
- Configured iptables rules
- Configured and active network interface information.
Run the following command to see only running services in the system.
Run the following command to see the specified service status. For instance, use the following command to check the Apache Web server status on a RHEL based system.
To determine the current status of a particular service, execute the following command.
Use the following command to see a list of services that were enabled on boot. These services will be kicked on as part of the system boot process.
Method-1(a): How to check running services in System V (SysV) init System
Alternatively, you can view services running on a Linux system by issuing the ‘initctl’ command as shown below.
Method-1(b): How to check running services in Linux with pstree command
Run the ‘pstree’ command without any additional parameter to see services running in the Linux system:
Method-2: How to check running services in systemd system using the systemctl command
‘systemctl’ command allows users to check and list all services running in a Linux system that uses “systemd” as the system manager.
- UNIT Describe about the corresponding systemd unit name.
- LOAD Describes whether the corresponding unit currently loaded in memory or not.
- ACTIVE Indicate whether the unit is active or not.
- SUB Indicate whether the unit is in running state or not.
- DESCRIPTION A short description about the unit.
To see loaded service in the system, use the list-units subcommand and the —type switch with a value of service. It shows active, running, exited or failed services in the output.
Run the following command to view a particular service status.
Detailed information about a particular service can be verified with the systemctl command as shown below.
Run the following command to view the services running on the system with the systemctl command:
Use the below command to see which services were enabled on boot:
systemd-cgtop shows top control groups by their resource usage such as tasks, CPU, Memory, Input, and Output:
Method-2(a): Listing Linux services with pstree command
List of services running in a Linux system can be verified using the ‘pstree’ command as shown below.
Method-2(b): Listing Linux Services with chkservice command
chkservice is a new tool for managing systemd units in terminal. It requires super user privileges to manage the units.
To view the help page, hit ‘?’ button. This will show you available options to manage the systemd services.
Conclusion
This article explained several ways to check and list all running Linux services.
If you have any questions or feedback, feel free to comment below.
Источник
How to check running process in Linux using command line
I am a new system administrator for the Linux operating system. How do I check running process in Linux using the command line option?
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | Yes |
Requirements | Linux terminal |
Est. reading time | 4 mintues |
One can use the Linux command line or terminal app to display a running process, change their priorities level, delete process and more. This page shows how to use various commands to list, kill and manage process on Linux.
Check running process in Linux
The procedure to monitor the running process in Linux using the command line is as follows:
- Open the terminal window on Linux
- For remote Linux server use the ssh command for log in purpose
- Type the ps aux command to see all running process in Linux
- Alternatively, you can issue the top command or htop command to view running process in Linux
Let us see some example and usage in details.
Please note that vivek@nixcraft:
$ is my shell prompt. You need to type commands after the $ prompt.
How to manage processes from the Linux terminal
The ps command is a traditional Linux command to lists running processes. The following command shows all processes running on your Linux based server or system:
vivek@nixcraft:
$ ps -aux
vivek@nixcraft:
- root – User name
- 1 – PID (Linux process ID)
- 19:10 – Process start time
- /sbin/init splash – Actual process or command
There may be too many processes. Hence, it uses the following less command/more command as pipe to display process one screen at a time:
vivek@nixcraft:
$ ps -aux | more
vivek@nixcraft:
$ sudo ps -aux | less
Press q to exit from above Linux pagers. You can search for a particular Linux process using grep command/egrep command:
vivek@nixcraft:
$ ps aux | grep firefox
vivek@nixcraft:
$ sudo ps aux | grep vim
vivek@nixcraft:
$ sudo ps -aux | egrep ‘sshd|openvpn|nginx’
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
Linux pgrep command
Many variants of Linux comes with the pgrep command to search/find process. The syntax is:
vivek@nixcraft:
$ sudo pgrep sshd
vivek@nixcraft:
$ pgrep vim
vivek@nixcraft:
$ pgrep firefox
vivek@nixcraft:
Linux top command
The top command is another highly recommended method to see your Linux servers resource usage. One can see a list of top process that using the most memory or CPU or disk.
vivek@nixcraft:
$ sudo top
vivek@nixcraft:
Linux htop command to check running process in Linux
The htop command is an interactive process viewer and recommended method for Linux users. One can see a list of top process that using the most memory or CPU or disk and more:
vivek@nixcraft:
$ sudo htop
vivek@nixcraft:
Linux kill command
Want to kill a process? Try kill command. The syntax is:
vivek@nixcraft:
$ kill pid
vivek@nixcraft:
$ kill -signal pid
Find PID using ps, pgrep or top commands. Say you want to kill a PID # 16750, run:
vivek@nixcraft:
$ kill 16750
For some reason if the process can not be killed, try forceful killing:
vivek@nixcraft:
$ kill -9 16750
OR
vivek@nixcraft:
$ kill -KILL 16750
Linux pkill command
If you wish to kill a process by name, try pkill command. The syntax is:
vivek@nixcraft:
$ pkill processName
vivek@nixcraft:
$ pkill vim
vivek@nixcraft:
$ pkill firefox
vivek@nixcraft:
$ pkill -9 emacs
vivek@nixcraft:
$ sudo pkill -KILL php7-fpm
Linux killall command
The killall command kills processes by name, as opposed to the selection by PID as done by kill command:
vivek@nixcraft:
$ killall vim
vivek@nixcraft:
$ killall -9 emacs
Linux nice and renice command
The primary purpose of the nice command is to run a process/command at a lower or higher priority. Use the renice command to alter the nice value of one or more running Linux processes. The nice value can range from -20 to 19, with 19 being the lowest priority. Say, you want to compile software on a busy Linux server. You can set a very low priority, enter:
vivek@nixcraft:
$ nice -n 13 cc -c *.c &
Set a very high priority for a kernel update. Before rebooting Linux server, run:
Источник