FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 12-08-2010, 09:46 PM
Knute Johnson
 
Default aliases in .profile don't work?

Anybody know why putting an alias in ~/.profile doesn't work but putting
it in ~/.bash_aliases does? ~/.bash_profile or ~/.bash_login do NOT
exist. Adding a change to the PATH works just fine in ~/.profile.

XUbuntu 10.10

Thanks,

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-08-2010, 10:19 PM
Marius Gedminas
 
Default aliases in .profile don't work?

On Wed, Dec 08, 2010 at 02:46:25PM -0800, Knute Johnson wrote:
> Anybody know why putting an alias in ~/.profile doesn't work but putting
> it in ~/.bash_aliases does?

~/.profile is sourced for login sessions only (both ssh logins and gdm
logins, the latter thanks to Ubuntu's /etc/gdm/Xsession). Aliases
aren't exported via the environment, so any new shell sessions -- such
as those you get by opening a terminal window -- do not inherit them.

~/.bash_aliases is sourced for every new shell session.

> ~/.bash_profile or ~/.bash_login do NOT
> exist. Adding a change to the PATH works just fine in ~/.profile.

PATH is usually exported via the environment, so setting it in ~/.profile
is sufficient.

Marius Gedminas
--
Did you hear that the author of _Nitpicking for Dummies_ has just
received it back from the publisher with the 182nd set of editorial
markups?
-- Bill Snyder
--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-08-2010, 10:46 PM
Knute Johnson
 
Default aliases in .profile don't work?

On 12/08/2010 03:19 PM, Marius Gedminas wrote:
> On Wed, Dec 08, 2010 at 02:46:25PM -0800, Knute Johnson wrote:
>> Anybody know why putting an alias in ~/.profile doesn't work but putting
>> it in ~/.bash_aliases does?
>
> ~/.profile is sourced for login sessions only (both ssh logins and gdm
> logins, the latter thanks to Ubuntu's /etc/gdm/Xsession). Aliases
> aren't exported via the environment, so any new shell sessions -- such
> as those you get by opening a terminal window -- do not inherit them.
>
> ~/.bash_aliases is sourced for every new shell session.
>
>> ~/.bash_profile or ~/.bash_login do NOT
>> exist. Adding a change to the PATH works just fine in ~/.profile.
>
> PATH is usually exported via the environment, so setting it in ~/.profile
> is sufficient.
>
> Marius Gedminas
>

Thanks very much Marius. That explains why it works when I log into my
server but not on my desktop.

Thanks again.

knute...


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-08-2010, 11:01 PM
MR ZenWiz
 
Default aliases in .profile don't work?

On Wed, Dec 8, 2010 at 3:19 PM, Marius Gedminas <marius@pov.lt> wrote:
> On Wed, Dec 08, 2010 at 02:46:25PM -0800, Knute Johnson wrote:
>> Anybody know why putting an alias in ~/.profile doesn't work but putting
>> it in ~/.bash_aliases does?
>
> ~/.profile is sourced for login sessions only (both ssh logins and gdm
> logins, the latter thanks to Ubuntu's /etc/gdm/Xsession). *Aliases
> aren't exported via the environment, so any new shell sessions -- such
> as those you get by opening a terminal window -- do not inherit them.
>
> ~/.bash_aliases is sourced for every new shell session.
>
This is not standard behavior - there is no special handling of
~/.bash_aliases built into bash.

When bash is invoked as a login shell, it first reads /etc/profile if
that file exists, then it looks for the first of ~/.bash_profile,
~/.bash_login and ~/.profile, in that order, to execute whatever it
finds there.

Interactive bash shells that are not login shells (i.e., scripts or
direct invocations from the command line) read and execute
/etc/bash.bashrc and then ~/.bashrc, if these files exist.

These are the places to look, in that order, to see what's happening.

I generally prefer to have a consistent environment for execution, so
I set my .bash_profile to source .bashrc and have all my settings in
.bashrc. I keep my aliases and functions in separate files that my
.bashrc sources explicitly.

(Above taken directly from 'man bash' on Maverick.)

>> ~/.bash_profile or ~/.bash_login do NOT
>> exist. *Adding a change to the PATH works just fine in ~/.profile.
>
> PATH is usually exported via the environment, so setting it in ~/.profile
> is sufficient.
>
True, and this will also affect most other shells as well, as
~/.profile is more or less universal (except for csh).

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-09-2010, 12:46 AM
Marius Gedminas
 
Default aliases in .profile don't work?

On Wed, Dec 08, 2010 at 04:01:38PM -0800, MR ZenWiz wrote:
> On Wed, Dec 8, 2010 at 3:19 PM, Marius Gedminas <marius@pov.lt> wrote:
> > On Wed, Dec 08, 2010 at 02:46:25PM -0800, Knute Johnson wrote:
> >> Anybody know why putting an alias in ~/.profile doesn't work but putting
> >> it in ~/.bash_aliases does?
> >
> > ~/.profile is sourced for login sessions only (both ssh logins and gdm
> > logins, the latter thanks to Ubuntu's /etc/gdm/Xsession). *Aliases
> > aren't exported via the environment, so any new shell sessions -- such
> > as those you get by opening a terminal window -- do not inherit them.
> >
> > ~/.bash_aliases is sourced for every new shell session.
> >
> This is not standard behavior - there is no special handling of
> ~/.bash_aliases built into bash.

That's right; I should've mentioned that Ubuntu's default ~/.bashrc
sources ~/.bash_aliases.

And Ubuntu's default ~/.profile sources ~/.bashrc, if detects that your
shell is bash.

You can see the default versions of these files in /etc/skel, even if
you've overridden them in your directory with customized ones.

Marius Gedminas
--
Favorite MS-DOS error message: "Drive C: not ready, close door."
--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-09-2010, 12:56 AM
MR ZenWiz
 
Default aliases in .profile don't work?

On Wed, Dec 8, 2010 at 5:46 PM, Marius Gedminas <marius@pov.lt> wrote:
>
> That's right; I should've mentioned that Ubuntu's default ~/.bashrc
> sources ~/.bash_aliases.
>
> And Ubuntu's default ~/.profile sources ~/.bashrc, if detects that your
> shell is bash.
>
That makes more sense.

I do find it odd that your .profile alias did not "take" - I used to
put an alias x=exit in my /etc/profile (not a good idea, but at the
time I thought it was) and it "took" for all users (i.e., me).

Anyway, glad we cleared that one up.

Cheers.

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 06:59 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org