更改 Linux 中的默认 shell

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13046192/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 17:35:34  来源:igfitidea点击:

Changing default shell in Linux

linuxbashshellenvironmenttcsh

提问by mahmood

How is it possible to change the default shell? The envcommand currently says:

如何更改默认外壳?该env命令目前说:

SHELL=/bin/tcsh

and I want to change that to Bash.

我想把它改成 Bash。

采纳答案by Summer_More_More_Tea

Try linux command chsh.

试试 linux 命令chsh

The detailed command is chsh -s /bin/bash. It will prompt you to enter your password. Your default login shell is /bin/bashnow. You must log out and log back in to see this change.

详细命令是chsh -s /bin/bash. 它会提示您输入密码。您的默认登录 shell/bin/bash现在是。您必须注销并重新登录才能看到此更改。

The following is quoted from man page:

以下引用自手册页:

The chsh command changes the user login shell. This determines the name of the users initial login command. A normal user may only change the login shell for her own account, the superuser may change the login shell for any account

chsh 命令更改用户登录 shell。这决定了用户初始登录命令的名称。普通用户只能修改自己账户的登录shell,超级用户可以修改任何账户的登录shell

This command will change the default login shell permanently.

此命令将永久更改默认登录 shell。

Note: If your user account is remote such as on Kerberos authentication (e.g. Enterprise RHEL) then you will not be able to use chsh.

注意:如果您的用户帐户是远程的,例如 Kerberos 身份验证(例如 Enterprise RHEL),那么您将无法使用chsh.

回答by arkascha

You should have a 'skeleton' somewhere in /etc, probably /etc/skeleton, or check the default settings, probably /etc/defaultor something. Those are scripts that define standard environment variables getting set during a login.

您应该在/etc,可能 中的某处有一个“骨架” /etc/skeleton,或者检查默认设置,可能/etc/default或其他。这些是定义在登录期间设置的标准环境变量的脚本。

If it is just for your own account: check the (hidden) file ~/.profileand ~/.login. Or generate them, if they don't exist. These are also evaluated by the login process.

如果仅用于您自己的帐户:检查(隐藏)文件~/.profile~/.login. 或者生成它们,如果它们不存在。这些也由登录过程评估。

回答by Desert Ice

You can change the passwd file directly for the particular user or use the below command

您可以直接为特定用户更改密码文件或使用以下命令

chsh -s /usr/local/bin/bash username

Then log out and log in

然后注销并登录