LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/)
-   -   adding permanent aliases to profile (https://www.linuxquestions.org/questions/ubuntu-63/adding-permanent-aliases-to-profile-450826/)

cnc 06-02-2006 04:40 AM

adding permanent aliases to profile
 
hello ;D

HOWTO add permanent aliases into the bash profile?
I added them just like that, like a command.
when I restart my box, the aliases are no more.

I didn't however edit /etc/profile cuz I was affraid.
(I was puzzled that it wasn't .profile, like my friend mentioned it should be)
I made a /home/[username]/profile and a /home/[username]/.profile just in case as well.
Any idea?

BTW, I have Ubuntu Badger


TNX :D

David the H. 06-02-2006 05:17 AM

Don't worry too much about the name. There are often minor variations between distributions. Debian has /etc/profile also.

You also don't need to be that afraid to edit the things. They're just textfiles. Simply make a copy of it before you change anything, and if you have problems you only have to put the old one back in place.

BTW, there are actually several places you can put aliases. /etc/profile is where you'd put systemwide settings. But there's also /etc/.bashrc (actually /etc/bash.bashrc on my system), for aliases that will only appear in gui bash shells. I've found that sometimes you have to put aliases in both /etc/profile and etc/bash.bashrc to have access to them in all environments.

~/.bash_profile and ~/.bashrc in your home directory are for things that only affect that single profile, with a breakdown similar to the above. You can put aliases there, but they'll only be available when you're logged in as that user.

cnc 06-05-2006 06:47 AM

Quote:

Originally Posted by David the H.
I've found that sometimes you have to put aliases in both /etc/profile and etc/bash.bashrc to have access to them in all environments.

That's why I never had aliases in my xterm...
so, I just put
"alias bla=echo bla" or whatever at the end of /etc/profile
or...?
cool if so.

tnx

Oupa 05-10-2007 03:08 AM

aliases
 
Hi, I not familiar with Ubuntu naming conventions, but in general you will place aliases in the following files.
/etc/profile - if you want system wide access irrespective of the shell being used.
/etc/bashrc - if you want to set them specifically for the bash users.
/home/user/.bashrc - if you only want that particular account to use the alias
------
The reason that they are dot files in your home directory is to keep them hidden as generally you dont want to see configuration files. Oupa.

binary_y2k2 05-11-2007 04:40 AM

You only need to edit /etc/bash.bashrc or /etc/profile if you want all users to have the aliases. If you only want it for your user you can just add them to ~/.bashrc
or just uncomment the part in ~/.bashrc (about line 50)
Code:

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

and put all your aliases in ~/.bash_aliases

jschiwal 05-11-2007 04:46 AM

The ~/.profile script is sourced when you login. It could be that you hadn't logged out.
By the way, write an alias like:
Code:

alias md='mkdir -p'
There are different possible profile scripts that bash will source. (.profile, .bash_profile, .bash_login). One possible problem is that another exists. Examine what exists in your home directory and read the relevant section in "info bash".
Quote:

When Bash is invoked as an interactive login shell, or as a
non-interactive shell with the `--login' option, it first reads and
executes commands from the file `/etc/profile', if that file exists.
After reading that file, it looks for `~/.bash_profile',
`~/.bash_login', and `~/.profile', in that order, and reads and
executes commands from the first one that exists and is readable. The
`--noprofile' option may be used when the shell is started to inhibit
this behavior.

When a login shell exits, Bash reads and executes commands from the
file `~/.bash_logout', if it exists.
So if a ~/.bash_login script exists, ~/.profile won't be sourced unless there is a "source ~/.profile" command in the ~/.bash_login script.

Also, double check whether the profile script sources the .bashrc script. If not, then use the profile script to add aliases. Otherwise, when you login, the alias commands won't be run.


All times are GMT -5. The time now is 10:02 AM.