UNIX / Linux Find File Owner Name

Q. How do I find out the name of file / directory owner under UNIX / Linux operating systems?

A. You can use ls -l command (list information about the FILEs) to find our the file / directory owner and group names.

The -l option is known as long format which displays Unix / Linux / BSD file types, permissions, number of hard links, owner, group, size, date, and filename. In some environments and UNIX versions / Linux distributions, providing the option –color (for GNU ls) or -G (FreeBSD ls) causes ls to highlight different types of files with different colors.

(Fig. 01: Linux file colors)

(Fig. 02: Understanding Linux / UNIX file colors code [ image credit wikipedia] )

How do I find out owner / group name for a file?

Type the ls -l command at a shell prompt:
$ ls -l filename
Sample output:

-rw-r--r-- 1 vivek admin 2558 Jan  8 07:41 filename


  • -rw-r–r– : file mode
  • 1 – number of links
  • vivekOwner name (if user name is not a known user, the numeric user id displayed)
  • adminGroup name (if group name is not a known group, the numeric group id displayed)
  • 2558 – number of bytes in the file (file size)
  • Jan 8 07:41 – abbreviated month, day-of-month file was
    last modified, hour file last modified, minute file last modified
  • filename – File name / pathname

ls -l file mode (permissions)

Quoting from the unix ls command man page – the file mode printed under the -l option consists of the entry type and the permissions. The entry type character describes the type of file, as follows:

Regular file.
b Block special file.
c Character special file.
d Directory.
l Symbolic link.
s Socket.
w Whiteout.

The next three fields are three characters each: owner permissions, group permissions, and other permissions. Each field has three character positions:

  1. If r, the file is readable; if -, it is not readable.
  2. If w, the file is writable; if -, it is not writable.
  3. The first of the following that applies:
  • S : If in the owner permissions, the file is not executable and set-user-ID mode is set. If in the group permissions, the file is not executable and set-group-ID mode is set.
  • s : If in the owner permissions, the file is executable and set-user-ID mode is set. If in the group permissions, the file is executable and set group-ID mode is set.
  • x : The file is executable or the directory is searchable.
  • : The file is neither readable, writable, executable, nor set-user-ID nor set-group-ID mode, nor sticky.
  • These next two apply only to the third character in the last group (other permissions).
    • T : The sticky bit is set (mode 1000), but not execute or search permission.
    • t : The sticky bit is set (mode 1000), and is search able or executable.

    See ls command man page for more information:
    $ man ls

    🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

    🐧 3 comments so far... add one

    CategoryList of Unix and Linux commands
    Disk space analyzersdf ncdu pydf
    File Managementcat cp mkdir tree
    FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
    Network UtilitiesNetHogs dig host ip nmap
    OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
    Package Managerapk apt
    Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
    Searchinggrep whereis which
    User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
    WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
    3 comments… add one
    • Afsar Uddinn Sep 13, 2011 @ 12:17

      Very good article. I know another way to get ONLY the ownername or groupname with 1 shot:
      # stat -c %U /path/to/file
      # stat -c %G /path/to/file

      These are helpful in writing scripts. More details at:
      # man stat

      • Bhargav Kesavan Jun 24, 2015 @ 19:43

        It helped me. Thank you.

    • ed May 23, 2012 @ 19:03

      Anybody know how to do this on Solaris?

    Leave a Reply

    Your email address will not be published.

    Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum