Control volume levels at the commandprompt

Ever been working away at the command-prompt and wanted to mute the sound (or ever been working away at the prompt and wanted to crank up the sound when your favorite track comes on)? Simply type alsamixer. Hey presto—primitive but useful text-mode faders. Use the left and right cursor keys to move between faders. Use the up and down keys to change the values. Hit [Escape] to quit.

To play MP3s from the prompt, even if there's no GUI up and running, see Tip 292, on page 339.

A little known fact is that the average human spends a high proportion of her/his time looking for things that have been lost. Ubuntu helps avoid this, at least in computing terms, by including a number of powerful file search functions for both command-line and GUI users.

Command-line searching

There are essentially two methods used to search for files at the command-line: locate and find. The difference is that locate relies upon a database of files and locations, while find literally searches the file system each time you use it.

locate is partnered to a back-end program—updatedb—that is run periodically and automatically by the system to update the database of files. This highlights a weakness of the system—locate's results are only as good as the last time the database was updated. Therefore it's often a good idea to manually update the database using the updatedb command (as root—sudo updatedb) before using locate. There are several different versions of the locate software and the version provided with Ubuntu—called mlocate—is designed to update its database quickly by only looking for and adding new files. This means updatedb doesn't take long to run each time.

Using locate is easy. just type locate and then the search word, or search phrase. If the search phrase includes symbols or spaces, enclose it in quotation marks. For example, to search for any files or folders that include fstab in their names, you would type locate fstab. To search for the file accounts 2008.xls, you might type locate "accounts 2008". locate can use wildcards. To search for any MP3 files on the system, you could type locate *.mp3.

Using find is a little different. First you must specify the search location and then the search term. For example, to search for the file accounts 2008.xls in your /home directory, you could type find /home/username -name "accounts 2008". You should replace username with your own details. To search the entire file system, specify the file system root instead: find / -name "accounts 2008".

Both locate and find use regular expressions (known as regexes) to specify search terms. It's beyond the scope of this book to go into this rather arcane field but several very good beginner guides can be found by searching Google. Regexes permeate all of Linux and spending some time learning how to use them can be very rewarding.

Searching at the desktop

Ubuntu includes the Tracker tool for all desktop searching needs. Like recent developments in Mac OS X and Vista, this is designed to catalog all kinds of data, above and beyond just files. Recently visited websites are cataloged, for example, as are programs installed on the system. Tracker also indexes the contents of emails and also files (provided it understands the file format). Thus a PDF file containing a certain phrase can be searched for, even if its filename is obscure and/or unrelated.

Thus Tracker can actually be an alternative access point for day-to-day use of Ubuntu. Rather than using Nautilus to navigate to a file in the Documents directory, simply open a Tracker window and type its name (or part of its name). Then double-click to open it. Rather than clicking Applications ^ Office ^ OpenOffice.org Writer, just type writer and then double-click the program that appears in the search results.

Tracker isn't enabled by default in Ubuntu 8.04 Hardy Heron because some believe it can slow the system down. It runs a background service

Figure 3.20: Tracker (see Tip 77, on page 134)

that's always monitoring the file system and thereby using resources, and it also performs an indexing run each time you log in. That said, many report no problem using it, and there's little reason to give it a try. The same steps below that describe how to enable it can also be used to disable it.

Before activating it, it's a good idea to install the wv package using Synaptic. This allows Tracker to index the contents of Word documents (.doc files). Then, to activate the Tracker service, click System ^ Preferences ^ Search and Indexing, and click the check boxes alongside Enable indexing and Enable watching. If you're using a notebook, you might also want to check the box alongside Disable all indexing when on battery.

Click the OK button. You'll be told the tracker daemon has to restart. This is fine. Following this, a new magnifying glass icon will appear in the panel. Clicking this provides access to Tracker's search tool. However, you can't use it just yet! First, you must let Tracker index your hard disk and files. This might take some time. You'll know when it's finished because the Tracker icon will change to an orange magnifying

Remove the "bad password" wait period M 137

glass, rather than a clear one. In future the glass might change again but this simply indicates that Tracker is "catching up"; you'll still be able to search.

To use Tracker, just click its panel icon, type the search term (or phrase, if you want to search for content within documents), and then click the Find button. The categories of search results will be listed on the left of the program window (actual files, folders, applications, documents, and so on), and the specific search results will be listed on the right. To open any file or folder, simply double-click it. See Figure 3.20 for an example.

Tracker can also be used from the command-line, once synaptic has been used to install the tracker-utils package. once the package has installed, just type tracker-search followed by your search term.

Was this article helpful?

0 0

Post a comment