I have this simple command saved as .sh-file

xdg-open https://stackoverflow.com

upon opening it, I can choose between launching it directly or in a terminal. However, it only works when opening it directly. When I chose "Run in Terminal", it shows a Terminal, which instantly closes again and nothing happens.

Why does this behave differently and how do fix it, since I later need user input in the script from the terminal?

1 Answer 1


You should add the 'shebang' to the first line of your script.:

xdg-open https://stackoverflow.com

This tells how the script is executed or which interpreter should be run to execute your code.

Then you need the execute permission for it. You can set it in the properties in your GUI or commandline

chmod +x myscript.sh

After this you should be able to execute it and your default browser should open a new window.

  • unfortunately I tried both of these already, and it still doesn't work...
    – xeruf
    Feb 13, 2018 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.