Linux Customization With .bashrc

This post will explain what a .bashrc file is and how it can be used to customize your usage in a Linux environment. It will explain what alias and export are used for. Also it will explain how easy it is to create functions. Finally, to tie it all together, it will explain how to set up a colored system-status display that will be shown when you first log into your machine via the command line.

What is a .bashrc file?

A .bashrc file is a startup configuration file used with the Bourne-Again SHell (Bash). Bash is the most common shell on Linux systems, as far as I know at least; I would also assume it is on OS’s like Solaris and Mac OSX too, though I .

What is a .bashrc file used for?

The .bashrc file is used for personal aliases of commands, think shortcuts, and user-functions.

Some quick example .bashrc files

This Novell CoolSolutions page on configuring the .bashrc file is what prompted me to write this entry. This is a fairly lengthy .bashrc file example. You may also just want to google for more examples.

Aliases, Export, Functions, etc.

Alias

You can think of an alias just like you think of a shortcut on your GUI desktop. Effectively they are no different. Isn’t it easier to type something like web instead of cd /opt/lampp/htdocs. If I wanted to, I could have even shortened the alias to just w. Aliases allow you to quickly move around your system as well as execute complex commands with ease.

Export

The export system command can be used in a similar manner as alias. The main difference is that when using export, you create a system variable. An example of this usage is updating the default PATH system variable. For example: export PATH=$PATH:/sbin:/opt/lampp/bin/. This updates the PATH variable to include, what else, other paths. Programs, really the whole system, can access the value of this system variable by referring to $PATH. I mentioned that exporting variables can be used in a similar manner as an alias. An example of this would be creating a system variable called WEB, i.e. export WEB=/opt/lampp/htdocs. On the command line simply execute cd $WEB. This has the exact same effect as having the web alias mentioned above.

Functions

Understanding functions is really quite simple. A function simply wraps around a code block of system commands. An example will probably do the explaining for me:
netinfo () {
echo "---------------- Network Information ----------------"
/sbin/ifconfig | awk /'inet addr/ {print $2}
echo ""
/sbin/ifconfig | awk /'inet addr/ {print $3}
echo ""
/sbin/ifconfig | awk /'inet addr/ {print $4}
echo "------------------------------------------------"
echo ""
}

This block of code, this netinfo function, simply outputs my network information with some nice formatting. From the command line, all I’d have to do is type netinfo.

An example to put it all together

I will put the code here that will allow you to set up your own ‘Welcome / System Status’ display upon logging into your computer via command line. My comments and explanation of what is going on will be shown as comments in the actual code. At the very bottom will be a link to my actual .bashrc file which will include everything I’ve mentioned here.

# WELCOME SCREEN
#######################################################
clear; #remove anything above this welcome screen
for i in `seq 1 15` ; do spin; done ;echo -ne "${WHITE} Welcome to Apache01 ${NC}"; for i in `seq 1 15` ; do spin; done ;echo ""; # this will display a header
echo -e ${LIGHTBLUE}`cat /etc/SuSE-release` ; # this shows some information about my machine itself
echo -e "Kernel Information: " `uname -smr`;
echo "";
echo -ne "Hello $USER today is "; date
echo -e "${WHITE}"; cal ; echo ""; # some date / calendar info
echo -ne "${CYAN}";netinfo; # network info
mountedinfo; echo ""; # filesystem info
raidinfo; echo ""; # RAID info
echo -ne "${LIGHTPURPLE}";fortune; echo ""; # and for a little fun, a fortune
echo -ne "${LIGHTBLUE}Uptime for this computer is ";uptime | awk /'up/ {print $3,$4}' # machine uptime
for i in `seq 1 15` ; do spin; done ;echo -ne "${WHITE} Welcome to Apache01 ${NC}"; for i in `seq 1 15` ; do spin; done ;echo ""; #ending header
echo ""; echo ""

My .bashrc file

A note about the code snippets you see here: I do not claim to be the originator of all this code you see here. Though, much of the code can be found in various places around in the intarweb. Also, if you happen to see anything incorrect, please let me know!

And a question for my those who read this: What interesting things do you have in your .bashrc file?

Thank You Providian

For about a month now I’ve had a Post-It Note on my desk telling myself to call up Providian and see if I can get a lower APR on my Visa that I have through them. At some point a while back my year-long introductory APR ended and I started on the not-so-nice higher APR. This was something like 13.5% variable. It was this high because I was recently out of college when I got the card and my credit score was around 45 points lower than it is now – at least this is why I think it was that high.

Anywho, I finally got around to calling them up to see what I could do about the high APR. After about 5 minutes of getting lost in their automated phone service, I finally get a real person. I asked if there was someone I could talk to about getting my APR lowered. She informed me that Providian does a periodic three month audit of your account and automatically offers you a higher limit or a lowered APR if it’s applicable. She also informed me that there was nothing on my account that indicated I had an offer for a lowered APR.

That’s all well and good. In fact I can vouch for this system because about four months ago my limit increased 1300 dollars without me calling and asking for it.

My issue was that I wanted it lowered now, I didn’t want to have to wait until they were nice enough to simply grant me a lowered APR. So, I asked her if I could talk to someone about getting it lowered. She put me on hold, talked to her supervisor (I assume), and then said that there was, in fact, an offer for a lowered APR on my account. She then transfered me to whatever department it is that handles that sort of thing.

I get transfered to a very vibrant lady who is nice enough to explain everything to me. She said I have 2 offers. One, I could take a fixed 11% APR. Two, I could take a three month fixed 1.5% APR teaser, then afterwards a fixed 11% APR. Seems like a no-brainer to me; I obviously took the latter.

However, that’s not quite the end of the story. I did learn something else from this phone call thanks to my very forthcoming contact on the other end of the phone. After I mentioned that the 11% was still above what I wanted to pay, she told me to simply call back after the three month teaser was over. She explained that there is a very good chance I could get it lowered more after that. In fact, she advises people to call their credit card company every 5-6 weeks to see if there are any offers for either a higher limit or a lower APR. Interesting, I learned something new.

So, my recomendation: Call your credit card companies and see what they can do for you, specifically, Providian. I can honestly say, despite the higher APR I had/will have three months from now, Providian is my favorite credit card. They gave me my highest limit on any of my cards and they have a free credit score that they give to you every month.