Joh*_*ith 6 command-line adduser home-directory username
这里有一个希望很简单的方法,我不知道为什么添加新帐户并登录时 $ 上没有用户名?
Welcome to Ubuntu 12.04.3 LTS (GNU/Linux 3.2.0-23-generic-pae i686)
* Documentation: https://help.ubuntu.com/
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
You have mail.
$
Run Code Online (Sandbox Code Playgroud)
如果您使用添加了新帐户,useradd那么它可能会将新用户的登录 shell 设置为 /bin/sh,它在 Ubuntu 中是指向 dash shell 的符号链接。Dash 是一个更简单的 shell,它不读取 ~/.bashrc 文件,也不设置user@host命令行提示。您可以通过查看 /etc/passwd 文件或使用
getent passwd usernameRun Code Online (Sandbox Code Playgroud)
您可以将默认外壳更改为更常用的bash使用
chsh -s /bin/bashRun Code Online (Sandbox Code Playgroud)
如果您以要更改其 shell 的用户身份登录,或者
sudo chsh -s /bin/bash usernameRun Code Online (Sandbox Code Playgroud)
更改另一个帐户的登录外壳。为了防止这种情况再次发生,您可以useradd使用-s或--shell选项在命令行上指定登录 shell ,或者改用更高级别的实用程序adduser。