Ubuntu This forum is for the discussion of Ubuntu Linux. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
06-02-2006, 04:40 AM
|
#1
|
LQ Newbie
Registered: May 2006
Posts: 5
Rep:
|
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 
Last edited by cnc; 06-02-2006 at 04:41 AM.
|
|
|
06-02-2006, 05:17 AM
|
#2
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852
|
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.
|
|
1 members found this post helpful.
|
06-05-2006, 06:47 AM
|
#3
|
LQ Newbie
Registered: May 2006
Posts: 5
Original Poster
Rep:
|
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
|
|
|
05-10-2007, 03:08 AM
|
#4
|
LQ Newbie
Registered: Apr 2007
Location: Welkom, South Africa
Distribution: RHL + Mandriva
Posts: 15
Rep:
|
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.
|
|
|
05-11-2007, 04:40 AM
|
#5
|
Member
Registered: Jul 2005
Location: England, UK
Distribution: Ubuntu 8.04 Server, Kubuntu 12.04
Posts: 698
Rep:
|
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
|
|
|
05-11-2007, 04:46 AM
|
#6
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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.
Last edited by jschiwal; 05-11-2007 at 04:52 AM.
|
|
|
All times are GMT -5. The time now is 03:35 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|