Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've added the following line to the .bashrc file:

alias midos="sh /home/erkanmdr/Belgeler/midos/"

This command works fine in the terminal and tty. But not working in my .desktop shortcut file.

midos.desktop file:

[Desktop Entry]

How do I execute my midos command in the .desktop shortcut file?

share|improve this question
You can just substitute Exec=midos with Exec=sh /home/erkanmdr/Belgeler/midos/ – c0rp Jul 16 '14 at 15:55
I do not want it. I want to use directly. Its possible? – ErkanMDR Jul 16 '14 at 15:57
I'd replace sh with bash (alias midos="bash /home/erkanmdr/Belgeler/midos/") – Sylvain Pineau Jul 16 '14 at 15:57
@SylvainPineau not worked – ErkanMDR Jul 16 '14 at 16:10
up vote 17 down vote accepted

While the other answers offer a good workaround for your problem, to answer your question, the right way to use an alias inside a .desktop file is, in your case:

Exec=bash -ic "midos"

That's because aliases from ~/.bashrc file will work only in a bash interactive shell (-i option is used in this case to start bash interactive).

If another user wants to use the same .desktop file, then he must to have defined as well that alias.

share|improve this answer
Great! Exactly what I was looking for. Thank you very much – ErkanMDR Jul 17 '14 at 12:01

I would be extremely surprised if the GUI has any idea about your shell. You should put the full path in your desktop file:


And make sure that your script is executable.

share|improve this answer

Little workaround.

Add this #!/bin/bash to the first line of your script, if it is not there already.

For example your script before:


You script after:


Now copy your script to /usr/local/bin, and make it executable:

sudo cp /home/erkanmdr/Belgeler/midos/ /usr/local/bin/midos
sudo chmod +x /usr/local/bin/midos

After that it should work as you want.

share|improve this answer
Yes! Its worked. Thanks – ErkanMDR Jul 16 '14 at 17:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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