Debian 系统找不到基本命令的解决方法

您所在的位置:网站首页 好运达商业保险是什么保险啊 Debian 系统找不到基本命令的解决方法

Debian 系统找不到基本命令的解决方法

2023-09-09 16:49| 来源: 网络整理| 查看: 265

Debian9升级到Debian10后,运行了apt autoremove 命令后,发现系统存在很多问题,就连最基础的reboot、poweroff ,ifconfig 等命令都无法使用,如下

其实造成这个问题的原因是没有把 /sbin 的目录路径(系统用户目录)添加到$PATH变量中

查看当前$PATH

root@debian:/home/user# echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

如果没有 /sbin 可以使用命令

root@debian:/home/user# export PATH=$PATH:/sbin/ root@debian:/home/user#

临时把对应路劲加到$PATH变量中,测试一下是否可用。 但是这只是临时添加,断开ssh重连就失效了,需要永久添加需要编辑 .bashrc 文件(每个用户都有.bashrc 文件,想要每个用户都能正常使用命令,需要去编辑每个用户的 .bashrc 文件)

#切换到root目录 root@debian:/home/user# cd ~ root@debian:~# vim .bashrc

在最后一行添加

export PATH=$PATH:/usr/sbin # ~/.bashrc: executed by bash(1) for non-login shells. # Note: PS1 and umask are already set in /etc/profile. You should not # need this unless you want different defaults for root. # PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ ' # umask 022 # You may uncomment the following lines if you want `ls' to be colorized: # export LS_OPTIONS='--color=auto' # eval "`dircolors`" # alias ls='ls $LS_OPTIONS' # alias ll='ls $LS_OPTIONS -l' # alias l='ls $LS_OPTIONS -lA' # # Some more alias to avoid making mistakes: # alias rm='rm -i' # alias cp='cp -i' # alias mv='mv -i' export PATH=$PATH:/usr/sbin

保存后,执行一下

root@debian:~# source ~/.bashrc root@debian:~#

然后在重新查看一下$PATH变量

root@debian:~# echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/sbin

可以看到,多了个/usr/sbin

现在就可以正常的使用reboot、service等命令了。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3