systemctl加上/bin/bash
时间: 2023-08-08 18:07:14 浏览: 49
对于CentOS 6.8系统来说,无法识别systemctl命令的原因是因为CentOS 6.X版本不支持安装firewall,而firewall是CentOS 7.X版本以后系统内置的。所以在CentOS 6.8系统中是无法使用systemctl命令的。如果你想在CentOS 6.8系统中使用systemctl命令,你可以尝试使用/bin/bash命令来替代systemctl命令。
#### 引用[.reference_title]
- *1* [-bash:systemctl:command not found【CentOS 6.8】](https://blog.csdn.net/qq_44079145/article/details/124538898)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关问题
容器内使用systemctl 命令时出现(System has not been booted with systemd as init system (PID 1). Can't operat....信息。
当在容器内使用systemctl命令时,可能会出现“System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down”这样的错误信息。这是因为容器内没有systemd进程作为init进程,而systemctl命令需要systemd进程作为init进程才能正常运行。解决这个问题的方法是在启动容器时加上--privileged参数,并在容器内运行systemd进程作为init进程。具体步骤如下:
1. 运行centos容器:docker run -itd --name centos centos /bin/bash
2. 停止并删除容器:docker stop centos && docker rm centos
3. 运行centos容器并获取systemd权限:docker run --privileged -itd --name centos centos /usr/sbin/init
4. 进入容器终端:docker exec -it centos /bin/bash
linux怎么让命令开机就加载
要让 Linux 命令开机自动加载,可以使用以下两种方法:
1. 使用 rc.local 文件
在 Linux 系统中,可以通过修改 `/etc/rc.local` 文件的方式,让命令在系统启动时自动执行。具体步骤如下:
1. 打开 `/etc/rc.local` 文件,输入要执行的命令,例如:
```
#!/bin/bash
/usr/bin/command
```
注意,必须在文件开头加上 `#!/bin/bash`,表示使用 bash 执行命令。
2. 将文件设置为可执行权限,输入以下命令:
```
sudo chmod +x /etc/rc.local
```
3. 重启系统,命令就会在系统启动时自动执行。
2. 使用 systemd 服务
在较新版本的 Linux 系统中,可以使用 systemd 服务来自动加载命令。具体步骤如下:
1. 创建一个新的服务文件,例如 `mycommand.service`,输入以下内容:
```
[Unit]
Description=My Command
[Service]
ExecStart=/usr/bin/command
Restart=always
[Install]
WantedBy=multi-user.target
```
其中,`ExecStart` 指定要执行的命令,`Restart` 表示命令出错时自动重启服务,`WantedBy` 表示服务要启动的目标。更多配置可以参考 systemd 文档。
2. 将服务文件保存在 `/etc/systemd/system/` 目录下。
3. 运行以下命令启动服务,并设置为开机自动启动:
```
sudo systemctl enable mycommand.service
sudo systemctl start mycommand.service
```
4. 重启系统,命令就会在系统启动时自动执行。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.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)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)