2

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
fi

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?

4

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

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.