Ubuntu 18.04 中 update-rc.d 还能继续使用吗
时间: 2024-06-05 13:10:20 浏览: 21
在 Ubuntu 18.04 中,`update-rc.d`命令仍然可以使用。该命令用于管理系统启动时运行的服务。但是,从 Ubuntu 16.04 开始,Ubuntu 已经采用了 Systemd 作为默认的系统初始化系统,因此推荐使用 `systemctl` 命令来管理服务。如果您想使用 `update-rc.d` 命令,请确保在使用之前安装了 `sysv-rc-conf` 软件包。
相关问题
ubuntu 18.04 update-rc.d xcenter.sh defaults 90 为什么不生效
在 Ubuntu 18.04 中,使用 `update-rc.d` 命令添加服务的方式已经过时了,现在使用 `systemd` 来管理服务。因此,如果你想在系统启动时运行 `xcenter.sh` 脚本,你需要创建一个 systemd 服务单元文件。
以下是如何创建一个 systemd 服务单元文件的步骤:
1. 创建一个名为 `xcenter.service` 的服务单元文件,可以使用 `sudo` 来创建:
```
sudo nano /etc/systemd/system/xcenter.service
```
2. 在服务单元文件中添加以下内容:
```
[Unit]
Description=XCenter Service
After=network.target
[Service]
ExecStart=/path/to/xcenter.sh
[Install]
WantedBy=multi-user.target
```
其中,`Description` 字段是你的服务的描述,`After` 字段表示服务应该在网络启动后运行,`ExecStart` 字段是你要运行的脚本的绝对路径,`WantedBy` 字段表示服务应该在 multi-user.target 启动时运行。
3. 启用服务:
```
sudo systemctl enable xcenter.service
```
4. 启动服务:
```
sudo systemctl start xcenter.service
```
现在,你的 `xcenter.sh` 脚本应该在系统启动时运行了。你可以使用 `sudo systemctl status xcenter.service` 命令来检查服务的状态。
ubuntu18.04开机启动脚本优先级设置
在 Ubuntu 18.04 中,开机启动脚本的优先级可以通过以下步骤进行设置:
1. 打开终端,输入命令 `sudo update-rc.d -f your_script_name remove`,将原有的开机启动脚本从系统中删除。
2. 编辑新的开机启动脚本文件 `your_script_name`,并将其拷贝到 `/etc/init.d/` 目录下。
3. 在终端中运行命令 `sudo chmod +x /etc/init.d/your_script_name`,给新的开机启动脚本文件赋予可执行权限。
4. 运行命令 `sudo update-rc.d your_script_name defaults`,将新的开机启动脚本添加到系统中。
5. 运行命令 `sudo update-rc.d your_script_name enable`,启用新的开机启动脚本。
6. 重启系统,新的开机启动脚本即可按照设定的优先级执行。
注意:在步骤1中,`your_script_name` 指的是原有的开机启动脚本文件名称。在步骤2和3中,`your_script_name` 指的是新的开机启动脚本文件名称。
相关推荐
![torrent](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![iso](https://img-home.csdnimg.cn/images/20210720083646.png)
![iso](https://img-home.csdnimg.cn/images/20210720083646.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)