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
the best way is using of nmap
tool in terminal.
nmap is an useful tool that analyse an up system, using it's IP Address
, then show all actived network services
.
open terminal
and use of this example :
~$ nmap 192.168.1.3/24
Starting Nmap 5.21 ( http://nmap.org ) at 2016-05-16 22:49 IRDT
Nmap scan report for 192.168.1.3
Host is up (0.00020s latency).
Not shown: 994 closed ports
PORT STATE SERVICE
22/tcp open ssh
23/tcp open telnet
139/tcp open netbios-ssn
445/tcp open microsoft-ds
3389/tcp open ms-term-serv
3689/tcp open rendezvous
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}
For Ubuntu (checked with 12.04)
You can get list of all services and select by color one of them with 'grep':
sudo service --status-all | grep postgres
Or you may use another way if you know correct name of service:
sudo service postgresql status
run
ps -ef | grep name-related-to-process
above command will give all the details like pid, start time about the process.
like if you want all java realted process give java or if you have name of process place the name
I don't have an Ubuntu box, but on Red Hat Linux you can see all running services by running the following command:
service --status-all
On the list the +
indicates the service is running, -
indicates service is not running, ?
indicates the service state cannot be determined.
for Centos 6.10 :
/sbin/service serviceNAME status
for Centos 7.6 and ubuntu 18.04:
systemctl status NAME.service
works for all of them:
service --status-all