# How to Create Users in Linux with useradd (Step-by-Step) ```shell # On ubuntu Ubuntu 24.04.2 LTS, user created with # this command its login shell is /bin/sh sudo useradd -m username sudo useradd -m -s /bin/bash username sudo passwd username ``` useradd 指令的預設登入 Shell 取決於系統的設定,通常是 /bin/sh 或 /bin/bash,這可以從 /etc/default/useradd 檔案查看: ```shell grep SHELL /etc/default/useradd ``` 使用者預設登入 shell ```shell echo $SHELL ``` 針對特定使用者 ```shell getent passwd username cat /etc/passwd | grep username cat /etc/passwd | awk -F: '{print $1, $7}' ``` 注意: useradd 與 adduser 為兩個不同的指令!其行為不完全相同 ```shell! # On ubuntu Ubuntu 24.04.2 LTS, user created with # this command its login shell is /bin/bash sudo adduser username sudo adduser --shell /bin/bash username ``` [How do I check which shell I am using?](https://askubuntu.com/questions/590899/how-do-i-check-which-shell-i-am-using) [How to Create Users in Linux with useradd (Step-by-Step)](https://www.strongdm.com/blog/create-users-in-linux-with-useradd-command)