YouTip LogoYouTip

Os Lchown

# Python2.x Python os.lchown() Method [![Image 3: Python File Methods](#) Python OS File/Directory Methods](#) * * * ### Overview The os.lchown() method is used to change the file owner, similar to chown, but it does not follow symbolic links. It is only supported on Unix systems. ### Syntax The syntax format of the **lchown()** method is as follows: os.lchown(path, uid, gid) ### Parameters * **path** -- The file path to set permissions for * **uid** -- The owner user ID * **gid** -- The owner group ID ### Return Value This method does not return a value. ### Example The following example demonstrates the use of the lchown() method: #!/usr/bin/python# -*- coding: UTF-8 -*-import os, sys # open file path = "/var/www/html/foo.txt" fd = os.open( path, os.O_RDWR|os.O_CREAT )# close opened file os.close( fd )#
← Linux Comm CompressLinux Comm Unarj β†’