【问题标题】:Unix permission denied error even though directory is writable即使目录是可写的,Unix权限被拒绝错误
【发布时间】:2016-05-21 14:29:36
【问题描述】:

我在为我的目录设置权限时遇到问题。 有问题的目录是,

/usr/home/Test/me

我已使用chmod 命令将其设置为777,如下所示,

drwxrwxrwx  2 root  me  2 May 22 00:06 me

我的Test目录的权限如下,

drwxrwxrwt  4 root           wheel           4 May 22 00:06 Test

现在我正在运行以下代码来检查目录是否可写,

if [ ! -d "$SDIR" -o ! -w "$SDIR" ]; then
  echo "ERROR: directory $SDIR not writable"
  exit 1
fi

它总是显示目录不可写。我不明白为什么即使我将它设置为777,它总是说不可写?

【问题讨论】:

  • 我工作得很好。还有什么问题……
  • 有没有办法弄清楚它有什么问题?
  • 如果没有手下的环境,很难为您提供帮助。你尝试过另一个目录吗?

标签: unix permissions


【解决方案1】:

我不知道“$SDIR”是什么意思,但我很确定这就是问题所在。

我运行了一个类似的脚本,将文件夹作为参数传递,它可以工作。

if [  -d $1 -a ! -w $1 ]; then
  echo "ERROR: directory $SDIR not writable"
  exit 1
else
  echo "It is a directory and it is writable"
fi

【讨论】:

  • $SDIR/usr/home/Test/me
  • 在这种情况下,您可能应该删除双引号:if [ ! -d $SDIR -o ! -w $SDIR ]; then
猜你喜欢
  • 2015-09-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-25
  • 2011-01-16
  • 2018-07-19
  • 1970-01-01
  • 2020-08-27
相关资源
最近更新 更多