Find the group name of the folder in UNIX / Linux

last updated in Categories , , , , , , , , ,

How do I find out the owner and group of a directory in Linux? How can I find the group name of the folder in Unix?

Unix and Linux users are organized into groups. Each user is in at least one group and maybe in other secondary groups too. Group membership can give you exclusive access to files and directories belonging to that group. Group membership also allows you to access hardware devices and much more.

Find the group name of the folder in UNIX

The procedure to discover the group name of the folder in UNIX and Linux is as follows:

  1. Open the terminal application
  2. Run command on the folder: ls -ld /path/to/folder
  3. To find owner and group of a directory named /etc/ use: stat /etc/
  4. Use the Linux and Unix GUI file manager to locate the group name of the folder

Let us see some examples in details.

How to find owner and group of a directory in Linux

Say you want to find the group name of the $HOME/Downloads/ folder, run:
ls -ld $HOME/Downloads/
Second method is to run the stat command as follows:
stat /etc/
stat /home/vivek/Downloads/

Look for GID (group ID) and UID (User ID):
Find the group name of the folder in UNIX and Linux command

Find the group name of the folder in Linux or UNIX using GUI

nautilus is a file manager, designed for the GNOME 3 desktop.

  • Start the nautilus.
  • Choose the folder.
  • Right click it.
  • Select Properties and click on the Permissions tab

Check the ownership of directory in Linux GNOME GUI

How to check ownership of directory in Linux or Unix

Another option is to just run the following stat command:
stat -c "User:%U Group:%G" /path/to/dir/
stat -c "User:%U Group:%G" /etc/

Sample outputs:

User:root Group:root

One can pass the -c option for the specified FORMAT instead of the default. In this example:

  • %U – user name of owner
  • %G – group name of owner

Conclusion

One can use the stat command to display file status including owner and group names. The ls command provides information easily too. Finally, one can use the KDE or GNOME desktop file manager to obtain the group and owner names on Linux and Unix-like systems.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive

1 comment

    Still, have a question? Get help on our forum!