How to set a files owner in python?

os.chown(path, uid, gid)

http://docs.python.org/library/os.html

The uid and gid can be retrieved from a string by

import pwd
import grp
import os

uid = pwd.getpwnam("nobody").pw_uid
gid = grp.getgrnam("nogroup").gr_gid

Reference: How to change the user and group permissions for a directory, by name?

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)