chown, fchown, lchown
#include <sys/types.h>
#include <unistd.h>
Function Prototype
int chown(const char *pathname, uid_t owner, gid_t grp);
int fchown(int filedes, uid_t owner, gid_t grp);
int lchown(const char *pathname, uid_t owner, gid_t grp);
- set
owner or grp to -1 if no change wanted
Function
- These function can change the user or the group owning the file
chown, fchown will trace symbolic link until the original file and change its ownership
lchown will only change the ownership of the symbolic link
- UID of a file can only be changed if you’re the superuser
- GID of a file can be change if
- The process running
chown is the owner of the file, and
grp parameter indicate a group the process is in