在 CentOS 中,“替换默认 Shell”通常有两层含义,下面分别说明。
echo $SHELL
cat /etc/shells
常见有:
/bin/bash/bin/zsh/bin/fish/sbin/nologinchsh -s /bin/zsh
修改后 重新登录 或重启终端生效
编辑:
vipw
或修改:
/etc/passwd
例如:
user:x:1000:1000::/home/user:/bin/zsh
useradd -D -s /bin/zsh
验证:
useradd -D
vi /etc/default/useradd
修改:
SHELL=/bin/zsh
chsh -s /bin/zsh root
或:
vipw
将 root 行改为:
root:x:0:0:root:/root:/bin/zsh
⚠️ 注意:root 的 Shell 必须是 /etc/shells 中存在的,否则可能导致无法登录。
su 而非 su -su - 用户名
yum install -y zsh
chsh -s /bin/zsh
如果你是指:
可以告诉我具体场景,我可以给你更精确的方案。