7

I am under Ubuntu 12.04 LTS.
I have added such line to ~/.bashrc

alias myconf="sudo nano /opt/nginx/conf/sites-available/efiling"

I tried with single quotes too:

alias myconf='sudo nano /opt/nginx/conf/sites-available/efiling'

Then I logged out and logged in again.

test@STORK:~$ myconf
myconf: command not found

But after test@STORK:~$ source ~/.bashrc it works.

Can Anyone help me?

Lesha Pipiev
  • 342
  • 2
  • 4
  • 10
  • It is better to put all your aliases in `~/.bash_aliases` than in `~/.bashrc`. Though technically it won't make a difference, but for administrative purpose. – jobin May 27 '14 at 06:57
  • Logout and login and then check the command alias.... it works for me –  May 27 '14 at 06:25

1 Answers1

12

I think it should be

alias myconf='sudo nano /opt/nginx/conf/sites-available/efiling'

with single-quotes instead of double-quotes.

You can also use

$ source ~/.bashrc

to load bash.rc without closing the terminal/logging out.

Anju Fabulina
  • 236
  • 2
  • 4
  • 1
    Thaks for help. **source ~/.bashrc** helped me. But why it isn't applied automatically when I am logging in? – Lesha Pipiev Aug 15 '12 at 08:00
  • Check the file `~/.profile` to see whether `bash.rc` is loaded on logging in. – Anju Fabulina Aug 15 '12 at 08:06
  • ~/.profile contains **if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi fi** – Lesha Pipiev Aug 15 '12 at 08:27
  • 1
    That looks okay. What about the two files `~/.bash_profile` and `~/.bash_login`, do these exist on your system? Because in my default `.profile` file the comment at the top says that, "This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login exists." – Anju Fabulina Aug 15 '12 at 08:34
  • 1
    Oh, thanks a lot. Iy works. It was a problem that I had bash_login file. – Lesha Pipiev Aug 15 '12 at 08:44
  • using . in place of source also runs .bashrc doesn't? >$ . .bashrc – Sergio Abreu Dec 18 '16 at 21:51