.bash_profile
我的主目录中有一个,但它没有在登录时运行。如果我执行以下操作,那么事情似乎如我所料:
ssh myhost
bash
source ~/.bash_profile
Run Code Online (Sandbox Code Playgroud)
但通常这一切都发生在登录时。想法?
aki*_*ira 215
用:
chsh
Run Code Online (Sandbox Code Playgroud)
输入您的密码并说明您要使用的 shell 的路径。
对于 Bash,这将是/bin/bash
. 对于 Zsh,这将是/usr/bin/zsh
.
Joh*_*n T 43
除了 akira 的回答之外,您还可以编辑您的/etc/passwd文件以指定您的默认 shell。
你会发现像这个例子这样的一行:
john:x:1000:1000:john,,,:/home/john:/bin/sh
Run Code Online (Sandbox Code Playgroud)
外壳在最后指定。
小智 10
启用 bash:
$ /bin/bash
Run Code Online (Sandbox Code Playgroud)
为用户更改外壳:
$ sudo usermod -s /bin/bash username
Run Code Online (Sandbox Code Playgroud)
在哪里:
-s, --shell SHELL new login shell for the user account
Run Code Online (Sandbox Code Playgroud)
小智 7
如果您以某种方式在 /etc/passwd 文件中看不到您的用户名 [当您的系统受到其他域(例如 IT 公司)的控制时就会出现这种情况] 或者它显示“找不到用户”,并且带有chsh
以下选项的选项帮你。
以下技巧背后的逻辑 -> 在 Ubuntu 上,/bin/sh 是破折号。您可以将系统切换为使用 bash。在 Ubuntu 上,/bin/sh 是 dash 的符号链接。您可以将其设为 bash 的符号链接。要更改它,请运行
sudo dpkg-reconfigure dash
然后按否切换到bash。
现在,转到终端->编辑->首选项->命令并勾选带有语句的复选框
作为登录 shell 运行命令
就是这样。
您可能会检查您的终端程序。它可能被配置为运行 /bin/sh 而不是 /bin/bash
Bash 仅对登录会话执行 .bash_profile。.bashrc 为所有 bash 会话执行,而不仅仅是登录会话。尝试从 .bashrc 获取 .bash_profile (避免循环依赖!)或配置您的终端程序以将 /bin/bash -l 作为 shell 程序运行。
要将任何 shell 设置为默认 shell,请首先通过查看以下内容来验证它是否已安装并在您的计算机上被识别/etc/shells
:
$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/bin/dash
/usr/bin/dash
/usr/bin/fish
Run Code Online (Sandbox Code Playgroud)
然后使用chsh
来改变你的外壳:
$ sudo chsh -s /usr/bin/bash $(whoami) # or sudo chsh -s /bin/bash $(whoami)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
172473 次 |
最近记录: |