简体   繁体   English

makedirs给出OSError:[错误13]权限被拒绝

[英]makedirs gives OSError:[Error 13] Permission denied

I want to create a folder on apache 我想在apache上创建一个文件夹

#!/usr/bin/python
import cgi, os
import cgitb; cgitb.enable()
import subprocess
import sys

if not os.path.exists("/home/suni"):
        os.makedirs("/home/suni")

But i am unable to do that and facing this error 但是我无法做到这一点,并面临这个错误

<type 'exceptions.OSError'>: [Errno 13] Permission denied: '/home/suni' 
      args = (13, 'Permission denied') 
      errno = 13 
      filename = '/home/suni' 
      message = '' 
      strerror = 'Permission denied'

i have tried chmod 777 /home still facing the error. 我尝试过chmod 777 /home仍然遇到错误。

Considering Linux filesystem, /home directory is tied with root:root user. 考虑到Linux文件系统, /home目录与root:root用户绑定。

You should run your python script as root or with sudo . 您应该以root用户或使用sudo运行python脚本。 Doing chmod 777 on home directory is not suggested. 不建议在主目录上执行chmod 777

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM