1

Running Ubuntu 14.04 LTS

I open a terminal, and type a simple alias command, but then it doesn't work:

~> alias ge='gedit &'
~> ge
ge: command not found

I've also tried adding aliases to .bashrc, .profile, .bash_aliases, all to no avail. What is most disturbing is that it doesn't work in command line.

Additional things, in response to comments:

    > alias ge='gedit &'
    > ge
    ge: Command not found.
    > alias
    >
    > echo $-
    Illegal variable name.
    > shopt -p expand_aliases
    shopt: Command not found.

    > . ~/.bashrc
    /usr/sbin/.: Permission denied.
    > source ~/.bashrc
    Illegal variable name.
A.B.
  • 89,123
  • 21
  • 245
  • 323
  • Can you add the exact error message that you received? The one shown is incomplete. – John1024 Sep 27 '15 at 04:55
  • 5
    Could not reproduce. – muru Sep 27 '15 at 04:59
  • @muru same here, either something is very wrong with his installation or he did a typo while typing his command – H. Freeze Sep 27 '15 at 05:13
  • 2
    Running just `alias` should list all of your aliases (including several which come with Ubuntu out of the box). Does this give you output? Does it include your new `ge` in the output? – Michael Martin-Smucker Sep 27 '15 at 05:17
  • Please add output of `echo $-` and `shopt -p expand_aliases` to your question. – Cyrus Sep 27 '15 at 05:32
  • Thoth:~> alias ge='gedit &' Thoth:~> ge ge: Command not found. Thoth:~> alias Thoth:~> Thoth:~> echo $- Illegal variable name. Thoth:~> shopt -p expand_aliases shopt: Command not found. – user3347308 Sep 27 '15 at 13:11

3 Answers3

3

You can also edit your ~/.tcshrc file when using tcsh instead of bash to set a persistent alias:

echo 'alias ge "gedit &"' | tee -a ~/.tcshrc

Then, source the file and ge should open gedit:

source ~/.tcshrc
mchid
  • 42,315
  • 7
  • 94
  • 147
  • 2
    he tried running it from terminal, if that really didn't work i doubt it will work from .bashrc. – H. Freeze Sep 27 '15 at 05:15
  • Still cannot get alias to work on command line. Here are additional bashrc problems: Thoth:~> . ~/.bashrc /usr/sbin/.: Permission denied. Thoth:~> source ~/.bashrc Illegal variable name. – user3347308 Sep 27 '15 at 13:20
  • @user3347308 That's cause you're in tcsh you crazy person:) You need to run /bin/bash before you go and try sourcing your bashrc file. – mchid Sep 27 '15 at 13:32
3

Because you use tcsh instead of bash, your alias definition is wrong. Define an alias in tcsh via

alias ge gedit 

or

alias ge 'gedit &'
A.B.
  • 89,123
  • 21
  • 245
  • 323
0

Answer: My shells were running tcsh. I had to switch this to bash. I realized this after accidentally just typing "bash" on the command line, and this made everything work (aliases, bashrc, etc.) All the problems above were due to simply not having bash running.