ypchsh 未更改為某些 shell

ypchsh 未更改為某些 shell

我目前使用的是 bash,但我想將 shell 更改為 tcsh。我使用 ypchsh,在出現提示時輸入密碼,然後將登入 shell 變更為 /bin/tcsh。它似乎有效,因為我收到一條訊息,顯示「[網域] 上的登入 shell 已更改」。然後我登出並重新登入。但是,當我 echo $SHELL 時,我得到 /bin/tcsh。當我執行 ps 時,它顯示正在運行 bash 而不是 tcsh。

採取的其他故障排除步驟:嘗試執行相同的步驟切換到不同的 shell,例如 sh 和 ksh,這有效。但是,變更為 csh 給出的結果與嘗試變更為 tcsh 的結果相同。檢查 /etc/shells 並列出 tcsh。我也嘗試過 exec tcsh 但係統仍在運行 bash。

我正在嘗試在學校帳戶上執行此操作,因此可能存在權限問題。雖然我的一位同學能夠讓他的帳號更改外殼。如果沒有權限,是否有我需要設定的檔案?

[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。

相關內容