I am trying to create an alias and I have added this line 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 address 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"

I believe that whenever I start the terminal my aliases should work. However, unless I run the command source ~/.bash_aliases it’s not working. Also, for the first 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 it if someone could point out to me what I am doing wrong. I know that the problem is very trivial, but I must be just missing something.

I have now fixed the error

Couldn't get a file descriptor referring to the console

by using sensible-browser instead of open:

alias server-python='sensible-browser http://localhost:8000 && python -m SimpleHTTPServer'
  • Do the second alias (ssh-aad) work for you? Because I think it has a flaw. Dec 13, 2012 at 9:15
  • yes it does work for me can you tell me what is the flaw that you find
    – Saad
    Dec 13, 2012 at 12:21
  • alias name='commands' something The something part shouldn't work. Dec 13, 2012 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, 2012 at 14:29
  • I had understood that you can't pass a argument outside the quotes. Dec 13, 2012 at 19:35

2 Answers 2


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

then ~/.bashrc file will be 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

One other solution 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.

  • Having ~/.bash_login prevents ~/.profile being sourced, not ~/.bashrc. You definitely did need to uncomment those lines in ~/.bashrc though. Typing bash opens a new Bash shell which sources ~/.bashrc. The original shell (started when you opened a terminal) would have done so too, unless it was not a Bash shell.
    – Zanna
    Mar 23, 2018 at 6:20

"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 https://google.com    # opens https://google.com 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.

  • The "more general thing" is actually xdg-open(1), which is supposed to work on every XDG-compatible desktop environment. Dec 13, 2012 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, 2012 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. Dec 14, 2012 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? Dec 14, 2012 at 15:27

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.