TL;DR
You can compare Linux user permissions without root access by examining the output of id and groups for each user, and comparing file/directory ownership and permissions using ls -l. You won’t see *all* details (like other users’ group memberships), but you can determine effective permissions for files you have access to.
How to Compare Linux User Permissions Without Root Access
- Understand the Basics
- User ID (UID): A unique number identifying each user.
- Group ID (GID): A unique number identifying each group. Users can belong to multiple groups.
- Permissions: Read (r), Write (w), Execute (x). Applied to the owner, group, and others.
Start by understanding your own user ID and group memberships:
id
This will output something like:
uid=1000(yourusername) gid=(yourgroup) groups=(yourgroup, othergroups)
You can see another user’s UID and primary group using id . However, you won’t be able to see all their group memberships without root access.
id otheruser
Example output:
uid=1001(otheruser) gid=(othergroup) groups=(othergroup)
Use ls -l to see the owner, group, and permissions of a file or directory. This is the most useful command.
ls -l myfile.txt
Example output:
-rw-r--r-- 1 yourusername yourgroup 2048 Jan 15 10:00 myfile.txt
- The first character indicates the file type (- for regular file, d for directory).
- The next nine characters represent permissions (owner/group/others).
1 yourusername yourgroupshows the owner and group of the file.
- Owner: The user who owns the file.
- Group: The group associated with the file.
- Others: All other users on the system.
- Permissions are represented as
rwx(read, write, execute). A hyphen (-) means permission is denied.
Let’s say:
- Your user ID: 1000, primary group: yourgroup
- Another user’s UID: 1001, primary group: othergroup
- File permissions for
myfile.txtare-rw-r--r-- 1 yourusername yourgroup ...
You can determine:
- Your access: You own the file, so you have read and write permissions.
- Other user’s access: They are not the owner. If they are in
yourgroup, they have read permission. Otherwise, they only have read permission (if any).
- You cannot see other users’ full group memberships without root access.
- You can only determine permissions for files you have some level of access to. You won’t be able to see the permissions of files you don’t have permission to even list.