Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running a script but there is an unusual warning: This is what happened in my console

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

Edit: my script:

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

any idea? thank you

share|improve this question
Try to run it using strace ./ This may give you a hint. – Khaled Feb 2 '14 at 7:58
Works for me on my CentOS Linux system. I'm guessing selinux is blocking execution. To disable selinux: setenforce 0 then try to run the script again. /etc/selinux/config sets whether selinux is enabled at system boot time. – samiam Feb 2 '14 at 8:14
@samiam I tried setenforce 0 but no result guy – MLSC Feb 2 '14 at 8:15
Try this: echo 0 > /selinux/enforce – samiam Feb 2 '14 at 8:19
@samiam: The correct thing to do if you suspect SELinux is to look for messages in /var/log/audit/audit.log and take appropriate action. That turning it off with setenforce 0 didn't solve the problem suggests that the problem lies elsewhere. – Iain Feb 2 '14 at 12:24

im guessing it has do with SELINUX. You are able to check the status with simply typing sestatus

share|improve this answer
If you read the extensice comments above the OP setenforce 0 and the problem didn't go away. – Iain Feb 3 '14 at 8:51
up vote 0 down vote accepted

I am running the script in /tmp directory as you see the result of ls is:

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

there is . after permissions which indicates that an SELinux security context applies to that file. so I copied in a directory else...

the problem was solved

I was in a directory where it might be a bad idea for executables to reside

ls -l /
drwxrwxrwt.   8 root root  1024 Feb  2 07:44 tmp/
share|improve this answer
Thanks, I learned something new (I wondered what that trailing dot was) – samiam Feb 2 '14 at 9:00
You don't say which version of CentOS but I have an out of the box CentOS 6.5 with SELinux enabled. If I create your file in /tmp, and make it executable it runs just fine. That you copied your file elsewhere and it works does not prove SELinux is involved. the setenforce 0 command should have enabled permissive mode, that this didn't solve the problem also suggests SELinux is not involved. You should check /var/log/audit/audit.log for AVC denied messages relating to your issue to prove SELinux is involved. – Iain Feb 2 '14 at 12:46
@ samiam your welcome – MLSC Feb 2 '14 at 12:47
@Iain I have centos 6.5 ...why negative? what I understand: "I was in a directory where it might be a bad idea for executables to reside" may be something happend with my /tmp..This is my tmp output (drwxrwxrwt. 8 root root 1024 Feb 2 07:44 tmp/) – MLSC Feb 2 '14 at 12:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.