Archive for the 'Linux' Category

Eclipse Won’t Print under Linux

Thursday, March 30th, 2006

Eclipse won’t print under linux. The bug report makes for an interesting read.

However, Kim Lux has posted a rather satisfying workaround for KDE users which allows you to open your currently selected text file in kwrite and print from there.

To set this up: Run/External Tools/External Tools. Create New, name it kwrite-print, location: /usr/bin/kwrite, Working directory: ${container_loc}, Arguments ${resource_name} then, if you wish, switch to the Common tab and select External Tools in the Display in Favourites menu window.

Now you can use Run/External Tools/kwrite-print to open your code in the external editor and print it from there.

Fixing Eclipse 3.1.2 for Debian 3.1

Saturday, March 4th, 2006

The easiest solution is to download the source for the whole of Eclipse, comment out lines 914-916 of plugins/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java then build the whole thing as per instructions here.

No doubt there is a way of just re-building SWT from scratch but I couldn’t work it out.

Enabling Bootlogd on Debian 3.1

Sunday, December 11th, 2005

Bootlogd does not work out of the box on Debian 3.1 with a 2.6.8 kernel. If you enable it by setting the option to yes in /etc/default/bootlogd you’ll see the error message bootlogd: ioctl (/dev/ttyzf, TIOCCONS): Bad file descriptor scroll by on boot and the log is not created.

The problem lies with the version of udev used in Debian stable.

One solution is to upgrade the udev package to one from testing or unstable but that is not acceptable to someone who wants a pure system.

The alternative is to move the order the scripts are executed in /etc/rcS.d/. Remember, execution order is determined by the number in the filename so by renaming the bootlogd launching script you can get it to run before the udev script S04udev

mv /etc/rcS.d/S05bootlogd /etc/rcS.d/S03bootlogd-was-S05

The next time you boot, the log will be enabled for reading in /var/log/boot.

(Solution by Frans Pop on the debian-laptop mailing list)

Making a Linux Box into a CUPS Print Server for OS X

Thursday, December 8th, 2005

I don’t really know my way around OS X but I know enough to get frustrated at how unnecessarily difficult it is to set up access to a shared printer on a CUPS server from an iBook.

John Fry’s advice to set up your CUPS server (in my case my Debian box) to broadcast services on the local subnet is a lifesaver.

Forget about printer setup on the Mac, and just let your print server broadcast its services on the local subnet (or to specific IP addresses). Your /etc/cups/cupsd.conf file should look something like this:

ServerName foo.bar.org
MaxLogSize 0
MaxJobs 10
Browsing On
BrowseProtocols cups
BrowseAddress @LOCAL
BrowseAllow from All
Listen 631
<location />
Allow from All
AuthType None
<location /admin>
AuthType Basic
AuthClass System
</location>

Remember to restart CUPS with /etc/init.d/cupsys restart after changing the cupsd.conf file and you should have no more trouble.

Stack-Based Arithmetic on Linux

Saturday, December 3rd, 2005

I’ve just discovered that you can run ghostscript in a no display mode from the console and use the interpreter as an environment to perform stack-based arithmetic.

tim@withnail:~$ gsnd
GPL Ghostscript 8.01 (2004-01-30)
Copyright (C) 2004 artofcode LLC, Benicia, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
GS>2
GS<1>3
GS<2>stack
3
2
GS<2>add
GS<1>stack
5
GS<1>10
GS<2>mul
GS<1>stack
50
GS<1>quit

stack displays the stack, entering a number pushes it onto the stack, pop removes the top item, add / div / mul / sub remove the top two operands, and add them / divide them / multiply them / subtract second from first then return the result to the stack.

More info here.

One for computer science geeks only.

Open Links from Thunderbird in Firefox

Friday, October 7th, 2005

In Debian 3.1, Thunderbird does not launch Firefox if you click on a link in an email message by default. There is no option to change this option from within Thunderbird itself.

Instead, close the email client, fire up an xterm or konsole and type:

find ~/ -name prefs.js | grep thunderbird

This will find the full path to the file that holds the Thunderbird preferences on your machine.

Now you know where it is (the path varies on everyone’s machine for security reasons) edit it and add the following line:

user_pref("network.protocol-handler.app.http", "/usr/bin/firefox");

Restart Thunderbird. Now when you click on a link in an email it should open in your favourite browser.

(Adapted from Linux Basics tutorial.)

Enable Tab Completion in Debian

Monday, October 3rd, 2005

Tab completion makes your life easier at the command line. Just type the first few letters of a command then hit TAB and the computer will fill the rest in for you. You can do the same with files: just type the unique first few digits of a file and hit TAB and bash will do its magic. If there is more than one match you will be presented with all the possibilities.

There is a way of extending this so that you can do the same with the man command. For example, type “man shut” then TAB and the rest of the word you are looking for, “shutdown” is filled in for you.

To enable this, edit .bashrc and enable tab completion by uncommenting the lines in .bashrc

# enable programmable completion features (you don’t need to enable
# this, if it’s already enabled in /etc/bash.bashrc and /etc/profiles
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi

Some distros do this by default. Debian does not.

I Was Wrong…

Sunday, September 25th, 2005

As a Suse user, I was pleased by the ability to use pin to find packages and yast -i to install them from the command line. Pointing my yast sources to the Suse ftp servers meant I didn’t even have to reach for a disk when I wanted to install something. I thought that was pretty good.

But apt-cache search beats pin hands down and apt-get install makes yast -i seem like a dinosaur.

The more I use Debian, the more I love it.

Shutdown From GDM without Typing Root Password

Saturday, September 24th, 2005

On the default Debian 3.1 setup, you need to be root to shut your computer down. This makes sense on a server but is a nuisance on a desktop machine.

To enable ordinary users to shutdown without having to type the root password, you need to use sudo which allows named users to run certain commands as if they were root.

The configuration file /etc/sudoers is edited by root with the tool visudo. Since visudo uses vi as the default editor you may want to change this unless you’re comfortable with its somewhat cryptic interface.

Your default editor is controlled by the $VISUAL variable. To permanently set your default editor as root edit /root/.bashrc and add the line export VISUAL=/usr/bin/joe, replacing joe (my favourite) with your own favourite console editor: /bin/nano is installed by default on Debian and is simple to use.

Now that you’re ready to edit, run visudo. You could edit the file directly but visudo has two added benefits: it prevents more than one person trying to edit the configuration file at the same time and more importantly it provides syntax checking when you finish editing and warns you if you’ve made any mistakes.

In the section headed # User privilege specification add: tim ALL = NOPASSWD:/sbin/shutdown -[hr] now (Obviously replace “tim” with your own username!)

Now you will be able to run shutdown as an unprivileged user without having to enter a password. Remember that /sbin will not be in your $PATH so type /sbin/shutdown -h now to run it.

Once this is working, you are ready to enable shutdown in gdm. Edit /etc/gdm/gdm.conf and change the line SecureSystemMenu=true to read SecureSystemMenu=false. You will no longer need to enter the root password when you select the Shutdown or Restart options in the gdm drop down menus.

Convert HTML to Text with Lynx

Friday, September 23rd, 2005

Quick tip: to convert a html document to text, stripping out all the markup tags and just leaving the content, use the lynx browser:

lynx -dump example.html > example.txt

This works on both local and remote files.