Create New User In Ubuntu with the adduser Command
To create a user account on Ubuntu, we use the adduser command. The adduser command is an interactive way to create user accounts and passwords with a single command.
The syntax of adduser is as follows:
adduser user_name
Here’s an example of using the command, which creates a user account named sysadmin:
adduser sysadmin
The command prompts for a new Unix password. You can omit other information such as Full Name and Room Number (By pressing the Enter key) which are not required.
Creating a User With a Custom Home Directory
The adduser command in Ubuntu creates a home folder for the user under the /home directory.
To set up the user on the Ubuntu system with a different home directory, you have to specify the --home option.
adduser --home /var/sysadmin sysadmin
For some reason, if you don't want to create the home folder for the new user, use the --no-create-home option.
adduser --help will display command options that can be used to override the default behaviour of the Ubuntu adduser command.
Apart from adduser, we can also use the useradd command to create a new user account in Ubuntu Linux.
useradd -m sysadmin
However the useradd command in Ubuntu does not set up user password. You have to manually set up the user password with the passwd command.
passwd sysadmin
The adduser command which is an interactive command not suitable for use in Linux shell scripting. Instead, use the useradd command in shell scripting.