I can chown a file with chown myuser:mygroup /tmp/file, but how can I see who a file is already chowned to, or who already owns it? Something like chown --show-who maybe...

How can I list the user and group for a file?

  • 3
    did you try ls -l ? – Ouki Mar 25 '14 at 19:23
  • Or stat --format="%U %G" filename – doneal24 Mar 25 '14 at 19:27
  • With ls -l I get something like -rw-r--r-- 1 root root 10618 Mar 16 18:16 filename. So would that be chowned root:root? – Questionmark Mar 25 '14 at 19:27
  • @Questionmark Exactly. – n.st Mar 25 '14 at 19:27
  • That's the only piece that I was missing. I've used ls -l plenty but I never caught the direct correlation. Thanks guys! – Questionmark Mar 25 '14 at 19:28

A simple ls -l would do the trick.

The -l option to the Unix command ls will list the files using a long format. In short this displays for each file:

  • Unix file type
  • permissions
  • number of hard links
  • owner
  • group
  • size
  • last-modified date
  • filename


$ ls -l
-rw-------  1 root  root   9560 23 mar 12:05 .bash_history
-rwxr-xr-x  1 root  root    524 28 mai  2007 .bashrc
drwxr-xr-x  3 root  root      3  4 nov 14:51 .cache

From the FreeBSD ls man page (Linux one is a bit scarce):

The Long Format

 If the -l option is given, the following information is displayed for
 each file: file mode, number of links, owner name, group name, MAC label,
 number of bytes in the file, abbreviated month, day-of-month file was
 last modified, hour file last modified, minute file last modified, and
 the pathname.

 If the modification time of the file is more than 6 months in the past or
 future, and the -D or -T are not specified, then the year of the last
 modification is displayed in place of the hour and minute fields.

 If the owner or group names are not a known user or group name, or the -n
 option is given, the numeric ID's are displayed.

 If the file is a character special or block special file, the device num-
 ber for the file is displayed in the size field.  If the file is a sym-
 bolic link the pathname of the linked-to file is preceded by ``->''.

 The listing of a directory's contents is preceded by a labeled total num-
 ber of blocks used in the file system by the files which are listed as
 the directory's contents (which may or may not include . and .. and other
 files which start with a dot, depending on other options).

 The default block size is 512 bytes.  The block size may be set with
 option -k or environment variable BLOCKSIZE.  Numbers of blocks in the
 output will have been rounded up so the numbers of bytes is at least as
 many as used by the corresponding file system blocks (which might have a
 different size).

 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

To know more:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.