"bash:shutdown:command not found"或"bash:reboot:command not found"的解决方法

解决“bash:reboot:找不到命令”的问题

在虚拟机装了个Debian,结果被关机重启命令给弄懵了,能用systemctl reboot命令来重启,reboot不行。
查了一下:reboot只是一个 systemctl reboot的一个连接,所以,当执行reboot时,其实就是执行 systemctl reboot.

网上有说改.bash_profile的,但我debian-4.19.0-8-amd64版本
里面没有.bash_profile文件

所以用到/etc/profile来修改环境变量
但必须用sudo执行(比如sudo + reboot/shutdown/halt)

whereis reboot(找到reboot的文件路径)
reboot的文件路径

找到/etc/profile 这个配置文件后,进入文件改写
sudo vim /etc/profile

加入下面这句话
export PATH=$PATH:xxx(xxx是你的reboot文件的目录路径)
比如上面图片中我的reboot文件路径是/usr/sbin

保存退出后别忘了source /etc/profile

然后sudo reboot就行了

换做shutdown也类似

whereis shutdown(找到shutdown的文件路径)
shutdown的文件路径

找到/etc/profile 这个配置文件后,进入文件改写
sudo vim /etc/profile

加入下面这句话
export PATH=$PATH:xxx(xxx是你的shutdown文件的目录路径)
比如上面图片中我的shutdown文件路径是/usr/sbin

扫描二维码关注公众号,回复: 11314731 查看本文章

保存退出后别忘了source /etc/profile

然后sudo shutdown就行了

其他的关机重启命令:init 0(关机),init 6(重启)

猜你喜欢

转载自blog.csdn.net/bell_love/article/details/105320031