Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

#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

Edit: my script:

#!/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

any idea? thank you

share|improve this question

1 Answer 1

up vote 3 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 test.sh*

there is . after permissions which indicates that an SELinux security context applies to that file. so I copied test.sh 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/

These may work as well:

setenforce 0 | reboot

OR

echo 0 > /selinux/enforce | reboot

OR:

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

SELINUX status: sestatus

share|improve this answer
1  
Disabling SElinux just to run a script might not be a good idea... –  Wilf Feb 2 at 8:32

Your Answer

 
discard

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.