繁体   English   中英

运行脚本中的权限被拒绝

[英]permission denied in running script

我正在运行脚本,但有一个不寻常的警告:这是我的控制台中发生的情况

#whoami
root
#ls -l test.sh
-rwxr-xr-x. 1 root root 1894 Feb  2 01:58 test.sh*
#./test.sh
-bash: ./test.sh: Permission denied

编辑:我的脚本:

#!/bin/bash
while read pass port user ip file; do
  echo "startt------------------------------------" $ip
  ping $ip -c 4
  if [ $? -eq 0 ]; then
    echo $ip ok...
  else
    echo $ip failed...
  fi
  echo "finish------------------------------------" $ip
done <<____HERE
pass  22  root  1.1.1.1  test.txt
____HERE

任何想法? 谢谢

我在/ tmp目录中运行脚本,因为您看到ls的结果是:

-rwxr-xr-x. 1 root root 1894 Feb  2 01:58 test.sh*

. 权限之后,表示SELinux安全上下文适用于该文件。 所以我将test.sh复制到其他目录中...

问题解决了

ls -l /
drwxrwxrwt.   8 root root  1024 Feb  2 07:44 tmp/

我在一个目录中,驻留可执行文件可能不是一个好主意

这些也可以工作:

setenforce 0 | reboot

要么

echo 0 > /selinux/enforce | reboot

要么:

putting SELINUX=disabled in /etc/selinux/config and reboot (making sure to comment out anything in that file enabling selinux)

SELINUX状态: sestatus

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM