Creating users manually in Linux or Unix is a valuable skill that provides a deeper understanding of how user management works under the hood. While the useradd command offers a quick way to add users, doing it by hand teaches you what changes are made behind the scenes. This method can be particularly useful in minimal environments or custom configurations. For a broader look at foundational commands that help you navigate the terminal more effectively, check out this list of 15 basic Linux commands.
Let’s walk through how to manually create a new user called DarthVader. This process includes editing essential system files such as passwd, shadow, and group, all of which are located in the /etc folder. We’ll also set up a home directory and assign the proper permissions. If you’re also interested in path manipulations or retrieving system info via CLI, refer to this guide on basename and dirname or this article on gathering computer information.
- Backup essential system files: Before making any changes, it’s important to back up the
passwd,shadow, andgroupfiles located in the/etcfolder. These hold user data, encrypted passwords, and group information. Run the following as root:
sudo su
cd /etc
cp passwd{,.bak}
cp shadow{,.bak}
cp group{,.bak}
ls -l *.bak
This ensures you have a restore point in case of errors.
- Add the user to the
passwdfile: This file holds basic user account details. Change directory first, then append the new user:
cd /etc
echo 'DarthVader:x:1699:1699:Dark Side:/home/darth/vader:/bin/bash' >> passwd
Here, 1699 is the UID and GID, Dark Side is the full name/comment, the home directory is /home/darth/vader, and the login shell is /bin/bash.
- Add the user to the
shadowfile: This file stores encrypted passwords and password-related info. Change directory first, then use:
cd /etc
echo 'DarthVader:x:15481:0:99999:7:::' >> shadow
This line sets the initial password entry (x placeholder), last password change date (15481), and password expiration fields.
- Add the user to the
groupfile: This file contains group definitions. Change to the/etcfolder and append:
cd /etc
echo 'DarthVader:x:1699:' >> group
This assigns the group ID 1699 to the DarthVader group.
- Create the user’s home directory:
mkdir -p /home/darth/vader
The -p flag ensures parent directories are created if they don’t exist.
- Populate the home directory: Copy the default configuration files from
/etc/skel, which provides a basic user environment:
cp -r /etc/skel/. /home/darth/vader/
- Set ownership: Make the new user and their group the owner of their home directory:
chown DarthVader:DarthVader /home/darth/vader
- Set permissions: Assign appropriate access rights:
chmod 755 /home/darth/vader/
chmod -R 644 /home/darth/vader/*
This allows full access for the user, and read/execute for others.
- Set the user’s password: Run the
passwdcommand to assign a secure password:
passwd DarthVader
You’ll be prompted to enter and confirm the new password.
By following these steps, you’ve manually created a fully functional user in Linux. This approach is a great way to build deeper system knowledge and understand what tools like useradd do automatically. It also prepares you to handle advanced system administration tasks with more confidence and precision.






Pingback: AlmaLinux OS 10: A Major Leap Forward for Open-Source Enterprise Linux - iDoLinux
Pingback: AlmaLinux OS 10: A Major Leap Forward for Open-Source Enterprise Linux - Open Source Software News
Pingback: How to Give Passwordless Root Privileges to a Normal User - Open Source Software News
Pingback: useradd Ubuntu Command Line: How to Create Users in Linux - iDoLinux
Pingback: How to Delete Users in Linux Using the Userdel Command - iDoLinux