Os Chown
# Python2.x Python os.chown() Method
[ Python OS File/Directory Methods](#)
* * *
### Overview
The os.chown() method is used to change the file owner. If no modification is needed, it can be set to -1. You need superuser privileges to perform permission modification operations.
Only supported on Unix systems.
### Syntax
The **chown()** method syntax is as follows:
os.chown(path, uid, gid);
### Parameters
* **path** -- File path to set permissions for
* **uid** -- User ID to own the file
* **gid** -- Group ID to own the file
### Return Value
This method has no return value.
### Example
The following example demonstrates the use of the chown() method:
## Example
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os,sys
# Assume /tmp/foo.txt file exists.
# Set owner ID to 100
os.chown("/tmp/foo.txt",100, -1)
print"Permission modified successfully!!"
The output of the above program is:
Permission modified successfully!!
[ Python OS File/Directory Methods](#)
YouTip