Linux 操作source /etc/profile 失败

2,707 阅读1分钟

问题产生

在Linux /etc/profile配置环境变量后,去执行source时,会报异常 'case' builtin not inside of switch block

root# source /etc/profile
'case' builtin not inside of switch block
/etc/profile (line 12): case ":${PATH}:" in
^
from sourcing file /etc/profile
called on standard input

source: Error while reading file “/etc/profile”

原因时shell fish导致早成的,需要切换shell

解决方案

修改linux 默认SHELL

1.命令:chsh -l ,结果如下:

/bin/sh /bin/bash /sbin/nologin /usr/bin/sh /usr/bin/bash /usr/sbin/nologin /usr/bin/fish

2.设置默认shell

chsh -s /usr/bin/fish 输入管理员密码