Linux User Management 🐧

In Linux, user management works just like it does in Windows - different user types have different privileges and they can be grouped together with various access levels. However, there are a few differences in how Linux does labeling:

  • Standard Users: Regular user accounts in Linux

  • Administrators: Users with elevated privileges

  • Root User: A special user account with full access to the OS

The Root User is the first user that gets automatically created when we install a Linux OS. This user has all the privileges on the OS and is considered the "super user". 🔑

Viewing Protected Files ⚠️

Let's try to view the contents of a restricted file, /etc/sudoers:

cat /etc/sudoers
# Permission denied

The sudoers file is a protected file that can only be read by the Root user. We can log in as Root and run the command with no problem:

sudo cat /etc/sudoers
# Able to view contents

However, it's generally not a good idea to always be logged in as Root, as it has unrestricted access and any mistakes could be catastrophic. 💥

Using sudo 🔼

Instead, we can use the sudo command (superuser do) to run a single command as Root:

sudo cat /etc/sudoers
# Able to view contents

If you don't want to run sudo every time, you can use the su command (substitute user) to switch to the Root user:

su
root@cindy-ncy $

Viewing User and Group Information 👥

You can view who has access to run sudo by checking the /etc/group file:

cat /etc/group
# Lists all the groups and their members

To view user information, the relevant file is /etc/passwd:

cat /etc/passwd
# Lots of user accounts, including non-human processes

The key fields in these files are:

  • Group Name: The name of the group

  • Group ID: The numerical identifier for the group

  • User Name: The username

  • User ID: The numerical identifier for the user

Overall, Linux user management is similar to Windows, but with some unique terminology and file locations. Just remember to use sudo judiciously and be careful when working as the Root user! 🐧💻

Last updated