Understanding User Management on Linux Systems

Rishabh SinghRishabh Singh
2 min read

Linux provides robust tools for managing users and groups from the command line. Understanding user management is essential for any system administrator. In this post, we cover all the basic commands used for creating, modifying, and deleting users and groups in Ubuntu Linux.

1. Creating Users

To create a user and set a home directory automatically:

Add user with a comment and specific shell:

2. Deleting Users

To delete the user along with their home directory:

3. Basic Group Management

Create a group:

Delete a group:

Add user to a group:

List groups of a user:

4. Modifying User Details

usermod Part 1 – Change username, move home directory

usermod Part 2 – Change login shell, lock/unlock

5. Whois Command

Displays user information:

Install it first if needed:

6. Change User Password

Change your own password:

7. chage Command (Password Expiration)

8. Hostname Command

View hostname:

Set a new hostname:

Summary of Key Commands

TaskCommand Example
Add usersudo useradd -m username
Delete usersudo userdel -r username
Create groupsudo groupadd groupname
Add user to groupsudo usermod -aG group username
Change passwordsudo passwd username
Set password policysudo chage -M 90 username
View/change hostnamehostname, hostnamectl

Conclusion

Mastering user management in Linux is crucial for effective system administration. Whether you're creating new accounts, setting security policies, or managing group memberships, the commands discussed here will equip you with essential tools to manage Ubuntu systems securely and efficiently.

0
Subscribe to my newsletter

Read articles from Rishabh Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rishabh Singh
Rishabh Singh