Archive for the 'linux' Category

Spent a while looking for info on this online, but couldn’t find it.

We have a windows machine which has a few printers on it. I want to connect to it from Linux (Fedora 8).

First, share the printer via windows share. Give it a name like OKIB2200.

Now, open system-config-printer

Choose “New Printer”, then “Windows Printer via SAMBA”. If that option does not appear, then close out of system-config-printer and install samba (yum install samba*) then repeat the above.

Enter the appropriate smb address. In my case, it was smb://mshome/192.168.1.252/OKIB2200.

Click “Verify” to make sure it’s accessible (if not, check spelling in the URL. if still not, I dunno…).

For the Make, choose Generic

For the Model, choose PCL 4 (laserjet).

test, and you’re done.

Just thought I’d regale ye with two errors from my past.

The first involves SSH. SSH rules. It is /so/ handy to be able to work on many machines simultaneously. However, there is a single fundamental flaw to this method of working.

[root@localhost ~]# poweroff

I turn my laptop off every night. As I usually have my fingers on the keyboard, I usually turn it off using the above command.

One night, I turned my machine off, then went upstairs to bed. I realised I’d forgotten to lock the back door, and came down to do so.

My laptop was still humming away.

I don’t think you can imagine the feeling of dread that came over me. A cold sweat welled up, and I could feel the hair on the back of my neck raising. I realised I must have typed poweroff in an active SSH connection. I checked, and it was our live production server, with a hundred or more active websites on it.

The next hour or two was frantic, as I tried to get in contact with the hosting provider (which has a supposed “24-7″ phone line which is only ever answered from 9-5).

Luckily, it was Sunday, so no-one noticed before the provider’s support techies finally turned up for work in the morning and turned it back on.

As soon as I knew the machine was on, I logged into it and added this line to the ~/.bashrc file:

alias poweroff="echo No! Step away from the computer and think about what you\'re doing"

The second error is probably a common one.

It /sounds/ like a good idea to set up an error log which emails you if an error ever occurs on your server.

Don’t! Or at least, read on and find out how to do it properly.

I made the mistake of setting up an error catcher which would email me as soon as an error occurred. The reasoning was that I’m usually online, so I could catch the error quickly and fix it before the client even noticed the error was happening.

Unfortunately, one day I made an upgrade to one piece of code which adversely affected another piece that was almost unrelated (so it didn’t occur to me to check it - admit it, you’ve all made this mistake).

I went home and was offline for the rest of the day. The following day, I came in to find the office phone’s answering machine was blinking. Apparently, that client’s site had “stopped responding”.

I thought it would be something simple, so tried to log in. The system was /slow/. After a few minutes of painful testing (even SSH is very slow if your load is high enough!), I found the problem - about 5 million emails in the email queue, and qmail was going CPU mad trying to deal with it all.

It turns out that any time anyone accessed the client’s site, it would trigger a recursive chain of events which each caused an error. Before we could even start on solving the problem, we needed to turn off web access to the machine! Not a good thing, when your business is the web.

The next few hours days were spent clearing the emails and scouring for any code which sends an automatic error email…

The solution to the above? Log your errors to the syslog instead of via email. If you still want an email sent out, then set it up using a cron job which emails the contents of the log file then clear it.

Moral of the story is - there is always a better way to do things. Usually, though, it will not occur to you until after the damage is done.

This post is a reminder to myself in case I re-install my OS (as I do every now and then).

Fedora has a few bugs on the Acer TravelMate 2420. The most annoying one is that every now and then, the system freezes for a few seconds at a time. There have been reports of this in the Fedora forums, but no clear indication of what was causing it.

To solve the freezes, you need to compile a new kernel - there is something wrong with the Fedora kernel, but I’m not sure what it is (scheduler, maybe, but I can’t be certain).

So, get a copy of the most recent full kernel from kernel.org. I’m using version 2.6.23-rc2. Create a directory ~/compile/ and unzip the file in there.

The simplest way to get up and running is to go into that directory and run make bzImage && make modules, then su -c "make modules_install && make install". That will build and install the kernel, but with a load of modules that you don’t need. It will also take a very long time to finish, as it is compiling almost /everything/…

If you want, though, you can use my own kernel config. I’ve tried to cut it down to only the modules used by the TravelMate 2420. I’ve left out PCMCIA and Parallel Port support (I don’t use them). Download this file, move it into the root of your kernel source, and rename it to .config. Then run the above commands.

You will also need MadWifi to get your Atheros wifi to work. cd ~/compile; svn checkout http://svn.madwifi.org/trunk madwifi.

Now build MadWifi: cd ~/compile/madwifi; make -C /lib/modules/2.6.23-rc1/build SUBDIRS=/home/kae/compile/madwifi modules. Make sure to replace the 2.6.23-rc1 with your kernel version, and kae with your username. Then, reboot into the new kernel.

Install madwifi: cd ~/compile/madwifi; su -c "make install". Reboot again. Sorry about that - can’t be bothered finding the right way to do this, but it only takes a minute or so anyway.

That’s it - you’re done. You should not experience any of those freezes, and the system should be a tiny tiny little bit faster as well.

If you upgrade your kernel at any time, or recompile the present one, then remember to install madwifi again.