Sunday, June 17, 2007

A couple of linux tips for newbies



Being a GNU/Linux newbie, having only switched completely to Ubuntu GNU/Linux from Windows about a year and a half ago, I am still trying to figure out what works and what doesn't for me, and how I can fix it. Ubuntu is my distro of choice, not necessarily because it's an easier distro, but because I like the Debian way of doing things, I like bleeding edge, and I like being backed up by the huge Ubuntu community. Having said that, most of these tips are from the point of view of a Debian/Ubuntu user, however, they can be applied to other distros:

1. Backup Script. It's usually good to backup at least your /home directory every once in a while. However, backing up manually can be a pain, and most of the scripts I found out there where too complex for what I needed, so I wrote my own:





#!/bin/bash
backup_path="/full/path/to/backup"
compress(){ #compress backed up files
tar cvvf $backup_path/backup$(date %d%m%G).tar $HOME
exit 0
}

if [ -d $backup_path/backup ]
then
compress
else
mkdir $backup_path/backup
compress
fi
else

exit 0


What I'm doing with this script is backing up my home directory and saving it as a compressed file with the name "backup[daymonthyear].tar"
I suggest you not save the backup files in the same hard drive as the original; if the hard drive fails you might be in trouble. You should mount to an external hard drive or a file server. If you want to get more detailed and run backups from only on a list of files, you can substitute the compress function for:

compress(){
tar cvvf $backup_path/backup$(date %d%m%G).tar -l file.list
exit 0
}


where the list of files is in a text file called "file.list" (remember: one file path per line and be careful with white spaces).

2. One thing that I miss when I use the command line is not being able to undo mistaken deletions. In Windows, or Using the Desktop manager ( I use GNOME), when I delete something, it goes to the "trash" folder, where I can go to retrieve it if i deleted it by mistake. When I use the rm command in the command line, whatever is gone, is gone for good. That's why I use a nice little trick: I use a "trash" function in my .bashrc file instead of "rm" when what to get rid of a file, but I am not sure if I am going to need it later. The trash directory (.Trash) is hidden in your home directory, so you just need a command that will move unwanted files and directories to the .Trash directory:


trash() { mv "$@" /home/$USER/.Trash;}


I call my function "trash" so when I call it I just type "trash [filename]" on the command line. Notice that I actually use the move command instead of the remove command, to move my files to the .Trash directory. Notice also that I use the $USER system variable instead of the actual home folder name - it's slightly more elegant since I can run this function under any username and the system will recognize what home directory to look for. Also, I'm lazy and my username is longer than the variable name. This function also allows me to attach move options as well as pointing to the file that I want to "trash". Copy this function to your .bashrc (in your /home directory). and you have yourself a new "delete" command!!

Monday, June 11, 2007

10 Tips on How to be an American and Survive In Spain


1. Expect chaos at arrival. Unless you arrive to Spain from another European Union country, immigration is complete chaos in Madrid. Your plane from the U.S. will arrive with another 16 other planes from boisterous, rowdy, South American immigrants.

2. No, surprising as it may seem, no one in Spain walks around in everyday life wearing funny hats and dressed as "toreadors".

3. Yes, Euros look like Monopoly money. Don't make fun of them, they are worth more than the U.S. dollar.

4. When you order coffee, you will get a tiny cup (even cups in Starbucks are smaller). Do not be fooled. That shot of espresso holds more bang than 2 or 3 large cups of American coffee.

5. Do not discuss politics unless you know that the person you talk to agrees with you. Be warned: regardless of your political views 50% of Spaniards will agree with you, and the other 50% will try to stone you. A discussion about politics can turn into a heated argument in seconds. If you are caught between 2 Spaniards arguing about politics, smile, nod and back away slowly.

6. Spaniards talk with their hands. You might have the urge to back away so as to not get your eye poked out during normal conversation. Do not fret, Spaniards have perfected hand flailing with years of practice. Unlike on the previous example, backing is a bad idea. The irritated Spaniard will corner you and flail harder.

7. People will try to speak to you in very fast Spanish, even if you do not speak the language. When you express to them that you are not able to understand what they are saying, they will nod, and agree as if understanding; then proceed to continue to speak in Spanish, only slower and much louder. After all English is just Spanish spoken slowly and very loud.

8. Be careful how you order food, and be sure you know what you order. My wife once thought she was ordering lamb ("oveja") when she had really ordered "oreja" (fried pig ears).

9. Criticize a Spaniard's soccer team at your own risk. Likewise do not criticize a Spaniard's city of origin (this is specially true with the rivalry between Madrid and Barcelona). You will get hurt. My brother-in-law almost got mauled by my 87 year old grandmother when he dared say that he preferred Barcelona to Madrid in front of her (and the rest of the family, myself included, would have looked the other way while she skinned him alive).

10. Finally, about the running of the bulls: The only reason why you hear about Americans getting killed every year during the running of the bulls in Spain is because the only people that run in front of the bulls are 1.) experts with years of experience who know what they are doing and 2.) drunk Americans. The rest of Spaniards just laugh at the drunk Americans.

Who Needs Internet Explorer?!!