ypchsh 不会更改为某些 shell

ypchsh 不会更改为某些 shell

我目前处于 bash 状态,但我想将我的 shell 更改为 tcsh。我使用了 ypchsh,在提示时输入密码,然后将登录 shell 更改为 /bin/tcsh。它似乎有效,因为我收到一条消息,提示“登录 shell 已在 [域] 上更改”。然后我注销并重新登录。我执行了 echo $0 来检查我当前的 shell,但它显示我仍在 /bin/bash 中。但是,当我执行 echo $SHELL 时,我得到的是 /bin/tcsh。当我执行 ps 时,它显示正在运行的是 bash,而不是 tcsh。

采取的其他故障排除步骤:尝试执行相同的步骤以切换到不同的 shell,例如 sh 和 ksh,效果不错。但是,更改为 csh 得到的结果与尝试更改为 tcsh 的结果相同。检查了 /etc/shells 并列出了 tcsh。我还尝试了 exec tcsh,但系统仍在运行 bash。

我正在尝试在学校帐户上执行此操作,因此可能存在权限问题。尽管我的一个同学能够让他的帐户更改 shell。如果没有权限,是否有我需要配置的文件?

[user@machine ~]> echo $0
/bin/bash
[user@machine ~]> echo $SHELL
/bin/tcsh
[user@machine ~]> ypchsh
Changing NIS account information for user on machine
Please enter password:

Changing login shell for user on machine
To accept the default, simply press return. To use the
system's default shell, type the word "none".
Login shell [/bin/tcsh]: /bin/tcsh

The login shell has been changed on machine

[user@machine ~]> logout

[user@machine ~]> echo $0
/bin/bash
[user@machine ~]> echo $SHELL
/bin/tcsh
[user@machine ~]> FOO=BAR
[user@machine ~]> ps
  PID TTY          TIME CMD
14549 pts/21   00:00:00 bash
14780 pts/21   00:00:00 ps
[user@machine ~]> exec /bin/tcsh
[user@machine ~]> echo $0
/bin/bash
[user@machine ~]> echo $SHELL
/bin/tcsh
[user@machine ~]> FOO=BAR
[user@machine ~]>

[user@machine ~]> uname -a
Linux machine 2.6.32-696.3.2.el6.i686 #1 SMP Tue Jun 20 00:48:23 UTC 2017 i686 i686 i386 GNU/Linux
[user@machine ~]> /bin/ls -ld
drwx--s--x 49 user group 4096 Sep  1 13:08 .
[user@machine ~]> /bin/*sh
/bin/csh: /bin/csh: cannot execute binary file
[user@machine ~]> /usr/bin/*sh
Usage: amuFormat.sh <Card Type> <drive>
<Card Type> has to be defined in amuFormat.sh itself
<drive> has to be defined in mtools.conf

答案1

我的 shell 不断返回 bash 甚至阻止我使用 exec 进入 tcsh 的原因是因为 .cshrc 文件中有一行内容exec /bin/bash -l。为了解决这个问题,我删除了该行,从此我可以切换 shell。

相关内容