Ubuntu – Command not found for alias


I recently installed the apache2 package using the Software Centre, I want to create an alias apacheres which will replace the more cumbersome command /etc/init.d/apache2 restart.

I opened the .bashrc file in my home directory, and it contains the following lines:

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

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

So I created a .bash_aliases file in my home directory, and added only this line:

alias apacheres ='/etc/init.d/apache2 restart'

When I started my terminal, I get this error message:

bash: alias: apacheres: not found
bash: alias: =/etc/init.d/apache2 restart: not found

The shell has obviously read the file, otherwise it wouldn't know of its existence. I have checked the directory path and I can find the file apache2 there. What do I need to do to make this alias work?

Best Answer

You need to remove the space before the = in the alias assignment

alias apacheres='/etc/init.d/apache2 restart'
Related Question