How do I check who owns a file in Linux

By Angus Published 14 January 2025 Updated 28 January 2026 2 min read

Need to know who owns a file on your Linux server? Two commands show you: ls and stat.

Both reveal ownership details. ls gives you a quick overview, stat provides comprehensive information.

Check ownership with ls

Open your terminal.

Navigate to the directory containing the file:

cd /path/to/directory

List the file with detailed information:

ls -la filename

Replace filename with your actual file name.

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

Breaking this down:

  • First character shows file type (- for regular files, d for directories)
  • Next nine characters show permissions for owner, group, and others
  • user is the file owner
  • group is the group owner
  • 1024 is the file size
  • Date and time show when it was last modified

Want file sizes in readable format? Use ls -lh instead.

Check ownership with stat

The stat command gives you more detail:

stat filename
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

Uid shows the user ID and username of the owner. Gid shows the group ID and name.

You also get access, modification, and change timestamps.

Check ACL permissions

If Access Control Lists are configured, use getfacl for extended permission details:

getfacl filename

Shows additional permission layers beyond standard Unix permissions.

Change ownership if needed

Found the wrong owner? Change file ownership with chown:

sudo chown newuser:newgroup filename

Replace newuser and newgroup with the correct owner and group.

You’ll need superuser privileges. If you’re working as a different user and need to switch users in Linux, do that first.

Other useful file commands

Checking ownership is often part of broader file management. You might also need to check directory sizes when investigating disk usage or tracking down large files.

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