Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Basic bash help



On Tue, Sep 21, 2004 at 09:46:49AM -0400, trlists at clayst.com wrote:
> I could use a little help with bash.  I'm using it on a couple of 
> different machines -- one running Slackware, another RH.  All I'm 
> trying to do right now is set up a few simple aliases.  I'm familiar 
> with the command line and the concept of aliases, what I can't figure 
> out is where and how they get set.

As you have seen, there are many, many possible places.  While I
understand Red Hat's reason for setting things up they way they did,
I still think it's a gross hack.

> The aliases for vi and which are findable in the files in profile.d, 
> however those for cp, mv, and rm are not there nor in ~/.bashrc, nor in 
> /etc/bashrc.  Where might they be?

Usually, the noclobber aliases for rm and friends are (I think) only
created in root's .bashrc (/root/.bashrc).  If you're running as root,
that's probably where they're getting set.  To be honest though, I'm
not 100% sure of the exact location, because the first thing I usually
do after I install Linux on any system is copy a portable environment
I've been toting around for the better part of a decade now, erasing
any signs of what was there before.

> Also, for my own aliases, where is the usual place to set them if I 
> want them global?  

Just what do you mean by global?  "My own aliases" and "global" don't
mesh for me.  I'm assuming that you mean really global, i.e. for all
users, system wide.  The usual place is to put them in /etc/bashrc or
/etc/profile, depending on if you need them in non-interactive shells.

> Specific to a particular user?  

The best place is probably .bashrc, but see below.

> Do I create my own script in profile.d for my own aliases, or modify
> an existing script?  For local ones do I use ~/.bashrc, or make it
> call a separate script?  I know all of these approaches will work,
> I'm wondering if there is a common practice for defining aliases.

Ultimately, it doesn't matter.  As you say, all of these approaces
will work, and you should use the one which seems most natural to you.
Unless, that is, these are systems you manage for someone else.  Then,
applying the principle of least surprise, it's best to put things in
one of the standard default places, i.e.  /etc/profile for global
aliases, and .profile or .bashrc for user-specific aliases.  For your
own stuff, It Just Doesn't Matter[1], as the saying goes...  except as
below.

BELOW
-----

The bash shell has the idea that shells can be login shells
or non-login shells.  It tries to source different files, based on
whether or not the shell is a login shell.  Shells run in xterms are
usually NOT login shells, unless you (or your vendor) has done
something interesting to make that happen (i.e. run xterm with the -ls
option, set a resource, etc.).

Normal order that files are sourced is something like this:

  login shell - /etc/profile ~/.bash_profile ~/.bash_login, ~/.profile
  non-login shell - ~/.bashrc

Your vendor, however, has probably gummed up the works by adding a
variety of scripts in different places which it sources from one of
the above files (probably /etc/bashrc).  You'll need to comb over
those to see what's what.

For more specific details, especially for distro-specific changes on
your system, see the INVOCATION section of the bash man page, and the
local scripts on your system.

[1] Anyone remember the source of this quote?

-- 
Derek D. Martin    http://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address.  Replying to it will result in
undeliverable mail.  Sorry for the inconvenience.  Thank the spammers.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.blu.org/pipermail/discuss/attachments/20040921/47ee7139/attachment.sig>



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org