centos7 init.d 和system.d

总结先说:

  • systemd 替代了传统的 init.d 脚本,管理服务更高效。
  • 可以通过 systemctl 命令执行服务的启动、停止、启用和禁用等操作。
  • 旧的 init.d 脚本仍兼容,但推荐迁移到 systemd
  • 通过 man 和在线文档学习更多 systemd 的高级功能。

root@bogon init.d\]# more README You are looking for the traditional init scripts in /etc/rc.d/init.d, and they are gone? Here's an explanation on what's going on: You are running a systemd-based OS where traditional init scripts have been replaced by native systemd services files. Service files provide very similar functionality to init scripts. To make use of service files simply invoke "systemctl", which will output a list of all currently running services (and other units). Use "systemctl list-unit-files" to get a listing of all known unit files, including stopped, disabled and masked ones. Use "systemctl start foobar.service" and "systemctl stop foobar.service" to start or stop a service, respectively. For further details, please refer to systemctl(1). Note that traditional init scripts continue to function on a systemd system. An init script /etc/rc.d/init.d/foobar is implicitly mapped into a service unit foobar.service during system initialization. Thank you! Further reading: man:systemctl(1) man:systemd(1) http://0pointer.de/blog/projects/systemd-for-admins-3.html http://www.freedesktop.org/wiki/Software/systemd/Incompatibilities \[root@bogon init.d\]# 这份 `README` 文件是对传统 `init.d` 脚本在现代 `systemd` 系统中被替换的说明,以下是解析和解释: 在 `systemd` 取代传统的 SysVinit 后,旧式的 `/etc/rc.d/init.d` 脚本功能由 `systemd` 的 **unit 文件** 替代。也就是说,`init.d` 脚本不再是服务管理的主要工具。 ##### **传统 `init.d` 脚本去哪里了?** > **"You are looking for the traditional init scripts in /etc/rc.d/init.d, and they are gone?"** 在 `systemd` 取代传统的 SysVinit 后,旧式的 `/etc/rc.d/init.d` 脚本功能由 `systemd` 的 **unit 文件** 替代。也就是说,`init.d` 脚本不再是服务管理的主要工具。 ##### **`systemd` 的作用** > **"You are running a systemd-based OS where traditional init scripts have been replaced by native systemd services files."** `systemd` 是现代 Linux 系统的默认初始化系统(init system),提供以下功能: * 更快的启动速度。 * 更高效的并行任务处理。 * 强大的日志和依赖管理。 传统的 init 脚本功能被 **systemd 服务文件** 替代,这些服务文件比 init 脚本更灵活和高效。 ##### **如何使用 `systemd`** > **"Service files provide very similar functionality to init scripts. To make use of service files simply invoke 'systemctl'..."** `systemd` 通过 `systemctl` 命令管理服务,可以执行以下操作: 1. **列出当前运行的服务:** ##### **兼容传统 `init.d` 脚本** > **"Note that traditional init scripts continue to function on a systemd system."** 虽然 `systemd` 主要使用服务文件,但它仍然兼容传统的 `init.d` 脚本: * 位于 `/etc/rc.d/init.d/` 的脚本会被自动映射为 `foobar.service`。 * 您仍然可以通过 `service` 命令管理旧的 `init.d` 脚本,例如: 这份 `README` 文件是对传统 `init.d` 脚本在现代 `systemd` 系统中被替换的说明,以下是解析和解释: *** ** * ** *** #### 内容逐段解读 ##### **传统 `init.d` 脚本去哪里了?** > **"You are looking for the traditional init scripts in /etc/rc.d/init.d, and they are gone?"** 在 `systemd` 取代传统的 SysVinit 后,旧式的 `/etc/rc.d/init.d` 脚本功能由 `systemd` 的 **unit 文件** 替代。也就是说,`init.d` 脚本不再是服务管理的主要工具。 *** ** * ** *** ##### **`systemd` 的作用** > **"You are running a systemd-based OS where traditional init scripts have been replaced by native systemd services files."** `systemd` 是现代 Linux 系统的默认初始化系统(init system),提供以下功能: * 更快的启动速度。 * 更高效的并行任务处理。 * 强大的日志和依赖管理。 传统的 init 脚本功能被 **systemd 服务文件** 替代,这些服务文件比 init 脚本更灵活和高效。 *** ** * ** *** ##### **如何使用 `systemd`** > **"Service files provide very similar functionality to init scripts. To make use of service files simply invoke 'systemctl'..."** `systemd` 通过 `systemctl` 命令管理服务,可以执行以下操作: 1. **列出当前运行的服务:** ``` ``` bash 复制代码 `systemctl ` 2. **列出所有已知服务(包括停止或禁用的服务):** ``` ``` bash 复制代码 `systemctl list-unit-files ` 3. **启动服务:** ``` ``` bash 复制代码 `systemctl start foobar.service ` 4. **停止服务:** ``` ``` bash 复制代码 `systemctl stop foobar.service ` 5. **启用开机启动:** ``` ``` bash 复制代码 `systemctl enable foobar.service ` 6. **禁用开机启动:** ``` ``` bash 复制代码 `systemctl disable foobar.service ` *** ** * ** *** ##### **兼容传统 `init.d` 脚本** > **"Note that traditional init scripts continue to function on a systemd system."** 虽然 `systemd` 主要使用服务文件,但它仍然兼容传统的 `init.d` 脚本: * 位于 `/etc/rc.d/init.d/` 的脚本会被自动映射为 `foobar.service`。 * 您仍然可以通过 `service` 命令管理旧的 `init.d` 脚本,例如: ``` ``` bash 复制代码 `service foobar start ` *** ** * ** *** ##### **进一步阅读** * **`man:systemctl(1)`** : 查看 `systemctl` 的手册页。 * **`man:systemd(1)`** : 查看 `systemd` 的手册页。 * **在线文档:** * [Systemd for Administrators](http://0pointer.de/blog/projects/systemd-for-admins-3.html "Systemd for Administrators") * [Systemd Incompatibilities](http://www.freedesktop.org/wiki/Software/systemd/Incompatibilities "Systemd Incompatibilities")

相关推荐
lgily-12252 分钟前
Linux机器测试IP及端口连通性方法记录
linux·运维·tcp/ip
weixin_贾21 分钟前
【海洋建模实战】从0到1掌握ROMS全流程!Linux开发+多尺度耦合+风暴潮模拟
linux·拉格朗日·roms·风暴潮耦合模拟·粒子追踪模拟
_zwy1 小时前
【Linux 进程控制】—— 进程亦生生不息:起于鸿蒙,守若空谷,归于太虚
linux·运维·服务器·c++
杨凯凡1 小时前
Linux目录探秘:文件系统的核心架构
linux·运维·服务器·架构
陆沙3 小时前
centos-LLM-生物信息-BioGPT-使用1
linux·centos·aigc·生物信息·生信
俺不是文盲3 小时前
Linux驱动开发:SPI设备树处理过程
linux·驱动开发
等等,要下雨4 小时前
linux安装ollama
linux·运维·服务器
Starry_hello world8 小时前
Linux 的准备工作
linux·笔记·有问必答
_考不上研究生不改名9 小时前
【完美解决】VSCode连接HPC节点,已配置密钥却还是提示需要输入密码
linux·服务器·vscode·远程连接·hpc·超算集群
_长银10 小时前
Vim搜索和替换
linux·编辑器·vim