Thursday, July 09, 2009

Moonlight Sonata

With help from the project wiki, I succeeded in configuring MPD on my server. Then I installed the Sonata client on my laptop. However, it refused to connect. When I ran it from a terminal, I saw this message:
[Errno 111] Connection refused
I guessed there was a problem with my server configuration, but I didn't know what it was. Luckily the troubleshooting section of the wiki pointed out that bind_to_address should not be set to "localhost" if you want to connect from a client on another host. I commented out that line and got a connection the next time I started Sonata.

It's Alsa Confusing

I decided to install the ubuntu-desktop metapackage on top of my existing Ubuntu Server system. Since the tower is already hooked up to a KVM, I sometimes find it useful to sit down in front of it and use it as a desktop instead of connecting via ssh.

Unfortunately, sound did not work out of the box, despite the fact that ubuntu-desktop has dependencies on ALSA and PulseAudio. I was pleased to find that the solution was relatively easy. I only had to fire up alsamixer, unmute PCM, and raise the volume. My next task is to get Music Player Daemon (MPD) working.

Wednesday, July 08, 2009

Suspended Animation

I read somewhere that you can specify the resume device that uswsusp uses by UUID. I edited my config as follows:
josh@penryn64:~$ cat /etc/uswsusp.conf
# /etc/uswsusp.conf(8) -- Configuration file for s2disk/s2both
resume device = /dev/disk/by-uuid/ba2d5cd5-fd65-46c6-9be1-70851d8038f2
splash = y
compress = y
early writeout = y
image size = 1427192791
RSA key file = /etc/uswsusp.key
shutdown method = platform
It seems to work. There are no errors in /var/log/pm-suspend.log.

Wednesday, July 01, 2009

Permission to Land

Last week, I installed CentOS on my old tower. The installation was a breeze. However, afterward, I was annoyed to find that sshd prompted me for a password, even though I had appended my public key to ~/.ssh/authorized_keys on the server. As it often is, the solution was simple.

I spotted the problem in /var/log/secure:

Jul 1 22:08:44 madhatter sshd[25996]: Authentication refused: bad ownership or modes for file /home/josh/.ssh/authorized_keys

I had the wrong permissions on my .ssh directory and my authorized_keys file.
chmod 755 ~/.ssh
and
chmod 644 ~/.ssh/authorized_keys
did the trick.

Temporary Like Achilles

Today I got a perfect demonstration of why you want /tmp and /var/tmp on a separate partition in any serious server installation.

It came at an inopportune moment, as I was already cursing at Amarok 2 for its failure to copy all the music from my Creative Zen to my laptop. I discovered a way to downgrade to Amarok 1.4, but when I went to run Synaptic I got an error: "Failed to run /usr/sbin/synaptic as user root. Unable to copy the user's Xauthorization file." I tried it a few more times with the same results.

After Googling for an answer, I came upon a forum post that suggested I might be out of disk space. So I checked. Yep, sure enough, something had barfed about 2.3 GB into my 8-GB root partition. It was almost completely full.

Filesystem Size Used Avail Use% Mounted on
/dev/sda5 7.6G 7.2G 0 100% /
tmpfs 1.5G 0 1.5G 0% /lib/init/rw
varrun 1.5G 164K 1.5G 1% /var/run
varlock 1.5G 0 1.5G 0% /var/lock
udev 1.5G 164K 1.5G 1% /dev
tmpfs 1.5G 1.7M 1.5G 1% /dev/shm
lrm 1.5G 2.5M 1.5G 1% /lib/modules/2.6.28-13-generic/volatile
/dev/sda1 111M 28M 77M 27% /boot
/dev/sda6 129G 71G 51G 59% /home

I went on the hunt for the offending files. With the du command, it didn't take long to find them—in a directory called /tmp/kde-josh/amarok4ddofD, of course. (Curse you, Amarok 2!) They were all the MP3s I had been trying to copy to my home directory but somehow never made it there. I removed them in a hurry and breathed a sigh of relief.

Now to see if the Amarok downgrade worked…

Thursday, June 18, 2009

Adventures in Gentoo

I made some abortive attempts at installing Gentoo on my old PowerBook G4 a few years back. I haven't fooled around with it since. I decided to give Gentoo another chance, so I popped the 20090616 minimal install CD into my old Pentium II tower.

I was unsurprised to meet with trouble running a bleeding edge kernel on legacy hardware. Here are the issues I encountered and how I solved them:
  1. I get an error that says, "Undefined Video Mode Number: 317." I pressed Enter to see the list of available modes. After some quick calculations, I decided 80x43 (option 2) was most appropriate for my monitor dimensions. It looks okay, so I'll stick with that setting.
  2. The install CD hangs at wd7000 while loading the kernel modules. A bug report pointed me to a segfault that occurs when the pata_qdi module loads. Booting with the kernel option noload=pata_qdi results in a successful boot.
  3. Near the end of the boot sequence, I see, "ERROR: cannot start nfsmount as rpc.statd could not start." A comment on another bug report indicates that setting RC_NET_STRICT_CHECKING="yes" in /etc/conf.d/rc allows NFS to start at boot time. I never had to do this because the error disappeared after installation.
  4. Throughout the installation process, my hard disk was detected as /dev/hda. However, when I finished installing GRUB and rebooted, I got an error:

    CHECKING ROOT FILESYSTEM...

    fsck.ext3: No such file or directory while trying to open /dev/hda3

    /dev/hda3:

    The superblock could not be read or does not describe a correct ext2 filesystem. If the device is valid and it really contains an ext2 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock:

    e2fsck -b 8193 <device>

    * filesystem could not be fixed.

    I soon realized that my new Gentoo system, unlike the install CD, was using SCSI emulation. As a result, it detected my hard disk as /dev/sda instead of /dev/hda. I popped in the install CD, rebooted, and went through the process of mounting my filesystems and chrooting again. Then I simply changed every occurrence of hda in /etc/fstab to sda. For some reason, GRUB had automagically updated /boot/grub/menu.lst with the sda names, so there was nothing to do there.

    After one more reboot, everything is hunky dory.

Thursday, December 04, 2008

GNOME Appearance Properties pegs CPU

After experimenting with Openbox for a while, I got frustrated and returned to GNOME. However, I discovered that every time I ran gnome-appearance-properties, it would use 100% of the CPU time—and, to make matters worse, the process would fail to terminate after I closed the window. I also noticed I couldn't change my theme to anything besides Clearlooks.

I did some Googling and came up with a solution.
  1. Remove GTK-Qt Theme Engine and GTK Theme Switch. If you're using GNOME, you probably don't need these packages.
    sudo apt-get autoremove gtk-qt-engine gtk-theme-switch
  2. Get rid of your gtkrc-2.0 file. You could rename it or just blow it away, depending on how confident you are that you won't need it again.
    mv ~/.gtkrc-2.0 ~/.gtkrc-2.0.bad

Wednesday, November 19, 2008

Samba and UFW

Earlier today, I found myself frustrated because I could not see my Samba shares when browsing my network in Nautilus. It turned out to be a firewall issue.

From The Official Samba 3.2.x HOWTO and Reference Guide:
Many people use a firewall to deny access to services they do not want exposed outside their network. This can be a good idea, although I recommend using it in conjunction with the above methods so you are protected even if your firewall is not active for some reason.

If you are setting up a firewall, you need to know what TCP and UDP ports to allow and block. Samba uses the following:

Port 135/TCP - used by smbd
Port 137/UDP - used by nmbd
Port 138/UDP - used by nmbd
Port 139/TCP - used by smbd
Port 445/TCP - used by smbd

The last one is important because many older firewall setups may not be aware of it, given that this port was only added to the protocol in recent years.

When configuring a firewall, the high order ports (1024-65535) are often used for outgoing connections and therefore should be permitted through the firewall. It is prudent to block incoming packets on the high order ports except for established connections.
In order to open these ports, you must run the following commands:
sudo ufw allow proto tcp to any port 135 from 192.168.1.0/24
sudo ufw allow proto udp to any port 137 from 192.168.1.0/24
sudo ufw allow proto udp to any port 138 from 192.168.1.0/24
sudo ufw allow proto tcp to any port 139 from 192.168.1.0/24
sudo ufw allow proto tcp to any port 445 from 192.168.1.0/24
Of course, you should replace 192.168.1.0/24 with the appropriate IP/CIDR subnet for your network.

Generally speaking, I find it useful to add rules by service whenever possible. For example, if I want to open up ports for AOL/AIM, I can add this rule:
sudo ufw allow aol
The syntax is much less verbose and thus easier to remember. You can see a list of all service names by doing
less /etc/services
Not everything will be listed, but most common services are.

Wednesday, November 05, 2008

Entering Unicode characters in Pidgin IM

For a long time, I didn't know how to type Unicode characters in the Pidgin IM client. Apparently, all I had to do was read the FAQ:
Entering character codes works differently in GTK+; press Ctrl+Shift+u and then type the Unicode number (in hexadecimal) with Ctrl and Shift held down. GTK+ 2.10.0 and later versions do not require Ctrl and Shift to be held down while typing the number. For example, Alt-164 would become Ctrl+Shift+u, f1.

Monday, October 27, 2008

Setting your default web browser in Openbox on Ubuntu

I just installed Openbox on my laptop running Ubuntu. When I clicked the web browser menu item, it opened Konqueror. Since this is not my preferred browser, I ran

sudo update-alternatives --config x-www-browser

It provides an interactive way to choose which browser opens when you run x-www-browser.

Tuesday, October 14, 2008

Using Gmail as the default mail client in Ubuntu

I finally got annoyed with Evolution opening up every time I clicked a mailto link in Firefox. So I did a little Googling and came up with this:
  1. Create a script in your home directory. I put it in ~/scripts and called it mailto.sh.
  2. As of today, this script works with Firefox 3.0.3:
    #!/bin/sh
    firefox "https://mail.google.com/mail?view=cm&tf=0&ui=1&to=`echo $1 | sed 's/mailto://'`"
  3. Make the script executable:
    chmod u+x ~/scripts/mailto.sh 
    (or a+x if you want to allow all other users to run it)
  4. Go to System → Preferences → Preferred Applications.
  5. Set Mail Reader to Custom, and enter the path to the script.
Shell scripting is a beautiful thing, folks.

Saturday, October 11, 2008

Oh, Brother

My Brother HL-2070N laser printer had been printing documents as though they were on A4 paper, despite the size being set to Letter in the CUPS configuration. After considerable Googling, I came up with the answer. I had to edit /usr/Brother/inf/brHL2070Nrc. I changed the PaperType variable to Letter. Everything prints properly now.

Sunday, September 23, 2007

Refreshingly Simple: SyncMastery Achieved

About a week ago, I noticed that my monitor, a Dell 1703FP I've had for almost five years, would flicker when returning from power-save mode. I decided I would rather start shopping for a replacement immediately than wait for it to die altogether.

After some deliberation, I chose a Samsung SyncMaster 932B, a 19" TFT-LCD with a maximum supported resolution of 1280 × 1024 @ 75 Hz. The picture looks gorgeous, and the brightness presets have already proven useful. As I anticipated, it presented a small challenge when configuring X.

The monitor's manual states its recommended refresh rate is 60 Hz, but X seemed determined to use the highest available rate. Thinking this must be hard on the monitor, I looked up the supported frequency ranges in the manual and manually added them to my xorg.conf. To edit the file, do
sudo vi /etc/X11/xorg.conf
and add the appropriate ranges to the "Monitor" section. Mine looks like this:
Section "Monitor"
Identifier "Samsung SyncMaster 932B"
Option "DPMS"
HorizSync 30-81
VertRefresh 56-75
# 1280x1024 @ 60.00 Hz (GTF) hsync: 63.30 kHz; pclk: 108.88 MHz
Modeline "1280x1024_60.00" 108.88 1280 1360 1496 1712 1024 1025 1028
1060 -Hsync +Vsync
EndSection
HorizSync is measured in kHz and VertRefresh in Hz. DPMS stands for Display Power Management Signaling, and you should enable it if your hardware supports it. I'll explain the last two lines in a moment. They turned out to be essential for getting X to use the monitor's optimum refresh rate.

Before I added those lines, X insisted on pushing the monitor to 75 Hz and wouldn't acknowledge other possibilities. I searched until I found an informative how-to and downloaded the GTF modeline generator from the link it provided. To compile the generator, I did the following:
gcc gtf.c -o gtf -lm -Wall
Initially GCC warned me
gtf.c: In function ‘parse_command_line’:
gtf.c:665: warning: implicit declaration of function ‘strcmp’
I've seen that warning before; it usually means you forgot to explicitly include the header file for some C library function—in this case, strcmp, which string.h defines. So I did
vi gtf.c
and added
#include <string.h>
after the other includes. As expected, the warning disappeared.

I wanted to be able to run gtf from any working directory, so I moved the executable to /usr/bin:
sudo mv gtf /usr/bin
I ran it with the desired resolution and refresh rate as arguments:
gtf 1280 1024 60
This produced two lines, which I added to the end of the "Monitor" section above. I also needed to change every occurrence of "1280x1024" in the "Screen" section to "1280x1024_60.00" to match the modeline. Then I saved the file, logged out and restarted X with Ctrl+Alt+Backspace.

Problem solved!

Friday, September 14, 2007

Ubuntu Server on Pentium II


For a Pentium II machine I recently revitalized, I wanted to install only the most essential software, so I started from the Ubuntu Server 6.06.1 CD. I did an expert install, since this particular motherboard, an Elitegroup (ECS) P6BX-A+ with Award BIOS, doesn't play nice with GRUB. Plus I planned on some little tweaks, like setting a static IP from the get-go and making a more server-like partitioning scheme.

NOTE: Unless you specify otherwise via the expert installer, Ubuntu disables login as root.

After completing the base installation, during which I opted to use all available repositories, I updated the package indices and installed the necessary packages for X, plus a window manager and other conveniences.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install x-window-system-core xdm fluxbox xterm
Then I rebooted and was delighted to find the X server started without a single problem.

While installing additional packages, I discovered that it took an intolerably long time to connect to the repositories. Once I installed Firefox, I observed similar delays in loading pages. For some reason, disabling IPv6 (via about:config) got Firefox working, but apt-get remained sluggish. So I used traceroute in the hope of finding the cause.

Apart from the delay in passing through the gateway, which I also observed on my Debian box when I traced the same route for comparison, it wasn't resolving domain names. Instead of the expected output,
traceroute to us.archive.ubuntu.com (91.189.89.8), 30 hops max, 40 byte packets
1 192.168.1.1 (192.168.1.1) 1.931 ms 1.680 ms 1.782 ms
2 * * *
3 XX-N-N-XXNN.XXXXXXX.pa.panjde.comcast.net (NN.NN.NNN.NN) 8.599 ms 7.877 ms 9.530 ms
4 XX-NN-XXNN.XXXXXXX.pa.panjde.comcast.net (NN.NN.NNN.NNN) 9.573 ms 8.122 ms 9.572 ms
5 XX-NN-XXNN.XXXXXXXX.de.panjde.comcast.net (NN.NN.NNN.NNN) 10.248 ms 8.929 ms 9.522 ms
6 po-10-ur01.norristown.pa.panjde.comcast.net (68.86.209.98) 10.724 ms 9.759 ms 9.519 ms
7 po-10-ur02.norristown.pa.panjde.comcast.net (68.86.209.102) 9.838 ms 10.222 ms 9.526 ms
8 po-21-ar01.wallingford.pa.panjde.comcast.net (68.86.209.106) 12.028 ms 11.325 ms 11.952 ms
9 68.86.91.182 (68.86.91.182) 14.310 ms 14.387 ms 14.187 ms
10 68.86.85.2 (68.86.85.2) 13.551 ms 13.315 ms 14.142 ms
11 68.86.84.153 (68.86.84.153) 17.783 ms 16.573 ms 17.901 ms
12 te-1-3-pr01.ashburn.va.ibone.comcast.net (68.86.84.154) 18.032 ms 16.492 ms 16.894 ms
13 xe-3-1-0.was11.ip.tiscali.net (213.200.84.117) 16.672 ms 17.544 ms 16.504 ms
14 so-6-1-0.lon11.ip.tiscali.net (213.200.80.26) 94.043 ms 93.927 ms 93.544 ms
15 01502-004-01-gw.ip.tiscali.net (213.200.77.114) 93.777 ms 93.384 ms 93.506 ms
16 195.72.129.70 (195.72.129.70) 92.104 ms 90.699 ms 91.123 ms
17 byrd.canonical.com (91.189.88.11) 93.688 ms 93.222 ms 94.142 ms
18 * * *
every line looked like lines 9-11 above: no FQDN, only an IP. That pointed to a DNS problem. So I opened resolv.conf and found that the resolver had been using my router as its name server—a less than ideal configuration, since my router is an entry-level Linksys. I merely changed resolv.conf to read
search hsd1.pa.comcast.net.
nameserver 68.87.75.194
nameserver 68.87.64.146
and restarted networking services:
sudo /etc/init.d/networking restart
and it worked flawlessly.

The server install achieved exactly what I envisioned for this box: low resource usage. Here's the process tree right now, with one user active.
init─┬─atd
├─cron
├─cupsd
├─dd
├─events/0
├─6*[getty]
├─khelper
├─5*[kjournald]
├─klogd
├─ksoftirqd/0
├─kswapd0
├─kthread─┬─aio/0
│ ├─kacpid
│ ├─kblockd/0
│ ├─kgameportd
│ ├─khubd
│ ├─kseriod
│ └─2*[pdflush]
├─mdadm
├─migration/0
├─shpchpd_event
├─sshd───sshd───sshd───bash─┬─firefox-bin───2*[{firefox-bin}]
│ └─pstree
├─syslogd
├─udevd
├─watchdog/0
└─xdm─┬─Xorg
└─xdm
Yes, I'm writing this post in Firefox on the Ubuntu server with X forwarding to my laptop. Remember, this is a Pentium II at 450MHz, circa 1998. Legacy hardware has a place in modern computing—in the third bedroom, right beside my main Debian box.

Friday, August 17, 2007

The Slit

Fluxbox has something called the slit. It's like the Windows Vista Sidebar—except n times better because you're not running Windows Vista. In short, it gives you convenient access to "dockable" applications in the form of a sidebar on your desktop.

For example, GKrellM can be run with the "withdrawn" option and will then appear in the slit. It provides an easily customized set of system monitors, so you can keep an eye on your box's vital signs. If you don't have it already, it's no problem to install.

apt-get install gkrellm
gkrellm -w


I know no one's working on the original XMMS project anymore, but I still use it. It can also be docked in the slit. Just run wmxmms & and it should appear there.

The Fluxbox FAQ suggests that you can use wmDrawer to display the Fluxbox logo in the slit. Of course, you could use the same method to display any other image. The FAQ doesn't go into the specifics, but it's simple.

First we install it. I also chose to copy the example resource file to my home directory.

apt-get install wmdrawer
cp /usr/share/doc/wmdrawer/wmdrawerrc.example ~


Then I copied the Fluxbox logo to the directory where wmDrawer looks for images.

cp fb-icon48x48-metal.png /usr/share/pixmaps

The example file also has a line for /usr/local/share/pixmaps, which I ignored because that path doesn't exist on my system. I edited the file to use the logo as its dock icon and commented out the lines defining the buttons, since I don't use them. When I was done, the file looked like this:
# Config file example for wmdrawer
[general]
# Dock's icon [optional]
dock_icon fb-icon48x48-metal.png

# Drawer's opening direction [required]
# Top to bottom = 0
# Right to Left = 1
# Bottom to Top = 2
# Left to Right = 3
direction 2

# Image used for icons' background [optional]
#icons_bg defaultTile.xpm

# Allow icons' enlargement to fit them to buttons' size [optional, default 1]
# 0 indicate that icons should never be larger than their original size.
#icons_expand 1

# Activate the drawer's pseudo-transparency [optional, default 0]
# if you choose transparency, icons_bg will be ignored
#transparency 0

# dock's width: min=12, max=128 [optional, default=64]
#dock_width 64

# dock's height: min=12, max=128 [optional, default=64]
#dock_height 64

# buttons' size: min=12, max=128 [optional]
# Useful for the people who want for example to have big icons
# and to define several columns.
#btns_size 32

# Icon's highlight type: 0, 1 or 2 [optional, default 2]
# 0 : no highlight
# 1 : target (unavailable if transparency is activated)
# 2 : shading
#highlight 2

# Image used as highlight [optional]
# only used if you choice target type
#highlight_img highlight.xpm

# Tint icons by a specified color [optional, default #ffffff]
# only used if you choice shading type
#highlight_tint #ffffff

# Shade icons at a specified level [optional, default 60]
# only used if you choice shading type
#highlight_sh 60

# Display buttons' tooltips [optional, default 1]
#tooltips 1

# Tooltips' font [optional, default fixed]
#tooltips_font fixed

# Drawer's animation speed: 0, 1, 2, 3, 4 [optional, default 1]
#animation_speed 1

# Mouse cursor in drawer: 0, 1, ..., 76 [optional, default 30]
#cursor 30

# Auto opening of the drawer: 0, 1 [optional, default 0]
#show_on_hover 0

# Auto closing of the drawer: 0, 1 [optional, default 0]
#hide_on_out 0

# drawer's hiding timeout in miliseconds [optional, default 1000]
#hide_timeout 1000

# Runs the dockapp in windowed mode: 0, 1 [optional, default 0]
# Useful for AfterStep, Fvwm, Sawfish or KDE users.
#windowed_mode 0

# Instance name so window manager can distinguish between multiple copies
#instance_name distinguish_name

# Drawer's border size in pixels [optional, default 1]
#border_size 1

# Images directories
[images_paths]
/usr/share/pixmaps
/usr/local/share/pixmaps/

# A first column with 5 buttons
# Each button must be defined with this syntax:
# (tooltip) (image) (command)
#[column]
#(X Terminal) (gnome-term.png) (xterm -bg black -fg wheat)
#(Galeon) (galeon.xpm) (galeon -s)
#(Sylpheed) (sylpheed.png) (sylpheed)
#(XChat) (xchat.png) (xchat)
#(MPlayer) (gnome-multimedia.png) (mplayer)

# A second column with 5 buttons
#[column]
#(Xmms) (gnome-audio2.png) (xmms)
#(Gimp) (gnome-gimp.png) (gimp)
#(GQview) (gqview.png) (gqview)
#(Xcalc) (gnome-calc3.png) (xcalc)
#(GFtp) (gftp.png) (gftp)
The lines I changed are boldfaced. Although it serves a purely cosmetic purpose on my desktop, wmDrawer has many other capabilities. Its documentation can tell you more.

Once you've arranged your slit apps to your satisfaction, right-click on the slit. You may need to try clicking in a few different places before you get the slit menu instead of the menu of a slit app. Select the "save slit list" item. Now the next time you restart Fluxbox, all your favorite dockable applications will be at your fingertips.

EDIT: Okay, it took me over a month to realize I omitted some important info here. In order to have your apps run in the slit when you start a Fluxbox session, you must add them to the ~/.fluxbox/startup script. There are plenty of comments in the default script to guide you.

Sunday, August 05, 2007

Fluxbox Keys

Over the past several months, I've come to appreciate KDE applications—especially Amarok, Kaffeine and Konqueror. Unfortunately, KDE eats RAM like Cookie Monster once ate cookies. (Those were the days.) So I went back to Fluxbox.

One of my biggest frustrations with Fluxbox used to be the keybindings. The default keyboard shortcuts aren't much like the ones I know from GNOME and KDE. I would often hit Alt+F4, expecting the window to close, and instead get switched to Workspace 4. Then I discovered how easy they are to customize.

The first time you log into a Fluxbox session, it creates a directory ~/.fluxbox where it stores a small handful of config files. Among them is the keys file. All you have to do is remove the bindings you don't want and replace them with your preferred set. Here's mine:

Control F1 :Workspace 1
Control F2 :Workspace 2
Control F3 :Workspace 3
Control F4 :Workspace 4
Control Mod1 Escape :KillWindow
Mod1 F1 :RootMenu
Mod1 F2 :ExecCommand fbrun
Mod1 F4 :Close
Mod1 F9 :Minimize
Mod1 F10 :MaximizeWindow
Mod1 Shift Tab :PrevWindow
Mod1 Tab :NextWindow


I struck a compromise between the GNOME and KDE defaults. Note that Mod1 is the Alt key.

So, for example, I can press Alt+F2 and get what amounts to a "Run…" dialog. Then I enter a command, like xterm, and I'm on my way. It's an particularly handy binding for those who avoid the mouse whenever possible.

More detailed info can be found in the Fluxbox Keybindings section of the docs.

Saturday, August 04, 2007

Domo arigato, ISO-10646-1

A friend gave me a couple of Japanese CDs, which I added to my music collection. When I opened up an XTerm and listed out the directories, I found that the Japanese filenames weren't displayed correctly. Where the characters should have been, there were only empty boxes. Clearly this was a font issue.

As far as I can tell, you only need to add two lines to your .Xresources file:

XTerm*locale: true
XTerm*font: -misc-fixed-medium-r-normal-*-18-120-100-100-c-90-iso10646-1


You could also set the wideFont resource, but I didn't bother. By default, XTerm will simply double the width of the font you specified. For example, the font above has an average width of 90. So the wide font gets a width of 180.

If you want to see which fonts you have at your disposal, run xfontsel and play around with the various pull-down menus.

Then you merge the updated file

xrdb -merge ~/.Xresources

and you're good to go. The next XTerm you open will display Japanese characters perfectly.

Sunday, July 22, 2007

Help a Brother out!

Brother may make some of the ugliest printers on the market today, but I love how friendly they are toward Linux users. I ran into only one obstacle while setting up my HL-2070N as a network printer, and that wasn't their fault.

The LPR and CUPS (wrapper) drivers are available for download from the Brother Solutions Center. Since Ubuntu uses the Debian package management tools, I chose the Debian LPR driver and CUPS wrapper driver. The instructions Brother provided were clear and concise.

dpkg -i --force-all brhl2070nlpr-2.0.1-1.i386.deb
dpkg -i --force-all cupswrapperHL2070N-2.0.1-1.i386.deb


Ubuntu includes the LPR and CUPS packages, so I didn't need to install them. However, I had to make some slight configuration changes because Ubuntu expects you to set up your printers via the GNOME Print Manager. I'm accustomed to the CUPS web admin tool, which is disabled by default under Ubuntu. To enable it, the cupsys user must be added to the shadow group.

adduser cupsys shadow
passwd cupsys
/etc/init.d/cupsys restart


Note that you need superuser privileges for the above commands to work. Speaking of which, here's how to enable the root user in Ubuntu:

sudo passwd root

Now the only thing left to do is add the printer. Point your web browser to http://localhost:631, where you should find an entry for the Brother printer. For the moment, it's probably configured for a USB connection; that seems to be the default. Click "Modify Printer". The settings you must change are the device and the URI. For device, select "LPD/LPR Host or Printer". For the URI, type lpd://nnn.nnn.nnn.nnn/binary_p1 where n is a digit of the printer's IP address. (You should assign a static IP for the printer.) When you're done, CUPS will prompt you for a username and password. Use root and whatever password you've set.

That ought to do it. Enjoy your network printer!

Wednesday, July 18, 2007

Samba Server

A few weeks ago, I decided I would make my Linux box the file server for my network. Since shared files and folders must be accessible from Windows and Mac machines, Samba seemed like the best cross-platform solution.

The installation turned out to be a relatively painless process. Here's how I did it on Ubuntu Dapper.

First we need to install a couple of packages:

sudo apt-get install samba smbfs

I'm not positive that smbfs is required for the Samba server, but most guides recommend it. So I'll follow their lead.

A vanilla install of Ubuntu should be properly configured for Samba, so there's not much else to do besides add to the list of Samba users. In the second line, you may replace sudo with gksudo if you prefer one of the GTK editors, like gedit. There may be an analogous command for KDE apps, but I rarely run them as superuser, so I wouldn't know.

sudo smbpasswd -a system_username
sudo vi /etc/samba/smbusers


where system_username is the user you wish to add as a Samba user. You will be prompted to create a password. This is the password the user will use to connect to Samba shares.

We must add the following line to /etc/samba/smbusers:

system_username = "network username"

Note you may make the network username different from the system username. There are a variety of reasons you might do this. For example, the user may have a different name on the machine from which he will connect to the Samba shares. You might alternately designate a unique username as a security measure.

To set up your Samba shares, you must either edit /etc/samba/smb.conf by hand or install SWAT, which supposedly does the dirty work for you. Either way, the lines you add to the file should look something like this:

[music]
path = /windows/Music
browseable = yes
writeable = yes
valid users = jlz27
admin users = jlz27

I'm typing this from my PowerBook, running Mac OS X 10.4.10, while connected to one of the Samba shares. So it definitely works.

Sunday, April 08, 2007

Thanks, Jörg Höhle!

Count on a guy with umlauts in his name to find a fix for the problem with displaying special characters in filenames, mentioned in my previous entry on Samba. Here's the bug report he submitted:
Hi,
The Gnome desktop network mounter, the smbclient and a native MS-Windows-2k manage to display Umlaute in filenames from a Linux Samba server just fine.
Using smbmount however, an ls command merely displays "?" in lieu of the Umlauts in concerned filenames.

Trying out many combinations of iocharset and codepage options I finally got Umlaute to display fine as follows:
mount -t smbfs -o username=xyz,uid=hoehle,gid=hoehle,file_mode=0640,codepage=cp437,
iocharset=utf8 //10.0.0.79/hoehle /mnt/samba

which seems equivalent to:
smbmount //10.0.0.79/hoehle /mnt/samba -o username=xyz,uid=hoehle,gid=hoehle,file_mode=0640,codepage=cp437,
iocharset=utf8


codepage=utf8,iocharset=utf8 produces :x84 :x9a for some umlauts in ls output.
codepage=iso8859-1 produces :0084 :009a instead.
codepage=cp437, utf16 or utf-16 produce "?" instead.

codepage=cp852,iocharset=utf8 finally works.
codepage=cp437,iocharset=utf8 also works.
Note that the iocharset option must be given as well.

man mount on fat says: "By default, codepage 437 is used."
For consistency, I'd expect similar defaults with smbfs.
Similarly, I'm quite surprised that iocharset=utf8 is needed. I'd thought most Linux software did the transition to UTF-8 these days (since Hoary, Warty was not fully there).

smbfs should be as easy to use and provide similar defaults as all of smbclient, the Gnome desktop and MS-Windows do.

Affects: Dapper with http://wiki.ubuntu.com/LaptopTestingTeam/
FujitsuLifebookC1110


Regards,
Jörg Höhle

In case you didn't read the whole report, I'll sum it up. If you mount your share with the options codepage=cp437,iocharset=utf8, for example, special characters like the umlaut will display correctly.

I used codepage 437 because it's the default for FAT and VFAT filesystems. I haven't tested it with codepage 852 nor do I plan to do so.

If you have success with another codepage option, I invite you to post your experience here so other readers may benefit from your efforts.