How to check if a particular service is running on Ubuntu

前端 未结 13 1895
猫巷女王i
猫巷女王i 2021-01-29 17:48

I do not know the service\'s name, but would like to stop the service by checking its status.

For example, if I want to check if the PostgreSQL service is running or no

13条回答
  •  不思量自难忘°
    2021-01-29 18:07

    To check the status of a service on linux operating system :

    //in case of super user(admin) requires    
    sudo service {service_name} status 
    // in case of normal user
    service {service_name} status 
    

    To stop or start service

    // in case of admin requires
    sudo service {service_name} start/stop
    // in case of normal user
    service {service_name} start/stop 
    

    To get the list of all services along with PID :

    sudo service --status-all
    

    You can use systemctl instead of directly calling service :

    systemctl status/start/stop {service_name}
    

提交回复
热议问题