How to check file ownership in Linux

By Angus Published 14 January 2025 Updated 4 March 2026 3 min read

File ownership determines who can read, modify or execute files on your Linux server. When troubleshooting permission errors or auditing security, you need to identify which user and group own specific files.

You will check file ownership using two commands: ls for quick checks and stat for detailed information. Both reveal the owner username, group name and permission settings.

Before you begin

  • You need SSH access to your Linux server.
  • Basic familiarity with terminal commands is helpful.

Check ownership with ls

The ls command displays file ownership alongside permissions and modification dates. This gives you a quick overview without extra detail.

  1. Open your terminal.
    Connect to your server via SSH.
  2. Navigate to the directory containing the file.
    Use cd to change to the correct location, replacing /path/to/directory with your actual path:
cd /path/to/directory
  1. List the file with detailed information.
    Run ls -la followed by the filename:
ls -la filename

The output shows ownership and permission details:

-rw-r--r-- 1 user group 1024 Mar 6 12:00 filename

The third column (user) shows the file owner. The fourth column (group) shows the group owner. The first character indicates file type: - for regular files and d for directories. The next nine characters display permissions for owner, group and others.

For human-readable file sizes, use ls -lh instead. This converts bytes to KB, MB or GB automatically.

Check ownership with stat

The stat command provides comprehensive file information including numeric user IDs, group IDs and multiple timestamps. Use this when you need complete details beyond basic ownership.

  1. Run the stat command.
    Execute stat followed by the filename:
stat filename

The output displays detailed file metadata:

File: filename
Size: 1024       Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d   Inode: 1234567     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   user)   Gid: ( 1000/   group)
Access: 2024-03-06 12:00:00.000000000 +0000
Modify: 2024-03-06 12:00:00.000000000 +0000
Change: 2024-03-06 12:00:00.000000000 +0000

The Uid line shows both the numeric user ID (1000) and username (user). The Gid line shows the numeric group ID and group name. You also see three timestamps: when the file was last accessed, modified and when its metadata changed.

Check ACL permissions

Access Control Lists provide additional permission layers beyond standard Unix permissions. If your system uses ACLs, check them with getfacl:

getfacl filename

This reveals extended permissions that may grant or restrict access beyond what ls or stat display.

Wrapping up

You can now identify file ownership on your Linux server using ls for quick checks and stat for detailed information. Both commands reveal the owner username and group name, helping you troubleshoot permission issues and audit file access.

If you need to change ownership after checking it, see our guide on using chown in Linux. You may also want to switch users in Linux when working with files owned by different accounts, or check directory sizes when investigating disk usage. Our VPS hosting gives you full root access to manage file ownership and permissions.

Need more power?

Get scalable resources with our VPS hosting with root access and optional software.

Get VPS Hosting

Starting something new?

Perfect for websites and small businesses unlimited bandwidth with cPanel hosting.

Get cPanel Hosting