
Creating a New User Account
To create a new user, Linux provides the straightforwarduseradd command. The simplest usage creates a new user (for example, “john”) and automatically assigns a primary group with the same name:
- A new user (“john”) is added to the system.
- A new group (“john”) is automatically created as the primary group.
-
A home directory is established at
/home/johnfor storing personal files, subdirectories, and program settings. -
The default shell is set to
/bin/bash, ensuring John’s session runs Bash upon login. -
All files from
/etc/skelare copied into this new home directory. To inspect these default files, run:
Always review the default settings to ensure they align with your organization’s policies before creating user accounts.
Setting a Password and Deleting an Account
After creating a new account, the user does not have a password by default. To set a password for John, use:userdel command. By default, this command removes only the user account (and its associated primary group, if auto-removed) while retaining the user’s home directory:
--remove option (or the shorthand -r):
Customizing User Account Settings
You can modify default settings, such as the shell or home directory, when creating or updating an account. For example, to change a user’s home directory immediately after creation, run:--move-home (or -m) option ensures that the contents of the old home directory are moved to the new location.
User account details—comprising usernames, user IDs, group IDs, home directories, and login shells—are stored in the /etc/passwd file. You can view this information by running:
- The first numeric value (1001) represents John’s user ID.
- The second numeric value (1001) is his primary group ID.
- The home directory and the default shell are also listed.
useradd assigns the next available numeric ID by incrementing the previous value. For manual assignment of a specific user ID, use:
ls -l command and include the numeric option -n if needed.
You can also review the current user’s details, including group memberships, with commands like:
System Accounts
Linux also accommodates system accounts designed for programs and daemons. These accounts typically have numeric IDs less than 1000 and do not require a home directory. For example, to create a system account named “sysacc”, run:Removing Multiple Users
If you need to remove multiple users along with their personal files, the process can be streamlined. For instance:Use the
useradd --help option if you ever need a quick reminder of the available options for managing user accounts.Modifying User Accounts
To update user account details after creation—such as modifying the home directory, username, or login shell—theusermod command is invaluable. For example, to change John’s home directory, run:
usermod.
Locking an account is another common action to disable password-based logins without deleting the account:
chage command. To expire a password immediately, run:
-1. Additionally, you can enforce password change policies—such as prompting a change every 30 days—with:
-1. To review a user’s password expiration settings, use:
Conclusion
In this article, we have covered the fundamental processes for creating, modifying, and deleting Linux local user accounts. We explored the default settings applied to new accounts, how to set and manage passwords, and the nuances of modifying account details withusermod and chage. These tools empower system administrators to efficiently manage user access and maintain system security.
Happy system managing, and see you in the next article!
For further reading on managing Linux systems, check out Linux System Administration Basics.