ArticlesBlog

Managing Linux Users and Groups

Managing Linux Users and Groups


Each account consists of a username and a unique number called the UID which is short for user ID. Also, each account has a default group to which it belongs, some comments associated with that account, a shell to start when the user logs into the system, and a home directory. And all this information is stored in the /etc/passwd file. And note that /etc/passwd is spelled passwd. Historically encrypted password information was also stored in the /etc/passwd file. However, the /etc/passwd file is actually readable by anyone on the system, so storing password information, even though it’s encrypted, is actually a security risk. So now, by default, the encrypted password information is stored in /etc/shadow and that file is only readable by the super user or the root account on the system. Managing users on a Linux system is fairly straightforward. If you want to create an account, use the useradd command and to delete accounts, well, you use the userdel command and to modify existing accounts just use the usermod command. Now, these commands here listed on your screen are the low-level Linux commands and they’re available on all the Linux distributions. However, some distros provide their own account creation tools that you can use, if you so choose. Just like the /etc/passwd file contains account information, well, the /etc/group file contains group information. To create a group use the groupadd command. The groupdel command will delete a group and to modify a group, well, you use the groupmod command. To see what groups an account is in, use the groups command. If you specify an account after the groups command, it will show all the group memberships for that specified account. If you happen to execute the groups command without any arguments, it displays the groups that the current user is in. If you want to switch to another account use the su command, which stands for switch user. To verify what account you’re currently using, simply run the whoami command and it will return the account name. The sudo command is used to allow one user to run commands as another user. This is most commonly used to allow a normal user to execute a program as the super user, so you can think of sudo as “super user do.” To start a shell as another user, run “sudo -s” or you can also run “sudo su”. By the way, the file that stores the sudo configuration is /etc/sudoers. To modify the sudoers file, use the visudo command. It has syntax checking built in so you don’t accidentally break the sudo configuration. If you found this video helpful then I know you’re going to learn so much more in my Learn Linux in 5 Days course available at LinuxTrainingAcademy.com. In it, you’ll learn exactly what you need to know about the Linux operating system in order to become a proficient and professional user in a very short period of time. In the course, you’ll start at the very beginning by choosing a Linux distribution and installing it. From there, you’ll learn the most important Linux concepts and commands, plus you’ll be guided step-by-step through several practical and real-world examples. By the way, this course also comes with a 30-day money-back guarantee which means you have everything to gain and absolutely nothing to lose by trying it out. So if you can spare just a few minutes a day and want to learn the ins and outs of the Linux operating system, join me and the other students in this course today. I look forward to seeing you in the course!

Comments (1)

Comment here