Mastering User Management in Linux: A Guide with Examples π§βπ»π (Post-5/Part-IV)
User management is a fundamental aspect of Linux system administration. It allows you to control who can access your system, what they can do, and ensures the security and integrity of your data. In this blog, we'll delve into the world of user management in Linux, using our example user 'vrushabh' to illustrate the concepts. π
Adding a New User
To begin, let's create a new user named 'vrushabh'. Open your terminal and enter the following command:
sudo adduser vrushabh
This command prompts you to set a password, provide user information, and customize user settings. Once done, the new user 'vrushabh' is added to the system. π€β¨
Granting Administrative Privileges
In Linux, administrative users (often called 'superusers' or 'root') have elevated privileges. Let's grant 'vrushabh' administrative powers using the sudo
command. Edit the sudoers file with the following command:
sudo visudo
Then, add the following line to grant 'vrushabh' sudo privileges:
vrushabh ALL=(ALL:ALL) ALL
Now, 'vrushabh' can execute administrative commands by prefixing them with sudo
. ππ οΈ
Modifying User Properties
You can modify user properties using the usermod
command. Let's change 'vrushabh's shell to /bin/bash
:
sudo usermod -s /bin/bash vrushabh
This sets 'vrushabh's default shell to Bash, a commonly used shell in Linux. ππ§
Deleting a User
If 'vrushabh' no longer needs access to the system, you can delete the user using the userdel
command:
sudo userdel -r vrushabh
The -r
flag removes the user's home directory and associated files. Make sure to backup any important data before performing this action. ποΈπ¦
Switching to Another User
As an administrator, you might need to switch to 'vrushabh's account for troubleshooting or testing. Use the su
command:
su - vrushabh
Enter 'vrushabh's password, and you'll be logged into their account. This is especially handy for diagnosing user-specific issues. ππ
Conclusion
User management is a critical skill for Linux administrators, ensuring proper access control and maintaining system security. In this blog, we explored adding, modifying, and deleting users using the 'vrushabh' example. Remember, a well-managed user environment contributes to a stable and secure Linux system. ππ
So go ahead, unleash the power of user management in Linux, and ensure your system remains organized and protected! ππ¨βπΌπ©βπΌ
Thank you for giving your precious time for reading this blog/article and also follow Shahaji Kadam for more such blogs/articles.
HashTags: #90daysofdevops #devops #cloud #aws #awscloud #awscommunity #docker #linux #kubernetes #k8s #ansible #grafana #terraform #github #opensource #90days #challenge #learning