我无法理解为什么我无法附加到 python3 (3.2.3) 中的文件。我在共享文件夹中创建这些文件,但无法附加到它们。我的主文件夹中的文件没有问题。共享文件夹权限为:
drwxrwxrwx 2 nobody share 65536 2017-01-01 22:16 Pictures
我在拥有所有权限的“共享”组中:
groups alex
share www-data
我可以创建文件:
>>> testFile=open ('VID_2.mp4', 'wb')
>>> testFile.close()
但我不能附加到它:
>>> testFile=open ('VID_2.mp4', 'ab')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 13] Permission denied: 'VID_2.mp4'
我检查了文件权限,据我所知,我应该能够附加到该文件:
ls -l
-rw-rw-rw- 1 alex share 0 2017-01-01 22:40 VID_2.mp4
所以我很困惑为什么附加权限被拒绝,以及允许附加需要什么权限。
更新:
看来问题不在于 python 脚本,因为如果我使用 echo
,我会得到相同的权限错误:
touch myfile.txt
echo 1 > myfile.txt
echo 2 >> myfile.txt
-bash: myfile.txt Permission denied
ls -l myfile.txt
-rw-rw-rw- 1 alex share 2 2017-01-03 09:44 myfile.txt
更新 2:
这些文件夹在常规挂载 (/DataVolume) 下:
/dev/sda4 on /DataVolume type ext4 (rw,noatime,nodiratime)
/DataVolume/cache on /CacheVolume type none (rw,bind)
/DataVolume/shares on /shares type none (rw,bind)
/DataVolume/shares on /nfs type none (rw,bind)
cat /proc/mounts
/dev/sda4 /DataVolume ext4 rw,noatime,nodiratime,barrier=1,data=ordered 0 0
/dev/sda4 /CacheVolume ext4 rw,noatime,nodiratime,barrier=1,data=ordered 0 0
/dev/sda4 /shares ext4 rw,noatime,nodiratime,barrier=1,data=ordered 0 0
/dev/sda4 /nfs ext4 rw,noatime,nodiratime,barrier=1,data=ordered 0 0
我可以附加到 /DataVolume/home/alex
中的文件,但不能附加到 /DataVolume/shares
下的文件:
ls -l /DataVolume/
drwxrwxr-x 4 root root 65536 2013-11-14 21:15 home
drwxrwxr-x 7 root share 65536 2017-01-04 10:16 shares
ls -l /DataVolume/home/
drwxr-xr-x 7 alex share 65536 2017-01-01 22:24 alex
ls -l /DataVolume/home/alex
-rw-rw-rw- 1 alex share 4 2017-01-04 10:20 test.txt
ls -l /DataVolume/shares/
drwxrwxrw- 2 alex share 65536 2017-01-04 10:23 test
编辑:我不再拥有有问题的设备,因此我将无法再验证任何建议。
最佳答案
检查您的 umask
设置,文件在创建后未获得可执行权限。 umask 002
应该可以解决这个问题。
-rw-rw-rw- 1 alex share 2 2017-01-03 09:44 myfile.txt
关于linux - 尝试附加到已安装目录中的文件的权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41421138/