我正在linux盒子上选择一些路径进行安装。例如/var/test/installer如何检查该路径是否具有读取、写入和执行权限?
我确实尝试过"寻找命令",但没有取得很大成功。
伙计们,做"ls-l"对我没有帮助。这是一个真正的问题。。。我的/var/分区没有执行权限。我可以通过使用"mount"命令看到即>安装/dev/sd1在/var/type ext3(rw、noexec、nosuid、nodev、noatime)上
但是在/var/test/install下的任何文件夹的ls-l都会显示我的读、写&执行权限。
所以我看到了grep一个mount命令来检查noexec的唯一方法。
你的想法。
提前谢谢。
==============================================
我最终所理解的是,我必须检查两级权限
-
装载点的权限
使用"mount"命令或检查/etc/fstab文件
-
单个文件夹的权限
Usinf"ls-l"命令
这解决了我的问题。
查看test
命令
来自手册页
-c FILE
FILE exists and is character special
-d FILE
FILE exists and is a directory
-e FILE
FILE exists
-f FILE
FILE exists and is a regular file
-g FILE
FILE exists and is set-group-ID
-G FILE
FILE exists and is owned by the effective group ID
-h FILE
FILE exists and is a symbolic link (same as -L)
-k FILE
FILE exists and has its sticky bit set
-L FILE
FILE exists and is a symbolic link (same as -h)
-O FILE
FILE exists and is owned by the effective user ID
-p FILE
FILE exists and is a named pipe
-r FILE
FILE exists and read permission is granted
-s FILE
FILE exists and has a size greater than zero
-S FILE
FILE exists and is a socket
-t FD file descriptor FD is opened on a terminal
-u FILE
FILE exists and its set-user-ID bit is set
-w FILE
FILE exists and write permission is granted
-x FILE
FILE exists and execute (or search) permission is granted
一个好的手册页
try ls-l[文件名]请参阅此处
ls -la /path/
Sample Output:
-rw-r--r-- 1 eclipse adm 14112 Feb 18 08:49 st433.dat
-rw-r--r-- 1 eclipse adm 24700 Feb 18 08:49 st433.lst
-rw-r--r-- 1 eclipse adm 14112 Feb 18 08:49 st434.dat
-rw-r--r-- 1 eclipse adm 24624 Feb 18 08:49 st434.lst
解释权限位:
-rw-r--r-
0123456789
您可以看到文件列表属于用户eclipse和组adm
第一位0是一种特殊情况,对于普通文件为空,对于目录等为空,与权限无关。
位123定义所有者权限(在本例中为eclipse用户)。rw-意味着用户eclipse可以读取或写入这些文件。
位456是组权限,因此在这种情况下(r-)属于组adm的任何其他人都可以读取但不能修改上述文件。
位789是"其他"的权限,因此该文件对其他用户也是可读的,但不可写。
rwx-rwx-rwx
用户组其他
读取/写入/执行权限
如果你不喜欢test
命令,也许stat(1)
可以帮助你:
[joe@hal ~]$ stat --format='%A' /etc/passwd # access rights in human readable form
-rw-r--r--
[joe@hal ~]$ stat --format='%a' /etc/passwd # access rights in octal
644
[joe@hal ~]$ stat --format='%f' /etc/passwd # raw mode in hex
81a4
十六进制的81a4是八进制的100644。
chmod(1)
手册页介绍了如何解释文件模式:
字母rwxXst为受影响的用户选择文件模式位:读取(r)、写入(w)、执行(或搜索目录)(x),仅当文件是目录或已具有时执行/搜索对某些用户(X)执行权限,设置上的用户或组ID执行、受限删除标志或粘性位(t)。而不是一个或多个这样的字母,您可以指定其中一个letters ugo:授予拥有该文件的用户的权限(u) ,授予属于的其他用户的权限文件的组(g),以及授予中的用户的权限前面两个类别都不是(o)。
数字模式是从一到四个八进制数字(0-7),由将具有值4、2和1的比特相加。省略的数字为假定为前导零。第一个数字选择集合用户ID(4)和设置组ID(2)以及限制删除或粘性(1)属性。第二位数字为以下用户选择每个任务拥有文件:读取(4)、写入(2)和执行(1);第三个选择文件组中其他用户的权限价值观第四个用于不在文件组中的其他用户相同的值。