27

When I log in, I see the error:

bash: alias: alias: not found

If I source my .bashrc file, the message appears again.

What is causing this?

6 Answers 6

43

I had the same issue, so the solution is to follow simply rules.

alias alias_name='command '

no other symbols between equal sign.
I had whitespaces between the sign and the source ~/.bashrc always failed for me.
so be attentive

3
  • 2
    This solved my problem.
    – Sandeep C
    Aug 18, 2017 at 18:19
  • 2
    It solved mine as well ಠ_ಠ
    – MDMoore313
    Aug 23, 2018 at 20:34
  • I copy/pasted from another source and instead of a line break after each alias it added spaces. What appeared to be fine was not. Save yourself a headache and make sure each line ends in a linebreak.
    – Matt K
    May 19, 2021 at 17:46
7

It turns out that a line feed had been removed from ~/.bashrc, giving:

alias ll='ls -alF' alias la='ls -A'
alias l='ls -CF'

Breaking the first line into two commands fixes the error.

4

In my case, removing spaces in alias = ls -alF solved the problem.

1
  • If the command has spaces in it, surround it with single or double quotes. Jun 26, 2016 at 3:46
3

My problem is solved when I remove the space in

alias cdg = 'ls -al'

to

alias cdg='ls -al'
2

You can put quotes around the commands you are aliasing. You can even put them around the alias, too.

'llg'='ll | grep'

Newlines are also a problem. Widows-saved .bashrc file caused errors in Ubuntu virtual machine:

command not found

I ran dos2unix .bashrc to convert the line endings, and then everything worked.

1
  • 1
    dos2unix did the trick for me
    – JAponte
    May 22, 2020 at 3:57
0

I think you can do this:

alias 'll=ls -alF'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .