[kwlug-disc] Linux & Linux admin for newbies

Ronald Barnes ron at ronaldbarnes.ca
Tue Feb 6 03:50:33 EST 2018


John Johnson wrote on 2018-02-06 12:29 AM:

> After a fruitful chat with Paul at February's meeting I thought I would 
> add one more topic to this thread.
> 
> alias & .bashrc
> 
> And a question: How does one set up an alias for a command line string?

If it's a one-off, "alias" is the trick.

i.e. let's create an alias called kwlug that does... something.


> alias kwlug='pwd
> kwlug
/mnt/home-raid/ron/Documents/Toyota-4Runner


Right, so ... an aliased command called kwlug gives us our present 
working directory.

Useless, but illustrative.


Now, let's look at ~/.bashrc, where persistent aliases are defined, or 
referenced.

In my Ubuntu 16.04 .bashrc file is the following:

> # Alias definitions.
> # You may want to put all your additions into a separate file like
> # ~/.bash_aliases, instead of adding them here directly.
> # See /usr/share/doc/bash-doc/examples in the bash-doc package.
> 
> if [ -f ~/.bash_aliases ]; then
>     . ~/.bash_aliases
> fi

It's encouraging the user to place their alias definitions in 
~/.bash_aliases which gets run (if it exists) from .bashrc.


I prefer to define my aliases in .bash_aliases since I can transport 
them between users / systems with minimal effort.



I'm sorry I'm unable to present on this topic, but thought I'd throw 
this out there just in case someone finds it a useful starting point.


Also, sorry for missing the february meeting.

I'm knackered from gardening on sunday.  All the tulip bulbs were 
sprouting (easily a hundred of them) and I had to get them into the soil.

(It's my contractual obligation as a Vancouverite to bring this up, as I 
see the KW temperature is currently -11°C; I feel terrible about it, but 
what can I do?)




More information about the kwlug-disc mailing list