Archive for the ‘Computers’ Category

I recently read about a new Mozilla Labs project called Weave.  The basic premise is that it will store information securely on Mozilla’s servers.  Currently, it only backs up bookmarks and browsing history.  Two of the many things that the Google Browser Sync add-on already does.  It’s a very early on 0.1 prototype release, so there is still a lot that can come of it.  Eventually, it will be able to back up anything an add-on would like to store remotely.  That’s the theory at least.  Overall, I’m fairly interested in the project; I’m curious about how Weave will play with technologies like OpenID.

At work we use tons of open source software. Off the top of my head, I can name15:

  1. Gentoo, both desktop and server
  2. Apache 2
  3. Subversion
  4. MySQL
  5. OpenLDAP
  6. Zend Framework
  7. phpMyAdmin
  8. phpLDAPadmin
  9. MediaWiki
  10. Aptana
  11. PuTTy
  12. Mozilla Firefox
  13. Mozilla Thunderbird
  14. Open Office
  15. trixbox

That last one, trixbox, made the news recently when it was recently discovered that the software contacts a Fonality server once every 24 hours by itself. This process sends information about the hardware setup it’s running on and a few configuration details. This is all done via allowing a remote server to execute root-privileged commands on the local box. You can read this forum thread for more details.

The problem here is mainly that no one knew any of this was happening.  So, naturally, when people find out about it, they feel duped.  Now, this certainly should have been a better described “feature”, sure.  But, I’m not overly concerned about it.  The script doesn’t gather anything like phone numbers or email addresses.  The theoretical problem is if this “feature” was abused in some way.  It looks like their in the process of updating this part of their system and I’m satisfied with the changes they’re making to correct the potential problems with it.

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?

For reference, you should probably read this Yahoo article first.

Now my commentary…

Gotta love our government. Half a billion dollars down the tubes. I love how they’re still working on this program yet they’ve started soliciting offers for a new program to replace it at the same time.

And you know what the program does:

The prototype’s main feature allows users to prepare documents and forward them in a usable form.

and

Eventually, the FBI expects to have software with added features for managing records, evidence and other documents, along with the ability for users to collaborate on documents and share information online.

Jesus! What about this project can’t be done via the internet? Seriously. Prepare documents and forward them in usable form? What the hell is that? Sounds like email to me. Collaborate on documents and share information online? That just sounds like something you could just put on an encrypted network and then have like a Wiki or something along those lines, combine that in with the emailing of documents (mind you it could be heavy SSL or an equivalent).

I dunno, I just don’t get our government some times. This is my rant for the day.

If you haven’t heard, which you should have by the way, Apple announced two new products at their annual MacWorld conference: the Mac mini and the iPod shuffle. I won’t go into great detail about either one of them, as there are already tons of reports on them. However, I will quickly explain what they are.

The Mac mini is a Mac computer that retails at $499, the cheapest Mac to date. It comes with no keyboard, mouse, or monitor, however. If you don’t like your current PC, all you have to do is buy a Mac mini and replace it.

The iPod shuffle is a flash based iPod. It comes in sizes of 512MB and 1GB. Unlike the regular iPod and the iPod mini, there is no display to speak of. Thus, it is quite tiny.

That’s about that. Now, I want one of each, just because. So, from the people who brought you FreeiPods.com, Gratis Internet gives you:

Now, hook me up! Thanks!