Whenever I open a .sh file, it opens it in gedit instead of the terminal. I can't find any option similar to Right Click → Open With → Other Application... → Terminal.
How do I open this file in the terminal?
Give execute permission to your script:
And to run your script:
You need to mark shell scripts as executable to run them from the file manager:
Before you can run the .sh file, you need to make it executable:
Make sure you trust the source where you got the file from. It could be a virus.
The very simple way
This has problem. The terminal will close immediately and you will not be able to see the output.
The simple way
The way professionals do it
Why do it the complicated way?
The terminal has a rich set of powerful tools that are accessible by typing the commands. Professionals locate the .sh file by typing
or you can run and redirect the output to a file:
or you can filter the output for keywords (e.g. "apples") an then redirect to a file:
There are thousands of things you can to to that file just by typing a few commands.
Another one, you can download a file from the Internet with one simple command:
And then open the file like this:
On Ubuntu 13.04 executable files opened in Nautilus are now opened in gedit by default rather than prompting the user to execute them. To enable the classic behavior you need to adjust the preferences:
Nautilus → Edit menu → Preferences → Behaviour tab → Click the radio button near Ask each time.
Open a terminal and navigate to the folder where the
If you place your shell script or other executable you create in /usr/local/bin it will be found and executed without having to provide a folder path in the command line or adding ./ to the name. For example I created the following simple 3 line bash script to display disk UUIDs:
I called the file uuid and placed it in /usr/local/bin. All I need enter on the command line is:
2 main steps.
Now, when you double click the file on the desktop, it should execute.
no need for
There are a few ways to do this.
1) In the terminal, access the directory the Bash file is in using cd (change directory).
This also works with .run files. There is an example of this usage at this webpage on updating Rhythmbox.
1) In the terminal, navigate to the directory the bash file is in.
3) In Nautilus, open the file.
The problem i have found on a few distributions is they have hidden the preferences option in nautilus... but to fix it in both ubuntu and other distributions using gnome3 is the same (literally just done the fedora version of this and posting the actual fix to remind me how in the future)
1) install dconf-editor
2) run dconf-editor using the user account you want this on.. i.e NOT root
3) navigate to the following location
4) change the default option to not open by default
that will give you the option to edit, view or run the file going forward
You can also use