权限被拒绝尝试附加到已安装目录中的文件

问题描述 投票:6回答:1

我无法理解为什么我无法附加到python3(3.2.3)中的文件。我在共享文件夹中创建这些文件,但我无法附加到它们。我的主文件夹中的文件没有问题。共享文件夹权限是:

drwxrwxrwx  2 nobody   share       65536 2017-01-01 22:16 Pictures

我在'share'组中拥有所有权限:

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

编辑:我不再有问题的设备,所以我将无法再验证任何建议。

linux unix file-permissions
1个回答
1
投票

检查您的umask设置,该文件在创建后没有获得可执行权限。 umask 002应该解决这个问题。

-rw-rw-rw- 1 alex share 2 2017-01-03 09:44 myfile.txt

© www.soinside.com 2019 - 2024. All rights reserved.