- Background Process: Runs in the background without user intervention, unlike typical applications.
- System Management: Manages essential functions like networking, storage, logging, etc.
- Controlled by Init Systems: Managed by an init system like
systemd,upstart, orSysVinit, which controls the starting, stopping, and restarting of services. - Configuration and Logs: Usually have configuration files in
/etcand log files in/var/log.
SysVinit is an older service management system used in Debian-based and other older Linux distributions.
cd /etc/init.d/
ls -lh /etc/init.d/cat /etc/init.d/<service-name>Example:
cat /etc/init.d/apache2/etc/init.d/apache2 status/etc/init.d/apache2 start
/etc/init.d/apache2 stop/etc/init.d/apache2 restart/etc/init.d/apache2 force-reloadFor older Linux distributions that use init.d or SysVinit instead of systemd:
service <service_name> statusExample:
service apache2 statusservice <service_name> startExample:
service apache2 startservice <service_name> stopExample:
service apache2 stopservice <service_name> restartExample:
service apache2 restartservice apache2 reloadsystemctl is used in modern Linux distributions (Debian 8+, Ubuntu 15.04+, CentOS 7+, RHEL 7+).
yum install httpd*systemctl status <service_name>Example:
systemctl status apache2systemctl start <service_name>
systemctl stop <service_name>systemctl restart <service_name>systemctl reload <service_name>systemctl enable <service_name>systemctl disable <service_name>systemctl is-enabled <service_name>systemctl list-units --type=service --state=running
systemctl list-units --type=service --state=failedMasking prevents a service from running:
systemctl mask <service_name>Unmasking re-enables a service:
systemctl unmask <service_name>journalctl -u <service_name>Example:
journalctl -u httpd.servicejournalctl -u httpd.service --since "1 hour ago"journalctl -u httpd.service -fsystemctl rebootsystemctl poweroffsystemctl suspendsystemctl hibernateModern Linux distributions use systemd, replacing SysVinit. Instead of /etc/init.d/, use:
systemctl start apache2
systemctl stop apache2
systemctl restart apache2
systemctl status apache2
systemctl enable apache2
systemctl disable apache2