-
-
Save MorningLightMountain713/2188098ab14d25e70b7ea9e8bc9b0f8d to your computer and use it in GitHub Desktop.
Create a folder and set user:group with Python's os module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pwd | |
file_path = '/tmp/example' | |
if not os.path.exists(file_path): | |
os.makedirs(file_path) # creates with default perms 0777 | |
uid, gid = pwd.getpwnam('root').pw_uid, pwd.getpwnam('www-data').pw_uid | |
os.chown(file_path, uid, gid) # set user:group as root:www-data | |
# go check with ls -lah /tmp/example |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment