Every file and directory in Linux has an owner (user) and an associated group. Linux uses this information to determine who can read, write, or execute a file.
1. ls -l — Check File Ownership
Loading...Displays detailed information about files and directories.
Example:
Loading...- Owner (
atul) → The user who owns the file.
- Group (
developers) → The group associated with the file.
- The ownership information is important because file permissions can be different for the owner, group, and other users.
2. whoami — Check Current User
Loading...Shows the username of the currently logged-in user.
Example:
Loading...Use it when: You want to quickly know which user account you are currently using.
3. id — View User & Group Information
Loading...Shows detailed information about the current user.
Example:
Loading...It shows:
- UID → Unique ID of the user.
- GID → ID of the user's primary group.
- groups → All groups the user belongs to.
Use it when: You need complete information about the current user's identity and group memberships.
4. groups — Check Group Membership
Loading...Shows all the groups that the current user belongs to.
Example:
Loading...This means the user
atul belongs to the atul, sudo, and developers groups.Why are groups useful?
Groups allow multiple users to share access to files and resources without giving permissions to each user individually.
For example:
Loading...If the
developers group has permission to access project.txt, all users belonging to that group can get that access.Quick Summary
Command | Purpose |
ls -l | Check a file's owner and group |
whoami | Find the current logged-in user |
id | View user's UID, GID, and groups |
groups | List groups the user belongs to |
Remember:
User/Owner → Who owns the file
Group → Which group the file belongs to
Permissions → What the owner, group, and others are allowed to do
.jpg?table=block&id=29d76b1d-f1a8-8072-a9bf-cc78d1c7d881&cache=v2)