gpt4 book ai didi

用于读写和可执行权限的linux命令

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:43:44 25 4
gpt4 key购买 nike

我在 linux box 上选择一些路径进行安装。例如/var/test/installer如何检查该路径是否具有读取、写入和执行权限?

我确实尝试过“find command”,但没有取得太大的成功。

伙计们,执行“ls -l”对我没有帮助。这是一个真正的问题......我的/var 分区没有执行权限。我可以通过使用“mount”命令看到即 > 安装/dev/sda1 on/var type ext3 (rw,noexec,nosuid,nodev,noatime)

但 ls -l 用于/var 下的任何文件夹,即。/var/test/install 显示读取、写入和执行权限。

所以我只看到了 grep 挂载命令来检查 noexec 的方法。

你的想法。

提前致谢。

=============================================

我最终理解的是我必须检查两个级别的权限

  1. 挂载点权限

    使用“mount”命令或检查/etc/fstab 文件

  2. 单个文件夹的权限

    使用“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

A good man page

关于用于读写和可执行权限的linux命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14952460/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com