Linux User Management Unveiled: A guide to mastering user control

Linux User Management Unveiled: A guide to mastering user control

What is a Linux user?

Linux user is an account or an entity that provides interactive access to the system and allows one to create or modify files and perform several other operations.

Types of Linux users?

  • System users ->

A system user account aka privileged account is created by the operating system during its installation and is used for operating system-defined purposes. They have user id's predefined (100-999).

This range can be verified in the file /etc/login.defs.

cat /etc/login.defs  | grep -i SYS_UID_MIN
cat /etc/login.defs  | grep -i SYS_UID_MAX        

  • Regular users ->

The regular user accounts has ids begin from 1000 onwards.

cat /etc/login.defs  | grep -i UID_MIN | grep -v -E '^\#'
cat /etc/login.defs  | grep -i UID_MAX | grep -v -E '^\#'        

Q1 How to create user?

useradd <user_name>        

Q2 How to check user is present or not?

grep <user_name> /etc/passwd        

Q3 How to setup a user password?

passwd <user_name>        

Q4 How to delete a user?

userdel <user_name>        

Properties of Linux User Accounts

Q1 What is /etc/passwd file?

When you create a local user account, the user’s login information and all other details are stored in the /etc/passwd file.

Q2 What is /etc/shadow file?

it is a crucial component of Unix-like operating systems that stores password hashes and associated user account security information. It is a critical part of the system's security infrastructure, protecting user credentials and enforcing security policies.


Analyzing syntax of user properties

Q1 What is the syntax for displaying a user property in Linux?

The syntax is ->

username:password:UID:GID:name:homedirectory:shell

  1. Username: The username given at the time of creation.
  2. Password: The password stored as x indicates that encrypted password is stored in the /etc/shadow file.
  3. Primary UID: Each user on Linux must be assigned a user ID (UID). The UID zero/`0` is reserved for the super user which is the root.
  4. Primary GID: The primary group ID the user is associated with. (stored in /etc/group file)
  5. Comment: Contains extra information about a user such as its full name, phone number etc.
  6. Home Directory: The absolute path to the user's home directory.
  7. Login Shell: The absolute path to the shell the user will be assigned when logging. If set to no login shell which is /sbin/nologin the user won't be able to log in as the shell closes the connection.


Modifying an Existing user's properties

Q1 How to update the comment part of Linux user?

- Before adding comment

usermod -c <"comment"> <username>        

- After adding comment

Q2 How to change user home directory ?

- Before changing directory

usermod -d <dir> <user_name>        

- After changing directory


So, whether you're a seasoned Linux pro or just beginning your Linux journey, take a moment to appreciate the elegance of the Linux User Management. It's the foundation of a world where you have the power to control and customize your computing environment.

With that, happy Linux learning, and may your Linux directory explorations be filled with joy and success!


要查看或添加评论,请登录

Gauri Yadav的更多文章

社区洞察

其他会员也浏览了