Python os.lchown() Method
Example
Change the owner and group id of path to the numeric uid and gid:
#Import os Library
import os
#change owner id and group id of file
os.lchown("/tmp/test.txt", 100, 120)
Definition and Usage
The os.lchown()
method changes the owner and group id of path to the numeric uid and gid, but does not follow symbolic links. This method is used by Superuser and privileged user.
This is equivalent to os.chown(path, uid, gid, follow_symlinks=False)
.
Note: Available on UNIX platforms only.
Syntax
os.lchown(path, uid , gid)
Parameter Values
Parameter | Description |
---|---|
path | Required. Specifies the path to change owner and group for |
uid | Required. An integer value representing the owner id to be set for the path |
gid | Required. An integer value representing the group id to be set for the path |
Technical Details
Return Value: | None |
---|---|
Python Version: | 2.6 |
Change Log: | 3.6- Accepts a path-like object |