Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a .sh file which is not becoming an executable. I tried doing it in the properties but as soon I ticked the checkbox, the tick vanished in a second.

I then tried

sudo chmod +x filename.sh

which returned nothing and after checking its properties, it dint turn into an executable. Any solutions?

share|improve this question

migrated from stackoverflow.com Jan 1 '13 at 12:36

This question came from our site for professional and enthusiast programmers.

    
Even if it isn't executable, I guess you can just "execute" it by . ./filename.sh? –  Alvin Wong Jan 1 '13 at 7:40
    
Maybe the file is still opened in another program? Like gedit or another terminal. –  Lennart Jan 1 '13 at 13:44
    
@AlvinWong A closer approximation would be sh ./filename.sh - using . (equivalent of source) would parse it in the current shell, rather than spawning a subshell. –  Bob Oct 24 '13 at 14:23
    
1) @OP: Do you intend to run that script as uid 0 (aka toor, root, admin ,...)? If not, why use sudo? 2) What happens if you open a shell, cd to the the directory the script is in and type chmod +x filename.sh? 3) What is the first line of filename.sh? Is that #!/usr/bin/env bash or similar? –  Hennes Mar 9 at 12:10
add comment

3 Answers

open the terminal and write the following command

chmod +x filename.sh

Well that gonna make your file executable which can be run from terminal by simple command

sudo ./filename.sh

There is another way of doing it through GUI, when you right click on the file and goto permissions tab then you get an option to make the file executable by just clicking a checkbox

share|improve this answer
    
I was just about to type the same thing. I suspect the "./" prefix was getting missed. –  selbie Jan 1 '13 at 7:39
    
yupp tht was d error... and see that other way too. thtz more easy if you want to work just by GUI. If yu found my answer correct, plz mark it as accepted answer :) –  Azzy Jan 1 '13 at 7:40
    
@Azzy I already tried what you said. Using the GUI, when I clicked the checkbox in the permissions tab, the tick vanished in a second. And when I tried what you said, it returned sudo command not found. –  Ankit Agrawal Jan 1 '13 at 9:03
    
you don't need, and shouldn't use sudo unless you need to run it as root. Have you tried sh ./filename.sh? –  stib Mar 9 at 12:20
add comment
  1. use gedit to write and save script with .sh extension to desktop.
  2. open Nautilus and right click the script.sh file.
    • under properties, check box "allow executing file.."
    • in Nautilus menu, click file,then preferences,then behaviour
    • check the "run executable text files when they are opened".

Now, when you double click the file, it should execute.

share|improve this answer
add comment

Check the immutability of the file with the extended attributes of the filesystem:

lsattr script.sh

look for i attribute and remove it with chattr.

share|improve this answer
add comment

Your Answer

 
discard

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