Quantcast
Channel: bash – Wayno's Adventures and Sojourns through Linux
Viewing all articles
Browse latest Browse all 11

How to enable .bash_aliases

$
0
0

This is one of those things, I sort of take for granted. It was asked on #ubuntu (irc.freenode.net)

bash aliases

What’s an alias you say? An alias is a short form of a long command string for the bash terminal.

so how do you make it work?

1. edit the file .bashrc (using like gedit)

Remember that anything with a number sign (# or octothorpe) is a comment, and does NOT need to be coded.


cp .bashrc .bashrc.bkup # make a backup copy first!
gedit .bashrc

yes the peroid (.) at the beginning fo the file, is significant! The period (.) at the beginning of the file, tells us it is a hidden file.

2. find and uncomment the lines:


#
# enable bash_aliases by uncom the next 3 lines GU 12/1/2008
#
#
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

That will enable you to put user written aliases into a separate file called: .bash_aliases. Save and exit.

3. My .bash_aliases looks like this (again created .bash_aliases with the editor of your choice)

Note that if you already have a .bash_aliases file, you should backup that up first.


cp .bash_aliases .bash_aliases.bkup # make a backup copy first


gedit .bash_aliases

#
# note that when you see the # in a command it is a comment and
# does NOT need to be coded
#
alias ltr=’ls -l -t -r’ # ls command: long, sort by mod date, rev order
alias logc=’tail -150 /var/log/messages | more’ # tail last 150 lines of log
alias logdebug=’tail -f /var/log/messages’ # opens log in debug mode
alias ftplog=’sudo tail -150 /var/log/vsftpd.log | more’ # look at ftp log
alias sshmnd=’ssh -X lou@annlou’ # ssh into folks computer
alias clr=’clear’ # clear the screen
alias startvnc=’x11vnc -usepw -display :0′ # start vnc server

NOTE THAT YOU NEED TO LOGOUT/IN TO GET CHANGES MADE TO .bashrc or .bash_aliases TO WORK!

you can see typing those commands are pretty long.

the format is always:

alias (alias name)=’command strong’

the single quote marks ARE important.

So if I wanted to start my vnc server, instead of a long string, i’d just type:


startvnc

and everything after the equal sign (=) is then substituted.

Pretty neat!


Viewing all articles
Browse latest Browse all 11

Trending Articles