Tips
Showing 1 - 5 of 5 Results | Page 1 of 1 | 1
Make Grub2 Boot the Last Operating System You Used
20-Jul-10 11:54
The GRUB2 boot loader can seem confusing at first. Instead of one configuration file, there are several. You run one command (update-grub) to update the configuration file, another command (grub-install) to write the configuration to the Master Boot Record (MBR) on your hard drive.
On the plus side, GRUB2 can make life much easier if you're running a dual or multiple boot system -- say, switching between Linux and Windows, or hopping between multiple distros. update-grub scans your partitions, automatically detects operating systems, and adds them to the configuration. Yet, the choice of which OS to boot by default remains stupid: in Ubuntu 10.04, the menu highlights the first operating system listed (usually the latest kernel installed by Synaptic or Update Manager). If you don't select another one within 10 seconds, the Ubuntu OS will boot with that kernel. I think most users want a "sticky" menu selection that boots the very last OS they chose. If you were running Windows XP last night, that's probably what you want to boot this morning.
It's very easy to make GRUB2 remember your last OS choice. First, edit the file /etc/default/grub.cfg. Change the GRUB_DEFAULT line and add a new line, GRUB_SAVEDEFAULT:
#GRUB_DEFAULT=0 GRUB_DEFAULT=saved GRUB_SAVEDEFAULT=true
Then run the two usual commands to update the configuration file /boot/grub/grub.cfg and write it to the MBR:
sudo update-grub sudo grub-install /dev/sda1
Resources
View comments for this article
Shrink Image Files With GraphicsMagick
02-Jul-10 19:20
GraphicsMagick is a fork of the ImageMagick project that describes itself as "the swiss army knife of image processing". It contains command-line utilities for converting from one image format to another with the option to resize images. This makes it perfect for routine jobs that don't require a GIMP or Photoshop-like GUI, like creating compressed copies of original images for display on a web site.
Chances are, you already have GraphicsMagick installed with your distribution. If, not you can install the package in one step:
sudo apt-get install graphicsmagick
The command gm help will list all the commands available. The one I use all the time is gm convert.
Version: GraphicsMagick 1.1.11 2008-02-23 Q8 http://www.GraphicsMagick.org/
Copyright: Copyright (C) 2002-2007 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.
Usage: gm help command [options ...]
Where options include:
animate - animate a sequence of images
benchmark - benchmark one of the other commands
composite - composite images together
conjure - execute a Magick Scripting Language (MSL) XML script
convert - convert an image or sequence of images
display - display an image on a workstation running X
help - obtain usage message for named command
identify - describe an image or image sequence
import - capture an application or X server screen
mogrify - transform an image or sequence of images
montage - create a composite image (in a grid) from separate images
version - obtain release version
Some examples of the convert command:
gm convert MyImage.png MyImage.jpg
Converts an image from PNG to JPG format.
gm convert -quality 50 MyImage.png MyImage.jpg
Converts the image with 50% lossy compression quality (on a scale from 0 to 100).
gm convert -scale 200 MyImage.png MyImage.jpg
Rescales the image proportionately so that it is 200 pixels wide. This parameter is useful for significantly reducing image size and therefore file size, e.g. for creating thumbnails on web sites.
gm convert -depth 8 MyImage.png MyImage.jpg
Converts using an image depth of 8 bits per pixel.
Note: The gm mogrify command does similar operations, but be warned: it deletes the original image after conversion.
View comments for this article
VNC Remote Desktop Connection Nvidia Display Problem
02-Jul-10 17:29
Ubuntu lets you share your desktop with remote computers. From the Gnome control panel, select System | Preferences | Remote Desktop. Then access the machine from any VNC client, such as Vinagre (Applications | Internet | Remote Desktop Viewer).
But it didn't work for me initially, although VNC has been around for years and runs on just about every platform. The symptom was that I could log in but then the desktop appeared frozen, and nothing happened when I pressed the keyboard or mouse.
The problem appears to have been the Nvidia binary drivers on the computer sharing its display. My graphics card used an onboard Nvidia 6150SE chipset. Ubuntu had installed the 173 series drivers, which are older than the ones issued for most of its recent graphic cards. If I watched the monitor connected to that machine instead of the one on the remote computer, I could see that the keyboard and mouse actions were getting through. The inputs for the connection were obviously working; the remote display wasn't.
A few Google searches later, I'd found the problem and the fix. It appears related to this bug logged against Ubuntu 9.10, and from my experience I'd say it's still present in Ubuntu 10.04, at least for old chipsets.
The workaround is to disable the fancy Visual Effects on the server. Again, from the Gnome control panel, select System | Preference | Appearance | Visual Effects, and select None

Now you can connect remotely, at the cost of slower performance locally. If you're not satisfied with the display speed, you might want to look at replacing Nvidia's proprietary drivers with the Nouveau open source drivers.
View comments for this article
Make Flash Video Run Smoothly With Ondemand CPU Frequency Scaling
13-Jun-10 17:10
Watching streaming video in Linux can be frustrating. The Flash web browser process (npviewer.bin) consumes a lot of processor time and it significantly raises the cpu temperature.
I could live with Flash's piggishness if it delivered good video. Unfortunately, Flash seems to stutter when you use CPU "on demand" frequency scaling to cut power consumption. On my desktop PC with an AMD BE-2400 dual core, I couldn't get Firefox in Ubuntu 9.04 (64-bit) to stream an ESPN3 sports broadcast without missing half the action.
I found a good solution in this blog article. The default ondemand scaling threshold in Ubuntu is 95. This means that if your CPU is running at less than full power, it won't jump to the next speed until it's 95% busy. By setting a lower threshold than 95, you can force the CPU to scale up under moderate usage. Changing the threshold to a lower value like 40 completely fixed my problem.
I took the commands documented in the article and made the cputhresh script shown below. It pokes the proper values into the processor settings. I run it selectively when I need to watch a Flash broadcast. For example:
cputhresh setsets threshold to 40cputhresh set NNsets threshold to NN, where NN is any number between 20 and 95cputhresh resetresets threshold back to 95
#!/bin/sh
# cputhresh utility, adapted from:
# http://allredb.wordpress.com/2009/05/07/speed-up-flash-and-firefox-in-ubuntu-jaunty-904
# Sets ondemand cpu threshold lower than default
# in order to scale up CPU to fater speeds when running Flash under Firefox
case "$1" in
set)
if [ "$2" ] && [ "$2" -ge 20 ] && [ "$2" -le 95 ]; then
INDEX="$2"
else
INDEX=40
fi
for CPU_THRESHOLD in /sys/devices/system/cpu/cpu*/cpufreq/ondemand/up_threshold
do
[ -f $CPU_THRESHOLD ] || continue
echo -n $INDEX > $CPU_THRESHOLD
cat $CPU_THRESHOLD
done
;;
reset)
for CPU_THRESHOLD in /sys/devices/system/cpu/cpu*/cpufreq/ondemand/up_threshold
do
[ -f $CPU_THRESHOLD ] || continue
echo -n 95 > $CPU_THRESHOLD
cat $CPU_THRESHOLD
done
;;
show)
for CPU_THRESHOLD in /sys/devices/system/cpu/cpu*/cpufreq/ondemand/up_threshold
do
[ -f $CPU_THRESHOLD ] || continue
cat $CPU_THRESHOLD
done
;;
*)
echo "Usage: $0 set|reset|show" >&2
exit 3
;;
esac
Instead of this script, you could also just switch to using the "performance" frequency scaling setting. However, the advantage of bumping the threshold is that you're retaining the power saving advantages of ondemand frequency scaling.
View comments for this article
Printing Text Files To PDF With Enscript
17-Jan-10 01:50
Sometimes you want to print a text file and apply some fancy formatting -- say, a header with page numbering, or printing two-pages per sheet to conserve paper. You have several options under Linux:
- Open the file in a word processor and apply the formatting before printing.
- Change the printer drivers applied to the file when it prints. This requires tinkering with .PPD or filter files on the CUPS printer server./li>
- Print the file using a utility command like a2ps or enscript.
I prefer the last approach, because it gives me the most flexibility. I can customize the output by varying the parameters. Plus, many text editors let you specify the command line to use for printing.
Neither of these utilities has all the features I'd like, but they get the job done. I chose enscript over a2ps because enscript is able to word-wrap long lines.
Install the enscript packagein Debian/Ubuntu:
sudo apt-get install enscript
Then run it in the format
enscript <parameters> <filename>
Some examples:
enscript -B -i 2 -f Courier8 --margins=26:18:18:18 MyTextFile.txt
Prints the file MyTextFile.txt with no page header, indenting each line 2 characters, using the font Courier8, with left_right:top margins of 26:18:18:18 in points.
enscript -2 -r -j --font=Times-Roman11 --word-wrap --mark-wrapped=arrow MyTextFile.txt
Prints 2-up, landscape orientation, with borders, using TimesRoman11 font, wrapping words that extend beyond the right margin using the arrow symbol. A typical page looks like this:

I set my Default Printer in Ubuntu 9.04 to the PDF printer. Enscript will then send all output to a PDF file, and I can verify its appearance before deciding to print hardcopy. Here's a way to extend the last example generically and automatically load the PDF for preview. I use this command in the Geany text editor (Edit | Preferences | Printing | Use an external command for printing).
enscript -2 -r -j --font=Times-Roman11 --word-wrap --mark-wrapped=arrow '%f' && sleep 2 && evince ~/PDF/_stdin_.pdf
The '%f' designates the filename parameter. To make it work in the Geany editor, I've found that it must be typed in single quotes. The && sleep 2 && evince ~/PDF/_stdin_.pdf commands will wait 2 seconds for the print job to finish, then run the Evince PDF viewer to display the file _stdin_.pdf you just generated in the user's PDF subdirectory.
View comments for this article
Showing 1 - 5 of 5 Results | Page 1 of 1 | 1
