Akshay Damle
Akshay Damle

Reputation: 1250

How to create an executable for a shell script in Ubuntu?

I have written a simple Shell script named decBright.sh that decreases my screen brightness by a bit every time I run it. However, I do not want to open the terminal and execute bash decBright.sh every single time.

Instead, I want to create some kind of executable file that I can place on my Desktop, which will run my script when it is double-clicked. One answer I found here on the askUbuntu forums did not work for me.

Is there some other way to do it?

I am using Ubuntu 14.04 (Trusty Tahr)

Upvotes: 4

Views: 6247

Answers (1)

willeM_ Van Onsem
willeM_ Van Onsem

Reputation: 476557

An executable in linux is a file with the executable bit on. Thus you simply modify it with chmod:

chmod +x decBright.sh

Then you can run it with:

./decbright.sh

You can also run it by double-clicking in many graphical linux distributions.

You also better provide a "Shebang": the first line of your script should specify the "interpreter":

#!/bin/bash

Or any other interpreter (at the first line of your file).

Upvotes: 2

Related Questions