3

I can't figure out why this simple alias isn't work. I've read online an example on creating it and don't know where I'm going wrong...

I've added the following to my .profile file at the bottom:

alias profile='sudo nano ~/.profile'

When I type in 'profile' in the terminal it says command not found...

I have a feeling this is a very very simple error I'm making.

Thanks everyone!

d-_-b
  • 21,536
  • 40
  • 150
  • 256

2 Answers2

5

What happens if you log out and back in?

Alternatively you could just type

source .profile

and that should activate your alias. Many people using bash set their aliases up in the .bashrc file.

Levon
  • 138,105
  • 33
  • 200
  • 191
  • Thank you! This worked....so what does this do? I did first try entering it there, but when that didn't work went to .profile (as I remember doing in the past) – d-_-b Sep 12 '12 at 23:44
  • 1
    When you log in, a number of configuration files (usually they are "hidden files", ie. start with a `.` in the file name) get read and "executed"/processed. When you logged out and back in, your `.profile` was processed and the alias was set up. `source .profile` does this "manually" without you having to log out and back in. – Levon Sep 12 '12 at 23:46
  • do you know why i would need to do the source command each time I open a terminal window? It seems to not remember it. Thanks! – d-_-b Sep 12 '12 at 23:59
  • 2
    @iight You should not have to do that. I would suggest you move your aliases to the `.bashrc` file. That way each time you opened a console it would be active. Some config files get processed only when you log in first, others each time you open a console, you'd have to read up on that, but I'm pretty sure that `.bashrc` will work for you. – Levon Sep 13 '12 at 00:06
  • 1
    Yes all is well now! Thanks for your help today Levon! – d-_-b Sep 13 '12 at 00:14
  • @iight Happy to been able to help. – Levon Sep 13 '12 at 00:18
  • I tried adding an alias to my .profile and it doesn't create it once I log out and back in. I've read multiple places it should work putting it in the ~/(username)/.profile but it doesn't work for me. When I added it to a .bashrc file in the same location, then it worked. – teaman May 28 '13 at 22:11
2

to add alias permanent you can edit ~/.bashrc and add alias to it

gedit ~/.bashrc

add alias at the end

alias update_linux='sudo apt-get update'

dont forget to refresh bashrc configuration.

source ~/.bashrc

for more details on creating alias you can read following blog: Codebucket

dev-null-dweller
  • 29,274
  • 3
  • 65
  • 85
Arvind
  • 1,882
  • 1
  • 15
  • 14
  • Thanks @Arvind ! I've since figured this out, but I never knew about the `source ~/.bashrc` , I always reset my connection. Thanks! – d-_-b Aug 27 '13 at 20:09