问题信息
虚拟机中新安装的Linux系统(debian12)找不到指令,例如 usermod。
配置信息
- Linux peag-k8s-master 6.1.0-17-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.69-1 (2023-12-30) x86_64 GNU/Linux
问题原因
环境变量PATH中未配置统管理员使用的系统命令和工具所在的目录 /usr/sbin
。
解决方案
在 root 用户目录下的 .bashrc
文件中配置统管理员使用的系统命令和工具所在的目录至PATH
环境变量
- 登录至
root
用户
$ su root
- 进入
root
用户目录
# cd
~#
- 修改
.bashrc
文件
~# nano .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
至此配置完成~