Python os.fchown() Method
Example
Changes the owner id and group id:
# Import os Library
import os
# Change owner id and group id of file
os.fchown("file.txt", 10, 12)
print ("Ids changed successfully")
Definition and Usage
The os.fchown()
changes the owner and group id of
a file to the numeric uid and gid. This method is only available by superuser or
privileged user.
Tip: This method is equivalent to
os.chown(fd, uid, gid)
.
Note: Available only on UNIX platforms.
Syntax
os.fchown(fd, uid, gid)
Parameter Values
Parameter | Description |
---|---|
fd | Required. A file descriptor |
uid | Required. An integer value representing the owner ID to be set for the file. To leave id unchanged, set it to -1. |
gid | Required. An integer value representing group ID to be set for the file. To leave id unchanged, set it to -1. |
Technical Details
Return Value: | None |
---|---|
Python Version: | 2.6 |