当执行驱动器的递归目录扫描以通过在sudo下运行程序可执行文件来生成每个文件的哈希时,我发现有1,000个文件正在抛出“Permission拒绝“错误。Linux - 从Sudo读取文件 - “权限被拒绝”
我的问题:这是否由设计,为什么是sudo无法读取文件?我在做什么甚至可能,因为在扫描期间文件可能被加密或当前正在使用?
当我编译到Mac OSX并执行相同的扫描sudo下,我没有这个问题,只是Linux。
Distro: 3.19.0-25-generiC#26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
许可文件的实例否认:
Can't open file: "/sys/class/gpio/unexport"
MSG: "Permission denied"
Can't open file: "/sys/class/gpio/export"
MSG: "Permission denied"
的权限设置示例:
/sys/class/gpio$ ls -al
total 0
drwxr-xr-x 2 root root 0 Oct 5 04:51 .
drwxr-xr-x 57 root root 0 Oct 4 11:25 ..
--w------- 1 root root 4096 Oct 5 04:51 export
--w------- 1 root root 4096 Oct 5 04:51 unexport
MD5函数,其中文件读取失败: