Maintaining system security requires a clear understanding of who can access specific data.
Checking user permissions in Linux helps you establish security boundaries between different people and programs. This guide explains four practical methods to verify these settings.
These commands work across all major distributions, including Red Hat Enterprise Linux, Ubuntu, and Debian. Master these approaches to ensure your Linux file permissions are configured correctly.
Table of Contents
Method 1: Using the ls Command
The ls command is the most common way to view permission attributes. It lists directory contents along with their ownership and access levels.
Run this command for a detailed view of a specific file: ls -l filename
The -l flag activates the long listing format. In the output, the first character indicates the file type (e.g., - for a regular file or d for a directory), followed by nine characters representing permissions for the User (owner), the Group, and Others.
For directories, use the -d flag to see permissions for the folder itself rather than its contents: ls -ld /path/to/directory
Method 2: Applying the id Command
While ls shows the permissions assigned to a file, the id command displays the identity and group memberships of a specific user. This is vital because users are granted access to files based on whether any of their groups have access.
Use this syntax to check the identity of the currently logged-in user: id
To check the IDs and groups for a different account, pass the username as an argument: id username
See also: Mastering the Linux Command Line — Your Complete Free Training Guide
The output reveals the User ID (UID) and Group ID (GID). If you need to see a full list of accounts on the system, refer to this guide on how to list all users in Linux.
Method 3: Employing the stat Command
The stat command delivers comprehensive file metadata that goes beyond a simple directory listing. It is particularly useful for administrators who need to see permissions in numeric (octal) format.
Run stat to view complete information, including timestamps and access rights: stat filename
For a concise view of numeric permissions (like 755 or 644), use the format specifier: stat -c "%a" filename
Experienced administrators often prefer these numeric values because they are shorter to type and easier to use in scripts. You can learn more about interpreting these values in our article on how to check file permissions.
Method 4: Searching with the find Command
The find command can locate files based on specific permission criteria across the entire system. This is invaluable for identifying security risks, such as files that are accessible to everyone.
To locate files with exactly 777 permissions (read, write, and execute for all users): find /path -perm 777
You can also use find to identify “unowned” files—data that belonged to a user who has been deleted from the system: find / -nouser -o -nogroup
This method is a powerful tool for maintaining a clean and secure file system.
Understanding Linux Permission Precedence
Linux uses a specific hierarchy when determining access. The most specific permissions always take precedence. This means:
- User permissions override group permissions.
- Group permissions override “other” permissions.
If you are the owner of a file, your specific “user” rights apply even if the group or “others” have different settings. To modify these, you will need to use the chmod command.
Step-by-Step Process
- Launch your terminal application.
- Verify your identity by typing
whoamiorid. - Navigate to the target location using the
cdcommand. - Execute
ls -lto view the owner, group, and permission string. - Use
statif you require the numeric (octal) permission mode.
Practical Tips
- Check Hidden Files: Apply the
-aflag (e.g.,ls -la) to see permissions for hidden configuration files that start with a dot. - Identify File Types: The first character in
ls -ltells you if an item is a regular file (-), a directory (d), or a symbolic link (l). - Administrative Access: If you receive a “Permission denied” error when checking system files, you may need to use the
sudocommand to escalate your privileges to root. Learn more about understanding the sudo command here.
Summary Table
| Task | Recommended Command |
|---|---|
| View file owner and permissions | ls -l filename |
| Check directory permissions | ls -ld dirname |
| Show user UID and Group GIDs | id username |
| Get numeric (octal) permission mode | stat -c "%a" filename |
| Search for world-writable files | find / -perm -002 |
FAQs
What is the quickest way to check user permissions in Linux? The fastest method for a single file is ls -l filename. The first column displays the permission string (e.g., -rw-r--r--), while the third and fourth columns show the owning user and group.
Why can I list a directory but not open the files inside? You likely have Read (r) permission on the directory, which allows you to see file names, but you lack Execute (x) permission, which is required to enter the directory and access the files.
What do the ‘s’ and ‘t’ characters mean in permissions? These are special permissions. A lowercase s indicates setuid or setgid, which allows a program to run with the privileges of the owner or group. A lowercase t represents the “sticky bit,” often used on directories like /tmp to ensure only file owners can delete their own files.
How do I check my own group memberships? Simply type id without any arguments to see your UID, primary group, and all supplementary groups.
Related Posts




