When you spin up a brand-new Linux server, you are usually logged in as the root user. Operating a server as root is highly dangerous, as a single typo can delete the entire operating system. The very first security task you must perform is creating a standard, limited user account for yourself (or a new employee) using the terminal.
To do this correctly and ensure the user actually has a place to store their files, you must use the useradd command.
Step 1: Create the User Account
Open your Linux terminal. You must have superuser (root) privileges to execute this command. If you are not logged in as root, you must place sudo in front of the command.
To create a new user named “alex”, type:
sudo useradd -m alex
Press Enter. The command will execute silently without a success message.
Why is the -m flag so important? If you simply run useradd alex, Linux will create the account credentials, but it will not create a home directory for them. When Alex logs in, they will have nowhere to save their files and will likely encounter errors. The -m (make home directory) flag forces Linux to automatically generate a brand-new folder at /home/alex with the correct permissions.
Step 2: Assign a Password
Although you have created the account, the user cannot actually log in yet because they do not have a password. You must assign one using the passwd command.
sudo passwd alex
Press Enter. The terminal will prompt you to enter a new password:
New password:
Type a secure password. Crucially: As you type, absolutely nothing will appear on the screen. No stars, no dots. This is a standard Linux security feature to prevent people looking over your shoulder from guessing the length of the password. Just type it carefully and press Enter.
The terminal will ask you to retype it to confirm. Once confirmed, you will see a success message: passwd: password updated successfully.
The new user account is now fully active, securely configured with a home directory, and ready for immediate login.