Why is my alias now not working?

13,492

Solution 1

Use double quotes instead of single quotes:

alias newcommand="full path of the binary to be executed"

and not:

alias newcommand='full path of the binary to be executed'

No space near equal either on the left or on the right.

Solution 2

You have a space between the = and the opening '. Remove it.

$ alias foo= 'bar baz'
bash: alias: bar baz: not found
Share:
13,492

Related videos on Youtube

thinksinbinary
Author by

thinksinbinary

Updated on September 18, 2022

Comments

  • thinksinbinary
    thinksinbinary over 1 year

    So before I reformatted (to get rid of Windows), I simply used this command to open documents by putting it at the end of the ~/.bashrc file:

    alias commandless= 'gnome-open ./Documents/the-linux-command-line.pdf; gnome-open ./Documents/linux.odt'
    

    But now everytime I start the terminal, it says:

    bash: alias: gnome-open ./Documents/the-linux-command-line.pdf; gnome-open ./Documents/linux.odt: not found
    

    before even typing anything in, and when I run the command nothing happens, not even error messages.

    • andruso
      andruso about 4 years
      thinksinbinary, please accept the correct answer, it would help future readers.
  • AVS
    AVS over 8 years
    There should not be any space between equal to
  • thinksinbinary
    thinksinbinary over 8 years
    no, ABISHEK appears to be right, i had to remove the space and put in the quotes instead of the apostrophe
  • kos
    kos over 8 years
    That I'm afraid still doesn't make the "use double-quotes" suggestion right. If you want to remove it, since it's wrong and misleading, I'll remove my downvote, however there's another answer pointing out the space problem which was posted 45 minutes before yours, so your answer is (aside from the single / double quotes thing) basically identical to the answer already present. It doesn't really add anything new.
  • fiatux
    fiatux over 8 years
    Especially with bash -- it parses the commands into tokens by whitespace, so it's extremely sensitive to stray spaces.
  • AVS
    AVS over 8 years
    If it still does not work then replace gnome-open with its full executable path. You can use which gnome-open or whereis gnome-open to get the complete path
  • thinksinbinary
    thinksinbinary over 8 years
    kos- perhaps my os is different but i tried with the single quotes and it does not work