Ubuntu – How to make a file (e.g. a .sh script) executable, so it can be run from a terminal

command lineexecutable

I have a script.sh file and type of this file is shellscript file. I want to make this file as application/x-executable file. How can I make it?

Best Answer

  • You can mark the file as executable:

    chmod +x filename.sh

    You can then execute it like this:


    If you want to use a different command to start it, you can add an alias:

    gedit ~/.bashrc

    Add this at the end of the file:

    alias <new name>='/home/<full path to script>/filename.sh'

    Open a new terminal session or type source ~/.bashrc in your terminal to apply. Then simply use the new name to start the script.

  • Related Question