Summer training at Goeduhub Technologies-Jaipur
Register for Free Certified Workshop on RTU Python Lab (VI SEM):: 01-03-2020 ||  Career options for aspiring CS/ITECEEE or EIC or EEE Engineers
0 like 0 dislike
4 views
in Tutorial & Interview questions by Summer Trainee (7k points)

1 Answer

0 like 0 dislike
by Summer Trainee (7k points)
 
Best answer

List running service on Ubuntu

To get a list of the service on your system, you may run:

service --status-all

The output of service --status-all lists the state of services controlled by System V.

The + indicates the service is running, - indicates a stopped service. You can see this by running service SERVICENAME status for a + and - service.

Some services are managed by Upstart. You can check the status of all Upstart services with sudo initctl list. Any service managed by Upstart will also show in the list provided by service --status-all but will be marked with a ?.

ref: https://askubuntu.com/questions/407075/how-to-read-service-status-all-results

Systemd service management 

Listing services

systemctl To list running services

systemctl --failed To list failed services

Managing Targets (Similar to Runlevels in SysV)

systemctl get-default To find the default target for your system

systemctl set-default <target-name> To set the default target for your system

Managing services at runtime

systemctl start [service-name] To start a service

systemctl stop [service-name] To stop a service

systemctl restart [service-name] To restart a service

systemctl reload [service-name] To request service to reload its configuration

systemctl status [service-name] To show current status of a service

Managing autostart of services

systemctl is-enabled [service-name] To show whether a service is enabled on system boot

systemctl is-active [service-name] To show whether a service is currently active(running)

systemctl enable [service-name] To enable a service on system boot

systemctl disable [service-name] To disable a service on system boot

Masking services

systemctl mask [service-name] To mask a service (Makes it hard to start a service by mistake)

systemctl unmask [service-name] To unmask a service

Restarting systemd

systemctl daemon-reload


Managing Services

Diagnosing a problem with a service
On systems using systemd, such as Fedora => 15, Ubuntu (Server and Desktop) >= 15.04, and RHEL/CentOS >= 7:
systemctl status [servicename]
...where [servicename] is the service in question; for example, systemctl status sshd.
This will show basic status information and any recent errors logged.
You can see further errors with journalctl. For example,journalctl -xe will load the last 1000 logged into a pager (like less), jumping to the end. You can also use journalctl -f, which will follow log messages as they come in.
To see logs for a particular service, use the -t flag, like this:
journalctl -f -t sshd
Other handy options include -p for priority (-p warnings to see only warnings and above), -b for "since last boot", and -S for "since" — putting that together, we might do
journalctl -p err -S yesterday

to see all items logged as errors since yesterday.

If journalctl is not available, or if you are following application error logs which do not use the system journal, the tail command can be used to show the last few lines of a file. A useful flag for tail is -f (for "follow"), which causes tail continue showing data as it gets appended to the file. To see messages from most services on the system:

tail -f /var/log/messages

Or, if the service is privileged, and may log sensitive data:

tail -f /var/log/secure

Some services have their own log files, a good example is auditd, the linux auditing daemon, which has its logs stored in /var/log/audit/. If you do not see output from your service in /var/log/messages try looking for service specific logs in /var/log/ 

Starting and Stopping Services

On systems that use the System-V style init scripts, such as RHEL/CentOS 6:
service <service> start
service <service> stop
On systems using systemd, such as Ubuntu (Server and Desktop) >= 15.04, and RHEL/CentOS >= 7:
systemctl <service> dnsmasq
systemctl <service> dnsmasq

Getting the status of a service 

On systems that use the System-V style init scripts, such as RHEL/CentOS 6:
service <service> status
On systems using systemd, such as Ubuntu (Server and Desktop) >= 15.04, and RHEL/CentOS >= 7.0:
systemctl status <service>

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Nov 2, 2019 in Tutorial & Interview questions by Goeduhub Summer Trainee (7k points)
0 like 0 dislike
1 answer
asked Nov 2, 2019 in Tutorial & Interview questions by Goeduhub Summer Trainee (7k points)
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Nov 2, 2019 in Tutorial & Interview questions by Goeduhub Summer Trainee (7k points)
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
 Go to your Branch CSE or IT | ECE | EE, EIC or EEEMECE
 Know About Popular Colleges/Universities  List of IITsList of NITs | RTU-KOTA | Manipal University-Jaipur | JECRC University | Amity University Jaipur | BIT Mesra-Jaipur | MODY UNIVERSITY | LNMIIT-Jaipur | JK Lakshmipat | Banasthali Vidyapith | POORNIMA University
 Exams:   List of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG) | JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs
Placements:  List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Online Free Training:  Artificial Intelligence(AI) & Machine Learning(ML)Python Programming | Internet of Things-IoT | OpenCV (Open Source Computer Vision Library) | LINUX | Big Data : Hadoop | 
 Goeduhub
About Us | Contact Us   Social::   |  | 
...