mkdir permission denied mkdir permission denied unix unix

mkdir permission denied


Have you tried using os.system with a sudo command on the operation only?

os.system("sudo mkdir /var/machine/hi")


The owners for /var is root wheel

The owners for /var/machine is root wheel

The owner of the directory in which you are trying to create the directory is root, and hence, you will either have to run as root, or as sudo.

Alternatively, you can change the directory user ownership using

sudo chown popcorn:wheel /var/machine

but this assumes user popcorn is added in wheel