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 am trying to create an alias and I have added these lines in ~/.bash_aliases

alias server-python='open http://localhost:8000 && python -m SimpleHTTPServer'

alias ssh-saad='ssh saad@<my-server>' <my-server> is replaced by the ip add of my server. So in my ~/.bashrc file these lines are uncommented

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases

and in my ~/.profile

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"

so I believe whenever I start the terminal my aliases should work but unless I run this command source ~/.bash_aliases its not working. Also for the 1st server-python alias I am getting an error

"Couldn't get a file descriptor referring to the console "

I have looked into these solutions here
How to create a permanent "alias"?
Ubuntu alias not applied in bashrc

but still cannot make it work. I would really appreciate if someone could point me out what I am doing wrong. I know the problem is very trivial, but I must be just missing something. Thanks in advance.

ok now I know why I am getting this error

"Couldn't get a file descriptor referring to the console "

I should have used alias server-python='sensible-browser http://localhost:8000 && python -m SimpleHTTPServer'

I should have used sensible-browser instead of open.

share|improve this question
Do the second alias (ssh-aad) work for you? Because I think it has a flaw. – NotFromBrooklyn Dec 13 '12 at 9:15
yes it does work for me can you tell me what is the flaw that you find – Saad Dec 13 '12 at 12:21
alias name='commands' something The something part shouldn't work. – NotFromBrooklyn Dec 13 '12 at 13:19
but its a simple ssh command all I am doing is ssh saad@ the ip address is just random – Saad Dec 13 '12 at 14:29
I had understood that you can't pass a argument outside the quotes. – NotFromBrooklyn Dec 13 '12 at 19:35
up vote 2 down vote accepted

ok I finally found one suitable solution for this problem. if there is a ~/.bash_login file and its not empty then ~/.bashrc file is not automatically loaded when we open the shell. if we move that ~/.bash_login ( $ mv ~/.bash_login ~/.bash_login_old)file then ~/.bashrc file will be get loaded and also it will load the ~/.bash_aliases file if the following lines are uncommented in the ~/.bashrc file.

if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi

one another solution which i can think of is if you dont want to rename or delete your ~/.bash_login file then what you can do is when you are in the shell just type this command $ bash and it will load the ~/.bashrc file.

share|improve this answer

"open" in ubuntu is /bin/open, described by open -h as "This utility help you to start a program on a new virtual terminal (VT)."

You the more general thing than sensible-browser is gnome-open, which is not installed by default (anymore?), and is provided by the libgnome2-bin:

$ sudo-apt-get install libgnome2-bin
$ gnome-open    # opens in default browser
$ gnome-open config.txt   # opens config.txt in gedit

I find gnome open so useful that I have the following in my (multi-site) bashrc:

if which gnome-open >/dev/null ; then
    alias o=gnome-open
elif which kde-open >/dev/null ; then
    alias o=kde-open
elif which xdg-open >/dev/null ; then
    alias o=xdg-open

which would let you do:

alias server-python="o http://localhost:8000 && python -m SimpleHTTPServer"

and it would work most places.

share|improve this answer
The "more general thing" is actually xdg-open(1), which is supposed to work on every XDG-compatible desktop environment. – Andrea Corbellini Dec 13 '12 at 19:20
open is not the main problem here I had solved it by using another command which is sensible-browser. My main problem is that ~/.bash_aliases is not getting loaded automatically when I log into the shell. I have to use this command $ source ~/.bash_aliases, even though the script ( which is in ~/.bashrc) for automatically loading this file when the shell starts is uncommented. – Saad Dec 14 '12 at 5:58
Andrea Corbellini: I agree, but gnome-open seems to sometimes to a better job of hooking into gnome preferences. But as you might notice I do hook into it if gnome-open isn't available. – quodlibetor Dec 14 '12 at 15:23
Saad: have you tried "$HOME/.bash_aliases" instead of ~/.bash_aliases? Also, have you tried just doing if [ -f "$HOME/.bash_aliases" ] ; then echo yes ; else echo no ; fi? – quodlibetor Dec 14 '12 at 15:27

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.