Skip to main content

User & Permission Management

Description Commands
Daily drivers sudo, passwd, chmod, chown, useradd, usermod
Group management groupadd, groupmod, groupdel, chgrp, gpasswd, groups
Identity checks id, whoami, who, users
Auditing/security last, lastb, finger
Special utilities umask, pwconv/pwunconv, grpconv/grpunconv, newaliases

sudo

Usage       : sudo apt update
Example     : sudo systemctl restart nginx
Description : Run commands with elevated privileges.
Takeaway    : Use whenever you need root-level access without logging in as root.

passwd

Usage       : passwd username
Example     : passwd shubham
Description : Change or reset user passwords.
Takeaway    : Use for password management and enforcing security policies.

chmod

Usage       : chmod 755 file.sh
Example     : chmod -R 644 /var/www/html
Description : Change file/directory permissions.
Takeaway    : Use to control read/write/execute access.

chown

Usage       : chown user:group file.txt
Example     : chown shubham:devops project.log
Description : Change file ownership.
Takeaway    : Use to assign ownership of files/directories.

useradd

Usage       : useradd -m shubham
Example     : useradd -m -s /bin/bash student
Description : Create new user accounts.
Takeaway    : Use to add new users with home directories.

usermod

Usage       : usermod -aG sudo shubham
Example     : usermod -aG devops student
Description : Modify existing user accounts.
Takeaway    : Use to update user properties or group memberships.

userdel

Usage       : userdel -r shubham
Example     : Remove user and home directory.
Description : Delete user accounts.
Takeaway    : Use to cleanly remove users from the system.

groupadd

Usage       : groupadd devops
Example     : groupadd students
Description : Create new groups.
Takeaway    : Use to organize users into permission groups.

groupmod

Usage       : groupmod -n newname oldname
Example     : Rename group qa to quality.
Description : Modify group properties.
Takeaway    : Use to adjust group names or IDs.

groupdel

Usage       : groupdel devops
Example     : Remove unused groups.
Description : Delete groups.
Takeaway    : Use for cleanup of obsolete groups.

chgrp

Usage       : chgrp devops file.txt
Example     : Assign project files to team group.
Description : Change group ownership of files.
Takeaway    : Use to manage group-level file access.

su

Usage       : su - username
Example     : su - root
Description : Switch user accounts.
Takeaway    : Use to temporarily switch to another user.

id

Usage       : id shubham
Example     : Output includes UID, GID, groups.
Description : Show user and group IDs.
Takeaway    : Use to verify user identity and group memberships.

whoami

Usage       : whoami
Example     : Output: shubham
Description : Display current logged-in user.
Takeaway    : Use in scripts or quick identity checks.

who

Usage       : who
Example     : See active sessions.
Description : Show logged-in users.
Takeaway    : Use to monitor user activity.

groups

Usage       : groups shubham
Example     : Output: shubham : devops sudo
Description : Show groups a user belongs to.
Takeaway    : Use to check group memberships.

gpasswd

Usage       : gpasswd -a user group
Example     : gpasswd -a student devops
Description : Manage group memberships.
Takeaway    : Use to add/remove users from groups.

umask

Usage       : umask 022
Example     : Files created with 644 permissions.
Description : Set default file permissions.
Takeaway    : Use to control default access rights.

last

Usage       : last
Example     : See login history.
Description : Show last logged-in users.
Takeaway    : Use for auditing user activity.

lastb

Usage       : lastb
Example     : Detect brute-force attempts.
Description : Show failed login attempts.
Takeaway    : Use for security monitoring.

finger

Usage       : finger shubham
Example     : Shows name, login, shell.
Description : Display user info.
Takeaway    : Use for quick user details.

chsh

Usage       : chsh -s /bin/zsh shubham
Example     : Switch user shell to zsh.
Description : Change default shell.
Takeaway    : Use to customize user environment.

newgrp

Usage       : newgrp devops
Example     : Temporarily change group ID.
Description : Switch to a new group.
Takeaway    : Use for group-based permission changes.

users

Usage       : users
Example     : Output: shubham root
Description : Show logged-in users.
Takeaway    : Use for quick session overview.

newaliases

Usage       : newaliases
Example     : Refresh email alias configs.
Description : Update mail aliases database.
Takeaway    : Use for mail system administration.

Tips, Tricks, Roadmaps, Resources, Networking, Motivation, Guidance, and Cool Stuff โ™ฅ

Updated on Dec 19, 2025