Gaurav Agarwal Asked: 2012-08-13 12:52:22 +0800 CST2012-08-13 12:52:22 +0800 CST 2012-08-13 12:52:22 +0800 CST How to find owner and group of a directory? 772 How can I find out owner and group of a directory in Ubuntu? permissions 5 Answers Voted Best Answer fromnaboo 2012-08-13T13:04:12+08:002012-08-13T13:04:12+08:00 You can do this: 1st way: ls -l /path/to/file *the third field in the ls -l output is the user and the fourth is the group 2nd way: stat /path/to/file $ stat py File: `py' Size: 32 Blocks: 8 IO Block: 4096 regular file Device: 801h/2049d Inode: 429064 Links: 1 Access: (0777/-rwxrwxrwx) Uid: ( 1000/ razvan) Gid: ( 1000/ razvan) Access: 2012-07-27 17:49:05.682143441 +0300 Modify: 2012-07-01 03:58:02.848540175 +0300 Change: 2012-08-01 21:12:57.129819212 +0300 The razvan in the Uid field is the owner/user, the razvan in the Gid field is the group. 8-| 3rd way: Get only the user and group with stat: stat -c "%U %G" /path/to/file OrangeTux 2012-08-13T13:04:31+08:002012-08-13T13:04:31+08:00 Run ls with the -l flag to show the owner and group-owner of files and directories in the current directory (or in a specific named directory). ~$ ls -l drwxr-xr-x 2 owner group 4096 Aug 12 19:12 Desktop ... ~$ ls -l /home/username drwxr-xr-x 2 owner group 4096 Aug 12 19:12 Desktop ... Run ls with the -l and -d flags to show this information about the current directory itself (or about a specific named directory): ~$ ls -ld drwxr-xr-x 2 owner group 4096 Aug 12 19:12 . ~$ ls -ld ~/Desktop drwxr-xr-x 2 owner group 4096 Aug 12 19:12 Desktop StarNamer 2012-08-13T13:13:45+08:002012-08-13T13:13:45+08:00 To get the owner and group of a directory you need ls -ld /path/to/folder Otherwise you get the attributes of the contents of the directory. John S Gruber 2012-08-13T14:11:20+08:002012-08-13T14:11:20+08:00 In Nautilus (the GUI file manager) Find the folder corresponding to the directory Right click it. Select Properties Select the Permissions Tab Providing you have the permission to change the permissions you can change them from that window, too. Nam G VU 2019-02-28T18:41:57+08:002019-02-28T18:41:57+08:00 My subtle way ls -alF /path/to/folder | grep -Ei ' ./' sample output drwxr-xr-x 2 some-user some-group 4096 Feb 28 02:29 ./
You can do this: 1st way:
*the third field in the ls -l output is the user and the fourth is the group
2nd way:
stat /path/to/file
The razvan in the Uid field is the owner/user, the razvan in the Gid field is the group. 8-|
3rd way: Get only the user and group with stat:
Run
ls
with the-l
flag to show the owner and group-owner of files and directories in the current directory (or in a specific named directory).Run
ls
with the-l
and-d
flags to show this information about the current directory itself (or about a specific named directory):To get the owner and group of a directory you need
Otherwise you get the attributes of the contents of the directory.
In Nautilus (the GUI file manager)
Find the folder corresponding to the directory
Right click it.
Select Properties
Select the Permissions Tab
Providing you have the permission to change the permissions you can change them from that window, too.
My subtle way
sample output