Skip to content

Category: General

What is the coolest thing you can do using Linux that you can’t do with Windows or on a Mac?

Someone asked me this recently. I don’t have just one answer. I compiled a list of things I thought of and emailed it to my friend…then I thought I would post it here for future reference. Feel free to add to the list! There is also a forums thread on the same topic, that I remembered as I complied my thoughts, so I stole some of the ideas posted there.

1. Upgrade to the newest version legally and without paying money
2. Have the latest version of the operating system run faster than the previous version on the same hardware
3. Easily install and run different graphical interfaces if I don’t like the default setup
4. Install twenty programs with one command
5. Have the system automatically update all my installed programs for me.
6. Install the same copy of my OS (Ubuntu) on multiple computers without worrying about license restrictions or activation keys
7. Give away copies of the operating system and other programs that run on it without breaking any laws, governmental or ethical or moral, because it was all intended to be used this way
8. Have full control over my computer hardware and know that there are no secret back doors in my software, put there by malicious software companies or governments
9. Run without using a virus scanner, adware/spyware protection, and not reboot my computer for months, even when I do keep up with all of the latest security updates
10. Run my computer without needing to defragment my hard drive, ever
11. Try out software, decide I don’t like it, uninstall it, and know that it didn’t leave little bits of stuff in a registry that can build up and slow down my machine
12. Make a major mistake that requires a complete reinstallation and be able to do it in less than an hour, because I put all of my data on a separate partition from the operating system and program files
13. Boot into a desktop with flash and effects as cool as Windows Vista on a three year old computer…in less than 40 seconds, including the time it takes me to type my username and password to login
14. Customize anything I want, legally, including my favorite programs. I can even track down the software developers to ask them questions, contribute ideas, and get involved in the actual design/software writing process if I want to
15. Have 4+ word processor windows open working on papers, listen to music, play with flashy desktop effects, have contact with a largely happy community and have firefox, instant messaging, and email clients all open at the same time, without ever having had to beg someone for a code to make my os work, and without the system running so slow it is useless
16. Use the command “dpkg –get-selections > pkg.list” to make a full, detailed list of all software I have installed, backup my /etc and /home directories on a separate partition, and you are able to recover your system any time, easily
17. Run multiple desktops simultaneously, or even allow multiple users to log in and use the computer simultaneously
18. Resize a hard disk partition without having to delete it and without losing the data on it
19. Use the same hardware for more than 5 years before it really needs to be replaced…I have some hardware that is nearly 10 years old, running Linux, and still useful
20. Browse the web while the OS is being installed!
21. Use almost any hardware and have a driver for it included with the operating system…eliminating the need to scour the internet to find the hardware manufacturer’s website to locate one
22. Get the source code for almost anything, including the OS kernel and most of my applications

I could go on, but that’s long enough. 🙂

Automatic MySQL backups using PHP

Okay, as pointed out in a comment on my last post, there are lots of ways to do this sort of thing. Many (most?) real sysadmins would probably choose to write a short shell script. Here’s the deal: I actually like PHP. Anyway, in my last post I shared a way to do site backups using PHP. Here’s a short followup, how to backup a MySQL database using PHP. You can put this script into the same file as the last script, to be run by a cron job, or you can do this at a different time. Like the last one, this script also originated from this site.

I hope someone finds this useful. 🙂

Again, sorry for the crossed out lines in the beginning of the script when the system command is called. My blog software uses a double dash to initialize and terminate the strikeout, and for some reason, even though the text is set as “preformatted,” parts are still being struck out. I presume it is because of the presence of quotation marks in the line. The interior of the line should read

mysqldump –user=$dbuser –password=$dbpswd –host=$host $mysqldb

 <?php $emailaddress = "yourname@emailaddress.com"; $host="localhost"; // database host $dbuser="weird_user_name"; // database user name $dbpswd="strong_password"; // database password $mysqldb="important_data"; // name of database $filename = "~/sqlbackup_important_data." . date("d") . ".sql"; if ( file_exists($filename) ) unlink($filename); system("mysqldump user=$dbuser password=$dbpswd --host=$host $mysqldb > $filename",$result); $size = filesize($filename); switch ($size) {   case ($size>=1048576): $size = round($size/1048576) . " MB"; break;   case ($size>=1024): $size = round($size/1024) . " KB"; break;   default: $size = $size . " bytes"; break; } $message = "The database backup for " . $mysqldb . " has been run.\n\n"; $message .= "The return code was: " . $result . "\n\n"; $message .= "The file path is: " . $filename . "\n\n"; $message .= "Size of the backup: " . $size . "\n\n"; $message .= "Server time of the backup: " . date(" F d h:ia") . "\n\n"; mail($emailaddress, "important_data db backup" , $message, "From: Website <>"); ?>

Making automatic backups for your website

I have several websites that I administer. As any good site admin will tell you, making consistent backups is vital. I have a script that I originally got from this site that I use to back my sites up automatically, using cron. Here’s how I do it, and how I have modified the script slightly for my own purposes.

First off, create a php text file. I named mine site_backup.php. You will need to modify this with your site and email info. This script will create a archive file with the name backup.<day>.tar.gz, where <day> is the number of the current day of the month. Every day of the month the number will change, thereby leaving you with a month’s worth of backups in your /home directory, that will be overwritten the next time the day of the month is the same.

<?php  $emailaddress = "yourname@emailaddress.com";  $target = "/home/".get_current_user()."/backup.".date(d).".tar.gz";  if (file_exists($target)) unlink($target);  system("tar create preserve gzip  file=".$target." --exclude-from=/public_html ~/mail",$result);  $size = filesize($target);  switch ($size) {    case ($size>=1048576): $size = round($size/1048576) . " MB"; break;    case ($size>=1024);    $size = round($size/1024) . " KB"; break;    default:               $size = $size . " bytes"; break;  }  $message = "The <yoursitename> website backup has been run.\n\n";  $message .= "The return code was: " . $result . "\n\n";  $message .= "The file path is: " . $target . "\n\n";  $message .= "Size of the backup: " . $size . "\n\n";  $message .= "Server time of the backup: " . date(" F d h:ia") . "\n\n";  mail($emailaddress, "<yoursitename> backup message" , $message, "From: Website <>");  ?>

One of my sites has a few directories that are loaded with graphics, all of which I have backed up elsewhere. I wanted to exclude those directories from the tar archive. If you have used tar by itself, you know this is an easy thing to do, but I had not done so in a script before. Fortunately, you do it the exact same way you would usually do it from the command line. Since we are using the “system” call in PHP, all we need to do is make sure our syntax is correct for tar.

After a quick look at the GNU tar man page to confirm how to use

--exclude

I noticed that I didn’t need to put all the directories directly in the script. This was news to me, and so I was happy I had read through the man page, discovering the

--exclude-from

option.

I created a text file, which I’ll call backupexclude, and included it in my /home directory. In it I listed each directory I wanted to exclude, one directory per line. Here’s an example

~/foldertoexclude1 ~/directory/subdirectorytoexclude1 ~/skipthis

Simple, huh?

To run it from the command line, you just type “php ~/site_backup.php” without the quotes. This way you can backup your website and email folders any time you want.

To call up the script using cron, add a line like this to the cron file (or added in whatever way your web host has configured cron jobs to be added by you).

# run at 2:15am every day of the month 15 2 * * *     php ~/site_backup.php

Elitism or equality: false dichotomy?

From time to time we hear people talk about equality. I think equality is a nice idea, if it is used to express the thought that every person is valuable, solely based on their existence. To say that every person is equally valuable in terms of their contributions to society, to projects, or to the universe is easily disproven. To say that each person is equal in their abilities, gifts, talents or acquired skills is absurd and not worth the time it would take to disprove. However, to say that we value each person highly, that we desire them to feel loved, welcome and important to us, this is something worthwhile.

Let’s try not to mix these things up. If/when we do, we run the risk of becoming what Kurt Vonnegut feared and described in his poignant short story, Harrison Bergeron. If you have never read it, please take a minute to do so. I think you will enjoy and appreciate it.

I don’t think it is elitist to say that one person is better at a specific skill. I also think it is completely appropriate to reward quality. Effort is important, and I would like to honor good effort as well, but perhaps in a different way.

What confuses me at times are the people who say that we should never give a special honor to people who contribute their time, efforts, and skills, and that we should never give an extra special honor to those to excel while doing so. I disagree. Merit should be rewarded with thanks and recognition. These are not the motivating forces behind the majority of people who do things well, but everyone appreciates it when their good work is recognized.

Do you have someone you would like to honor? Please do so.

Holiday greetings and hyper sensitivity

I have a love/hate relationship with this time of year.

I love holidays. I love being with family and friends. I enjoy the general atmosphere of friendship, caring, and fun.

I absolutely hate the pseudo-religious wars over holiday greetings.

Imagine standing in line in a store. The clerk gives a generic “Happy Holidays” to a guest, who rudely responds, “No, it’s Merry Christmas! Don’t destroy my season” or something similar. Hmm. It seems to me the clerk was merely trying to wish the guest peace, love and joy, not start a fight.

There is the other side, too. Someone says, “Merry Christmas,” and the recipient of the kind wishes gets his undies in a bunch and rudely replies, “I don’t believe in that holiday, I am a (insert other belief system here).” Yikes! All the greeter was trying to do was include the listener in a time of year that the greeter enjoys and appreciates.

Really, people, we need to stop being so irritatingly sensitive. All these things are being said with a kind intent, a desire to include you in the fun, frivolity, or even serious celebration of a time of year that is important to the person giving the greeting. You should feel desired, wanted, and loved, not offended, angry or threatened. Lighten up (both sides)!

If a Muslim says to me, “Mabrook al aid” or “Aid mubarak said,” thereby wishing me a wonderful Aid al Adha, I don’t need to respond that I am not a Muslim and get offended at her kind attempt to include me in a time of celebration that she finds meaningful and important. Instead, the proper response is, “Thank you.” It doesn’t actually hurt anything to return the greeting.

If a Jew wishes me a “Happy Hanukkah,” I have no reason to be offended. He is welcoming me to join in a celebration that he enjoys.

If a Christian wishes someone “Merry Christmas,” this is not automatically an invitation to convert, nor is it an attempt to insult, demean, or offend. She desires that you find pleasure from a holiday that he enjoys.

If a pagan wishes me a “Happy Yule” or a “Merry Solstice,” they are not trying to say that they are better or that I am worse, they are giving a greeting that has meaning for them and welcoming me to join them in a seasonal celebration that they enjoy.

If an atheist smiles and wishes me “Season’s Greetings,” they are not trying to be rude. It is more likely they don’t have a specific holiday that they celebrate, but they do want me to know that they consider me important and wish to share with me a hope for a joyous time of year.

Now, when someone says, “Happy Holidays,” they are not trying to offend anyone by excluding their holiday of choice. They are trying to be as inclusive as possible.

Bottom line for me: I wish the world would quit being so hyper-sensitive this time of year. If someone wishes you joy, using words you wouldn’t use or a holiday that you don’t celebrate, just say “Thank you” and move on. Please don’t do the exact opposite of their goal and cause a huge ruckus by complaining, arguing, or becoming bitter and rude. Oh, and Merry Christmas and Happy Holidays from me. 🙂

Users who impose their beliefs on others

Every once in a while in the Ubuntu Forums I get a private message from a user, or we find a reported post, or someone posts something like this in a thread. The following is a direct quote, with some things removed to obscure the specific user and thread. No other editing was done.

i would like to report that a user on this forum has offended me very much by using bad language. I know last time this happened and i emailed you guys you did nothing. I am sick of being offended and nothing is ever done about it.

he said the P word in *link* .

I am very religious and the bible says this word is not right to use. please make sure he does not offend me or my beliefs again.

Okay, where do I start?

Here’s my main problem: I’m really tired of people saying they want everyone to follow their system of belief or personal philosophy of life (all software must be free or else…join my religion or else…etc.) and then threatening the staff because we don’t allow those demands to be made. Seriously, guys (and it almost always is a male…), if you want people to follow your way of life, all you have to do is show us how and why it is better by being a better person than the people around you. If you want people to follow you, lead by example with respect, with kindness, and yes, with good and logical arguments that do not demean those who disagree with you, but rather show a better option than what they are presenting.

Okay, I’m done with my tirade (full version here). I feel better now.

The definitive guide to Trolls

We have all seen internet trolls. Some are more creative than others. Some are funny, others are mean. All of them are detrimental to community. I had an experience this week with a troll in the Ubuntu Forums that reminded me of an old thread that I had written. The definitive guide to Trolls was something I wrote in May 2006, partly tongue-in-cheek, partly to instruct forums users on what not to do in the forums, and partly to have something to point to when confronted with trolling.

Now, before I get comments reminding me of this fact, I will state clearly that the derivation of the term “to troll” revolves around fishing. There is a way to catch fish that involves pulling a lure behind a boat as you pass through the water, in the hopes of catching a fish that sees the lure and bites. This is the traditional definition of the verb “to troll.” One may also troll for complements, “Do you think this hairstyle looks good on me?” and one may troll for arguments, “Are you always this rude?” Trolling involves attempting to get someone or something to take the bait, to bite, to respond in a predetermined manner for your benefit (and not necessarily theirs, although the motive need not be sinister).

The use of the term to define online behavior goes back to the early days of Usenet newsgroups, and perhaps even predating that in bulletin board systems (BBSs). Let’s be honest. It is more fun to use the term in a modified manner, with a slightly twisted definition, while retaining the original meaning as well. I like it when the image of an ugly, mythical beast is conjured up because of the term “troll.”

The English language is fun that way. One may “troll” a forum, trying to get a response, and suddenly the verb becomes a noun through an accidental correlation between two words that are spelled exactly the same, but have vastly different meanings. Suddenly the person who committed the act of trolling has become an internet troll.

In the context of an online forum, to troll means to post something specifically provocative in the hopes of stirring up controversy. On occasion this can be considered a good thing, like Braveheart riding to the conference of the nobles to “pick a fight” in the hopes of obtaining a positive outcome for a noble cause. That is sometimes what forums trolls seem to think they are doing. Almost all of the time, actions done with this motive will achieve the exact opposite of their intended goal and they only serve to create an atmosphere that is harsh, argumentative, and unwelcoming. In the Ubuntu Forums, trolling can get a person banned permanently, and for very good reason. The overwhelming majority of the time trolling is witnessed, it is done for less honorable reasons.

To keep this short, if you are interested in a sometimes humorous description of internet trolls, including some very specific descriptions of certain types like the “Affected Profundity Troll” and “The Holy Misroller,” please check out this forum thread. I think you will enjoy it.

My custom amplifier…yep, I built it myself

When I made my guitar post, I promised to put up a picture of my custom, home-built tube amp. Here you go! Details below.

The amp started as a kit from Allen Amps and I built it at the end of 1999. It has since undergone a small amount of modification. The valve complement includes one 5U4G rectifier, two 6L6GC power tubes, and two 12AX7s plus two 12AT7s in the preamp and reverb circuits. The sound comes from two 10 inch Jensen C10Q speakers.

I know the real question is “How does it sound?” Think of a vintage Fender Vibrolux, without the vibrato and with no normal channel. Then add the reverb circuit from the old Fender stand alone reverb head from the 1960s. Finally, modify the preamp slightly to give it a bit of the tweed 4×10 Bassman feel, and you will be pretty close. Oh, except this amp is quieter…there is still some hiss, but very little.

Words are cheap, though. Here are a few mp3s. Let me know what you think…they were recorded about 7 years ago and the recordings aren’t perfect, but they are good enough for you to catch the feel and tone of the amp, and that is what I was going for at the time. Note: these are all played with my Tele (the one that you saw in the other post) plugged straight into the amp with no outside effects. All I did was change the settings on the amp.

Typical setting 1

Typical setting 2

I Wish I Could Play Jazz

Blue Thang

Amazing Grace

Satisfaction Plus

And there’s one more, from a day when I was doing some recording and discovered there was about 3 minutes of tape left at the end of a project. Instead of wasting the tape, I decided to play around a little. This one has two tracks instead of just one.

The End of the Tape

I performed, recorded, and own the copyright for all of these clips, and I hearby release them into the wild with a Creative Commons license (by-nc-sa-3.0). Enjoy. If you use them for anything, I would love a “heads up.”

Fun With Conky, part 2

As you will recall from my earlier blog entry, I have been having fun with Conky, a lightweight system monitor that displays output to your desktop. Since I have upgraded to Gutsy, and therefore the latest repo version of Conky (1.4.7), I have had the opportunity to play with some newly available wireless variables. These were first pointed out to me by Mike, to whom I give credit and thanks.

The new wireless variables make it easier than ever to have specific data output relating to your wireless ethernet adapter. Here is how I have modified my previous setup…see the earlier post for the full details on how I am using Conky.

First, the new display.

Second, the updated configuration file. Generally this is called .conkyrc and placed in your /home. I’ll include the entire file so that readers don’t have to cut and paste information from two blog entries to get my full setup. The important bit with the wireless changes is under the heading Wireless Networking, near the bottom. Enjoy!

# set to yes if you want Conky to be forked in the background background no cpu_avg_samples 2 net_avg_samples 2 out_to_console no # Use double buffering (reduces flicker, may not work for everyone) double_buffer yes # Create own window instead of using desktop (required in nautilus) own_window yes own_window_type override own_window_transparent yes own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager #own_window no #own_window_transparent no # Use Xft? use_xft yes # Xft font when Xft is enabled xftfont Liberation Mono Italic:size=8 uppercase no # Text alpha when using Xft xftalpha 0.8 # Update interval in seconds update_interval 1 # Draw shades? draw_shades no # Draw outlines? draw_outline no # Draw borders around text draw_borders no # Stippled borders? stippled_borders 10 # border margins border_margin 4 # border width border_width 1 # Text alignment, other possible values are commented #minimum_size 10 10 gap_x 13 gap_y 45 #alignment top_left alignment top_right #alignment bottom_left #alignment bottom_right # Add spaces to keep things from moving about?  This only affects certain objects. use_spacer yes # Subtract file system buffers from used memory? no_buffers yes # ideas that I didn't want to lose # ${time %a  %b  %d}${alignr -25}${time %k:%M} TEXT ${alignc}${color #D6CACA}$sysname kernel $kernel ${alignc}${color #D6CACA}${exec cat /etc/issue.net} on $machine host $nodename ${color #D6CACA}${execi 1000 cat /proc/cpuinfo | grep 'model name' | sed -e 's/model name.*: //'} ${color #c9d6d6} ${freq_dyn}Mhz ${color #D6CACA}Current CPU usage & temp:${color #c9d6d6}  ${cpu}%${color #D6CACA}, ${color #c9d6d6}${acpitemp}C ${color #D6CACA}/${color #c9d6d6} ${acpitempf}F ${color #D6CACA}Plug/battery status:${color #c9d6d6}  $acpiacadapter, $battery ${color #D6CACA}Load average:${color #c9d6d6}   $loadavg ${color #D6CACA}CPU usage         ${alignr}PID     CPU%   MEM% ${color #c9d6d6} ${top name 1}${alignr}${top pid 1}   ${top cpu 1}   ${top mem 1} ${color #c9d6d6} ${top name 2}${alignr}${top pid 2}   ${top cpu 2}   ${top mem 2} ${color #c9d6d6} ${top name 3}${alignr}${top pid 3}   ${top cpu 3}   ${top mem 3} ${color #D6CACA}Mem usage ${color #c9d6d6} ${top_mem name 1}${alignr}${top_mem pid 1}   ${top_mem cpu 1}   ${top_mem mem 1} ${color #c9d6d6} ${top_mem name 2}${alignr}${top_mem pid 2}   ${top_mem cpu 2}   ${top_mem mem 2} ${color #c9d6d6} ${top_mem name 3}${alignr}${top_mem pid 3}   ${top_mem cpu 3}   ${top_mem mem 3} ${color #D6CACA}RAM Usage:${color #c9d6d6} $mem/$memmax - $memperc% $membar ${color #D6CACA}Swap Usage:${color #c9d6d6} $swap/$swapmax - $swapperc% ${swapbar} ${color #D6CACA}Processes:${color #c9d6d6} $processes  ${color #D6CACA}Running:${color #c9d6d6} $running_processes ${color #D6CACA} ${color #D6CACA}Hard disks:   / ${color #c9d6d6}${fs_used /}/${fs_size /} ${fs_bar /}   ${color #D6CACA}/home ${color #c9d6d6}${fs_used /home}/${fs_size /home} ${fs_bar /home}   ${color #D6CACA}hdd temp: ${color #c9d6d6}${execi 300 nc localhost 7634 | cut -c22-23 ;} C ${color #D6CACA}Wireless Networking:   ${color #D6CACA}ESSID: ${color #c9d6d6}${wireless_essid eth1}  ${color #D6CACA}AP: ${color #c9d6d6}${wireless_ap eth1}   ${color #D6CACA}${exec iwconfig eth1 | grep "Frequency" | cut -c 25-45}   ${color #D6CACA}Mode: ${color #c9d6d6}${wireless_mode eth1}  ${color #D6CACA}Bitrate: ${color #c9d6d6}${wireless_bitrate eth1}   ${color #D6CACA}Local IP ${color #c9d6d6}${addr eth1}  ${color #D6CACA}Link Quality: ${color #c9d6d6}${wireless_link_qual_perc eth1}   ${color #D6CACA}total download: ${color #c9d6d6}${totaldown eth1}   ${color #D6CACA}total upload: ${color #c9d6d6}${totalup eth1}   ${color #D6CACA}download speed: ${color #c9d6d6}${downspeed eth1} k/s${color #c9d6d6} ${color #D6CACA}   upload speed: ${color #c9d6d6}${upspeed eth1} k/s   ${color #c9d6d6}${downspeedgraph eth1 15,150 ff0000 0000ff} $alignr${color #c9d6d6}${upspeedgraph eth1 15,150 0000ff ff0000} ${color #D6CACA}Wired Networking:   ${color #D6CACA}Local IP ${color #c9d6d6}${addr eth0} ${color #D6CACA}   ${color #D6CACA}total download: ${color #c9d6d6}${totaldown eth0}   ${color #D6CACA}total upload: ${color #c9d6d6}${totalup eth0}   ${color #D6CACA}download speed: ${color #c9d6d6}${downspeed eth0} k/s${color #c9d6d6} ${color #D6CACA}   upload speed: ${color #c9d6d6}${upspeed eth0} k/s   ${color #c9d6d6}${downspeedgraph eth0 15,150 ff0000 0000ff} $alignr${color #c9d6d6}${upspeedgraph eth0 15,150 0000ff ff0000} ${color #D6CACA}Public IP ${color #c9d6d6}${execi 3605 curl 'http://www.whatismyip.org'} ${color #D6CACA}Port(s) / Connections: ${color #D6CACA}Inbound: ${color #c9d6d6}${tcp_portmon 1 32767 count}  ${color #D6CACA}Outbound: ${color #c9d6d6}${tcp_portmon 32768 61000 count}  ${color #D6CACA}Total: ${color #c9d6d6}${tcp_portmon 1 65535 count} ${color #D6CACA}Outbound Connection ${alignr} Remote Service/Port${color #c9d6d6}  ${tcp_portmon 1 65535 rhost 0} ${alignr} ${tcp_portmon 1 65535 rservice 0}  ${tcp_portmon 1 65535 rhost 1} ${alignr} ${tcp_portmon 1 65535 rservice 1}  ${tcp_portmon 1 65535 rhost 2} ${alignr} ${tcp_portmon 1 65535 rservice 2}  ${tcp_portmon 1 65535 rhost 3} ${alignr} ${tcp_portmon 1 65535 rservice 3}  ${tcp_portmon 1 65535 rhost 4} ${alignr} ${tcp_portmon 1 65535 rservice 4}  ${tcp_portmon 1 65535 rhost 5} ${alignr} ${tcp_portmon 1 65535 rservice 5}

I love my guitars

I know there are some other players out there. Come on, let’s see some gear shots…

Included here: Guild D4 acoustic, Washburn Force 4 bass, Fender Telecaster, and a Squier Starfire IV. The Tele is my main axe.

Coming soon, a photo of my custom amp (that I built…).