操作系统之系统服务(system service)

610 阅读2分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路。 系统服务(system services)是指执行指定系统功能的程序、例程或进程,以便支持其他程序,尤其是底层(接近硬件)程序。

os主要服务 服务是每次开机会按照服务启动模式启动的进程的集合,服务可能包括很多进程。而且启动的进程可能是互相交叉的

pstree 命令是以树形结构显示程序和进程之间的关系,此命令的基本格式如下:
service命令,顾名思义,就是用于管理Linux操作系统中服务的命令。 系统服务是在后台运行的应用程序,并且可以提供一些本地系统或网络的功能。我们把这些应用程序称作服务,也就是 Service。不过,我们有时会看到 Daemon 的叫法,Daemon 的英文原意是"守护神",在这里是"守护进程"的意思。

那么,什么是守护进程?它和服务又有什么关系呢?守护进程就是为了实现服务、功能的进程。比如,我们的 apache 服务就是服务(Service),它是用来实现 Web 服务的。那么,启动 apache 服务的进程是哪个进程呢?就是 httpd 这个守护进程(Daemon)。也就是说,守护进程就是服务在后台运行的真实进程。

如果我们分不清服务和守护进程,那么也没有什么关系,可以把服务与守护进程等同起来。在 Linux 中就是通过启动 httpd 进程来启动 apache 服务的,你可以把 httpd 进程当作 apache 服务的别名来理解。 查看当前服务器所有服务:service --status-all [ + ] acpid [ - ] alsa-utils [ - ] apparmor [ + ] atd [ + ] auditd [ + ] avahi-daemon [ + ] bluetooth [ - ] bootmisc.sh [ - ] checkfs.sh [ - ] checkroot-bootclean.sh [ - ] checkroot.sh [ + ] console-setup [ + ] cpufrequtils [ + ] cron [ - ] cryptdisks [ - ] cryptdisks-early [ + ] cups [ + ] cups-browsed [ + ] dbus [ + ] grub-common [ - ] hostname.sh [ - ] hwclock.sh [ - ] killprocs [ + ] kmod [ + ] lightdm [ + ] lm-sensors [ + ] loadcpufreq [ - ] mcstrans [ - ] mountall-bootclean.sh [ - ] mountall.sh [ - ] mountdevsubfs.sh [ - ] mountkernfs.sh [ - ] mountnfs-bootclean.sh [ - ] mountnfs.sh [ + ] network-manager [ + ] networking [ + ] nmbd [ - ] ondemand [ - ] plymouth [ - ] plymouth-log [ - ] pppd-dns [ + ] procps [ + ] rc.local [ - ] restorecond [ - ] rpcbind [ - ] rsync [ + ] rsyslog [ + ] samba [ + ] samba-ad-dc [ + ] sendmail [ - ] sendsigs [ + ] smbd [ + ] ssh [ + ] udev [ - ] umountfs [ - ] umountnfs.sh [ - ] umountroot [ + ] urandom [ - ] uuidd wsl上操作:

sun@DESKTOP-24LRVMT:~$ service --status-all [ - ] apparmor [ ? ] apport [ - ] atd [ - ] console-setup.sh [ - ] cron [ ? ] cryptdisks [ ? ] cryptdisks-early [ - ] dbus [ ? ] hwclock.sh [ + ] irqbalance [ - ] iscsid [ - ] keyboard-setup.sh [ ? ] kmod [ - ] lvm2 [ - ] lvm2-lvmpolld [ - ] multipath-tools [ + ] open-iscsi [ - ] open-vm-tools [ ? ] plymouth [ ? ] plymouth-log [ - ] procps [ - ] rsync [ - ] rsyslog [ - ] screen-cleanup [ - ] ssh [ + ] udev [ - ] ufw [ - ] unattended-upgrades [ - ] uuidd [ - ] x11-common

The status is [ + ] for running services, [ - ] for stopped services and [ ? ] for services without a 'status' command.
复制自 man service

[root@localhost ~]# pstree [选项] [PID或用户名]

主要服务列表:

网络服务:network-manager
进程间的通信服务:dbus
日志管理:rsyslog
定时周期任务服务:cron
网络安全协议服务:ssh
设备管理服务:udev
安全审计服务: auditd
定时执行服务:atd
零配置网络服务:avahi-daemon
GRUB启动记录服务:grub-common
CPU主板监控服务:lm-sensors
桌面显示管理服务:lightdm
监视和终止系统进程服务: procps
samba服务
urandom服务
rc.local服务
    
    network-manager	网络服务