Managing Linux Users and Groups

In this video tutorial and cheat sheet, you’ll learn:

  • User management commands in Linux with examples.
  • Adding, deleting, changing Linux user accounts.
  • Managing groups in Linux.
Download My Managing Linux Users and Groups Cheat Sheet!
When you enter your email address below, you'll be sent my managing Linux users and groups cheat sheet.
We respect your privacy.

Video Transcript:

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. All of this information is stored in the /etc/passwd file. 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. That file is only readable by the superuser 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, use the userdel command. To modify existing accounts, just use the usermod command. These commands 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, the /etc/group file contains group information. To create a group, use the groupadd command. The groupdel command will delete a group. To modify a group, 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 superuser, so you can think of sudo as “superuser 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!

Download My Managing Linux Users and Groups Cheat Sheet!
When you enter your email address below, you'll be sent my managing Linux users and groups cheat sheet.
We respect your privacy.