1. View running services in Linux server
1. Use the systemctl command
In modern Linux systems, most system services aresystemd
manage. You can usesystemctl
Command to view the running service.
View all active services:
systemctl list-units --type=service
This command lists all services, including their status (such as running, stopped, etc.).
View running services:
systemctl --type=service --state=running
This command will only list the currently running services.
2. Use the service command (for older Linux distributions)
For some older Linux versions (such as CentOS 6 and earlier), you can useservice
Command to view the status of the service.
Check service status:
service --status-all
This command lists all services and displays their status (for example, running, stopped).
3. Use the ps command
If you want to view the running processes on your system, you can useps
Order.
View all processes:
ps aux
This command lists all processes on the system, including services, background tasks, etc.
Check the process of a service:
If you only care about a specific service, you cangrep
To filter the process list:
ps aux | grep <service_name>
For example, viewnginx
process:
ps aux | grep nginx
4. Use netstat to view network services
If you want to see which services are listening to ports and communicating with external networks, you can usenetstat
Order.
netstat -tuln
This lists all ports listened under TCP and UDP protocols and their corresponding services.
5. Use the top or htop command
top
andhtop
The command provides dynamically displayed resource usage to help you view services and processes running on the server.
top
Or, if you installed ithtop
:
htop
htop
It provides a more friendly interactive interface that can help you view the resource usage of the service.
2. Check the running services in the Windows server
1. Use the Task Manager
On a Windows server, you can view the running services through Task Manager.
- according to
Ctrl + Shift + Esc
Open Task Manager, or right-click the taskbar and select "Task Manager". - Switch to the Services tab, where you can see all the running services.
- You can right-click on the service and select Start, Stop, or Restart.
2. Use
You can passCommand to view all services and their status.
- according to
Win + R
Key, enterAnd press Enter.
- This will open the Services window where you can view all services, including their names, descriptions, statuses, etc.
3. Use PowerShell commands
You can also view services through the PowerShell command.
View all services:
Get-Service
Check the status of a service:
Get-Service -Name <ServiceName>
For example, viewwuauserv
Service status:
Get-Service -Name wuauserv
View running services:
Get-Service | Where-Object {$_.Status -eq 'Running'}
4. Use netstat to view ports and services
You can also passnetstat
Command to view the network service.
Open a command prompt (cmd) and enter the following command:
netstat -ano
This command will list all ports and corresponding service IDs, you can use it furthertasklist
The command combines PID to find which process is using which port:
tasklist | findstr <PID>
3. Summary
Whether you are using Linux or Windows operating systems, it is a common task to view services running on cloud servers. Depending on the operating system, you can use different commands to check the running service:
- existLinuxIn the system,
systemctl
、service
、ps
andnetstat
It is a commonly used command to view services. - existWindowsIn the system, you can use the task manager,
, PowerShell and
netstat
Command to view services and ports.
Understanding these commands can help you monitor the status of the server and promptly troubleshoot and deal with problems on the server.
The above is the detailed content of the method to view running services in the Linux server. For more information about viewing running services in Linux, please follow my other related articles!