./ does not work after chmod [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite
1












I'm on a Centos server and when I tried to run



./script.sh



I get the Permission Denied error even after I tried adding chmod +x script.sh.



sh script.sh works though.



UPDATE



The script file starts with #!/bin/sh










share|improve this question









New contributor




SachiDangalla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











closed as unclear what you're asking by muru, Goro, Jeff Schaller, αғsнιη, GAD3R Oct 1 at 15:31


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 11




    Could you edit your question to add any error messages output by the failed commands and the first few lines of the script? Also, do you know if the filesystem the script resides on is mounted as noexec or similar?
    – dsstorefile1
    Oct 1 at 8:05






  • 1




    dos file might trigger end-of-line problem, have you tried dos2unix script.sh ?
    – Archemar
    Oct 1 at 12:16










  • Does your user have read permission on the script?
    – Lie Ryan
    Oct 3 at 5:11










  • Is the script located on a partition mounted with noexec? Check with the mount command.
    – Kusalananda
    Oct 3 at 6:53














up vote
-1
down vote

favorite
1












I'm on a Centos server and when I tried to run



./script.sh



I get the Permission Denied error even after I tried adding chmod +x script.sh.



sh script.sh works though.



UPDATE



The script file starts with #!/bin/sh










share|improve this question









New contributor




SachiDangalla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











closed as unclear what you're asking by muru, Goro, Jeff Schaller, αғsнιη, GAD3R Oct 1 at 15:31


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 11




    Could you edit your question to add any error messages output by the failed commands and the first few lines of the script? Also, do you know if the filesystem the script resides on is mounted as noexec or similar?
    – dsstorefile1
    Oct 1 at 8:05






  • 1




    dos file might trigger end-of-line problem, have you tried dos2unix script.sh ?
    – Archemar
    Oct 1 at 12:16










  • Does your user have read permission on the script?
    – Lie Ryan
    Oct 3 at 5:11










  • Is the script located on a partition mounted with noexec? Check with the mount command.
    – Kusalananda
    Oct 3 at 6:53












up vote
-1
down vote

favorite
1









up vote
-1
down vote

favorite
1






1





I'm on a Centos server and when I tried to run



./script.sh



I get the Permission Denied error even after I tried adding chmod +x script.sh.



sh script.sh works though.



UPDATE



The script file starts with #!/bin/sh










share|improve this question









New contributor




SachiDangalla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm on a Centos server and when I tried to run



./script.sh



I get the Permission Denied error even after I tried adding chmod +x script.sh.



sh script.sh works though.



UPDATE



The script file starts with #!/bin/sh







bash shell-script






share|improve this question









New contributor




SachiDangalla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




SachiDangalla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Oct 3 at 4:40





















New contributor




SachiDangalla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Oct 1 at 8:01









SachiDangalla

1004




1004




New contributor




SachiDangalla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





SachiDangalla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






SachiDangalla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




closed as unclear what you're asking by muru, Goro, Jeff Schaller, αғsнιη, GAD3R Oct 1 at 15:31


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as unclear what you're asking by muru, Goro, Jeff Schaller, αғsнιη, GAD3R Oct 1 at 15:31


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 11




    Could you edit your question to add any error messages output by the failed commands and the first few lines of the script? Also, do you know if the filesystem the script resides on is mounted as noexec or similar?
    – dsstorefile1
    Oct 1 at 8:05






  • 1




    dos file might trigger end-of-line problem, have you tried dos2unix script.sh ?
    – Archemar
    Oct 1 at 12:16










  • Does your user have read permission on the script?
    – Lie Ryan
    Oct 3 at 5:11










  • Is the script located on a partition mounted with noexec? Check with the mount command.
    – Kusalananda
    Oct 3 at 6:53












  • 11




    Could you edit your question to add any error messages output by the failed commands and the first few lines of the script? Also, do you know if the filesystem the script resides on is mounted as noexec or similar?
    – dsstorefile1
    Oct 1 at 8:05






  • 1




    dos file might trigger end-of-line problem, have you tried dos2unix script.sh ?
    – Archemar
    Oct 1 at 12:16










  • Does your user have read permission on the script?
    – Lie Ryan
    Oct 3 at 5:11










  • Is the script located on a partition mounted with noexec? Check with the mount command.
    – Kusalananda
    Oct 3 at 6:53







11




11




Could you edit your question to add any error messages output by the failed commands and the first few lines of the script? Also, do you know if the filesystem the script resides on is mounted as noexec or similar?
– dsstorefile1
Oct 1 at 8:05




Could you edit your question to add any error messages output by the failed commands and the first few lines of the script? Also, do you know if the filesystem the script resides on is mounted as noexec or similar?
– dsstorefile1
Oct 1 at 8:05




1




1




dos file might trigger end-of-line problem, have you tried dos2unix script.sh ?
– Archemar
Oct 1 at 12:16




dos file might trigger end-of-line problem, have you tried dos2unix script.sh ?
– Archemar
Oct 1 at 12:16












Does your user have read permission on the script?
– Lie Ryan
Oct 3 at 5:11




Does your user have read permission on the script?
– Lie Ryan
Oct 3 at 5:11












Is the script located on a partition mounted with noexec? Check with the mount command.
– Kusalananda
Oct 3 at 6:53




Is the script located on a partition mounted with noexec? Check with the mount command.
– Kusalananda
Oct 3 at 6:53










1 Answer
1






active

oldest

votes

















up vote
1
down vote













Most probably your script lacks a "shebang". The system tries to read which interpreting program should be executed to run the script. A "shebang" is recognized by the system if it is on the very first line and starts with #!.



Examples:



#!/bin/bash




#!/bin/sh




#!/usr/bin/env python




#!/bin/sed


Note that #! is a comment otherwise in most scripting languages, so it will not error out if you run it with a specific interpreting program from the command line like so:



$ bash ./script.sh


More information: https://en.wikipedia.org/wiki/Shebang_(Unix)






share|improve this answer






















  • It has the line #!/bin/sh
    – SachiDangalla
    Oct 1 at 9:21











  • Does /bin/sh actually exist on your system? Is it a shell binary? Does /bin/sh have executable (x) permission set?
    – Hkoof
    Oct 1 at 9:30











  • What is the difference between a sh and bash hashbang?
    – Sam
    Oct 1 at 9:32











  • See stackoverflow.com/questions/5725296/…
    – RoVo
    Oct 1 at 11:25










  • @Sam, it runs a different shell. Not all systems have Bash, and even on those that do, /bin/sh might not be Bash (e.g. Debian and Ubuntu). See e.g. unix.stackexchange.com/q/250913/170373
    – ilkkachu
    Oct 1 at 11:27

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













Most probably your script lacks a "shebang". The system tries to read which interpreting program should be executed to run the script. A "shebang" is recognized by the system if it is on the very first line and starts with #!.



Examples:



#!/bin/bash




#!/bin/sh




#!/usr/bin/env python




#!/bin/sed


Note that #! is a comment otherwise in most scripting languages, so it will not error out if you run it with a specific interpreting program from the command line like so:



$ bash ./script.sh


More information: https://en.wikipedia.org/wiki/Shebang_(Unix)






share|improve this answer






















  • It has the line #!/bin/sh
    – SachiDangalla
    Oct 1 at 9:21











  • Does /bin/sh actually exist on your system? Is it a shell binary? Does /bin/sh have executable (x) permission set?
    – Hkoof
    Oct 1 at 9:30











  • What is the difference between a sh and bash hashbang?
    – Sam
    Oct 1 at 9:32











  • See stackoverflow.com/questions/5725296/…
    – RoVo
    Oct 1 at 11:25










  • @Sam, it runs a different shell. Not all systems have Bash, and even on those that do, /bin/sh might not be Bash (e.g. Debian and Ubuntu). See e.g. unix.stackexchange.com/q/250913/170373
    – ilkkachu
    Oct 1 at 11:27














up vote
1
down vote













Most probably your script lacks a "shebang". The system tries to read which interpreting program should be executed to run the script. A "shebang" is recognized by the system if it is on the very first line and starts with #!.



Examples:



#!/bin/bash




#!/bin/sh




#!/usr/bin/env python




#!/bin/sed


Note that #! is a comment otherwise in most scripting languages, so it will not error out if you run it with a specific interpreting program from the command line like so:



$ bash ./script.sh


More information: https://en.wikipedia.org/wiki/Shebang_(Unix)






share|improve this answer






















  • It has the line #!/bin/sh
    – SachiDangalla
    Oct 1 at 9:21











  • Does /bin/sh actually exist on your system? Is it a shell binary? Does /bin/sh have executable (x) permission set?
    – Hkoof
    Oct 1 at 9:30











  • What is the difference between a sh and bash hashbang?
    – Sam
    Oct 1 at 9:32











  • See stackoverflow.com/questions/5725296/…
    – RoVo
    Oct 1 at 11:25










  • @Sam, it runs a different shell. Not all systems have Bash, and even on those that do, /bin/sh might not be Bash (e.g. Debian and Ubuntu). See e.g. unix.stackexchange.com/q/250913/170373
    – ilkkachu
    Oct 1 at 11:27












up vote
1
down vote










up vote
1
down vote









Most probably your script lacks a "shebang". The system tries to read which interpreting program should be executed to run the script. A "shebang" is recognized by the system if it is on the very first line and starts with #!.



Examples:



#!/bin/bash




#!/bin/sh




#!/usr/bin/env python




#!/bin/sed


Note that #! is a comment otherwise in most scripting languages, so it will not error out if you run it with a specific interpreting program from the command line like so:



$ bash ./script.sh


More information: https://en.wikipedia.org/wiki/Shebang_(Unix)






share|improve this answer














Most probably your script lacks a "shebang". The system tries to read which interpreting program should be executed to run the script. A "shebang" is recognized by the system if it is on the very first line and starts with #!.



Examples:



#!/bin/bash




#!/bin/sh




#!/usr/bin/env python




#!/bin/sed


Note that #! is a comment otherwise in most scripting languages, so it will not error out if you run it with a specific interpreting program from the command line like so:



$ bash ./script.sh


More information: https://en.wikipedia.org/wiki/Shebang_(Unix)







share|improve this answer














share|improve this answer



share|improve this answer








edited Oct 1 at 8:47









Kusalananda

108k14210333




108k14210333










answered Oct 1 at 8:07









Hkoof

93266




93266











  • It has the line #!/bin/sh
    – SachiDangalla
    Oct 1 at 9:21











  • Does /bin/sh actually exist on your system? Is it a shell binary? Does /bin/sh have executable (x) permission set?
    – Hkoof
    Oct 1 at 9:30











  • What is the difference between a sh and bash hashbang?
    – Sam
    Oct 1 at 9:32











  • See stackoverflow.com/questions/5725296/…
    – RoVo
    Oct 1 at 11:25










  • @Sam, it runs a different shell. Not all systems have Bash, and even on those that do, /bin/sh might not be Bash (e.g. Debian and Ubuntu). See e.g. unix.stackexchange.com/q/250913/170373
    – ilkkachu
    Oct 1 at 11:27
















  • It has the line #!/bin/sh
    – SachiDangalla
    Oct 1 at 9:21











  • Does /bin/sh actually exist on your system? Is it a shell binary? Does /bin/sh have executable (x) permission set?
    – Hkoof
    Oct 1 at 9:30











  • What is the difference between a sh and bash hashbang?
    – Sam
    Oct 1 at 9:32











  • See stackoverflow.com/questions/5725296/…
    – RoVo
    Oct 1 at 11:25










  • @Sam, it runs a different shell. Not all systems have Bash, and even on those that do, /bin/sh might not be Bash (e.g. Debian and Ubuntu). See e.g. unix.stackexchange.com/q/250913/170373
    – ilkkachu
    Oct 1 at 11:27















It has the line #!/bin/sh
– SachiDangalla
Oct 1 at 9:21





It has the line #!/bin/sh
– SachiDangalla
Oct 1 at 9:21













Does /bin/sh actually exist on your system? Is it a shell binary? Does /bin/sh have executable (x) permission set?
– Hkoof
Oct 1 at 9:30





Does /bin/sh actually exist on your system? Is it a shell binary? Does /bin/sh have executable (x) permission set?
– Hkoof
Oct 1 at 9:30













What is the difference between a sh and bash hashbang?
– Sam
Oct 1 at 9:32





What is the difference between a sh and bash hashbang?
– Sam
Oct 1 at 9:32













See stackoverflow.com/questions/5725296/…
– RoVo
Oct 1 at 11:25




See stackoverflow.com/questions/5725296/…
– RoVo
Oct 1 at 11:25












@Sam, it runs a different shell. Not all systems have Bash, and even on those that do, /bin/sh might not be Bash (e.g. Debian and Ubuntu). See e.g. unix.stackexchange.com/q/250913/170373
– ilkkachu
Oct 1 at 11:27




@Sam, it runs a different shell. Not all systems have Bash, and even on those that do, /bin/sh might not be Bash (e.g. Debian and Ubuntu). See e.g. unix.stackexchange.com/q/250913/170373
– ilkkachu
Oct 1 at 11:27


Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?