Python | shutil.chown() method
Shutil module in Python provides many functions of high-level operations on files and collections of files. It comes under Python’s standard utility modules. This module helps in automating process of chowning and removal of files and directories.
shutil.chown() method in Python is used to change the owner and /or group of the specified path.
Syntax: shutil.chown(path, user = None, group = None)
path: A string value representing a valid path.
user: A string value representing a system user
group: A string value representing a group
user and group can be also given by user id (uid) and group id (gid) respectively.
Return Type: This method does not return any value.
shutil.chown()method to change owner and group of the specified path
Current owner and group of the specified path Owner: root Group: root Owner and group changed Current owner: ihritik Current group: ihritik Only group changed Current owner: ihritik Current group: root
Current owner and group of the specified path Owner: ihritik Group: ihritik Owner and group changed Current owner: root Current group: root
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course