Add a User on Ubuntu Server - Step-by-Step Guide

Adding Users on Ubuntu Server
Ubuntu Server, like other Linux distributions, supports multiple users simultaneously. A frequent administrative task is the creation of new user accounts on the system.
Using the useradd Command
The useradd command provides a command-line interface for adding new users. Its basic syntax is as follows:
useradd
Executing this command adds the user, however, it doesn't automatically assign a password or create a home directory.
Should you encounter an error indicating the command isn't found, attempt using its full path:
/usr/sbin/useradd
The -d option allows you to specify the desired home directory. Utilizing the -m option instructs useradd to create this directory. Let's demonstrate this with an example, followed by setting the account password using the passwd command. Alternatively, a password can be set directly with the -p option during user creation, though using passwd is generally preferred.
sudo useradd -d /home/testuser -m testuser
sudo passwd testuser
This sequence creates a user named 'testuser' and establishes a home directory at /home/testuser. The contents of this new home directory are initially copied from the /etc/skel directory, which holds default files for new user accounts.
To examine the contents of the newly created home directory:
geek@ubuntuServ:/etc/skel$ ls -la /home/testuser
total 20
drwxr-xr-x 2 testuser testuser 4096 2006-12-15 11:34 .
drwxr-xr-x 5 root root 4096 2006-12-15 11:37 ..
-rw-r--r-- 1 testuser testuser 220 2006-12-15 11:34 .bash_logout
-rw-r--r-- 1 testuser testuser 414 2006-12-15 11:34 .bash_profile
-rw-r--r-- 1 testuser testuser 2227 2006-12-15 11:34 .bashrc
As you can see, several bash scripts are present. Modifying the files within /etc/skel allows you to define default settings for all newly created users, as these files are copied during the user creation process.
Leveraging the adduser Command
The adduser command simplifies user creation by interactively prompting for necessary information. It's noteworthy that Linux often features two commands with similar names performing the same function. The syntax is straightforward:
adduser
For instance:
geek@ubuntuServ:/etc/skel$ sudo adduser thegeek
Password:
Adding user `thegeek'...
Adding new group `thegeek' (1004).
Adding new user `thegeek' (1004) with group `thegeek'.
Creating home directory `/home/thegeek'.
Copying files from `/etc/skel'
Enter new UNIX password:
Retype new UNIX password:
No password supplied
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for thegeek
Enter the new value, or press ENTER for the default
Full Name []: The Geek
Room Number []: 0
Work Phone []: 555-1212
Home Phone []: 555-1212
Other []:
Is the information correct? [y/N] y