Setting UID/GID for file/folder

When setuid (set-user identification) permission is set on an executable file or any ile, a process that runs this file is granted access based on the owner of the file (usually root), rather than the user who created the process. This permission enables a user to access files and directories that are normally available only to the owner.

The setuid permission is shown as an "s" in the file permissions.
# ls -l
-rw-r--r-- 1 admin other 54 Aug 8 01:43 pss.sh
# chmod 4554 pss.sh
#ls -l pss.sh
-r-sr-xr-- 1 admin other 54 Aug 8 01:43 pss.sh
You setuid permissions by using the chmod command to assign the octal value 4 as the first number in a series of four octal values

setgid Permission :
The setgid (set-group identification) permission is similar to setuid, except that the effective group ID for the process is changed to the group owner of the file and a user is granted access based on permissions granted to that group. The pss.sh program has setgid permissions:

# chmod 2554 pss.sh
# ls -l
-r-xr-sr-- 1 admin other 54 Aug 8 01:43 pss.sh
You can set setgid permissions by using the chmod command to assign the octal value 2 as the first number in a series of four octal values.

If you need to use both UID and GID on same file.follow below
# chmod 4554 pss.sh
# chmod g+s pss.sh
# ls -l
-r-sr-sr-- 1 admin other 54 Aug 8 01:43 pss.sh

Both files are enabled for UID/GID.

How to know which file belongs to solaris pkg

Determine Which Package a Particular File Belongs To - (Sun Solaris)
Use the pkgchk command, which package a particular file belongs to.

The syntax is:
# /usr/sbin/pkgchk -l -p /absolute/path/todir

For example,
# pkgchk -l -p /usr/bin/uuencode
Pathname: /usr/bin/uuencode
Type: regular file
Expected mode: 0555
Expected owner: root
Expected group: uucp
Expected file size (bytes): 6880
Expected sum(1) of contents: 43674
Expected last modification: Jan 05 06:51:49 PM 2000
Referenced by the following packages:
        SUNWesu
Current status: installed


[ OR ]

You can also simply query the packages as follows:

# grep /usr/bin/uuencode /var/sadm/install/contents
/usr/bin/uuencode f none 0555 root uucp 6880 43674 947116309 SUNWesu