Category Archives: Linux

A Programmer’s Dilemma: Choosing between Qt and .NET

I’ve been a programmer for a long time, but admittedly, most of my efforts have been devoted to web-based projects (PHP, ASP) and command line desktop programs with a very limited audience. Recently, I’ve decided to swallow my pride and accept that I need to learn to make desktop apps that…don’t suck. Where do I start?

I’m fortunate to have a group of software engineer friends — if I ever have a question about Dungeons & Dragons or programming, they have me covered. Over a couple of beers, I presented them a seemingly mundane question got these code monkeys a little hot under the collar:

Hey, guys… What framework should I develop in?

With the ensuing noise you would have thought I’d just thrown an unopened Chewbacca action figure out of a moving vehicle. Unsurprisingly, debates over the best framework can send nerds into a tizzy — after all, they’ve devoted a hell of a lot of time becoming well-versed in something that the opposition considers a “waste of time!” Once the bickering subsided, two contenders rose to the top of everybody’s lists: Nokia’s Qt and Microsoft’s .NET.

Qt is better than .NET? How about you say that to my face?

All you need to do is Google Qt versus .NET to see that the debate rages on, but there is no clear winner. However, depending on your situation, there is definitely a best fit for you. Some discussion and research led me to a few considerations when choosing where to focus your learning efforts.

What are your platform needs?

Both Qt’s SDK and Microsoft’s Visual Studio have a full set of tools for developing desktop apps complete with user interface controls, but if you intend to make software to work across all major platforms (Windows, OS X, Linux), you may want to think carefully. Qt is available under GPL for all platforms and will let you deploy desktop apps that don’t require the user to install a framework like .NET does. The .NET framework is pre-installed in modern versions of Windows, but the Mono framework allows for .NET-compatibility in Linux and OS X. Any way you cut it, you can probably make software that works on any machine — but Qt definitely has the advantage here.

Personally, I like the idea of developing cross-platform software from a single IDE installation (à la Qt), but you can’t ignore the fact that .NET works with WPF and Windows Forms to deliver some pretty awesome functionality without a lot of effort. How much emphasis do you put on cross-platform compatibility? If the answer is “a lot,” then Qt is for you. If you’re content to stick with Windows development, .NET will more than satisfy you.

Do you have strong programming fundamentals?

If you’re a student, the answer is probably “not yet.” Because Qt is a framework that uses C++, it requires you to learn certain concepts like pointers, memory management, and other lower language abilities that are greatly abstracted in .NET’s C#. The idea here is that if you are a burgeoning programmer, you should gain familiarity with practices inherent to a language like C++ because it will make the transition to C# much easier.

So, if you’re looking to be the best programmer you can ever be and you’re not very experienced in baseline techniques, pick up Qt. If you’re more interested in getting a good job quickly, .NET developers are a hot commodity.

How much time are you willing to invest in learning?

The general consensus is that C++ isn’t an easy language to master, but it is pretty close to the metal when it comes to the stack, I/O devices, and memory management. Gaining proficiency in Qt is definitely going to take some time, but perhaps will make you a more well-rounded programmer in the end. However, don’t underestimate the value of getting something done quickly and smoothly — because .NET and C# will allow you to do that.

In the end, both are great frameworks

The truth is that there is no “best” framework, and it will ultimately come down to your needs, professional goals, and personal interests. For fast-paced commercial programming, .NET/C# has an edge, but for open-source cross-platform development, Qt will lead you to good places. There is a lot of functional overlap in these two frameworks, so it may be wise to try them both…and don’t be quick to dismiss either.

How to Play Ogg Vorbis Files from the Linux Command Line

HeadphonesIf you’re a dedicated user of free and open source software, chances are your dedication goes beyond just software. You probably try to use as many open file formats as you can. Document formats, video formats, and audio formats. Especially audio formats.

In the world of free and open source software, a popular format is Ogg Vorbis. Ogg Vorbis offers comparable audio quality and file compression as MP3, but without all the potential hassles the come from the patents that apply to MP3.

Just about every free and open source desktop media player supports Ogg Vorbis. But what if you want a player that’s a little lighter, or are using a stripped-down Linux distribution on an older, underpowered computer? The obvious answer: turn to the command line.

Using a command line application called ogg123, you can play back your Ogg Vorbis files without a lot of overhead.

Installing ogg123

ogg123 isn’t a standalone application. It’s part of a package called vorbis-tools. vorbis-tools comes pre-installed with a number of Linux distributions. To find out if it’s installed in yours, open a terminal window and type the following command:

which ogg123

If the command returns something like the following (/usr/bin/ogg123 in this example), then you’re ready to go.
Is ogg123 installed?

Otherwise, you need to install vorbis-tools. You can do that using your favorite package manager. If vorbis-tools isn’t available, then you can download and install it manually.

Using ogg123

Open a terminal window and change to the directory containing the files that you want to play. Then type the command ogg123 *.oga. This will play all of the files in the directory, in order.

That’s not very exciting, is it? If you want to shuffle the tracks to play them randomly, then type ogg123 -z *.oga.

Playing an Ogg Vorbis file

If you’ve ripped songs off of a CD, chances are the ripping process created a playlist file (with the extension .m3u). You can use that with ogg123 by typing the command ogg123 -@ playlist.m3u, substituting the actual name of the file for playlist.

To jump to the next track, press CTRL+C on your keyboard.

Note that ogg123 has a number of options. You can view them by typing ogg123 at the command line or viewing this reference.

Dealing with Cover Art

Music files, no matter what their formats, contain a number of tags. These tags include the title of the track, the name of the album, the artist, and the like. One of the tags also points to cover art. When you play the file in a graphical music player, an image of the album’s cover appears in the player.

If an Ogg Vorbis file you’re playing with ogg123 contains the cover art tag, ogg123 will try to render the art. However, you won’t get the image. Instead, you’ll get a stream of numbers and letters, like this:

Trying to render cover art. Not pretty!

There’s no way to suppress this, sorry.

Summing Up

ogg123 is a simple yet effective media player for the Linux command line. It’s easy to use and does a very good job. It has one or two small quirks, but those are easy to ignore. In fact, once you start using ogg123 you might just wind up using it instead of your favorite GUI music player.

Photo credit: celiece

Backup Files from Your Linux Desktop with Pybackpack

BackupAs you probably know, there are a number of great web apps for backing up your files. Many of us here at Techerator are partial to Dropbox.

That said, for some people cloud-based storage is overkill. Others have serious reservations about trusting their files to others. Fair enough. So what can they do?

Well, they can manually copy their important files to a CD or a DVD, or they upload them to a personal web server. Those solutions are fine, but they also require manual intervention. Anyway, what’s the point of having a computer if you can’t let it do the heavy lifting for you?

If you use a Linux distribution with the GNOME desktop, you can use Pybackpack. It’s a simple but effective graphical tool that enables you to save your important files to a CD or DVD, a folder on your local file system, or even a remote web server.

Let’s take a look at how to use Pybackpack.

Downloading and Installing the Software

Before you download Pybackpack, make sure that the following software is installed on your computer:

  • Python
  • PyGTK
  • PyGlade
  • rdiff-backup
  • genisoimage

If you plan to back up your data to a CD or DVD, you’ll also need Nautilus CD Burner. To be honest, I find using CDs and DVDs to be a waste, but your mileage may vary. You probably have most of the software listed above installed on your computer. Anything you don’t have you can install using your package manager.

You can download Pybackpack here. The latest version is 0.5.8. Once you’ve downloaded Pybackpack, extract the contents of the archive to somewhere on your hard drive. Then, crack open a terminal window and navigate to that directory.

Run the following commands:

python build sudo python install 

Getting Started

Launch Pybackpack by pressing ALT+F2. In the Run Application dialog box, type pybackpack and then press Enter.

Pybackpack main window

If you want to copy the contents of your /home directory to a CD or DVD, make sure there’s a writable disk in your CD/DVD drive and then click Go. But, as I mentioned earlier, I find backing up to a CD or DVD to be a waste. You can generally only use them once. And you might not want to back up your entire /home directory.

Pybackpack enables you to back up specific folders and files. You do this by creating backup sets. Using backup sets makes a lot more sense. You can make copies of important files, and even group sets of similar files and folders together. Doing that makes your backups easier to manage.

Creating Backup Sets

In the Pybackpack window, click the Backup tab.

Backup tab

Select New backup set from the list and then click Edit. This starts a wizard that will walk you through the process of creating a backup set.

Creating a backup set - step 1

Click Forward. In the Backup Set Name window, enter the following information:

  • Name of the backup set. Make it descriptive or at least short and to the point.
  • An optional short description.

Then, select where you want to back up your files from the Destination type list. You can save them to a CD or DVD, somewhere on your computer, or to a remote server. Let’s assume you want to save the files to a web server. Select Remote Host (SSH) from the Destination type list. Then, fill in the following information:

  • Username – The name you use to log into the server.
  • Host – The address of the server.
  • Path – The directory on the server in which you want to save your files.

Creating a backup set - step 2

Click Forward. In the next window, select the file and/or folders that you want to include in the backup set by click them in the directory tree and then clicking the Include in set button.

Creating a backup set - step 3

Click Forward. You’re taken to a summary window. If you need to make changes, click the Back button. Otherwise click Forward to save the backup set.

Creating a backup set - step 4

Performing a Backup

When you’re ready to backup your files, select the backup set in the Pybackpack window.

Doing a backup

Then, click the Backup button. Depending on the number and size of the files you’re backing up, and where you’re backing them up to, the process could take a few seconds to a few minutes.

Restoring Your Backups

You might want to do that once in a while. Click the Restore tab in the Pybackpack window. Then click either Local (somewhere on your computer or on a CD/DVD) or Remote (SSH). In either case, enter the path to the directory containing the backup that you want to restore.

If you have multiple backups, you can select the one that you want to restore from the Restore as of list. Then, click the Restore button.

Restoring a backup

Final Thoughts

Pybackpack is a very flexible and very easy-to-use tool. It’s easy to use and offers several options. While it’s not designed to back up your entire system, Pybackpack does a solid job of backing up your important files and folders.

Photo credit: svilen001

Creating a Bootable Linux USB Drive with UNetbootin

Flash driveTest driving and installing a Linux distribution has become a lot easier over the years. In the early days, you needed to install Linux on a dedicated computer. Or, you could set your computer up to dual boot. Of course that meant navigating the potential perils of partitioning your hard drive.

Later, a Live CD (which lets you run the distribution right from a CD) was the way to do it. The problem with a Live CD, though, is that running anything from a CD is slow. And having to burn a CD for each distribution that you want to try is wasteful.

A better option is a bootable USB flash drive. You can reuse it and any distribution you install on it has the potential to run very quickly.

Whether you’re using Linux, Windows, or Mac OS you can easily create a bootable USB drive using UNetbootin. Let’s take a look at how to do that on the Linux desktop.

Note: Some of the options covered in this post aren’t available in the Windows and Mac OS versions of UNetbootin.

Installing UNetbootin

Just go to the UNetbootin site and download the installer for your operating system. There are buttons at the top of the page.

Buttons for downloading UNetbootin

You can also get packages for the following Linux distributions: Ubuntu, Debian, Fedora, SuSE, Arch, and Gentoo.

Once it’s installed, you can start UNetbootin from your applications menu. In Ubuntu, for example, select Applications > System Tools > UNetbootin.

Creating the Bootable Drive

First off, you’ll need a USB flash drive. At the very least, it should have a capacity of 1 GB. Just to be safe, use either a 2 GB or 4 GB drive.

UNetbootin has an interesting feature: it can automatically download and create a bootable flash drive for over 20 popular Linux distributions. That saves a lot of time and trouble!

The distribution that you want may also need an ISO image. An ISO image, which has the extension .iso, is a compressed version of an operating system. That includes everything — installer, file system, and all the collateral.

From there, fire up UNetbootin.

Main window

If you’re going to create a bootable drive from one of the supported distros, select it from the Select Distribution list. Then, choose the version that you want to use from the Select Version list.

If, on the other hand, you’re going to create a bootable drive from an ISO image, click the Diskimage option. Then, click the “…” button to find the ISO image that you downloaded.

From there, make sure that the Type list is set to USB Drive and the Drive option is set to /dev/sdb1. In Linux, /dev/sdb1 is the default mount point) for removable storage devices.

Note: In Windows, the option will be a drive letter like F:**. In Mac OS, it will be something like /Volumes/USBDRIVE/**.

Ready to create a bootable image

When you’re ready to go, click the OK button. It can take several minutes for the UNetbootin to write the files to the flash drive. When the process is finished, a message appears asking if you want to restart your computer. You can safely ignore the message.

Using the Bootable Flash Drive

Restart your computer with the flash drive plugged into a USB port. Chances are your computer’s boot sequence — which tells your computer which drive (hard drive, CD-ROM drive, or removable drive) to start from — will skip the flash drive the first time you try this. When your computer starts, you need to go into the BIOS to change the boot settings. Depending on your computer, this could mean pressing the F2 key or F10 key on your keyboard. You’ll have to do this quickly.

Once you’re in the BIOS, find the boot settings and make the removable drive (your flash drive) the one from which your computer boots first. You can find detailed instructions on how to do that here. Then, exit the BIOS. Your computer will restart and boot from the flash drive.

From there, a menu will appear. Just choose the option to run in live mode and then take the Linux distribution for a spin.

Photo credit: gytha_ogg

Converting Graphics on the Linux Desktop with Converseen

Convert it!If you’re a Linux user, then you probably know how spoiled you are when it comes to applications for working with graphics. Whatever you need to do — editing, resizing, viewing, converting — there’s an application for that.

One of the most powerful Linux tools for manipulating graphics is ImageMagick. As powerful as it is, ImageMagick can be a challenge to use. It’s a command line tool, which means quite a few options. That’s not a bad thing, but if you use it infrequently it can be tough to remember those options.

Enter Converseen. It is a graphical version of ImageMagick that focuses on converting and resizing images on the Linux desktop. Not only that, you can do that with more than one image at the same time.

Let’s take a look at how to use Converseen.

Getting Up and Running

The first thing you need to do is download and install Converseen. You can either download and compile the source code, or get packages for Fedora, Ubuntu, and openSUSE.

Once you’ve installed Converseen, launch it. In Ubuntu, for example, select Applications > Graphics > Converseen.

Main Converseen window

Let’s Start Converting!

Click the Add images button. In the dialog box that opens, navigate to the directory containing the images that you want to convert. You can select individual images or you can CTRL+click and select multiple images. If the images that you want to convert span multiple directories, repeat the process.

Then select Edit > Check All Items. This selects all of the images you loaded and tells Converseen that you want to convert them. If you don’t want to convert all of the images at once, click the To convert checkbox beside each image to select or deselect it.

Ready to convert

If you are converting the images to another format and not resizing them, click the Convert to list. Select a format from the list. You’ll notice that Converseen supports dozens of bitmap formats. Converseen can’t work with vector graphics, such as the popular SVG.

For those of you converting your images to JPEG or PNG, you can optionally click the Image settings button to change the amount by which Converseen compresses the resulting image. The more you compress an image, the smaller it is, but you also lose detail the more you compress it.

Changing settings

If you want to resize your images, click the Dimensions checkbox on the left side of the Converseen window. You can shrink or expand your images based on a percentage or on the number of pixels. Click the Maintain aspect ratio checkbox to keep the images in proportion.

Converting ...

When you’re ready to go, click the Convert button. Depending on the number and size of the images that you selected, this could take anywhere upward of a few seconds. Converseen dumps the converted images in your home directory — for example, /home/scott. You can change that in Output options section on the left side of the Converseen window.

Converseen is a fast, simple, and efficient way to convert and resize multiple files. It does the job very well and doesn’t require you to remember long strings of commands. It works as advertised, which is the hallmark of a good utility.

Photo credit: gimSM

Taking Screen Captures on the Linux Desktop with Shutter

I am a cameraOnce upon a time, just about the only people who took screen captures were technical communicators and technology writers. Nowadays, it seems that everyone needs to grab a window or screen on their desktop. Which is why, I guess, the number of screen capture tools available for various operating systems has blossomed over the years.

If you use Linux, then you suffer an embarrassment of riches when it comes to screen capture software. One of the most useful and flexible screen capture applications for the Linux desktop is Shutter.

Let’s take a closer look at how to use Shutter.

Installing Shutter

Chances are you don’t have Shutter installed on your computer. You can download source code and packages for various distributions.

If you use Ubuntu, then you can install Shutter from a Personal Package Archive. To do that, open a terminal window and run the following commands:

 sudo add-apt-repository ppa:shutter/ppa sudo apt-get update sudo apt-get install shutter 

Once Shutter is installed, you can launch it from a menu. For example, in Ubuntu select Applications > Accessories > Shutter.

Shutter main window

Getting Going

Using Shutter, you can grab the following:

  • Your entire desktop
  • A single window
  • An area that you select
  • A menu
  • A tool tip
  • A web page

Buttons for each of these options are on the application’s toolbar. When you minimize Shutter, its icon sits on a panel. You can choose an option by right clicking the Shutter icon.

Shutter right-click menu

The first two screen capture options — entire desktop and single window — pretty much explain themselves.

A captured window

To grab a portion of the screen, click the Selection button on the toolbar. Then, click and drag your mouse to select what you want to capture. When you’re done, press Enter on your keyboard.

Capturing a tooltip (the text that often appears when you hold your mouse over a button in an application) or a menu is probably only useful if you’re preparing documentation. You just have to remember to keep displaying the tooltip or menu for a few seconds before it’s captured.

Taking a screen capture of a web page works a little differently. When you click the Web button on the toolbar, a dialog box pops up. If you have a URL on your clipboard, Shutter assumes that’s the web page that you want to capture. You can also type a URL in the dialog box. Then, click the Capture button.

Capturing a website

This option doesn’t work with some websites. The capture process will sometimes time out, often without any rhyme or reason.

Editing Your Screen Captures

I usually like my screen capture software to do one thing and one thing only: take screen captures (obviously). If I want to manipulate screen captures, I can do that in an actual graphics program like The GIMP. But I make an exception for Shutter. Why? Its image editing tools, while limited, can be useful.

When you need to edit a screen capture, click the Edit button on the toolbar. You don’t get tools to resize, crop, rotate, or otherwise manipulate an image. You can add text, lines, callouts, and shapes to a screen capture. You can also highlight portions of a capture, or censor portions of an image to hide personal information.

Censoring private information

Final Thoughts

Shutter is a very flexible screen capture tool. I find it to be almost indispensable in my day-to-day work. It’s easy to use and has the features that I need (and a few that I find myself needing occasionally).

If you find yourself taking a large number of screen captures on the Linux desktop, then you should definitely give Shutter a look. It’s a worthy addition to your stable of applications.

Photo credit: Adorama

5 Basic Commands Every Linux User Should Know

Typing commandsSo you’ve been using Linux for a while but have never gone to the command line. Hmm … guess what? That’s not uncommon. While you don’t need to go to the command line to effectively use Linux, knowing even a few basic commands can be useful. That knowledge can open a few doors, expand your computing experience, and in some cases save your bacon.

But if you’re thinking about taking your first steps at the Linux command line, where do you start? There are literally hundreds of commands and it can be difficult to know which ones are useful to you.

Let’s take a look at five basic Linux commands that every user should know. Not only are these commands immediately useful, they’re a good foundation on which to build your knowledge of the command line.

1. cd

When you pop open a terminal window, you’re probably not in the directory in which you want to be. So, how do you get there? By using the cd command. Short for change directory, cd lets you quickly move around the command line.

To change to a directory, just type cd [directory_name] — for example, cd documents. Obviously, you can use this command to navigate to subdirectories, too.

What happens when you’re several subdirectories deep and want to move up a directory or two? To move back up one directory, type cd ... To move two directories up, type cd ../... You can see a pattern emerging here …

2. ls

You’ve moved into a directory and now you want to see what’s in there. To do that, type ls.

What the ls command returns

That’s all fine and dandy, but what if you want to find out more about one or more files? Like how big it is or when it was created or last modified? Type ls -l.

ls with the -l option

The -l option lists the permissions on the file, who owns it, who last edited it, its size in kilobytes, and the date and time when it was last modified.

While many people use ls with an entire directory, you can also use it with a single file or groups of files. How? For a single file, type ls [file_name]. For multiple files, use a wildcard — for example, ls *.html.

3. cp

Next up, the command to copy files: cp. There are a number of ways to use cp. The most common way to use this command is to copy a file to another directory.

To copy a file to another directory, type cp [file_name] [directory_name]. Say you want to copy a file named blue_background.png to the directory web_graphics/backgrounds. The directory is two levels above the directory you’re currently in. Type cp blue_background.png ../../web_graphics/backgrounds.

Remember that unless you’re at the top of your home directory (for example, /home/scott) or are copying a file to a directory that’s below the one you’re in, you need to do one of the following:

  • Enter the full path to the directory into which you’re copying a file
  • Specify how many levels up the target directory is (using ../)

Of course, you can copy multiple files with cp by using a wildcard — for example, cp *.odt myDocuments.

4. mv

Now that you know how to copy files, it’s time to learn how to move them around. That’s where the mv command comes in. You can use that command to either move files to another directory or rename them in place.

When you want to move a file to another directory, mv uses the same command syntax as cp: mv [file_name] [directory_name]. Let’s say you want to move a file named blue_background.png to the directory web_graphics/backgrounds. The directory is two levels above the directory you’re currently in. Type mv blue_background.png ../../web_graphics/backgrounds.

And, as with the cp command you can move multiple files by using a wildcard — for example, cp *.pdf Reports.

To rename a file, just type mv [file_name] [new_file_name] — for example, mv 14217_6794.jpg fast_typing.jpg.

5. rm

Finally, one of the more dangerous commands you’ll run into: rm. Use this command to delete files, but remember to use it with caution. You aren’t warned that you’re about to delete one or more files. Once you delete something, it’s gone.

To delete a file, type rm [file_name] — for example, rm presentation_template_2009.odp. To delete multiple files, use a wildcard — for example, rm *.odp.

Delving Deeper

Maybe this article has whetted your appetite for the command line and you want to learn more. Not just about other commands, but also the other options for the five commands that were just introduced. There are a number of excellent resources available to do just that.

I usually recommend two. First, Linux Phrasebook by Scott Granneman. It’s an indispensable dead-trees book. If your tastes are more aligned with the online world, then check out out Introduction to the Linux Command Line by the folks at FLOSS Manuals. It’s easily one of the best guides to the command line out there.

Photo credit: mulligand

Posting to Tumblr from the Linux Desktop with OpenTumblr Client

TumblrIf you’re looking to publish online, but want a platform that’s somewhere between Twitter and a fully-fledged blog, then you might want to check out Tumblr. With Tumblr, you post tumblelogs, short posts that can be text, video, or audio.

The great thing about a tumblelog is that it’s simple to set up and use. While posting from the Tumblr site itself is fairly easy,  you can also post from your desktop. However, if you’re running Linux, there aren’t too many Tumblr clients for the Linux desktop. One worth taking a look  at is OpenTumblr Client.

Getting Up and Running

OpenTumblr Client is written in Python, which you should have installed by default on your system. If not, install it using your distro’s package manager.

There are two versions of this application. One only requires Python, while the other requires both Python and the following libraries:

Again, you should be able to install those libraries from your distro’s package manager.

The main difference between the two version is that the Python QT version is a bit more compact and visually attractive.

Note: This post focuses on the Python + QT version of the OpenTumblr client.

Download the archive containing the installation files and extract it to your hard drive. Then, open a terminal window, navigate to the directory containing the files that you extracted, and then run the following command to install OpenTumblr Client:

sudo python install 

Let’s Get Tumblelogging!

Once OpenTumblr Client is installed, it’s added to your Applications menu. For example, in Ubuntu you can find the shortcut under Applications > Internet. If it isn’t, then pop open a launcher (press, for example, ALT+F2 in Ubuntu) and then type

Login window

You’re asked to enter the email address of your Tumblr account, the password, and the name of your tumblelog. The name isn’t actually the name that appears at the top of a page when someone visits your tumblelog. It’s the URL — for example, Then click the Log in button.

Once you’re logged in, you’re presented with the application’s dashboard.

The dashboard

It looks a bit like the dashboard in Tumblr’s web interface. Just click an icon to open the editor to post text (a traditional blog post), links, conversations, quotes, photos, audio, and video. The editor is tailored to the type of post you’re making. For example, here’s the editor for a text post:

Ready to publish a text post

Just type information in the main fields and add a tag or two if you want. If you’re writing a text post, you can also add formatting to the text, as well as insert an image or a link.

If you want to schedule the post to publish at a later date, click the Publishing options list and select publish on. Then, in the Date this post field, enter a date and time to publish the post. It defaults to next Tuesday, 10 am.

When you’re ready to publish, click the Create Post button.

Like Tumblr, OpenTumblr Client is very easy to use. If you want to post to Tumblr from the Linux desktop, you’ll find OpenTumblr client a simple and effective way to do just that.

Optimize Your MySQL Server With the MySQL Tuner Script

MySQL is powerful, open-source database software. When joined with PHP or another programming language, the uses of MySQL are almost endless.

The ability to use MySQL in an unlimited number of ways is both a blessing and a curse. While MySQL can be used for just about anything, there is no single proper way to configure a MySQL server. The amount of system resources such as memory and processor to allow the server to use depend on the application. For example, the settings that you would use for a small web server running a single WordPress site would be significantly different from if you were using MySQL with a whole network of WordPress sites.

MySQL Tuner Script

The MySQL Tuner Script is a Perl script that analyses your running MySQL server and makes configuration recommendations based on past performance of the server.  Making the changes suggested by the MySQL Tuner Script can help improve the performance and stability of your MySQL server along with any applications that are using it.

Step 1: Start by downloading the Perl script from


Step 2: Make the script executable.

chmod +x

Step 3: Run the script as any user.


Step 4: Enter your MySQL username and password when prompted.

Step 5: The script shows the values of current global MySQL variables.Any good values are shown as [OK] and bad values are shown with [!!].  Example output is shown below.

[user@mysql-server Desktop]$ ./

 >>  MySQLTuner 1.2.0 - Major Hayden
 >>  Bug reports, feature requests, and downloads at
 >>  Run with '--help' for additional options and output filtering
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password:

-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.5.13
[!!] Switch to 64-bit OS - MySQL cannot currently use all of your RAM

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 43M (Tables: 103)
[--] Data in InnoDB tables: 48K (Tables: 3)
[!!] Total fragmented tables: 16

-------- Security Recommendations  -------------------------------------------
[OK] All database users have passwords assigned

-------- Performance Metrics -------------------------------------------------
[--] Up for: 2d 19h 17m 51s (769K q [3.176 qps], 102 conn, TX: 301M, RX: 238M)
[--] Reads / Writes: 2% / 98%
[--] Total buffers: 288.0M global + 9.9M per thread (50 max threads)
[OK] Maximum possible memory usage: 784.9M (9% of installed RAM)
[OK] Slow queries: 0% (0/769K)
[OK] Highest usage of available connections: 24% (12/50)
[OK] Key buffer size / total MyISAM indexes: 64.0M/46.2M
[OK] Key buffer hit rate: 99.8% (8M cached / 19K reads)
[OK] Query cache efficiency: 62.1% (34K cached / 56K selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 2K sorts)
[OK] Temporary tables created on disk: 6% (33 on disk / 517 total)
[OK] Thread cache hit rate: 82% (18 created / 102 connections)
[!!] Table cache hit rate: 15% (163 open / 1K opened)
[OK] Open file limit used: 6% (285/4K)
[OK] Table locks acquired immediately: 100% (727K immediate / 727K locks)
[OK] InnoDB data size / buffer pool: 48.0K/128.0M

-------- Recommendations -----------------------------------------------------
General recommendations:
 Run OPTIMIZE TABLE to defragment tables for better performance
 Enable the slow query log to troubleshoot bad queries
 Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
 table_cache (> 2048)

[user@mysql-server Desktop]$

Step 6: To change the values of the variables you will need to edit the [mysqld] section of your my.cnf file, usually located in /etc/my.cnf, but this may vary for you.

Step 7: Make the changes to the global variables suggested by the script and restart your MySQL server.

/etc/init.d/service mysql restart

You can run the script again, but it is suggested that you wait 24 hours to see how the my.cnf changes affect the performance.

Have any tips for optimizing the performance of your MySQL server?  Share them with us in the comments below!

How to Learn the Linux Command Line with CLI Companion

CLI CompanionContrary to an enduring myth, you don’t need to constantly jump to the command line in order to effectively use Linux. There are people who spend all their time ensconced in their favorite window manager who’ve never, and never will, type a string of esoteric commands.

Having said that, there are times when knowledge of the command line can be useful. More than that, it can be beneficial. But what if you’re new to the command line, or just use it infrequently?

There are dozens of good books on the subject, and even more websites and other online resources. Having to grab a book or go to a website to find out, or refresh your memory about, how to do something can really disrupt your workflow. What if you could have a list of the commands that you use available right in your terminal window?

If you’re an Ubuntu user and that’s what you’re looking for, then it’s time to give CLI Companion a look.

CLI Companion?

CLI Companion is a yet another terminal application. But it’s a bit more than that. What sets CLI Companion apart is that you can store commands that you use frequently (or even just every so often). CLI Companion saves those commands in a text file (called a command dictionary) named .clicompanion2 found in your /home directory.

To get CLI Companion, you can download an installer here. After you’ve downloaded it, double-click on the file with the extension .deb to install. You can also install CLI Companion through a Personal Package Archive (PPA). Do that by opening a terminal window and entering the following commands:

sudo add-apt-repository ppa:clicompanion-devs/clicompanion-nightlies sudo apt-get update sudo apt-get install clicompanion

Now that it’s installed, let’s start working with CLI Companion.

Using CLI Companion

Start CLI Companion by selecting Applications > Accessories > CLI Companion. You can then type the command that you want to run in the main area of the CLI Companion window.

CLI Companion main window

Simple enough, but what about the command dictionary? Click on Command List to open it.

CLI Companion command dictionary

CLI Companion comes pre-loaded with a number of commands, ranging from commands to list the contents of a directory to networking commands. To run a command, click on it in the dictionary and then click Run.

You’ll notice that some of the commands in the dictionary have one or more question marks after them. This means that when you run the command, you’ll need to enter some information — for example, a directory path or the name of one or more files. When you run one of those commands, a dialog box pops up asking for the additional information.

Prompting for options

Just type the required information and then click OK.

Saving your own commands

What gives CLI Companion its power and flexibility is the ability for you to add your own commands to the dictionary. This is especially useful if you want to save commands that you use infrequently, but which are handy.

Click the Add button. A dialog box opens.

Dialog box for adding a command

Type the command that you want to run on the Command field. You might need to consult your favorite command line reference. That’s OK. You’ll only need to do it once for a command.

If you need to input one or more options when the command is executed, remember to add the correct number of question marks. Then, type a hint for each option in the User Input field. Finally, type a short description of the command in the Description field.

A custom command

Click OK to save the command. Simple, no?

CLI Companion is a great way to learn the command line, or to refresh your memory about commands that you haven’t used in some time. While I’m no command line tyro, I find CLI Companion very useful. Especially for those commands that I don’t regularly use.