Ubuntu – How to run .sh scripts

bashcommand lineexecute-commandscripts

Whenever I open a .sh file, it opens it in gedit instead of the terminal. I can't find any option similar to Right ClickOpen WithOther Application…Terminal.

How do I open this file in the terminal?

Best Answer

  • Give execute permission to your script:

    chmod +x /path/to/yourscript.sh
    

    And to run your script:

    /path/to/yourscript.sh
    

    Since . refers to the current directory: if yourscript.sh is in the current directory, you can simplify this to:

    ./yourscript.sh