Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Aliases

0 views
Skip to first unread message

Giovanni Radilla

unread,
Dec 3, 2002, 6:41:51 AM12/3/02
to
Hello,

I'm new to linux and using Mandrake 9.0

I'm able to put aliases on my account's .bashrc file
but when I use the command alias on a terminal I get
aliases that are not defined by my .bashrc and the
annoying thing is that some of them seem to overwrite
my .bashrc's aliases.

Can someone tell me where are those 'default' aliases defined
and what is the best way to set my own aliases?

Thanks a lot

Regards,

Giovanni

Joel Mayes

unread,
Dec 3, 2002, 6:54:20 AM12/3/02
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In a moment of clarity Giovanni Radilla said

have a look at /etc/profile

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE97Jttgqxx6A1W3V0RAoU8AJ9iImdISWUiO25LpPGpeedWLyj3eACgralB
GCFrA23VLQYYcjy2uLATbfQ=
=SiKd
-----END PGP SIGNATURE-----

--
begin signature.vbs
Joel Mayes | Sourcemage GNU/Linux
jmayes at sourcemage.org | http://sourcemage.org/
Musician and Music Teacher | x11 & doc Grimoire Guru

Giovanni Radilla

unread,
Dec 3, 2002, 8:41:54 AM12/3/02
to
Thank you for your help on both of my questions.
For this one I still don't know the answer. Here
is the file /etc/profile:

---->[BEGIN]

# /etc/profile -*- Mode: shell-script -*-
# (c) MandrakeSoft, Chmouel Boudjnah <chm...@mandrakesoft.com>

loginsh=1

# Users generally won't see annoyng core files
[ "$UID" = "0" ] && ulimit -S -c 1000000 > /dev/null 2>&1

if ! echo ${PATH} |grep -q /usr/X11R6/bin ; then
PATH="$PATH:/usr/X11R6/bin"
fi

if [ "$UID" -ge 500 ] && ! echo ${PATH} |grep -q /usr/games ; then
export PATH=$PATH:/usr/games
fi

umask 022

USER=`id -un`
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
HISTCONTROL=ignoredups
HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi

# some old programs still use it (eg: "man"), and it is also
# required for level1 compliance for LI18NUX2000
NLSPATH=/usr/share/locale/%l/%N

export PATH PS1 USER LOGNAME MAIL HOSTNAME INPUTRC NLSPATH
export HISTCONTROL HISTSIZE

for i in /etc/profile.d/*.sh ; do
if [ -x $i ]; then
. $i
fi
done

unset i

---->[END]

where are the aliases?

Thanks

In article <3dec9b6c$0$2764$afc3...@news.optusnet.com.au>,
jo...@invalid.invalid says...

Arjen Wiersma

unread,
Dec 3, 2002, 8:54:25 AM12/3/02
to
Hi,

> where are the aliases?

also look in your .bashrc if you are not including / sourcing any other
file. perhaps it is an idea to do something like
$ grep 'alias <aliasname>' /etc/*
to see if any startup files have an alias defined somewhere?

Regards,

Arjen

Bit Twister

unread,
Dec 3, 2002, 10:35:45 AM12/3/02
to
On Tue, 3 Dec 2002 11:41:51 +0000 (UTC), Giovanni Radilla wrote:
> Hello,
>
> I'm new to linux and using Mandrake 9.0
>
> I'm able to put aliases on my account's .bashrc file
> but when I use the command alias on a terminal I get
> aliases that are not defined by my .bashrc and the
> annoying thing is that some of them seem to overwrite
> my .bashrc's aliases.

Please cut/paste the command from the .bashrc file.
What you said you did, is correct.

>
> Can someone tell me where are those 'default' aliases defined
> and what is the best way to set my own aliases?

For bash, global for everyone
/etc/profile - environment variables (PATH, USER, LOGNAME,...)
/etc/bashrc - contains function & aliases, not environment vars

It is instructive to read the files in /etc/profile.d, if you have one.

I would place site/custom global environment variables in zz_local.sh
That way you can pop zz_local.sh in on new installs.

If you have an /etc/profile.d directory; do a

cd /etc/profile.d
touch zz_local.sh
chmod 755 zz_local.sh
Then add your changes, Example: export PATH=$PATH:new_path:another_path

The zz_local.sh name was picked to force it to be executed last.
/etc/profile runs the scripts in /etc/profile.d
do a ls -1 /etc/profile.d to see order of file execution.


User only
~userid_here/.bash_profile - for environment variables
~userid_here/.bashrc - for function & aliases, not env vars

ALWAYS do a su -l user_id to test your changes before logging out.


Profiles usually run once, bashrc run everytime you spin up a non-login
interactive session.

Sessions inherit env vars from the parent process.

Setting BASH_ENV=~/.bashrc will cause it to execute during
non-interactive session.


PS:
for extra points do a
man bash
http://www.pathname.com/fhs/2.2/fhs-3.12.html

Bruce Burhans

unread,
Dec 3, 2002, 12:10:59 PM12/3/02
to

"Giovanni Radilla" <rad...@mines.u-nancy.fr> wrote in message
news:asi59v$sra$1...@arcturus.ciril.fr...

Giovanni,

Check out your .bash_profile, which sets up
login shells. Unless it is sourced in .bash_profile,
.bashrc is for non-login shells.

It is my understanding that the local rc overrides the global ones, all
things being equal.

HTH

Bruce
--
Bellingham Washington USA
bburhan1 [ AT] earthlink [ DOT] net


Garry Knight

unread,
Dec 3, 2002, 2:52:53 PM12/3/02
to
Giovanni Radilla wrote:

> I'm able to put aliases on my account's .bashrc file
> but when I use the command alias on a terminal I get
> aliases that are not defined by my .bashrc and the
> annoying thing is that some of them seem to overwrite
> my .bashrc's aliases.
>
> Can someone tell me where are those 'default' aliases defined
> and what is the best way to set my own aliases?

Look in /etc/profile.d/alias.sh and remember that aliases defined there are
global, i.e. for all users.

I created a file called .aliases which contains nothing but alias
definitions, which I call from my ~/.bashrc. Here's the start of this file
so you can see how it's done:

# .bashrc

# Source global definitions
if [ -r /etc/bashrc ]; then
. /etc/bashrc
fi

# get my aliases
if [ -f ~/.aliases ]; then
. ~/.aliases
fi

--
Garry Knight
garry...@gmx.net ICQ: 126351135
Linux registered user 182025

Joel Mayes

unread,
Dec 3, 2002, 3:17:05 PM12/3/02
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In a moment of clarity Giovanni Radilla said

> Thank you for your help on both of my questions.
> For this one I still don't know the answer. Here
> is the file /etc/profile:

> for i in /etc/profile.d/*.sh ; do


> if [ -x $i ]; then
> . $i
> fi
> done

The above command will look in the /etc/profile.d/ directory and
execute any executably found in there, this might be a good place
to look

Cheers

Joel

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE97RFBgqxx6A1W3V0RAohMAJ913dRhFWzwslXiFBw5tslv2J/BfACeJp4D
ACBzehPjThaJOz+hzBoaBnU=
=7yUz

Bruce Burhans

unread,
Dec 3, 2002, 3:23:32 PM12/3/02
to

"Garry Knight" <garry...@gmx.net> wrote in message
news:103894518...@damia.uk.clara.net...


> Giovanni Radilla wrote:
>
> > I'm able to put aliases on my account's .bashrc file
> > but when I use the command alias on a terminal I get
> > aliases that are not defined by my .bashrc and the
> > annoying thing is that some of them seem to overwrite
> > my .bashrc's aliases.
> >
> > Can someone tell me where are those 'default' aliases defined
> > and what is the best way to set my own aliases?
>
> Look in /etc/profile.d/alias.sh and remember that aliases defined there
are
> global, i.e. for all users.
>
> I created a file called .aliases which contains nothing but alias
> definitions, which I call from my ~/.bashrc. Here's the start of this file
> so you can see how it's done:
>
> # .bashrc
>
> # Source global definitions
> if [ -r /etc/bashrc ]; then
> . /etc/bashrc
> fi

if the file /etc/bashrc exists and is readable (permissions set that way
for the user )then source it.
the dot is a synonym for source and must be
seperated from the / by at least a space.

>
> # get my aliases
> if [ -f ~/.aliases ]; then
> . ~/.aliases
> fi

if /home/him/.aliases exists and is a regular file
then source it. Source means run or include.

When you edit your .bashrc, you can type

$ source .bashrc
or
$ . .bashrc
and it will run that script without you having to log
off and then on again.

There is probably a line in .bash_profile that
says

#source .bashrc

after a little if clause like above.

That # means that bash will ignore anything following it on the same line,
so delete it if you
want the stuff in .bashrc to show up in your login
shell.

If you type a command at the prompt and want
to save it without running it, put a # in front of it
and hit enter. Now it's in your hisotory and you can bring it up and remove
the # to run it.

If you want to add a comment to a command and
have that stored in your history with the command

$ command # comment

will do it.

I have a file in my home directory for variables,
and this line in my .bashrc

source /home/me/.var

HTH

Bruce
--
Bellingham Washington USA
bburhan1 [ AT] earthlink [ DOT] net


>

Floyd Davidson

unread,
Dec 3, 2002, 3:34:31 PM12/3/02
to
rad...@mines.u-nancy.fr (Giovanni Radilla) wrote:
>Thank you for your help on both of my questions.
>For this one I still don't know the answer. Here
>is the file /etc/profile:
>
>---->[BEGIN]
>
># /etc/profile -*- Mode: shell-script -*-

[snip]

>for i in /etc/profile.d/*.sh ; do
> if [ -x $i ]; then
> . $i
> fi
>done

[snip]

>where are the aliases?

Read the man page for bash, and do "/INVOCATION" about three
times to find the subsection which describes how bash reads
init files.

A "login" shell (as opposed to a subshell) sources /etc/profile
first, and then sources the first of these files that it can
find,

~/.bash_profile
~/.bash_login
~/.profile

A login shell does *not* source ~/.bashrc, and hence if you do
not have a command to source it in whichever of the above three
files you use, nothing you have in ~/.bashrc file will affect
your login shell!

Also note that aliases are _not_ inherited by subshells, hence
an alias defined in /etc/profile or in ~/.bash_profile will not
exist in a subshell (for example in an xterm running bash unless
they are all configured to be login shells).

All of this make sense and works correctly *if* your init files
are used properly. /etc/profile should be used to set up a
system-wide bare minimum interactive shell environment. It is
*not* the place to define aliases! It should define environment
variables that are unique to each system (ones which a user
would not likely want to change), or which are necessary for an
interactive login to function. Hence PATH, MANPATH, PS1, PS2,
and things like that are all that should be set there.

Each user should choose one of the three files to be sourced by
a login shell, and use it to add to or adjust what is in
/etc/profile. Environment variables that are unique to this
user, but that will always be the same in all shells can be set
in this file, but it is actually easier to not do that. What
*must* be in this file are any terminal configuration setup
commands which need to only be executed one time per login (and
not every time a subshell is invoked). That would be something
like "stty erase ^H", for example. Also commands which add to
variables, and hence should only be done once, can be put in
this file:

PATH=~/bin:$PATH

In addition, non-interactive shells (shells used to run scripts,
for example) will source whatever file is set for BASH_ENV, so
that should be set. And if all aliases are set in ~/.bashrc, a
command to read it should be used.

Hence ~/.bash_profile might look like this,

stty erase ^H
export BASH_ENV=~/.bashrc
export PATH=~/bin:$PATH
. ~/.bashrc

And then you can put all of your function definitions,
environment variables, and aliases into ~/.bashrc and expect to
see them correctly in any shell you invoke!

--
Floyd L. Davidson <http://www.ptialaska.net/~floyd>
Ukpeagvik (Barrow, Alaska) fl...@barrow.com

Giovanni Radilla

unread,
Dec 4, 2002, 1:00:45 PM12/4/02
to

I would like to thank you all for your kind answers.
With your help I was able to set aliases just as I
wanted to.

Best regards,

Giovanni RADILLA

0 new messages