...making Linux just a little more fun!

December 2004 (#109):


The Mailbag


HELP WANTED : Article Ideas
Submit comments about articles, or articles themselves (after reading our guidelines) to The Editors of Linux Gazette, and technical answers and tips about Linux to The Answer Gang.


GTK in Mandrake, Theme change?

Fri Nov 26 02:43:41 PST 2004
Jimmy O'Regan (The LG Answer Gang)

Mandrake sucks. I get a mess of warnings any time I start a Gtk app because of the weird stuff they've done with their theme.

[Heather] I can give you my DarkGems gtk theme, would you like it? I carefully mucked with it till it looked good on gimp and some other gtk apps that eluded correct behavior under some themes.

I have plenty of themes, it's that Mandrake is set up to look for their own theme, and I can't get it to stop. My GTK package is libgtk+-x11-2.0_0-2.5.2-0.1gpw.

[Heather] ohhh. I might be able to help you with that sometime. If we do, then we can make a nice tip out of it.
Or if one of you readers knows the right answer, we'll cheerfully pub what you send us after Jimmy improves his life with GTK :) -- Heather

I think it's compiled in.

I've been through the fscking mess of a config layout they have several times and can't get it to stop looking for that bloody theme.

[Heather] You cant just move their theme to another name and copy your theme into the name it's reaching for? </hack type=cheap>

No. :(

I'm waiting for my Ubuntu cds to arrive :)


problem in sendmail.cf

Thu, 17 Jun 2004 11:20:38 +0530
vignesh (vignesh.raj from samsung.com)

Hai

I have seen ur page for the sendmail configuaration and goes fine ,

And i have tried to configure the sendmail as u said , but i have some problem regarding the configuration .

Iam trying to configure it as SMTP AUTH client for the mailserver,But its giving error msg as DNS:service unavailable , i don't understand what is missing in the configuration.and one more things is its not alaising the username to the mailid .

can u pls help me regarding in this

warm regards
vignesh


GENERAL MAIL


Re: Setting the Clock on Linux in issue 108

Thu, 18 Nov 2004 22:11:55 -0500
Suramya Tomar (security from suramya.com)
Reply by William Park

Hi, Firstly I would like to congratulate you on a nicely written article. I found it very useful.

In addition to the ways you have pointed out in your article there is another method we can use to sync linux clocks to a central server. I am talking about using rdate (http://freshmeat.net/projects/rdate).

On the website:

"The rdate utility retrieves the date and time from another machine on your network, using the protocol described in RFC 868. If you run rdate as root, it will set your machine's local time to the time of the machine that you queried."

I use the following command to sync my computers clock every day:

/usr/sbin/rdate -s tick.greyware.com

Thought I should share this with you.

Thanks,
Suramya

'rdate' is just another program using port 37 (Time protocol) which is what RFC-868 is about. I think 'netdate' is more prevalent. In fact, you can use shell script, because the server returns number of second since Jan 1, 1900, in 32-bit number. So:
    sec=`nc time.nist.gov 37 | od -A n -t xC | tr -d ' '`
    date --date="1970-1-1 0:0:$((0x$sec - 2208988800)) GMT"
where 2208988800 is to make it relative to Jan 1, 1970.
I find that there could be an extra 32-bit number for microseconds. So, if you change the script to:
    set -- `nc time.nist.gov 37 | od -An -txC`
    date -u --set="1970-01-01 0:0:$((0x$1$2$3$4 - 2208988800))"
you will use only the seconds.
You are encouraged to use UDP side of things. The shell script has no choice but to use TCP, because knowing when to exit 'nc' is a hassle.


I hate to disagree...

Thu, 18 Nov 2004 15:36:44 -0500
Brendan (endosquid from endosquid.com)
Ok, I admit it. http://linuxgazette.net/108/lg_mail.html has a serious glitch... -- Heather

but...

"[sic] folks. Debian's actual command (to do mass upgrades without breaking holds or allowing package removals for apps that changed drastically) is: apt-get upgrade dist -- Heather"

The command is:

apt-get dist-upgrade

I know, because I do it everyday.

I did attempt to correct a typo. I replaced it with a worse one. It was late, and my vim went one way, my hand another. At least as far as I can tell. Either that or I was on some amazing grade of sleep deprivation. -- Heather
[Kapil] You should avoid doing this for more reasons than one!
1. Since there are only three versions of Debian at any given time you will reach the top of the charts in exactly two days! Once you already run "unstable" (or "testing" for that matter), running:
apt-get update; apt-get upgrade
should do the trick.
I do have to say, that 'upgrade' will not help you if they drastically rearrange a package. And, if you do it habitually you may not notice that. I don't recommend upgrades where you don't pay attention to such details.
The package that came to mind a long while back was vim. With merely 'upgrade' Debian would have been glad to leave me in its older style of package splits. If only it could be told to offer the same care when a package changes its config files under the hood. -- Heather
2. There is more to life than keeping up with the Joneses...
[Jimmy] Yeah, of course. There's keeping up with the Smitheseseses.[1]
[1] Why yes, I am quite drunk. Why do you ask? :)

The real way in which I was wrong is that neither 'upgrade' nor 'dist-upgrade' keywords break holds, and I claimed that the latter does. D'oh!

If you're gonna throw tomatoes, let's try to completely dunk the target, shall we?

/me enjoys another big glass of tomato juice...


Linux Master Boot Record

Fri, 19 Nov 2004 11:23:37 -0800 (PST)
Didi (didi from dancephotos.ch)

Ciao Ben,

thank you for the the description of

"dd if=/dev/zero of=/dev/hda bs=512 count=1"

it almost saved my life.

[Ben] Ciao, Didi -
Glad you found it helpful! I appreciate your note... even though it was sent to a very old (and nearly unread) address of mine and thus took a long time to come to light.
(Didi's comment refers to my "Clearing out the Master Boot Record" article back in LG#63, which many people have found helpful over time; I keep receiving grateful comments on it even now, years later. It's very gratifying to know that I've been able to help so many folks with it. The reason I'm making this reply a public one is for the new readers of LG who may not be aware of this useful technique; the article can be found at http://linuxgazette.net/issue63/okopnik.html .)


Perl One-Liner of the Month

Sat, 06 Nov 2004 08:11:03 +0000
Hans Wennborg (hawe from bigfoot.com)
Reply by Jimmy O'Regan

Thanks for a good e-zine!

Thanks for reading it.

Just wanted to tell you that I miss Ben Okopnik's Perl One-Liner of the Month imensely! Those articles were what made me start loving Perl.

Will they return?

Well, that's up to Ben, but we did have a mini 1LotM in the Linux Laundrette: http://linuxgazette.net/108/lg_laundrette.html#laundrette.moreandmore

Woomert and Frink only get a brief cameo, but the one-liners are there.

[Ben] Hi, Hans -
Thanks for the compliment! For the moment, I've written Woomert and Frink into a blind alley; I think I need to put that particular story aside, to be revised at another time (I mean, what kind of a Perl one-liner can save an alien civilization, and from what threat??? Those guys get themselves into the craziest predicaments...) and write another one, not quite that deep.
POLOTM isn't dead, just resting... but it's notes like yours that can get me motivated to start it rolling again. Look for Woomert and Frink in the future issues of LG. :)


thanks for -Great- article

Sat, 6 Nov 2004 08:13:08 -0500
BellyOfTheBeast (swroomjnu from admin.state.ak.us)
Reply by Ben Okopnik

Ben O's review of the Averatec laptop is exactly what I'd like to see more of. It is accurate about the important things and gets right to the point. Far and away the best laptop review I've even seen. Thanks very much; I look forward to reading others as they become available.

-BA

Thanks, BA - reader's compliments make for great author motivation. The laptop reviews will continue happening (although I may skip a month in between), and will only terminate on EXIT_SUCCESS - or factors beyond my control. I definitely need a backup laptop, and will be "processing" more of them.


GAZETTE MATTERS


LG 97 typo

Tue, 23 Dec 2003 14:07:36 +0000
Francis Daly (francis from daoine.org)

Hi there,

(I got this address from http://linuxgazette.net/authors/okopnik.html)

I enjoyed your article in the recent LG issue -- thanks. There appears to be a minor typo in:

http://linuxgazette.net/issue97/misc/okopnik/mirrors.tmpl

which is propogated to the content at:

http://linuxgazette.net/mirrors.html

A patch below fixes it.

All the best,

See attached mirrors.diff.txt


Stephen Bint.......for Gianfranco..and with thanks to his friends.

Thu, 4 Nov 2004 22:25:30 -0500
Ann Morgan (ann_morgan from iinet.net.au)
[This is in response to an item in issue 101]

Hello,

I came across your question about Stephen quite by accident, and thought that, although there has been a response, I would take a moment to post a personal reply.

We do not actually know the date of Stephen's death...........February 27th was the day on which he was found by a farmer on Exmoor. The ensuing inquest concluded that it was 'Death by misadventure'...Hypothermia being the cause. Thank you for caring enough to question his whereabouts............I know many people will miss him and mourn his death.

He was my son.

Sincerely,

Ann Morgan

...............

'That man is a success who lived well, laughed often and loved much: who has gained the respect of intelligent men and the love of children: who has filled his niche and accomplished his task: who leaves the world a better place than he found it, whether by an improved poppy, a perfect poem or a rescued soul; who never lacked appreciation of earth's beauty or failed to express it; who looked for the best in others and gave the best he had.'

-- Robert Louis Stevenson.

...............

Thank you, Ann. Stephen was a man who held to his principles, and we can only respect him for that.
Readers, think kindly of your family this season, even those you don't deal well with or haven't seen in years. Look for the finer qualities in people around you. The winter may be cold - but don't forget to care.


This page edited and maintained by the Editors of Linux Gazette
HTML script maintained by Heather Stern of Starshine Technical Services, http://www.starshine.org/

Published in Issue 109 of Linux Gazette, December 2004

More 2 Cent Tips!

See also: The Answer Gang's Knowledge Base and the LG Search Engine


Adding custom headers in Thunderbird

Brian Bilbrey (bilbrey from orbdesigns.com)
Answered By Jimmy O'Regan, Ben Okopnik

I'd whined several times about lack of success in setting an X-gazette-tag header in Mozilla Thunderbird. The answer lies in the user.js file, every one of the tens of Google hits I tracked down promised me. But I'd do each one as specified, and no joy in Mudville.

Tonight, I googled again, and about 6 links into the process, I found something close to the answer via a link from about.com. In my user.js file (found in my setup at ~/.thunderbird/*default/user.js) I put in these two lines:

// insert X-gazette-tag header
user_pref("mail.compose.other.header", "X-gazette-tag");
[Ben] This works in Mozilla as well, although the file there is "prefs.js". Searching the Web for the above header confirms that you cannot set a default value for the header...
[Jimmy] No, there's a user.js as well. That's what I'm using, and it worked last time.
[Ben] Odd. My version doesn't have one - I searched with "find".

if user.js doesn't exist, put it in the same directory as prefs.js. Moz* is in charge of prefs.js and may/will overwrite any changes in that file. Additionally, order of loading has user.js last, and settings in user.js will override prefs.js settings.

[Ben] Ah - I didn't realize that.

Note that this does not automatically create the header in every message, nor apparently is there a way to set a default value for the header (which would make the first part a lie, eh?)

[Ben] ...however, you can add a plugin that will allow you to do that and a lot more header-related stuff - which reputedly works for Mozilla and Thunderbird:
http://mnenhy.mozdev.org

That was ONE of the things I tried that didn't meet my needs. It turns out that it does a lot of header VIEW customization, but not new composition headers, from about two hours of playing with it, trying to get to the point I wanted.

[Ben] Hmph. Might be worth tossing into Bugzilla as a wishlist item; seems like it's something a lot of folks could use, given how much discussion there is about it on the Web.

But when I'm sending to TAG, I can select from "To:", "Cc:" "Bcc:" ... "X-gazette-tag", and add a value for that header. This is the first test, let's see if it works.

[Jimmy] And indeed it does. Probably works in Mozilla Mail too.

References


Cygwin from a CD

Jimmy O'Regan (The LG Answer Gang)

I tried running cygwin from a CD, and it mostly works (X doesn't, but Perl, Python and most of the usual tools do). The only thing that needs to be done is that a few entries need to be added to the registry (these can be safely deleted when done), because Cygwin doesn't have an /etc/fstab.

This file should be put on the CD. To add the entries, just double click!

See attached cyg-cd.reg.txt


Gentoo tip: CUPS printing error

Mike Orr (LG Contributing Editor)

If your CUPS printing suddenly stops working with the error:

lp: error - scheduler not responding!

try deleting the printer in the web interface and re-adding it. According to Gentoo forum posts, glibc had an unexpected API change and that broke Gentoo's configuration. You probably installed some unrelated software that upgraded glibc. You may have to re-emerge glibc, cupsd, and turboprint, but I didn't.

Curiously, I was still able to do the "Print Test Page" from the web interface, although others said they couldn't.

In an ideal world, dependencies would prevent this kind of problem from happening. But it's impossible for maintainers to know what incompatibilities might appear in third-party libraries in the future.

Here are the forum posts:
http://forums.gentoo.org/viewtopic.php?t=144236&highlight=cups+glibc
http://forums.gentoo.org/viewtopic.php?p=1274761#1274761


KDE logout action

Mike Orr (LG Contributing Editor)

I found the KDE option to change it back to showing the login screen after logging out instead of shutting down (../106/orr.html). It's KDE Control Center -> Session Manager -> Login as different user.


Mouse acceleration with Linux/X

Dave Blackburn (blackburn from acm.org)
Answered By Ben Okopnik, Thomas Adam, Jason Creighton

How can I adjust the "base" ratio between mouse motion and cursor motion on the screen?

I have successfully used xset. It works well for me. My problem is that the "base" ratio (e.g. with xset m 1 10) is too high (fast).

[Ben] I'm not sure what you mean by a "base ratio", Dave; I've found that I prefer a different "xset m" setting for different computer/mouse combinations, but have never come up with an absolute "rate" to reflect that preference. Whenever I set up a new machine, I twiddle this for a minute or two, set it in my ~/.xinitrc, and forget about it from there on.

I mean the mouse speed (i.e. ratio between mouse movement and cursor movement) without using: xset -- the initial mouse speed provided by X as if e.g. xset 1 10 were active.

[Ben] Ah - I was misled by the word "ratio", which implied to me that you were using "xset" with some fraction as a parameter (the man page specifies that you can do this.) Now I get what you mean.
I usually use "xset m" with a single parameter (which specifies "acceleration" only); I find that this works well for pretty much every machine out there. Once you start using more than that, you're off into /Terra Incognita/: some meeces will respond in odd ways to "threshold" tweaks.

I am using both RH 9.0 and Fedora 2 on a laptop. With RH 9.0, the "base" ratio is fairly slow. With Fedora 2 the ratio is quite a bit faster.

[Ben] I presume the two of them use somewhat different mouse drivers.

Using RH 9.0, I apply xset m 3 20 getting a pleasant result. Using Fedora 2, the "base" ratio is too fast for me.

Doing an Internet search, I found many explanations for xset.

[Ben] The man page for it is quite informative as well.

Also, I found the suggestion that I could modify xorg.conf (in /etc/X11) by adding a line like:

Option "Resolution" "500"

in section:

Section "InputDevice" Identifier "Mouse0"

This seemed like the answer I was looking for. However, when trying different values for Resolution, I observed no change in the "base" rate.

[Ben] I'm not familiar with "xorg.conf", but I've learned from personal experience that, while the "Resolution" option used to work in XF86Config, it does not in XF86Config-4.

This info is helpful. This is what I experienced.

Do one of you know how I can slow down the mouse when running Fedora 2?

[Ben] Find the value of "xset m" that you like and add it to your "~/.xinitrc" or "~/.xsession".

I use xset in ~/.xinitrc.

It seems that xset can only be used to speed up the mouse.

[Thomas] Err, no. xset is used to control the mouse threshold speed which means you can either increase or decrease it. One other option you have is that you might be using an incorrect mouse protocol for your configured mouse.

I want to slow the mouse down. In connection with slowing the mouse, I will use xset to control the higher speed.

Since the "Resolution" option doesn't work in XF86Config-4, perhaps it's also unavailable in the X.org release.

[Ben] That would be my best guess. From /usr/share/doc/xserver-xfree86/README.mouse (note the obvious escape clause):
5.3 Resolution
The following option will set the mouse device resolution to N counts per inch, if possible:
Option "Resolution" "N"
Not all mice and OSs can support this option. This option can be set in the XF86Setup program.

Perhaps there is a workaround?

[Jason] Quoting from the xset manpage:
       m       The  m  option  controls  the  mouse  parameters.   The
               parameters for the mouse are `acceleration' and
               `threshold'.  The acceleration can be specified as an
               integer, or as  a  simple fraction.  The mouse, or
               whatever pointer the machine is connected to, will go
               `acceleration' times as fast when it travels more than
               `threshold' pixels in a  short  time.   This way,  the
               mouse can be used for precise alignment when it is moved
               slowly, yet it can be set to travel across the screen in
               a flick of the  wrist when  desired.   One or both
               parameters for the m option can be omitted, but if only
               one is given, it will be interpreted as the acceleration.
               If no parameters  or  the flag 'default' is used, the
               system defaults will be set.
The key to an ugly workaround is the fact that you can specify the acceleration as a simple fraction. Thus:
xset m 1/2 1
...will cut the speed in half. But you lose any acceleration features because you're using it to hack the mouse speed to where you want it. But if that doesn't bother you, this method is one option.
[Ben] The fractional specification may work for you. Conversely, as Thomas suggested, the two distros may be using two different mouse drivers (compare the '"Option" "Device"' and '"Option" "Protocol"' lines in their X config files); if that's the case, then simply choose the one that works best for you, and do the final tweaking with "xset" from there.


Upgrading Quota

Breman (012832161 from mobitel.com.kh)
Question by Breman (012832161 from mobitel.com.kh)
Answered By Thomas Adam

Dear Thomas,

[Thomas] Hello, Breman -

May I ask you some questions below:

[Thomas] By all means. I've Cc'ed The Answer Gang on this, since I assume this is where you got my e-mail address. If you don't want this published, let me know.

I have installed SuSe Linux 6.4 as a mail server. The current version of quota is 2.11 - what is the latest version? where can I get it?

[Thomas] Quota support is kernel and user-land. Therefore I can only assume that you are referring to the userland tools. Currently the version is at 3.12, available here:
http://puzzle.dl.sourceforge.net/sourceforge/linuxquota/quota-3.12.tar.gz

- How to update to the old version? please give me steps.

[Thomas] It's a case of removing the old quota tools and installing the new one. There's a number of ways you can do this. The INSTALL file within the tar file tells you all, and it should just be a simple matter of:
./configure && make && su -c 'make install'
Note that by default, this will install into /usr/local/* -- if "/usr/local/bin" is not in your $PATH, before "/usr/bin" and you still have the old quota-tools installed, this will conflict. If, however, /usr/local/bin is listed before /usr/bin in your $PATH then this should not be a problem. But you should make sure you remove the old quota-tools, regardless.

Thanks for your quick response and it helped me a lots.


Tip: ls -l, AIX style

Jimmy O'Regan (The LG Answer Gang)
Answered By Bradley Chapman, Kapil Hari Paranjape

On a certain other Linux site, I saw an unanswered question about getting the time format of ls -l to have a leading zero on single digit dates, like AIX does, instead of padding with a space as GNU ls does.

I was not aware of this (before I went to the man page), but GNU ls will format the date any way you like, if you use the --time-style switch. To use 'date' style formatting, you prefix it with a '+'.

So, AIX-style ls -l is:

ls -l --time-style=+"%b %d %H:%M"
[Brad] Does ls support any environment variables to do this? Something like
export TIME="%b %d %H:%M"
ls -l
or do you have to use an alias in your ~/.*rc files?
[Kapil] According to "info ls":
You can specify the default value of the `--time-style' option with the environment variable `TIME_STYLE'...
So the correct environment variable is TIME_STYLE not TIME.
Kapil.

You still need to have the '+', so it's

export TIME_STYLE=+"%b %d %H:%M"
ls -l


POP3 for Yahoo Mail

Breman (012832161 from mobitel.com.kh)
Question by Breman (012832161 from mobitel.com.kh)
Answered By Thomas Adam, Kapil Hari Paranjape

- What is pop3/smtp of yahoo mail?

[Thomas] There isn't any freely available as yahoo removed that service. That said, you can "emulate" it using a program called 'yahoopops' available here:
http://yahoopops.sourceforge.net
[Kapil] There is also fetchyahoo at http://fetchyahoo.twizzler.org
Also available as a Debian package under "testing".


DHCP Relay

Bill P (#hants IRC Channel)
17:09 < billp> /usr/local/sbin/dhcrelay -i xl0 -i xl2 -i ed2 dhcpserver
17:09 < billp> I knew it was something simple
17:11 <@Dee> what is it then? :)
17:11 < billp> How you forward dhcp serive across differenent interfaces on ones firewall
17:11 < billp> dhcp services*
17:11 * Wicket sniffs billp
17:13 < billp> So I have a dhcp server running on a hostname "dhcpserver", and it sends lease offers to networks it is not actully connected to, via connected interfaces on the firewall
17:14 < billp> So, a Linux firewall connecting a subnet with a dhcp server to two subnets without dhcp servers, would go something like:
17:14 < billp> /usr/sbin/dhcrelay -i eth0 -i eth1 -i eth2 dhcpserver
17:16 < billp> where dhcpserver is the hostname of your dhcp server. Dead useful, especially for having untrusted network segments, like an open-access wireless one
17:16 <@Dee> i see

This page edited and maintained by the Editors of Linux Gazette
HTML script maintained by Heather Stern of Starshine Technical Services, http://www.starshine.org/

Published in Issue 109 of Linux Gazette, December 2004

The Answer Gang

Linux Gazette 109: The Answer Gang (TWDT) The Answer Gang 109:
LINUX GAZETTE
...making Linux just a little more fun!
(?) The Answer Gang (!)
By Jim Dennis, Karl-Heinz Herrmann, Breen, Chris, and... (meet the Gang) ... the Editors of Linux Gazette... and You!


We have guidelines for asking and answering questions. Linux questions only, please.
We make no guarantees about answers, but you can be anonymous on request.
See also: The Answer Gang's Knowledge Base and the LG Search Engine



Contents:

¶: Greetings From Heather Stern
(?)Laptop review: Averatec 5400 series
(?)Linux boots from RAMdisk,
(?)Help --or--
Quota needs update, help!
a place for everything and everything in its place...

(¶) Greetings from Heather Stern

Greetings, dear readers, and welcome once again to the world of The Answer Gang.

A world, I note, which has changed quite a bit in the last year. Last December it was like the Gazette was under a sort of shadow - our crew handled the transition to our new site with all the energy we could muster, but there's only so much life we few who run this could pour in - we had to wait for you readers to rediscover us.

We were already a great team, but the effort bound us together in a way that's really rather hard to describe... except that I like the results. We learn from each other on the lists as much as we ever did, but it's more than that, we're closer as friends I think, and we back each other up on things. We don't always agree (you put 20 plus curmudgeonly and very smart people in a room together and watch the fun. Oh? You say that's your typical holiday party? You see what I mean then) and at times Real Life(tm) mugs one or another of us ... and we really are different people, in what can take us down or carry us forward ... but we try to do more for each other.

It brings me great joy this year to still be bringing Linux Gazette to your browser's doorstep. I have to admit that for awhile even my own enthusiasm was failing; in past years I had done it for simply knowing Jim's "Answer Guy" pages would look far better when I put my hand to them. For awhile I had done it just for knowing there were uncounted readers out there looking for our good bits every month. In my own harder times I did it simply because I had promised to, I couldn't let you people down, and what little energy I could gain from knowing I was getting at least one job done right was very much a boost to me. The ordeals we put ourselves through here have given me strength in my friendships and renewed hope for a lot of little things in my life, Linux just one of them. The world has turned again, and I'm glad to know that you people are out there, still reading this, telling your newbie friends that their Linux troubles are solvable, we can Make Linux Just A Little More Fun and even get a giggle now and then.

That's part of what has seriously changed the face of LG though. The kind of people who were Linux newbies 5 years ago are not the same today. For one thing those people aren't newbies, but they still like to read about Linux and expand their knowledge even further. But the people who even thought about Linux then have a smorgasboard of choices now - and the newbies of today are in many cases less technical - you can buy "a linux box" at Wal-Mart, on special at CompUSA, you might be leaping ship from the (amazing to me, why does Microsoft saw off its own foot like this??) myriad flavors of MSwin to be found nowadays. Whether or not they ever caught a virus, the crashes and the pain they encounter when they dare to change their hardware are just as stumping to them as the box of Red Hat or SuSE on the store shelves. If they're going to get their hands dirty anyway... they may as well try this Linux thing on for size.

It won't fit all of them.

That's the thing about a world of choices. vi versus emacs debate fans the world over know that when it comes down to someone being a power user, the fact they've learned all the deep magics is worth a lot more than what type of filesystem runs under the hood or what some geek thinks is an 'operating system'. If the system operates, that's what they like. And that's good. I made the choice to stick with Gazette the way that gave it its power, a monthly source of good knowledge and fun. It's been worth it, and I thank all of you, of whatever age, country, newness to linux or being such an old hat that "Red Hat" upstart's a whippersnapper, for joining us every month. Send us your tips and good stories. Have a great time with Linux.

So it's the holidays now, and I'm giving you folks out there the same thing I give my dear friends and family every year, however rich or poor I might be. Presence.


(?) Laptop review: Averatec 5400 series

From Rick

Answered By: Ben Okopnik

Hi Ben,

Good article. My experience with laptops have had varied results. By that I mean, in many cases it has more to do with the distribution of Linux as it does with the hardware. I have a Compaq Presario 915ca (the specs on this can be easily looked up). The only upgrade is to 512MB of RAM. In any event, I am currently running WinXP and 3 different versions of Linux (I am a bit of an OS junkie!) using a 3rd party boot loader.

Xandros recognizes everything out of the box, even the WinModem! I had

(!) [Ben] "Out of the box" functioning is nice to have, but I don't expect it - and once you don't, all distros become essentially equal. There is no difference between, e.g. the kernel used in Mandrake and the one in Debian beyond possibly compilation choices and maybe a patch or two - which I can also get and use at need. There's certainly no difference in the standard toolkit, and there's no real difference in configuration - the tools may vary, but the end result is the same. I'm expert enough with Linux to do the configuration myself, so that issue does not obtain.
Admittedly, this is more difficult than tossing in a different distro and seeing if it works - but it carries the near certainty that if something can be made to work, and I take the time to do so, it will work, regardless of the distro. In my experience with multiple distros, Debian is one of the more easily configurable ones (the only "tool" required being a text editor), and so I use, and will be using, Debian and possibly its derivatives (e.g., Knoppix or Morphix) for this testing.
You may be assured that if I can make Debian work on a given laptop, then any other distro can also be convinced to do so. It may take more or less work, but it's doable. On the other hand, if I'm unable to make it work, that fact will not be conclusive. :)

(?) to mess with the /etc/fstab file a bit to get my 80GB USB hard drive working properly, but overall Xandros works well on this machine.

I guess the point of my email here is, sometimes it's just as important to find the right distro as it is the right hardware. I recently tried to install Linux on a friends new laptop. I went through about 10 different distros (including Fedora Core 2, Ubuntu, and even tested with Knoppix, which is Debian based and with great hardware detection!). Everything failed! ... ie: no mouse, it crashed the X server, etc. Finally I tried SuSE 9.1 and it just worked. Yes, I had to install the Nvidia drivers, and I never did manage to get his built-in wireless to work!

(!) [Ben] That can be a valid strategy if you don't have a lot of expertise to rely on, and it's nice that it's available. It is, however, not the only strategy, nor is it one that I prefer.

(?) (sometime it seems the hardware manufactures engineer "anti-Linux" into their products!)

(!) [Ben] As much as a frustrating experience with hardware can make you lean in the direction of that belief, I have to believe that it's false at its core. PC OEMs are in the business of selling hardware; I can't think of an argument convincing enough to make them purposely chase customers away.

(?) Yes, I agree with you. However, the vast majority of users do not know how to recompile a kernel, nor do they want to know. I would say that people like you account for a very small percentage of computer users. Most of my friends think I am some kind of computer wizard, but in reality, I am nowhere near that. Everything is relative, isn't it? I am probably in the top 10% of computer users from a knowledge point of view, and you are likely in the top 1%.

(!) [Ben] I'm afraid you missed the point I was trying to make, Rick - I guess I didn't state it clearly enough. In essence, if I can get a laptop working well under Linux, whatever the distro, then it's at least possible and in fact not too difficult - you may have noticed in the article that I'll simply stop trying once it's consumed a certain amount of time (a few hours at most.) If I can't do it at all (as was the case with the HP 5000 I'd picked up from Staples), then it gets blackballed. In both cases, a report of the experience becomes useful and doable, whereas testing every laptop against a dozen distros is out of the realm of possibility.

(?) As for the comment about hardware manufacturers purposely engineering anti-Linux products, I was just being facetious.

(!) [Ben] I understood that, but wanted to use your comment to clarify my view of the situation; I've heard a lot of people grumbling about it as if they believed it.
(?) As for aviation, well I am only 43, but I took up flying when I was 16. I am not currently flying, as things got all f&*^%$d up for me after 9/11. It's a rather long story.
(!) [Ben] Yeah. I've heard of a number of pilots who were affected... and you've probably heard about the recent TSA alien flight training/citizenship verification rule. That's going to shaft a LOT of pilots - and the damned thing is as confusing as can be imagined, and a couple of miles beyond that. AOPA is fighting the good fight, but there's a lot of fear in the air - and about it.

(?) Linux boots from RAMdisk,

From keesan

Answered By: Kapil Hari Paranjape, Thomas Adam

I tried telling CMOS that there was no second drive because someone suggested that method to get linux to recognize a larger drive, but my drive is 3GB. I have DOS on a master drive and two linux partitions on the slave drive, with one linux in each, and RAMdisk and loop versions in DOS partitions.

I am able to mount the linux partitions when running from the RAMdisk or loop versions and then switch to run linux on them:

mount /dev/hdb1 /mnt

chroot /mnt

This puts hdb1 on / and I can then use linux on the ext2 partition.

(!) [Kapil] But this is essentially what most initrd-based start up procedures do anyway! So, though I haven't used BasixLinux, I would guess that the problem is with the start scripts on your ext2 partition in /etc/rcS.d or some such.

(?) This is a minor nuisance and I suppose I could put it in an rc file, or just use the smaller version unless I needed the larger one.

(!) [Kapil] The glass could also be half full! Given the variety of hardware that Linux runs on it is surprising that so many computers boot with it at all. :-)

(?) I am writing out of curiosity - why are so many computers difficult to boot with linux? Is there a better fix for this one? Is there a better fix for the other three besides installing Win98 DOS on them (and having to use a boot floppy to defragment the DOS partitions after that) or rebooting with a Win98 boot disk to go from DOS to linux?

I also have one Northgate 386 SX 20MHz 4.7MB RAM laptop which has no cursor in linux. Cirrus video, 256K video RAM, mono VGA. The cursor is plain white when used in color VGA. The computer in theory can output to a color monitor in 800x600 resolution.

(!) [Kapil] Is this with or without X? The question is not clear enough. Are you in graphics mode or text mode?
(!) [Thomas] The distinction here is whether he is running with Framebuffers or not. Framebuffers are pretty much standard and most monitors that are not of the dark age can handle them, assuming their VGAness is OK. That said, certain monitors can react badly to the Framebuffer modeline it has been given and blank out. In fact, I remember discussing this some time ago in LG:
http://linuxgazette.net/issue77/tag/2.html

(?) Does laptop video treat software cursors oddly? A cursor appears when I use a text editor. There is a cursor while booting to DOS and in DOS.

Another 386 with identical speed, RAM and video won't boot linux at all - the screen goes black and I need to reboot. What might cause this problem?

(!) [Kapil] Try booting with the additional option "vesafb=off". Some of the older hardware may not respond well to being switched to graphic mode.
(!) [Thomas] Again, that won't be enough. He'll need to tell it to not only ignore vesafb, but to ensure that the vag16 definitions are turned off. So at the boot prompt:
linux nofb video=vga16:off vesafb=off vga=normal
Ought to do it.

(?) Quota needs update, help!

a place for everything and everything in its place...

From Breman

Answered By: Thomas Adam, John Karns, Ben Okopnik

May I ask you some questions below:

I have installed SuSe Linux 6.4 as a mail server. The current version of quota is 2.11

(!) [Thomas] Quota support is kernel and user-land. Therefore I can only assume that you are referring to the userland tools. Currently the version is at 3.12, available here:
http://puzzle.dl.sourceforge.net/sourceforge/linuxquota/quota-3.12.tar.gz

(?) How to update to the old version? please give me steps.

(!) [Thomas] It's a case of removing the old quota tools and installing the new one. There's a number of ways you can do this. The INSTALL file within the tar file tells you all, and it should just be a simple matter of:
./configure && make && su -c 'make install'
Note that by default, this will install into /usr/local/* -- if "/usr/local/bin" is not in your $PATH, before "/usr/bin" and you still have the old quota-tools installed, this will conflict. If, however, /usr/local/bin is listed before /usr/bin in your $PATH then this should not be a problem. But you should make sure you remove the old quota-tools, regardless.
(!) [John] That's the way I usually do it, too. But there is also something to be said for staying within the boundaries of the package management system, which in SuSE's case (as well as Red Hat and Mandrake, and probably a few others) is the rpm system.
(!) [Thomas] I disagree. Package management should be sufficiently advanced that if one doesn't want a particular package (or one wants to override it), then one can. This is where stow shines, for all the reasons outlined above. You are not tied down to having to install .rpm just because you can.
Of course, if you are compiling from source, for the odd program then this is not so much an issue as all of the libaries are linked (or should be) for the appropriate versions that exist on the system at the time.
(!) [John] Note: with such an old version of the distro as in the case of the querent, dealing with this issue may prove to be more trouble than it's worth, depending on how the package in question has evolved. I.E., in cases where there have been significant changes to the number of files involved, and / or their placement in the filesystem, then the process would likely involve fundamental changes to the rpm spec file, which may require a good understanding of the inner workings of the rpm system.
But for a more current version of an rpm based distro, the process would be much less problematic, and provide the advantage of keeping the rpm database "in sync" with the installed system, thus easing efforts concerning system maintenance regarding package management issues. It would entail something along the lines of replacing the 'make install' with 'rpmbuild --rebuild', after replacing the older package source files with those of the newer version.

(?) What is pop3/smtp of yahoo mail?

There isn't any freely available as yahoo removed that service. That said, you can "emulate" it using a program called 'yahoopops' available here:

http://yahoopops.sourceforge.net

(?) I have install in as default configure (usr/local/) and now I want to reinstall it in /usr/local/quota312 folder. How to uninstall it?

(!) [Thomas] Uninstalling compiled software can be hit and miss, since it depends whether the source makefile has an "uninstall" target in it, or not. So the first thing I would do, is for the source where you compiled your quota-tools, do:
cd /tmp/quota-tools/ && su -c 'make uninstall'
If that doesn't work, then the makefile probably doesn't support the feature, although it is worth looking at the makefile to see. The other option, if not, is to delete the files by hand. There are various tar and rm incantations to do that. But I would do it by hand, myself.
One other thing I will mention to you for the future is that if you find yourself compiling software from source a lot, I really do recommend you use stow [1,2]. It is a really useful piece of software and would have helped you here easily.
[1] http://linuxgazette.net/issue75/peda.html
[2] http://www.hantslug.org.uk/cgi-bin/wiki.pl?LinuxHints/KeepingTrack

(?) Thanks for your quick response. I try your uninstall connand but not success. I got the warning: "make: *** No rule to make target `uninstall'. Stop" I will delete it manually. Can we just install again without uninstall first?

(!) [Ben] There's a way to do it that I invented in a fit of desperation; it's a little manual but quite effective.

1. Run "make -n install > uninstall".
2. Edit the newly-created "uninstall" file and replace the "install" or "cp" commands with "rm", editing each line as necessary.
3. Run "sh uninstall".


This page edited and maintained by the Editors of Linux Gazette
Copyright © its authors, 2004
Published in issue 109 of Linux Gazette December 2004
HTML script maintained by Heather Stern of Starshine Technical Services, http://www.starshine.org/

Published in Issue 109 of Linux Gazette, December 2004

News Bytes

By Michael Conry

News Bytes

Contents:

Selected and formatted by Michael Conry

Submitters, send your News Bytes items in PLAIN TEXT format. Other formats may be rejected without reading. You have been warned! A one- or two-paragraph summary plus URL gets you a better announcement than an entire press release. Submit items to bytes@linuxgazette.net


Legislation and More Legislation


 European Software Patents

The difficulties and delays dogging the European Union's attempts to agree on a software patent policy continued in November, this time to the benefit of anti-software-patent interests.

In September last year, the European Parliament (a directly elected body, with representatives from all European Union member states) voted to accept a directive on the "patentability of computer-implemented inventions". This directive was only accepted subject to a set of amendments that constituted real and substantial limits on the patentability of software. This fact was recognised both by gratified anti-software-patent campaigners and by chagrined patent attorneys.

However, following this initial success, May 2004 brought a setback as the European Council of Ministers (a body composed of ministerial representatives from EU member states' governments) instead moved to advance a directive that excluded the substantial amendments adopted by the Parliament. As well as disheartening Free Software advocates, this brought howls of protest from the Parliamentarians who (in a not untypical tug of war between the branches of EU administration) accused the Council of flying in the face of democracy. After May, the obstacles still standing between the Directive and its final ratification were for the Council to formally adopt the directive, and then for the directive to pass before Parliament once more. This brings us to the present day.

The directive has not yet found its way into parliament for an encore, but instead has floundered in the Council chamber. Poland, a new entrant into the EU (and apparently relatively undecided on this issue in May), has changed the position adopted by its representative in the summer Council meeting and now opposes the directive precisely because no effective limits are placed on the patentability of software.

This heroic about-turn by Poland, as well as similar pronouncements emanating from Austria should remind us that this fight is certainly still there to be won. The efforts of prominent Free and Open Software figures like Linus Torvalds, Michael Widenius, and Rasmus Lerdorf who have raised their voices to say "No to Software Patents" are welcome, especially as they provide an example to all of us that if we feel this issue is important then we should make our opinions known. Those supporting a future software industry stretched on a rack of software patents are certainly not shy about pushing their case. Truly, can we afford the luxury of silence? Wladyslaw Majewski, president of the Internet Society of Poland puts the point starkly:

"The questionable compromise that the EU Council reached in May was the biggest threat ever to our economic growth, and to our freedom of communication. The desire of the patent system and the patent departments of certain large corporations must never prevail over the interests of the economy and society at large."
( quoted in The Inquirer).


 Novell vs. Microsoft

During November, Slashdot highlighted and discussed a very illuminating article at Groklaw, written by a retired attorney. Written in the context of Novell's current anti-trust case against Microsoft, the article points out that quite apart from the interest stirred up by the substance of this particular case, this is also a great opportunity to store up ammunition for future legal adventures. The key to this opportunity is that the discovery process will, at least temporarily, move a lot of Microsoft material into the public eye. The trick is then to store it up for future use.


 Nmap

The Register and Security Focus have reported that Fyodor, the author of the port-scanning network security tool Nmap, has found that his software writing has brought him into surprisingly close terms with the FBI. Apparently the Feds have begun to look for access to his webserver logs in order to identify individuals or organisations downloading tools like Nmap.


 OSRM and Patent Risks

Open Source Risk Management has steered a somewhat controversial course since arriving on the scene offering to indemnify open source developers against hostile intellectual property lawsuits. In a bid to encourage use of its services, OSRM has at times appeared to over-emphasise the risks open source software developers and users expose themselves to. As reported by internetnews.com, this perception has now resulted in Pamela Jones (of Groklaw) resigning her position as litigation risk research director for the group. In particular, Pamela wished not to contribute to activities that she felt were creating fear and doubt about Linux, and providing ammunition to anti-open-source interests.

The potential damage caused by such publicity is demonstrated by the usefulness of one particular OSRM report to Microsoft's Steve Ballmer, who used it to claim in front of Asian business leaders that Linux violates over 200 patents. However, one should not be too critical of OSRM, since quite apart from any FUD there does appear to be a real and growing likelihood that open source software will in the future be attacked using patents. Microsoft's statements on the issue of intellectual property point in this direction, as does its policy of substantially increasing its own patent portfolio. This portfolio can be used either defensively, or offensively, but either way its existence and rapid growth indicate a messy time ahead, and it seems the lawyers can already smell blood in the water.

Highlighting this threat can lead to some bad publicity, such as Ballmer's showboating in Asia, but it is also useful for generating awareness. And as pointed out by Ballmer, and highlighted by The Register, our current framework of international agreements governed by the WTO means that these issues will have ramifications right across the globe. How any possible patent-war will pan out is still an open question, but having good awareness in the Free Software ranks of the risks and dangers that are faced is sure to be a good thing.

The FSF is already taking steps aimed at protecting Free Software from hostile parties armed with heavy patent portfolios. The GPL, which is currently being redrafted towards a 3rd revision (considered overdue by some), may yet offer some protection against patent attacks. Clever legal manoeuvres, however, are not necessarily a sufficient condition for safety, so it is important to be aware of opportunities for practical action, and to try to spread awareness of these risks as widely as possible.


Linux Links

Linux Insider has some interesting comments from Andrew Tanenbaum disputing findings in Kenneth Brown's report for The Alexis de Tocqueville Institute.

John C. Dvorak writing at CBS MarketWatch thinks Microsoft is planning to make an entry into the Linux marketplace, and that this explains the effort invested in the Lindows trademark lawsuit.

Vnunet.com interviews OSDL boss (and Linus's employer) Stuart Cohen.

NewsForge reports on the launch of LinuxFoo, a GNU/Linux discussion site.

The Register presents an outsider's view of technology in China, and opportunities for GNU/Linux.

O'Reilly on Knoppix for Windows users.

The Inquirer reports on Linux's position in the Japanese 3G mobile phone market.

Solaris is from Venus, Linux is from Mars.

A look at the Geronimo project, from the Apache Software Foundation.

Round up of hard real-time options under Linux.

Inside Memory Management.

Boot managing your Linux and Windows box, and in particular recovering from the Windows installer's boorish overwriting of your original bootloader.

Linux Weekly News has published interesting articles on binary-only firmware, and on the current state of play in the BSD arena.

Linux Weekly News roundup of PowerPC GNU/Linux distributions.


News in General


 Intel

Intel has announced an initiative that shows a growing interest in Linux. The new quick-start kit for systems-integrators, launched in the Asian market, is intended to facilitate the building of Linux-based desktop PCs. This is a small move towards providing the kind of support Windows PC integrators have grown used to.


 Netherlands

The European Union Interchange of Data Between Administrations Project has publicised the decision of the local government in the Dutch city of Haarlem to switch 2000 desktops to OpenOffice.org. As well as currently using GNU/Linux in server applications, the local government is exploring the feasibility of migrating desktops to the operating system, with initial estimates indicating that 20% of desktops could be migrated without causing particular difficulties or inconvenience to employees.

The Dutch prime minister and the office of the Irish prime minister have also encouraged European governments to consider open source software in the spirit of inter-agency collaboration. Now, while such pronouncements are good to hear, this writer is relatively familiar with Irish government policy on these matters, and it is anything but coherent. If this is the case elsewhere, then if your elected representative pays lip-service to open source and Free Software, then perhaps it would be helpful to follow up on this with a letter, to let them know you paid attention, that you'll remember what they said, and that if they do a U-turn on it then they'd better knock on somebody else's door come election time!


 Intel

SSC, publisher of Linux Journal and former supporter of Linux Gazette, will be launching a new magazine in February 2005. Aimed at Linux newcomers, TUX will be a monthly print and online publication providing articles of interest to desktop users.

This new publication has also received comment on Andy Oram's weblog at O'Reilly.com.


Distro News


 Damn Small Linux

OSDir.com has published a screenshot tour of Damn Small Linux 0.8.4. Damn Small Linux is a business card size (50MB) bootable Live CD Linux distribution that strives to have a functional and easy to use desktop.


 Debian

Debian Weekly News highlighted a tutorial written by Falko Timme on using the 2.6 kernel with Debian Woody 3.0.


 gnuLinEx

Linux Journal has published an interesting article on gnuLinEx. GnuLinEx is the Debian-based operating system used by the government of the Autonomous Community of Extremadura, Spain. The system is used widely in the region's schools, and also in local government administration.


 Knoppix

O'Reilly has published a book dealing with some of the cool things you can accomplish with the Debian-based GNU/Linux live-CD Knoppix: Knoppix Hacks.

This book was reviewed on Slashdot (the review was very favourable, to the extent that it was linked on the press-release advertising this title).


 Slackware

Patrick Volkerding, coordinator of Slackware Linux, has been having serious health problems in recent weeks. Patrick has found it difficult to obtain satisfactory treatment from the doctors that he has visited to date, so he has solicited help from members of the community.


 Topologilinux

Linuxforums.org has published a review of Topologilinux. Based on the much respected Slackware, Topologilinux is a free Linux distribution designed to be run on top of or inside an existing windows system. Thus, Topologilinux does not require any repartitioning of the system's hard drive, and instead it uses a single file as a linux root system.


Software and Product News


 Lulu

Lulu, a company that offers people the chance to self-publish at relatively modest costs (at least for small production runs) is now aiming to extend this service to open source software developers. The intention is to sell boxed sets comprising the software itself, as well as printed and bound manuals and documentation. An example of this class of product is the Fedora GNU/Linux distribution.


 O'Reilly

O'Reilly has announced the availability of a new book, Windows to Linux Migration Toolkit. From the publisher's website:

It provides migration process planning, automated migration scripts, anti-virus/anti-spam solutions, and specific migration and deployment details for all relevant technologies. The CD includes valuable automated scripts for migrating any flavor of Windows to Linux.

Another title likely to be of interest to readers is SELinux. This book provides a background to SELinux, as well as guidelines on its installation and subsequent use.


 Linux

Marcello Tosatti has announced the completion of a new release in the 2.4 series of kernels. You can read the changelog for 2.4.28 to see all the changes.


 Mozilla

The release of a stable version 1.0 of Mozilla Firefox, tied in with an unprecedented publicity drive for the open-source application, has been followed by an exceptionally strong download-demand for the package. Indeed it seems that the browser is even eating into the market share of the currently dominant Microsoft Internet Explorer, which has seen its share reportedly drop below 90%. The upsurge in demand also seems to be creating a good business environment for Mozilla-savvy developers.

Mick is LG's News Bytes Editor.


[Picture] Born some time ago in Ireland, Michael is currently working as a lecturer in the Department of Mechanical Engineering, University College Dublin. The topic of his PhD research was the use of Lamb waves in nondestructive testing. GNU/Linux has been very useful in this work, and Michael has a strong interest in applying free software solutions to other problems in engineering.

Copyright © 2004, Michael Conry. Released under the Open Publication license

Published in Issue 109 of Linux Gazette, December 2004

Virtual Filesystem: Building A Linux Filesystem From An Ordinary File

By Mike Chirico

Copyright (c) 2004 (GPU Free Documentation License)
Latest Update: http://prdownloads.sourceforge.net/souptonuts/README_Virtual_FS.html?download
Date: Sun Sep 19 01:08:31 EDT 2004

Under Linux, you can create a regular file, format it as an ext2, ext3, or reiser filesystem, and then mount it just like a physical drive. It's then possible to read and write files to this newly-mounted device. You can also copy the complete filesystem, since it is just a file, to another computer. If security is an issue, read on. This article will show you how to encrypt the filesystem and mount it with ACL (Access Control Lists), which gives you control of rights beyond the traditional read (r), write (w), and execute (x) permissions for the three user groups "file", "owner", and "other".

This is an excellent way to investigate different filesystems without having to reformat a physical drive, which means you avoid the hassle of moving all your data. This method is quick -- very quick compared to preparing a physical device. What is truly great about this technique is that you can explore different filesystems such as reiserfs, ext3, or ext2 without having to purchase an additional physical drive. Since the same file can be mounted on more than one mount point, you can also investigate sync rates.

Creating a filesystem in this manner allows you to set a hard limit on the amount of space used, which, of course, will be equal to the file size. This can be an advantage if you need to move this information to other servers. Since the contents cannot grow beyond the file, you can easily keep track of how much space is being used.

First, you want to create a 20MB file by executing the following command:

      $ dd if=/dev/zero of=disk-image count=40960
      40960+0 records in
      40960+0 records out

A count of 40960 created a 20 MB file because, by default, dd uses a block size of 512 bytes. That makes the size: 40960*512=20971520.

      $ ls -l disk-image
      -rw-rw-r--    1 chirico  chirico  20971520 Sep  3 14:24 disk-image

Next, to format this as an ext3 filesystem, you just execute the following command:

      $ /sbin/mkfs -t ext3 -q disk-image
      mke2fs 1.32 (09-Nov-2002)
      disk-image is not a block special device.
      Proceed anyway? (y,n) y

You are asked whether to proceed because this is a file, and not a block device. That is OK. We will mount this as a loopback device so that this file will simulate a block device.

Next, you need to create a directory that will serve as a mount point for the loopback device.

      $ mkdir fs

You are now one step away from the last step. You just want to find out what the next available loopback device number is. Normally, loopback devices start at zero (/dev/loop0) and work their way up (/dev/loop1, /dev/loop2, ... /dev/loopn). An easy way for you to find out what loopback devices are being used is to look into /proc/mounts, since the mount command may not give you what you need.

      $ cat /proc/mounts

      rootfs / rootfs rw 0 0
      /dev/root / ext3 rw 0 0
      /proc /proc proc rw,nodiratime 0 0
      none /sys sysfs rw 0 0
      /dev/sda1 /boot ext3 rw 0 0
      none /dev/pts devpts rw 0 0
      /proc/bus/usb /proc/bus/usb usbdevfs rw 0 0
      none /dev/shm tmpfs rw 0 0

On my computer, I have no loopback devices mounted, so I'm OK to start with zero. You must do the next command as root, or with an account that has superuser privileges.

      # mount -o loop=/dev/loop0 disk-image fs

That's it. You just mounted the file as a device. Now take a look at /proc/mounts, you will see this is using /dev/loop0.

      $ cat /proc/mounts

      rootfs / rootfs rw 0 0
      /dev/root / ext3 rw 0 0
      /proc /proc proc rw,nodiratime 0 0
      none /sys sysfs rw 0 0
      /dev/sda1 /boot ext3 rw 0 0
      none /dev/pts devpts rw 0 0
      /proc/bus/usb /proc/bus/usb usbdevfs rw 0 0
      none /dev/shm tmpfs rw 0 0
      /dev/loop0 /home/chirico/junk/fs ext3 rw 0 0

You can now create new files, write to them, read them, and do everything you normally would do on a disk drive. First, I'll give access to the chirico account.

      # chown -R chirico.chirico /home/chirico/junk/fs

Now, under the chirico account, it is possible to create files.

      $ cd /home/chirico/fs
      $ mkdir one two three
      $ ls -l

      total 15
      drwx------    2 chirico  chirico     12288 Sep  3 14:28 lost+found
      drwxrwxr-x    2 chirico  chirico      1024 Sep  3 14:34 one
      drwxrwxr-x    2 chirico  chirico      1024 Sep  3 14:34 three
      drwxrwxr-x    2 chirico  chirico      1024 Sep  3 14:34 two

      $ df -h

      Filesystem            Size  Used Avail Use% Mounted on
      /dev/sda2              17G   11G  4.6G  71% /
      /dev/sda1              99M   83M   11M  89% /boot
      none                   62M     0   62M   0% /dev/shm
      /home/chirico/junk/disk-image
                             20M  1.1M   18M   6% /home/chirico/junk/fs

If you need to unmount the filesystem, as root, just issue the umount command. If you need to free the loopback device, execute the losetup command with the -d option. You can execute both commands as follows:

      # umount /home/chirico/junk/fs
      # losetup -d /dev/loop0

Using RWX -- The Old Way To Collaborate

Before we get started with ACL, how would you set up rights on the filesystem so that users could create and save documents that others could modify? For instance, let's say that users chirico and sporkey are collaborating on a project together.

Well, you have to add everyone to the same group. You would execute commands like these:.

      # groupadd sharefs
      # chown -R root.sharefs /home/chirico/junk/fs
      # chmod 2775 /home/chirico/junk/fs
      # usermod -G sharefs sporkey
      # usermod -G sharefs chirico

Note that if these changes do not take effect for your users (for example, if they were logged in when you executed the commands), they'll have to log out and log in again or execute the "$ newgrp sharefs" command. No big deal, right? Well, keep reading, and see how ACL avoids this step.

More importantly, even though the old way worked for you, at some point, new users may need to be added to the project. What if some of these users only need a subset of the rights? For instance, you have developers, testers, managers, and a few special people. There are limits to what the 'rwx'-type rights can do. ACL solves a lot of these problems.

ACL, Reiserfs, and AES Encryption: The 2.6 Kernel

For the next steps, I will assume that you are running Red Hat Fedora Core 2. If not, reference the 2.6 kernel upgrade section below. Four things will be covered in this section:

Your installation of Fedora Core 2, by default, will be configured for loop, cryptoloop, and aes, but it is highly unlikely that you will have all of these modules loaded. So, execute the following commands to load these modules (you will need to do this as root):

      # modprobe loop
      # modprobe cryptoloop
      # modprobe aes

Next, create a directory to store the files. The Reiser filesystem will require more space than the ext3 filesystem.

      # mkdir /home/diskimg
      # cd /home/diskimg

Instead of creating the file zeroed out, like you did with the ext3 filesystem, this one is going to contain random bits, which may add a little extra security.

      # dd if=/dev/urandom of=disk-aes count=102400

We need to encrypt the loop device, so you need to use losetup. You will be prompted for a password, which you will need to remember when you mount the device.

      # losetup -e aes /dev/loop1 ./disk-aes
        Password:

This step is new also. Instead of formatting the file directly, you will format the loop device. The file stays encrypted. Again, you will be prompted to continue, so just enter "y".

      # mkfs -t reiserfs /dev/loop1

      mkfs.reiserfs 3.6.13 (2003 www.namesys.com)                                                
                                                                                           
      A pair of credits:                                                                   
      Elena Gryaznova performed testing and benchmarking.                                  
                                                                                           
      The  Defense  Advanced  Research  Projects Agency (DARPA, www.darpa.mil) is the      
      primary sponsor of Reiser4.  DARPA  does  not  endorse  this project; it merely      
      sponsors it.                                                                         
                                                                                           
                                                                                           
      Guessing about desired format.. Kernel 2.6.8-1.521 is running.                       
      Format 3.6 with standard journal                                                     
      Count of blocks on the device: 12800                                                 
      Number of blocks consumed by mkreiserfs formatting process: 8212                     
      Blocksize: 4096                                                                      
      Hash function used to sort names: "r5"                                               
      Journal Size 8193 blocks (first block 18)                                            
      Journal Max transaction length 1024                                                  
      inode generation number: 0                                                           
      UUID: 435e3495-5e2e-489d-bf55-1b5f9a44b670                                           
      ATTENTION: YOU SHOULD REBOOT AFTER FDISK!                                            
              ALL DATA WILL BE LOST ON '/dev/loop1'!                                       

      Continue (y/n):y                                                                     
      Initializing journal - 0%....20%....40%....60%....80%....100%                        
      Syncing..ok                                                                          
                                                                                           
      Tell your friends to use a kernel based on 2.4.18 or later, and especially not a     
      kernel based on 2.4.9, when you use reiserFS. Have fun.                              
                                                                                           
      ReiserFS is successfully created on /dev/loop1.                                      

Create the mount point /fs, and mount this device. Note that you will be entering the acl option as well. Plus, you will prompted for a password.

      # mkdir /fs
      # mount -o loop,encryption=aes,acl ./disk-aes /fs
        Password:

Ok, now take a look at the mount command. It should show up as the Reiser filesystem, encrypted, using ACL. Note that it says loop2; it mounted it on /dev/loop2, which is one above what losetup specified, /dev/loop1.

      $ mount
      /home/diskimg/disk-aes on /fs type reiserfs (rw,loop=/dev/loop2,encryption=aes,acl)

Exploring ACL

With ACL (Access Control Lists), you have finer control over access permissions. With the rwx permission scheme, you cannot easily change rights without creating new groups to handle the users. With ACL, you can set user permissions without creating a group, and individual users can add or remove access.

These rights are set with the setfacl command. The command below will give the users donkey, chirico, and bozo2 access to this new filesystem that we mounted. Again, I'm assuming that you are using Fedora Core 2, or some distribution that is set up for ACL.

# setfacl -R -m d:u:donkey:rwx,d:u:chirico:rwx,d:u:bozo2:rwx /fs

Next, create a few directories as one of the users. The example below was done as the user chirico.

      $ mkdir /fs/one
      $ touch /fs/one/stuff
      $ ls -l /fs/one/stuff
      -rw-rw----+ 1 chirico chirico 0 Sep  3 17:48 /fs/one/stuff

Notice the plus sign in the last line. It tells us a little about who has access. So, as user chirico, the getfacl command can be executed:

      $ getfacl /fs/one/stuff                                    

      getfacl: Removing leading '/' from absolute path names     
      # file: fs/one/stuff                                       
      # owner: chirico                                           
      # group: chirico                                           
      user::rw-                                                  
      user:chirico:rwx                #effective:rw-             
      user:donkey:rwx                 #effective:rw-             
      user:bozo2:rwx                  #effective:rw-             
      group::r-x                      #effective:r--             
      mask::rw-                                                  
      other::---                                                 

We now see that donkey, chirico, and bozo2 have effective rights on this file. Chirico has enough rights to remove bozo2.

      $ setfacl -x u:bozo2 /fs/one/stuff
      $ getfacl /fs/one/stuff
      getfacl: Removing leading '/' from absolute path names
      # file: fs/one/stuff
      # owner: chirico
      # group: chirico
      user::rw-
      user:chirico:rwx
      user:donkey:rwx
      group::r-x
      mask::rwx
      other::---

This is just scratching the surface of what can be done with ACL. For more information, see some of the references below.

2.6 Kernel Upgrade

This article will get you started with the 2.6 kernel if you are currently running Red Hat 8 or 9. You may want to take a look at it to see what is involved. If you decide to upgrade, you will need to configure your kernel for the following:

      CONFIG_BLK_DEV_LOOP
      CONFIG_BLK_DEV_CRYPTOLOOP
      CONFIG_CRYPTO_AES_586

This is done in the .config file, and you can download my config file here. Just look for kernel-2.6.8.1-i686-chirico-reiserfsacl.config in the tar.gz.

In addition to upgrading the kernel, you will need the latest version of the Linux utilities. Currently, there is no need to patch this version. In the past, there was a patch, but this version worked fine for me.

You will also need the Reiser tools.

References

Linux Tips and Tricks
Check out tips 12, 22, and 91, on how to use ssh with rsync. You can create a virtual filesystem on a server, then copy it to your laptop. As you work on the laptop, sync your changes using rsync.
Linux Magazine's article on ACL
This article goes into more depth on adding and removing users.
Access Control Lists in Linux
A PDF from Andreas Grünbacher.
Advanced Linux Programming
by Mark Mitchell, Jeffrey Oldham, and Alex Samuel, of CodeSourcery LLC, published by New Riders Publishing, ISBN 0-7357-1043-0, First Edition, June 2001. This book is free and you can view it online. Chapter 6 describes loopback devices.
Implementing Encrypted Home Directories
W. Michael Petullo, July 23, 2003.
The Loopback Encrypted Filesystem HOWTO
By Ryan T. Rhea.

Other Articles by Mike Chirico

Lemon Parser Generator Tutorial
This is a yacc alternative that is compact and thread safe. It is used in the sqlite project.
Recommended Reading
Read what others suggest. I started with a list of my own, and will add suggestions from other developers, readers, and opinionated people.
README_mysql.txt
Tips on MySQL.
README_COMCAST_EMAIL.txt
Tips on using Comcast Email with a home Linux box.


[BIO] Mike Chirico, a father of triplets (all girls) lives outside of Philadelphia, PA, USA. He has worked with Linux since 1996, has a Masters in Computer Science and Mathematics from Villanova University, and has worked in computer-related jobs from Wall Street to the University of Pennsylvania. His hero is Paul Erdos, a brilliant number theorist who was known for his open collaboration with others.
Mike's notes page is souptonuts.

Copyright © 2004, Mike Chirico. Released under the Open Publication license

Published in Issue 109 of Linux Gazette, December 2004

SQLite Tutorial: Common Commands and Triggers

By Mike Chirico

This article explores common methods in SQLite such as running commands from the shell prompt and creating triggers for populating time stamped fields with either UTC or local time values. In addition, delete, update, and insert trigger examples will be explored in detail.

All examples can be found in sqlite_examples.tar.gz (local copy), and I would encourage you to download and run these examples as you read through this document.

The home page for sqlite3 is www.sqlite.org and the source for sqlite3 can be downloaded at www.sqlite.org/download.htm. This tutorial was done with the source version 3.0.8

Getting Started - Common Commands

To create a database file, run the command "sqlite3" followed by the database name. For example, to create the database "test.db" run the sqlite3 command as follows:

     $ sqlite3 test.db
     SQLite version 3.0.8
     Enter ".help" for instructions
     sqlite> .quit
     $

The database file test.db will be created, if it does not already exist. Running this command will leave you in the sqlite3 environment. There are 3 ways to safely exit this environment (.q, .quit, or .exit).

You do not have to enter the sqlite3 interactive environment. Instead, you could perform all commands at the shell prompt, which is ideal when running bash scripts and commands in an ssh string. Below is an example of how you would create a simple table from the command prompt.

     $ sqlite3 test.db  "create table t1 (t1key INTEGER 
                  PRIMARY KEY,data TEXT,num double,timeEnter DATE);"

After table t1 has been created, data can be inserted as follows:

     $ sqlite3 test.db  "insert into t1 (data,num) values ('This is sample data',3);"
     $ sqlite3 test.db  "insert into t1 (data,num) values ('More sample data',6);"
     $ sqlite3 test.db  "insert into t1 (data,num) values ('And a little more',9);"

As expected, doing a select returns the data in the table. Note, the primary key "t1key" auto increments; however, there are no default values for timeEnter. To populate the timeEnter field with the time, an update trigger is needed. An important note on the PRIMARY KEY: do not use the abbreviated "INT" when working with the PRIMARY KEY. You must use "INTEGER", for the primary key to update.

     $ sqlite3 test.db  "select * from t1 limit 2";
     1|This is sample data|3|
     2|More sample data|6|

In the statement above, the limit clause is used and only 2 rows are displayed. For a quick reference of SQL syntax statements available with SQLite, see the link syntax. There is an offset option to the limit clause. For instance, the third row is equal to the following: "limit 1 offset 2".

     $ sqlite3 test.db "select * from t1 order by t1key limit 1 offset 2";
     3|And a little more|9|

The ".table" command shows the table names. For a more comprehensive list of tables, triggers, and indexes created in the database, query the master table "sqlite_master" as shown below.

     $ sqlite3 test.db ".table"
     t1

     $ sqlite3 test.db "select * from sqlite_master"
     table|t1|t1|2|CREATE TABLE t1 (t1key INTEGER 
                  PRIMARY KEY,data TEXT,num double,timeEnter DATE)

All SQL information and data inserted into a database can be extracted with the ".dump" command.

     $ sqlite3 test.db ".dump"
     BEGIN TRANSACTION;
     CREATE TABLE t1 (t1key INTEGER
                  PRIMARY KEY,data TEXT,num double,timeEnter DATE);
     INSERT INTO "t1" VALUES(1, 'This is sample data', 3, NULL);
     INSERT INTO "t1" VALUES(2, 'More sample data', 6, NULL);
     INSERT INTO "t1" VALUES(3, 'And a little more', 9, NULL);
     COMMIT;

The contents of the ".dump" can be filtered and piped to another database. Below table t1 is changed to t2 with the sed command, and it is piped into the test2.db database.

      $ sqlite3 test.db ".dump"|sed -e s/t1/t2/|sqlite3 test2.db

Triggers

An insert trigger is created below in the file "trigger1". The Coordinated Universal Time (UTC) will be entered into the field "timeEnter", and this trigger will fire after a row has been inserted into the table t1. Again, this trigger will fire after the row has been inserted.

     -- ********************************************************************
     --   Creating a trigger for timeEnter
     --     Run as follows:
     --            $ sqlite3 test.db < trigger1
     -- ********************************************************************
     CREATE TRIGGER insert_t1_timeEnter AFTER  INSERT ON t1
     BEGIN
      UPDATE t1 SET timeEnter = DATETIME('NOW')  WHERE rowid = new.rowid;
     END;
     -- ********************************************************************

The AFTER specification in ..."insert_t1_timeEnter AFTER..." is necessary. Without the AFTER keyword, the rowid would not have been generated. This is a common source of errors with triggers, since AFTER is NOT the default, so it must be specified. In summary, if your trigger depends on newly created data, in any of the fields from the created row, which was the case for us in this example since we need the rowid, then, the AFTER specification is needed. Otherwise, the trigger is a BEFORE trigger, and will fire before rowid or other pertinent data is entered into the field.

Comments are preceded by "--". If this script was created in the file "trigger1", you could easily execute this script as follows.

     $ sqlite3 test.db < trigger1

Now try entering a new record as before, and you should see the time in the field timeEnter.

     sqlite3 test.db  "insert into t1 (data,num) values ('First entry with timeEnter',19);"

Doing a select reveals the following data:

     $ sqlite3 test.db "select * from t1";
     1|This is sample data|3|
     2|More sample data|6|
     3|And a little more|9|
     4|First entry with timeEnter|19|2004-10-02 15:12:19

If you look at the statement above, the last value has the timeEnter filled in automatically with Coordinated Universal Time - or (UTC). If you want local time, then, use select datetime('now','localtime'). See the note at the end of this section regarding UTC and local time.

For examples that follow the table "exam" and the database "examScript" will be used. The table and trigger are defined below. Just like the trigger above, UTC time will be used.

     -- *******************************************************************
     --  examScript: Script for creating exam table                        
     --   Usage:                                                           
     --       $ sqlite3 examdatabase < examScript                          
     --                                                                    
     --   Note: The trigger insert_exam_timeEnter                          
     --          updates timeEnter in exam                                 
     -- *******************************************************************
     -- *******************************************************************
     CREATE TABLE exam (ekey      INTEGER PRIMARY KEY,                     
                        fn        VARCHAR(15),                             
                        ln        VARCHAR(30),                             
                        exam      INTEGER,                                 
                        score     DOUBLE,                                  
                        timeEnter DATE);                                   
                                                                           
     CREATE TRIGGER insert_exam_timeEnter AFTER  INSERT ON exam            
     BEGIN                                                                 
                                                                           
     UPDATE exam SET timeEnter = DATETIME('NOW')                           
              WHERE rowid = new.rowid;                                     
     END;                                                                  
     -- *******************************************************************
     -- *******************************************************************

After the script file, it can be executed, by redirecting the contents of the script file into the sqlite3 command, followed by the database name. See the example below:

     $ sqlite3 examdatabase < examScript                            
     $ sqlite3 examdatabase "insert into exam (ln,fn,exam,score)   
            values ('Anderson','Bob',1,75)"                        
                                                                   
     $ sqlite3 examdatabase "select * from exam"                   
                                                                   
     1|Bob|Anderson|1|75|2004-10-02 15:25:00                       

And, as a check, the PRIMARY KEY and current UTC time have been updated correctly, as seen from the above example.

Logging All Inserts, Updates, and Deletes

The script below creates the table examlog and three triggers update_examlog, insert_examlog, and delete_examlog to record update, inserts, and deletes made to the exam table. In other words, anytime a change is made to the exam table, the changes will be recorded in the examlog table, including the old value and the new value. By the way if you are familiar with MySQL, the functionality of this log table is similar to MySQL's binlog. See (TIP 2, TIP 24 and TIP 25) if you would like more information on MySQL's log file.

     -- *******************************************************************
     --  examLog: Script for creating log table and related triggers       
     --   Usage:                                                           
     --       $ sqlite3 examdatabase < examLOG                             
     --                                                                    
     --                                                                    
     -- *******************************************************************
     -- *******************************************************************
     CREATE TABLE examlog (lkey INTEGER PRIMARY KEY,                       
                       ekey INTEGER,                                       
                       ekeyOLD INTEGER,                                    
                       fnNEW   VARCHAR(15),                                
                       fnOLD   VARCHAR(15),                                
                       lnNEW   VARCHAR(30),                                
                       lnOLD   VARCHAR(30),                                
                       examNEW INTEGER,                                    
                       examOLD INTEGER,                                    
                       scoreNEW DOUBLE,                                    
                       scoreOLD DOUBLE,                                    
                       sqlAction VARCHAR(15),                              
                       examtimeEnter    DATE,                              
                       examtimeUpdate   DATE,                              
                       timeEnter        DATE);                             
                                                                           
     --  Create an update trigger                                          
     CREATE TRIGGER update_examlog AFTER UPDATE  ON exam                   
     BEGIN                                                                 
                                                                           
       INSERT INTO examlog  (ekey,ekeyOLD,fnOLD,fnNEW,lnOLD,               
                             lnNEW,examOLD,examNEW,scoreOLD,               
                             scoreNEW,sqlAction,examtimeEnter,             
                             examtimeUpdate,timeEnter)                     
                                                                           
               values (new.ekey,old.ekey,old.fn,new.fn,old.ln,             
                       new.ln,old.exam, new.exam,old.score,                
                       new.score, 'UPDATE',old.timeEnter,                  
                       DATETIME('NOW'),DATETIME('NOW') );                  
                                                                           
     END;                                                                  
     --                                                                    
     --  Also create an insert trigger                                     
     --    NOTE  AFTER keyword ------v                                     
     CREATE TRIGGER insert_examlog AFTER INSERT ON exam                    
     BEGIN                                                                 
     INSERT INTO examlog  (ekey,fnNEW,lnNEW,examNEW,scoreNEW,              
                           sqlAction,examtimeEnter,timeEnter)              
                                                                           
               values (new.ekey,new.fn,new.ln,new.exam,new.score,          
                       'INSERT',new.timeEnter,DATETIME('NOW') );           
                                                                           
     END;                                                                  
                                                                           
     --  Also create a DELETE trigger                                      
     CREATE TRIGGER delete_examlog DELETE ON exam                          
     BEGIN                                                                 
                                                                           
     INSERT INTO examlog  (ekey,fnOLD,lnNEW,examOLD,scoreOLD,              
                           sqlAction,timeEnter)                            
                                                                           
               values (old.ekey,old.fn,old.ln,old.exam,old.score,          
                       'DELETE',DATETIME('NOW') );                         
                                                                           
     END;                                                                  
     -- *******************************************************************
     -- *******************************************************************

Since the script above has been created in the file examLOG, you can execute the commands in sqlite3 as shown below. Also shown below is a record insert, and an update to test these newly created triggers.

     $ sqlite3 examdatabase < examLOG                            
                                                                    
     $ sqlite3 examdatabase "insert into exam                       
                               (ln,fn,exam,score)                   
                             values                                 
                               ('Anderson','Bob',2,80)"             
                                                                    
     $ sqlite3 examdatabase "update exam set score=82               
                                where                               
                              ln='Anderson' and fn='Bob' and exam=2"

Now, by doing the select statement below, you will see that examlog contains an entry for the insert statement, plus two updates. Although we only did one update on the command line, the trigger "insert_exam_timeEnter" performed an update for the field timeEnter -- this was the trigger defined in "examScript". On the second update we can see that the score has been changed. The trigger is working. Any change made to the table, whether by user interaction or another trigger is recorded in the examlog.

  $ sqlite3 examdatabase "select * from examlog"

  1|2||Bob||Anderson||2||80||INSERT|||2004-10-02 15:33:16
  2|2|2|Bob|Bob|Anderson|Anderson|2|2|80|80|UPDATE||2004-10-02 15:33:16|2004-10-02 15:33:16
  3|2|2|Bob|Bob|Anderson|Anderson|2|2|82|80|UPDATE|2004-10-02 15:33:16|2004-10-02 15:33:26|2004-10-02 15:33:26

Again, pay particular attention to the AFTER keyword. Remember by default triggers are BEFORE, so you m