<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Geek Pit</title>
	<link>http://blog.unixlore.net</link>
	<description>Geek tech-tips, news and commentary</description>
	<pubDate>Sat, 28 Jun 2008 00:39:44 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>
	<language>en</language>
			<item>
		<title>A Lightweight Linux Desktop</title>
		<link>http://blog.unixlore.net/2008/05/a-lightweight-linux-desktop.html</link>
		<comments>http://blog.unixlore.net/2008/05/a-lightweight-linux-desktop.html#comments</comments>
		<pubDate>Fri, 23 May 2008 16:39:59 +0000</pubDate>
		<dc:creator>Doug</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.unixlore.net/2008/05/a-lightweight-linux-desktop.html</guid>
		<description><![CDATA[I recently had the need to install Linux on an older PC - a generic
PIII 1Ghz with 384MB of RAM. I&#8217;ve long been a fan of Debian for older
hardware - the installer allows you to install a base system of about
400MB which you can tweak and add onto after-the-fact. I find this
much easier than installing [...]]]></description>
			<content:encoded><![CDATA[I recently had the need to install Linux on an older PC - a generic
PIII 1Ghz with 384MB of RAM. I&#8217;ve long been a fan of Debian for older
hardware - the installer allows you to install a base system of about
400MB which you can tweak and add onto after-the-fact. I find this
much easier than installing a complete desktop and removing loads of
uneccesary bloat afterwards. I&#8217;m going to show you how to proceed with
such a minimal install of <a
href="http://www.debian.org/releases/stable/">Debian Etch</a> and get
X and a few lightweight apps installed.

<br /><br />

To get started, during the installation, select your network mirror
as usual, but do not select anything during the software selection
phase. By default, you will have &#8220;Desktop Environment&#8221; and &#8220;Standard
System&#8221; selected. Un-select both and proceed with the rest of the
install. Here is what the default looks like:

<p align="center">
<img src="http://blog.unixlore.net/images/tasksel.png" alt="Software Package Selection" />
</p>

Proceed with the rest of the installation as normal; it will be very
fast, since only a basic console system is installed. Log into your
bare-bones desktop as root and edit (with vi or nano)
<i>/etc/apt/sources.list</i> to remove the Debian CD (or DVD)
line at the top. You should have just a couple of lines left:
<br />

<span style="font-size:78%;">
<code>
deb http://ftp.debian.org/debian/ etch main
deb http://security.debian.org/ etch/updates main contrib
</code>
</span>

<br />

Now let&#8217;s install a few basics - X, a lightweight window manager, GNU
Emacs and some tools for text-mode and graphical browsing. Feel free
to substitute your own window manager here, I prefer icewm as it has
the &#8220;standard&#8221; keybindings I&#8217;m used to for a desktop.
<br />

<span style="font-size:78%;">
<code>
aptitude update
aptitude upgrade
aptitude install ssh openssl wget elinks less screen xserver-xorg \
                  xresprobe icewm icewm-themes exim4 menu \
                  build-essential emacs21 iceweasel rxvt
</code>
</span>

<br /> 

You may want to leave out <span
style="font-style:italic;">emacs21</span> and replace it with <span
style="font-style:italic;">vim</span> or <span
style="font-style:italic;">nvi</span>. Remove <span
style="font-style:italic;">build-essential</span> if you won&#8217;t be
compiling any software. <span
style="font-style:italic;">Iceweasel</span> is just Mozilla Firefox in
a Debian package. <span style="font-style:italic;">rxvt</span> is a
lightweight replacement for xterm, and <span
style="font-style:italic;">menu</span> is a Debian-specific package
that keeps your window manager applications menu updated as packages
are installed and removed.

<br /><br />

If you want to play that music collection, install <span
style="font-style:italic;">mpg321</span> and <span
style="font-style:italic;">aumix</span>, console-based mp3 player and
volume control, respectively. For image manipulation, <span
style="font-style:italic;">imagemagick</span> is a suite of powerful
command-line image viewing and editing tools. For printing, install
CUPS and associated print filters: 
<br />

<code>aptitude install cupsys cupsys-client foomatic-filters-ppds</code>
<br />
Then open a web browser to http://localhost:631 to add a printer. For
mail, give mutt and getmail a try: <code>aptitude install mutt getmail4</code>
<br />

Remember that in Debian, extended package documentation is in
<i>/usr/share/doc/&lt;package name&gt;</i>, for example
<i>/usr/share/doc/getmail4</i>. A helpful tip - a lot of package
documentation is stored in compressed form - you can read it with
<i>zless</i>, which will uncompress it on the fly.

<br /><br />

During the Xorg server configuration, you can probably accept the
defaults to all of the questions - with <span
style="font-style:italic;">xresprobe</span> installed, critical things
like screen resolution and monitor timings will be auto-detected. When
all this is done, log out and back in as a non-root user, and type
&#8220;startx&#8221; at the prompt. Here is a look at the spartan desktop:

<p align="center">
<a href="http://blog.unixlore.net/images/desktop.png"><img src="http://blog.unixlore.net/images/desktop-thumbnail.png" alt="Icewm Desktop" /></a>
</p>

If you need to, you can redo the Xorg configuration with this:
<br />

<code>dpkg-reconfigure -phigh xserver-xorg</code>

<br />

If you would rather install a graphical login manager, you can choose
from <span style="font-style:italic;">gdm</span>, <span
style="font-style:italic;">xdm</span> or <span
style="font-style:italic;">kdm</span>, or do a package search with
<i>apt-cache search &#8220;display manager&#8221;</i>. I recommend <span
style="font-style:italic;">xdm</span>, as it has the fewest
dependencies.

<br /><br />

That&#8217;s pretty much it. At this point, you still have far less than a
gigabyte of software and OS installed, and your desktop will seem
positively snappy, even on slow hardware.

]]></content:encoded>
			<wfw:commentRss>http://blog.unixlore.net/2008/05/a-lightweight-linux-desktop.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Migrating From Blogger to Wordpress</title>
		<link>http://blog.unixlore.net/2008/02/migrating-from-blogger-to-wordpress.html</link>
		<comments>http://blog.unixlore.net/2008/02/migrating-from-blogger-to-wordpress.html#comments</comments>
		<pubDate>Fri, 29 Feb 2008 17:15:47 +0000</pubDate>
		<dc:creator>Doug</dc:creator>
		
		<category><![CDATA[upgrade]]></category>

		<category><![CDATA[wordpress]]></category>

		<category><![CDATA[blogger]]></category>

		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://blog.unixlore.net/2008/02/migrating-from-blogger-to-wordpress.html</guid>
		<description><![CDATA[As I related previously, I just upgraded to Wordpress from
Blogger. I&#8217;m using Wordpress 2.2 under Debian Etch. There were a few
snags in the upgrade, so I&#8217;d like to tell you about my solutions to
them.

Preparing for the Jump

The first thing I found was that Wordpress 2.2 has a nice new Blogger
import feature, but it requires that [...]]]></description>
			<content:encoded><![CDATA[As I related previously, I just upgraded to Wordpress from
Blogger. I&#8217;m using Wordpress 2.2 under Debian Etch. There were a few
snags in the upgrade, so I&#8217;d like to tell you about my solutions to
them.

<h2>Preparing for the Jump</h2>

The first thing I found was that Wordpress 2.2 has a nice new Blogger
import feature, but it requires that you are using the &#8220;new&#8221; Blogger
(called &#8220;Beta&#8221; for quite some time), not the old. Since I had some
Blogger template modifications, I had been resisting the urge to
upgrade. This forced my hand, however. I used the Blogger control
panel to upgrade my template, then added back my
modifications <a href="http://blog.unixlore.net/2006/03/shaded-text-boxes-in-blogger-templates.html">for
shaded blockquote and code boxes</a>. I also had previously added some
javascript code that handled &#8220;Read More..&#8221; links in posts, but I left
this out of the upgraded template.

<h2>Authentication Failures</h2>

Next, I logged into my Wordpress control panel, and went to
<span style="font-style:italic;">Manage->Import->Blogger</span>. There
was an &#8220;Authorize&#8221; link, which I clicked on, but the first time I did
this it failed Google authentication with the message &#8220;We were not
able to gain access to your account. Try starting over&#8221;. When I
clicked on &#8220;Clear account information&#8221; and tried again, the same error
would be displayed. After a little digging on the Wordpress support
forums, I
found <a href="http://wordpress.org/support/topic/131952?replies=2">a
couple of solutions</a>. One is to edit the PHP file responsible for
the import, the other is to use wordpress.com as a waypoint for
imports to your own installation. I chose the former, since this is my
own server and editing a file is much quicker than the other
method. The file
is <span style="font-style:italic;">wp-admin/import/blogger.php</span>,
you&#8217;ll find it relative to your web root, so if you have a site hosted
in
<span style="font-style:italic;">/var/www/foo</span>, the file will be
<span style="font-style:italic;">/var/www/foo/wp-admin/import/blogger.php</span>. Edit
this file and search for the
text <span style="font-style:italic;">Host: www2.blogger.com</span>
(around line 84), and change it
to <span style="font-style:italic;">Host:
www.blogger.com</span>. That&#8217;s it. Now the importer worked like a
charm. One note - this was fixed in Wordpress version 2.3, so if you
are using that version or higher, you should be fine. The importer
also won&#8217;t change your Blogger blog in any way, it just reads the
data, so it&#8217;s safe to experiment with if you&#8217;re not sure Wordpress is
for you.

<h2>Post Formatting</h2>

The next issue related to the fact that
I <a href="http://blog.unixlore.net/2006/03/using-emacs-to-edit-blog-posts.html">edited
my blog posts using Emacs</a> (I now use the Firefox
extension <a href="http://blog.unixlore.net/2007/11/great-firefox-extension-its-all-text.html">It&#8217;s
All text</a> to integrate more smoothly with Emacs). Anyway, in text
and HTML modes where you are using Emacs&#8217; auto-fill, Emacs
inserts <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Hard-and-Soft-Newlines.html#Hard-and-Soft-Newlines">soft
newlines</a>, which are not true newlines, but used just to display
formatting on-screen. Blogger&#8217;s HTML post editor ignores these
linebreaks in pasted text (as it should), but the Wordpress editor
does not; it converts these pseudo-linebreaks to real (hard)
newlines. The end result was that every one of my imported posts had
bizarre formatting when it was displayed on-screen - this even broke a
bunch of hyperlinks where the link text spanned a line boundary.

<br /><br />

After more digging, I found a Wordpress plugin that was tailor-made to
deal with this problem - Alex
King&#8217;s <a href="http://alexking.org/projects/wordpress/readme?project=wp-unformatted">WP
Unformatted</a> plugin. Once I had this installed in my
<span style="font-style:italic;">wp-content/plugins</span> directory,
I could then set a custom field in each new post with a key
of <span style="font-style:italic;">sponge</span> and a value
of <span style="font-style:italic;">1</span>.

<br /><br />

<img src="/images/wp_unformatted.jpg" alt="WP Unformatted Plugin Custom Field Setting">

<br />

The effect of this is to cause Wordpress to ignore the linebreaks in
pasted text. This works great for new posts, but what about my
100-some-odd existing posts? This is where GUI interfaces really fall
down - it would take me forever to manually set the required custom
field in each of my posts. Not to be deterred, I jumped into the MySQL
shell and started poking around the database used for the blog. I
found that the &#8220;geek_postmeta&#8221; table (&#8217;geek_&#8217; is my database prefix,
yours will be different, and is specified in
your <span style="font-style:italic;">wp-config.php</span> file) held
each post&#8217;s custom field data. I drilled in on one of the posts where
I had set the &#8217;sponge&#8217; field manually. Notice the row with the
meta_key of <span style="font-style:italic;">sponge</span> and the
meta_value of <span style="font-style:italic;">1</span>:

<br /><br />

<span style="font-size:88%;">
<code>
mysql> describe geek_postmeta;
+------------+--------------+------+-----+---------+----------------+
| Field      | Type         | Null | Key | Default | Extra          |
+------------+--------------+------+-----+---------+----------------+
| meta_id    | bigint(20)   | NO   | PRI | NULL    | auto_increment | 
| post_id    | bigint(20)   | NO   | MUL | 0       |                | 
| meta_key   | varchar(255) | YES  | MUL | NULL    |                | 
| meta_value | longtext     | YES  |     | NULL    |                | 
+------------+--------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

mysql> select * from geek_postmeta where post_id = 122;
+---------+---------+-------------------+--------------------...-+
| meta_id | post_id | meta_key          | meta_value         ... |
+---------+---------+-------------------+--------------------...-+
|     356 |     122 | blogger_blog      | blog.unixlore.net  ... | 
|     357 |     122 | blogger_author    | Doug               ... | 
|     358 |     122 | blogger_permalink   /2007/11/great-fire... | 
|     405 |     122 | sponge            | 1                  ... | 
+---------+---------+-------------------+--------------------...-+
4 rows in set (0.00 sec)

mysql>
</code>
</span>

<br />

I needed one more piece of information to proceed - the post ID&#8217;s of
all my posts. The post ID is the number displayed to the left of each
post in the Wordpress admin panel, but you can also use the MySQL
shell to get the start and end post ID&#8217;s:

<span style="font-size:88%;">
<code>
mysql> select MIN(ID) from geek_posts;
+---------+
| MIN(ID) |
+---------+
|       3 | 
+---------+
1 row in set (0.00 sec)

mysql> select MAX(ID) from geek_posts;
+---------+
| MAX(ID) |
+---------+
|     141 | 
+---------+
1 row in set (0.00 sec)
</code>
</span>

<br />

I was now ready to script a solution; this one is in Perl, feel free
to substitute your favorite language:

<br /><br />

<span style="font-size:88%;">
<code>
#!/usr/bin/perl
use DBI;
use strict;
use warnings;

my ($sth,$sql);

my $dbh = DBI->connect('DBI:mysql:wordpress:localhost','user','pass');

for (my $i=3; $i<=141;++$i) {
  next if ($i == 122 || $i == 129 || $i == 123);
  $sql = "INSERT INTO geek_postmeta (post_id,meta_key,meta_value)\
          VALUES ('$i','sponge','1')";
  print "Executing SQL: INSERT INTO geek_postmeta \
         (post_id,meta_key,meta_value) VALUES ('$i','sponge','1')\n";
  $sth = $dbh->prepare($sql);
  $sth->execute();
}
</code>
</span>

<br />

You need to modify a few things to use this code:

<br />

<ul>
<li>You need to specify your database username and password in the
<span style="font-style:italic;">DBI->connect</span> line.</li>
<li>You need to change the table
prefix <span style="font-style:italic;">geek_</span> to match your own
in the line that begins <span style="font-style:italic;">$sql =
&quot;INSERT INTO geek_postmeta&#8230;</span></li>
<li>You need to edit the starting and ending post ID&#8217;s in the for
loop. Mine were 3 and 141, respectively.</li>
<li>You may or may not need a line
like <span style="font-style:italic;">next if ($i == 122 || $i == 129
|| $i == 123)</span>. I used this to skip the post ID&#8217;s where I had
already set the custom field manually. Just edit it appropriately or
comment it out if you haven&#8217;t manually changed any posts.</li>
</ul>

<h2>Permalink Structure</h2>

Another issue I ran across had to do with permalinks. Blogger was
using the following link structure:

<br /><br />

<code>
http://blog.unixlore.net/year/month/post-name.html
</code>

<br />

This was important to me because I have a few posts that get quite a
bit of traffic, and I did not want users to get 404 errors from broken
links. I duplicated the Blogger permalink structure by specifying a
custom format in the Wordpress control panel, using the format
specifier <span style="font-style:italic;">/%year%/%monthnum%/%postname%.html</span>.

<br /><br />

<img src="/images/wp_permalinks.jpg" alt="Worpress Permalink Format Customization">

<br />

I also had to create
an <span style="font-style:italic;">.htaccess</span> file in my web
root with the following contents (this was displayed on-screen once I
set the permalink format. Your installation may be able to create the
file for you if permissions are set appropriately).

<br /><br />

<span style="font-size:88%;">
<code>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</code>
</span>

<br />

After all this, there were a few posts where the permalinks did not
match, most notably where the word &#8216;a&#8217; was in the post title
(Wordpress includes the &#8216;a&#8217;, Blogger does not). You can individually
edit a post&#8217;s permalink in Wordpress by changing
the <span style="font-style:italic;">Post Slug</span> from the post
editor as needed.

<h2>The Blogroll</h2>

The final issue I came across was how to transfer my blogroll and
lists of links I had in my Blogger sidebar. These were specified as
HTML unordered lists in my Blogger template:

<br /><br />

<span style="font-size:88%;">
<code>
    &lt;ul&gt;
       &lt;li&gt;&lt;a href=&quot;http://blog.unixlore.net/2006/...&lt;/li&gt;
       &lt;li&gt;&lt;a href=&quot;http://blog.unixlore.net/2006/...&lt;/li&gt;
       &lt;li&gt;&lt;a href=&quot;http://blog.unixlore.net/2006/...&lt;/li&gt;
       &lt;li&gt;&lt;a href=&quot;http://blog.unixlore.net/2006/...&lt;/li&gt;
    &lt;/ul&gt;
</code>
</span>

<br />

The easiest way to transfer these lists over is to place a text widget
into the site&#8217;s sidebar using the control panel (Go
to <span style="font-style:italic;">Presentation->Widgets</span>),
then edit that specific text widget and just paste the unordered list
directly into the widget&#8217;s text area, adding an appropriate title. If
you want to be able to categorize your links, you&#8217;ll need to convert
the list into OPML first (I
used <a href="http://www.smartpeer.net/jiescripts/html2opml.php">this
site to convert my list of HTML links into OPML</a>). Copy/paste the
OPML into a file, then import it
via <span style="font-style:italic;">Blogroll->Import
Links</span>. The OPML for the above list of links looks like this:

<br /><br />

<span style="font-size:88%;">
<code>
&lt;opml version="1.1"&gt;
&lt;head&gt;
&lt;title/&gt;
&lt;dateModified/&gt;
&lt;ownerName&gt;mmpower&lt;/ownerName&gt;
&lt;ownerEmail&gt;foo@example.com&lt;/ownerEmail&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;outline type=&quot;link&quot; url=&quot;http://blog.unixlore.net/... /&gt;
&lt;outline type=&quot;link&quot; url=&quot;http://blog.unixlore.net/... /&gt;
&lt;outline type=&quot;link&quot; url=&quot;http://blog.unixlore.net/... /&gt;
&lt;outline type=&quot;link&quot; url=&quot;http://blog.unixlore.net/... /&gt;
&lt;/body&gt;
&lt;/opml&gt;
</code>
</span>

<br />

That&#8217;s pretty much everything. Probably the hardest part was dealing
with the unformatted posts; if you use the various visual post
editors, you probably won&#8217;t run into that problem.

<br />

]]></content:encoded>
			<wfw:commentRss>http://blog.unixlore.net/2008/02/migrating-from-blogger-to-wordpress.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Migrated From Blogger to Wordpress</title>
		<link>http://blog.unixlore.net/2008/02/migrated-from-blogger-to-wordpress.html</link>
		<comments>http://blog.unixlore.net/2008/02/migrated-from-blogger-to-wordpress.html#comments</comments>
		<pubDate>Thu, 28 Feb 2008 21:38:04 +0000</pubDate>
		<dc:creator>Doug</dc:creator>
		
		<category><![CDATA[meta]]></category>

		<guid isPermaLink="false">http://blog.unixlore.net/2008/02/migrated-from-blogger-to-wordpress.html</guid>
		<description><![CDATA[I&#8217;ve just migrated the original Blogger blog over to Wordpress - I&#8217;ve been using Wordpress for a while, and am pretty comfortable with it. It&#8217;s also nice to get away from shared hosting, this blog is being hosted on my own server.



I&#8217;m going to put something up shortly with the details of how the migration [...]]]></description>
			<content:encoded><![CDATA[I&#8217;ve just migrated the original Blogger blog over to <a href="http://www.wordpress.org">Wordpress</a> - I&#8217;ve been using Wordpress for a while, and am pretty comfortable with it. It&#8217;s also nice to get away from shared hosting, this blog is being hosted on my own server.

<br /><br />

I&#8217;m going to put something up shortly with the details of how the migration went, there were definitely some hiccups; hopefully the details will help others looking to get away from Blogger. Anyway, everything seems to be running well now, let me know if I missed any links, and be sure to update your feeds to the new feed address: http://blog.unixlore.net/feed.
]]></content:encoded>
			<wfw:commentRss>http://blog.unixlore.net/2008/02/migrated-from-blogger-to-wordpress.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Blogging Hiatus &#38; Random Thoughts</title>
		<link>http://blog.unixlore.net/2008/02/blogging-hiatus-random-thoughts.html</link>
		<comments>http://blog.unixlore.net/2008/02/blogging-hiatus-random-thoughts.html#comments</comments>
		<pubDate>Mon, 18 Feb 2008 13:49:00 +0000</pubDate>
		<dc:creator>Doug</dc:creator>
		
		<category><![CDATA[usenet]]></category>

		<category><![CDATA[blogging]]></category>

		<category><![CDATA[musings]]></category>

		<category><![CDATA[updates]]></category>

		<guid isPermaLink="false">http://geekpit.net/?p=136</guid>
		<description><![CDATA[I&#8217;ve been taking a break from blogging lately (as you can see from my
last post). Blogs are interesting things. I&#8217;m not sure blogging itself
was a very new or even ingenious idea; I think advances in search,
coupled with ideas like tagging and the accessibility of a pure
browser-based content medium made the idea of blogging more appealing
(You [...]]]></description>
			<content:encoded><![CDATA[I&#8217;ve been taking a break from blogging lately (as you can see from my
last post). Blogs are interesting things. I&#8217;m not sure blogging itself
was a very new or even ingenious idea; I think advances in search,
coupled with ideas like tagging and the accessibility of a pure
browser-based content medium made the idea of blogging more appealing
(You mean someone might actually read what I write?). I had a
PHP-Nuke-based pseudo-blog back in 2000-2001; I used it as a way to
distribute software and howtos. There were certainly many online
journals prior to that, they just weren&#8217;t called blogs.

<br /><br />

From a purely utilitarian standpoint, Usenet is a much nicer medium
for conversations (Blogger&#8217;s posting model is particularly
bad). However, if you want to get noticed and perhaps make some money
from what you write, blogs are it. Blogging has also changed the
political landscape forever. I came
across <a href="http://www.timheuer.com/blog/archive/2003/11/22/279.aspx">this
decent comparison of blogs and Usenet recently</a> (noted with some
irony that I&#8217;m linking to a blog and not a Usenet post).

<br /><br />

Anyway, just some musings, I&#8217;ll have some more posts up shortly&#8230;]]></content:encoded>
			<wfw:commentRss>http://blog.unixlore.net/2008/02/blogging-hiatus-random-thoughts.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Excursions With Find, Xargs, and Perl</title>
		<link>http://blog.unixlore.net/2007/11/excursions-with-find-xargs-and-perl.html</link>
		<comments>http://blog.unixlore.net/2007/11/excursions-with-find-xargs-and-perl.html#comments</comments>
		<pubDate>Thu, 29 Nov 2007 03:56:00 +0000</pubDate>
		<dc:creator>Doug</dc:creator>
		
		<category><![CDATA[find]]></category>

		<category><![CDATA[sysadmin]]></category>

		<category><![CDATA[chmod]]></category>

		<category><![CDATA[xargs]]></category>

		<category><![CDATA[Perl]]></category>

		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://geekpit.net/?p=129</guid>
		<description><![CDATA[It&#8217;s a common sysadmin task to want to change permissions on all the
files and subdirectories under a top-level directory. You could just
use the &#8216;-R&#8217; switch
to chmod,
but what if your files and directories need different permissions? One
scenario that comes up is with shared directories - you have a
directory tree that has to be writable by users [...]]]></description>
			<content:encoded><![CDATA[It&#8217;s a common sysadmin task to want to change permissions on all the
files and subdirectories under a top-level directory. You could just
use the &#8216;-R&#8217; switch
to <span style="font-weight:bold;"><a href="http://www.gnu.org/software/coreutils/manual/html_node/chmod-invocation.html">chmod</a></span>,
but what if your files and directories need different permissions? One
scenario that comes up is with shared directories - you have a
directory tree that has to be writable by users in a specific
group. To do this you want to set the group ID bit on all the
directories, so that files created by an individual user are always
writable by the entire group (this is numeric permission mode
2775). We want regular files to just have permissions 664.

<h2>Find</h2>

So we first need a way to differentiate files and directories - one
easy way is with
the <span style="font-weight:bold;"><a href="http://www.gnu.org/software/findutils/manual/html_node/find_html/index.html">find</a></span>
command, which as a bonus will also recurse into subdirectories for
us. Here&#8217;s our first crack at a solution - let&#8217;s assume we have
changed to the top-level directory we are interested in already:

<br /><br />

<code>
find . -type f -exec chmod 664 {} \;
find . -type d -exec chmod 2775 {} \;
</code>

<br />

A word of warning - <span style="font-weight:bold;">don&#8217;t</span> try
something like &#8220;find . -type f | chmod 664 *&#8221; - chmod will ignore its
standard input and change the permissions on all the files in the
current directory. This is easily fixable by just re-running chmod,
but it would be a disaster if you were trying to delete only certain
files or directories. Anyway, in the command above, the &#8220;-type f&#8221; and
&#8220;-type d&#8221; output just files and just directories, respectively. The
&#8220;-exec&#8221; will execute the given command on each file or directory
produced by find. The special construct &#8220;{}&#8221; is a placeholder for the
current argument, as output by find. These commands will work, but
they are very slow on large directory trees, since the chmod is
operating on one file or directory at a time. We could try to improve
the speed by feeding the entire output of find to chmod:

<br /><br />

<code>
chmod 664 $(find . -type f)
chmod 2775 $(find . -type d)
</code>

<h2>Xargs</h2>

These last two commands will work fine until we have more than a few
dozen files or directories in total - if we do, we&#8217;ll get the error
&#8220;/bin/chmod: Argument list too long&#8221;. That&#8217;s a cue that we should be
using <span style="font-weight:bold;"><a href="http://www.ctssn.com/man/index.cgi?section=all&#038;topic=xargs">xargs</a></span>,
a very useful command that will submit its input in manageable chunks
to the specified command. Here is our next try:

<br /><br />

<code>
find . -type f | xargs chmod 664
find . -type d | xargs chmod 2775
</code>

<br />

This is better - the errors about the command line being too long will
go away, and this will work, most of the time. But what happens if we
have directories or filenames with spaces, quotes or other special
characters in them? This comes up quite a bit when you have
transferred files from Windows filesystems - the end result will be
that xargs will mangle its input, and the command will fail with an
error like <span style="font-style:italic;">xargs: unmatched single
quote; by default quotes are special to xargs unless you use the -0
option</span>. The error leads us in the right direction, the solution
is to use a couple of options to find and xargs that go
together: <span style="font-weight:bold;">-print0</span>
and <span style="font-weight:bold;">-0</span>.

<br /><br />

<blockquote>
<span style="font-weight:bold;">-print0</span>: Find option that
prints the full filename to standard output, terminated by a null
character instead of a newline.
<br /><br />
<span style="font-weight:bold;">-0</span>: Xargs option that says
input is terminated by a null character, rather than a newline, and
all characters are treated literally (even quotes or backslashes).
</blockquote>

<br />

Here is our final attempt with find and xargs:

<br /><br />

<code>
find . -type f -print0 | xargs -0 chmod 664
find . -type d -print0 | xargs -0 chmod 2775
</code>

<br />

This will work for us all the time, no matter what special characters
comprise file or directory names.

<h2>Perl</h2>

There are some versions of find that don&#8217;t support the &#8220;-print0&#8243;
switch. On these systems, you may be able to use a <a
href="http://perl.org">Perl</a> solution:

<br /><br />

<code>
perl -MFile::Find -e 'find sub { -f &#038;&#038; chmod 0664, $_; \
                                 -d &#038;&#038; chmod 02775, $_ },"."'
</code>

<br />

The <span style="font-weight:bold;">find</span> procedure exported by
the the <span style="font-weight:bold;"><a
href="http://search.cpan.org/~rgarcia/perl/lib/File/Find.pm">File::Find</a></span>
module takes two arguments - a callback subroutine and a list of
directories. It will recursively descend into the list of supplied
directories (in this case just the current directory &#8220;.&#8221;), and run the
callback subroutine on each file or directory found. The subroutine in
this case is an anonymous one, given by &#8220;sub { -f &#038;&#038; chmod 0664, $_;
-d &#038;&#038; chmod 02775, $_ }&#8221;. It first tests whether the current argument
is a regular file, if it is it performs the required &#8220;chmod 664&#8243;. It
then tests whether the current argument is a directory, and as you
might expect, performs the required &#8220;chmod 2775&#8243;. The variable &#8220;$_&#8221;
represents the current argument, in this case whatever the current
file or directory name is. Note also that the numeric permissions must
always have a leading zero so that the Perl interpreter knows they are
octal numbers.

<br /><br />

This solution has the advantage of working on any Unix system that has
Perl installed, since File::Find is a core Perl module.

<br /><br />

I was curious about how fast each solution ran, here are the timings
on a directory tree with 9105 files and 370 directories:

<code>
time find . -type f -exec chmod 664 {} \;

real    0m15.687s
user    0m5.676s
sys     0m9.877s

time find . -type f -print0 | xargs -0 chmod 664

real    0m0.132s
user    0m0.036s
sys     0m0.080s

time perl -MFile::Find -e 'find sub { -f &#038;&#038; chmod 0664, $_; },"."'

real    0m0.151s
user    0m0.080s
sys     0m0.056s

time perl -MFile::Find -e 'find sub { -f &#038;&#038; chmod 0664, $_; \
-d &#038;&#038; chmod 02775, $_ },"."'

real    0m0.160s
user    0m0.064s
sys     0m0.076s
</code>

<br /><br />

The Perl solution was surprisingly fast, very much comparable to the
xargs solution. When you consider that the last Perl solution timed
tests for both files and directories at once, it is faster than
running two xargs commands in a row.

<br /><br />]]></content:encoded>
			<wfw:commentRss>http://blog.unixlore.net/2007/11/excursions-with-find-xargs-and-perl.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Article Roundup</title>
		<link>http://blog.unixlore.net/2007/11/article-roundup-30.html</link>
		<comments>http://blog.unixlore.net/2007/11/article-roundup-30.html#comments</comments>
		<pubDate>Fri, 23 Nov 2007 23:35:00 +0000</pubDate>
		<dc:creator>Doug</dc:creator>
		
		<category><![CDATA[roundup]]></category>

		<guid isPermaLink="false">http://geekpit.net/?p=123</guid>
		<description><![CDATA[Some humor from WTF-d00d.com
- Bourne shell server
  pages. Classic:




The basic idea behind all server page technologies is this: rather
than writing code that generates an HTML document on-the-fly by
writing it out as a series of print statements, you start with a
&#8220;skeleton&#8221; HTML document and embed the code right inside it. Voila!
Instead of having a tangled, [...]]]></description>
			<content:encoded><![CDATA[Some humor from WTF-d00d.com
- <a href="http://hyperrealm.com/wtfd00d/shsp/">Bourne shell server
  pages</a>. Classic:

<br /><br />

<blockquote>
The basic idea behind all server page technologies is this: rather
than writing code that generates an HTML document on-the-fly by
writing it out as a series of print statements, you start with a
&#8220;skeleton&#8221; HTML document and embed the code right inside it. Voila!
Instead of having a tangled, unreadable, unmaintainable mess of HTML
embedded in source code, you have a tangled, unreadable,
unmaintainable mess of source code embedded in HTML.
<br /><br />
Bourne Shell Server Pages are ordinary ASCII text files, with the
special extension .shit, which denotes &#8220;Shell-Interpreted Template.&#8221;
The result of invoking the page compiler on a .shit file, is,
naturally, a shell script.
</blockquote>

<br />

and yet&#8230;the minimalist in me thinks this might be a good idea&#8230;

<br /><br />

Didier Stevens wanted to see
if <a href="http://blog.didierstevens.com/2007/05/07/is-your-pc-virus-free-get-it-infected-here/">people
  would click on an ad that offered to infect them with a
  virus</a>. Short version, they did.

<br /><br />

Mark Pilgrim expresses
his <a href="http://diveintomark.org/archives/2007/11/19/the-future-of-reading">frustrations
with Amazon&#8217;s new ebook reader and DRM</a>.

<br /><br />

More humor
- <a href="http://blogoscoped.com/archive/2007-11-20-n35.html">what if
Gmail had been designed by Microsoft</a>?.

<br /><br />

Finally, <a href="http://www.howtoforge.com/enable-multiple-https-sites-on-one-ip-using-tls-extensions-on-debian-etch">you
can run multiple HTTPS sites off of one IP address with OpenSSL and
TLS extensions</a>. You
can <a href="http://www.g-loaded.eu/2007/08/10/ssl-enabled-name-based-apache-virtual-hosts-with-mod_gnutls/">also
do this with mod_gnutls</a>.

<br /><br />]]></content:encoded>
			<wfw:commentRss>http://blog.unixlore.net/2007/11/article-roundup-30.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Great Firefox Extension - It&#8217;s All Text!</title>
		<link>http://blog.unixlore.net/2007/11/great-firefox-extension-its-all-text.html</link>
		<comments>http://blog.unixlore.net/2007/11/great-firefox-extension-its-all-text.html#comments</comments>
		<pubDate>Sun, 18 Nov 2007 01:53:00 +0000</pubDate>
		<dc:creator>Doug</dc:creator>
		
		<category><![CDATA[text editing]]></category>

		<category><![CDATA[extension]]></category>

		<category><![CDATA[firefox]]></category>

		<category><![CDATA[Emacs]]></category>

		<guid isPermaLink="false">http://geekpit.net/?p=122</guid>
		<description><![CDATA[I just came
across a
great Firefox extension called &#34;It&#8217;s All Text!&#34;. Any
HTML textarea you see while browsing gets a
little edit button on the
bottom right corner - clicking it launches your favorite editor (the
frst time you use it, it brings you to the preferences screen). For
me, that&#8217;s GNU Emacs. 



To use it with Emacs, just add (server-start) [...]]]></description>
			<content:encoded><![CDATA[I just came
across <a href="https://addons.mozilla.org/en-US/firefox/addon/4125">a
great Firefox extension called &quot;It&#8217;s All Text!&quot;</a>. Any
HTML textarea you see while browsing gets a
little <span style="font-weight:bold;">edit</span> button on the
bottom right corner - clicking it launches your favorite editor (the
frst time you use it, it brings you to the preferences screen). For
me, that&#8217;s GNU Emacs. 

<br /><br />

To use it with Emacs, just add <code>(server-start)</code> to
your <span style="font-style:italic;">.emacs</span> and
use <span style="font-style:italic;">/usr/bin/emacsclient</span> as
your editor in the preferences dialog. Now when you click on the
&#8216;edit&#8217; button, you&#8217;ll get a new, empty Emacs buffer to type in. When
you are done, type <span style="font-style:italic;">C-x #</span> to
close the buffer and get back to the browser. You&#8217;ll see the contents
of the Emacs buffer in the text window. Made a mistake? Clicking
&#8216;edit&#8217; a second or subsequent time will copy whatever is in the
textarea into your editor once again.

<br /><br />]]></content:encoded>
			<wfw:commentRss>http://blog.unixlore.net/2007/11/great-firefox-extension-its-all-text.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Article Roundup</title>
		<link>http://blog.unixlore.net/2007/11/article-roundup-29.html</link>
		<comments>http://blog.unixlore.net/2007/11/article-roundup-29.html#comments</comments>
		<pubDate>Sat, 17 Nov 2007 02:33:00 +0000</pubDate>
		<dc:creator>Doug</dc:creator>
		
		<category><![CDATA[roundup]]></category>

		<guid isPermaLink="false">http://geekpit.net/?p=121</guid>
		<description><![CDATA[This Code Goes to Eleven asks
if adding
namespaces to PHP can save it. That question presupposes that PHP
is in need of saving - for better or worse, I think PHP is far too
widely used at this point to be in danger of extinction. But yes, the
lack of proper namespaces in PHP is a royal pain for [...]]]></description>
			<content:encoded><![CDATA[This Code Goes to Eleven asks
if <a
href="http://codeeleven.blogspot.com/2007/11/can-namespaces-alone-save-php.html">adding
namespaces to PHP can save it</a>. That question presupposes that PHP
is in need of saving - for better or worse, I think PHP is far too
widely used at this point to be in danger of extinction. But yes, the
lack of proper namespaces in PHP is a royal pain for anything outside of a
trivial script.

<br /><br />

You have to worry when Bruce Schneier wonders
if <a
href="http://www.wired.com/politics/security/commentary/securitymatters/2007/11/securitymatters_1115">the
NSA put a backdoor in the new PRNG standard</a>.

<br /><br />

<a
   href="http://ca.today.reuters.com/news/newsArticle.aspx?type=entertainmentNews&#038;storyID=2007-11-14T183959Z_01_N14187018_RTRIDST_0_ENTERTAINMENT-KISS-COL.XML">Gene
   Simmons is an idiot</a>. Perhaps he should speak to one
   of <a
   href="http://www.magnatune.com/">these</a> <a
   href="http://www.radiohead.com/deadairspace/">gentlemen</a>. They
   seem to be doing quite well, despite the evil music downloaders.

<br /><br />

Emacs fans who still like to read printed
manuals, <a href="http://www.gnu.org/doc/emacs16.html">the GNU Emacs
manual for the latest version 22</a> is finally out in paperback.

<br /><br />

TechRepublic talks
about <a
href="http://articles.techrepublic.com.com/2415-10877_11-176034.html">alternative
Linux desktops</a>.

<br /><br />

OFB.biz has a good series of articles
on <a
href="http://www.ofb.biz/go/Computers%20and%20Technology/Linux%20and%20BSD%20on%20the%20Desktop/FreeBSD/">desktop
FreeBSD</a>.

<br /><br />]]></content:encoded>
			<wfw:commentRss>http://blog.unixlore.net/2007/11/article-roundup-29.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Do You Run X on Linux or Unix Servers?</title>
		<link>http://blog.unixlore.net/2007/11/do-you-run-x-on-linux-or-unix-servers.html</link>
		<comments>http://blog.unixlore.net/2007/11/do-you-run-x-on-linux-or-unix-servers.html#comments</comments>
		<pubDate>Fri, 16 Nov 2007 04:37:00 +0000</pubDate>
		<dc:creator>Doug</dc:creator>
		
		<category><![CDATA[servers]]></category>

		<category><![CDATA[X-Windows]]></category>

		<category><![CDATA[unix]]></category>

		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://geekpit.net/?p=120</guid>
		<description><![CDATA[I very infrequently install X11/Xorg on any servers, unless I&#8217;m doing an install for a client and they ask for it.  My most common server install is a base installation of Debian stable that weighs in at about 300MB. I always thought there was no need for a graphical display on a server, for [...]]]></description>
			<content:encoded><![CDATA[I very infrequently install X11/Xorg on any servers, unless I&#8217;m doing an install for a client and they ask for it.  My most common server install is a base installation of Debian stable that weighs in at about 300MB. I always thought there was no need for a graphical display on a server, for the standard reasons: 

<br /><br />

<ul>
<li>The X server uses resources better devoted to key server processes</li>
<li>There are security implications to having the additional libraries and binaries on a system</li>
<li>The command line is much more efficient when you need to get something done</li>
</ul>

<br />

Of course, you can leave out the X server, and just install the needed X clients. SSH works great with its built-in X forwarding. But you still have a potential security problem to deal with on the server itself - local privilege escalation from an insecure X binary, for example.

<br /><br />

It seems things have been changing lately. Memory and CPU are more plentiful, so resources are not as much of a concern as they were even five years ago. Default installs from the commercial Linux vendors install a full-blown graphical desktop, as much as they still offer the choice of a minimal installation. Security will always be an issue, but SELinux and AppArmor ease the concerns for buffer overflows and privilege escalation. And there are some useful graphical tools with features that would be hard to replicate from a shell - Red Hat&#8217;s virtual machine manager comes to mind. I still refuse to install X on servers, mainly because I&#8217;m habituated to years of shell use (hell, even on my desktops I spend a disproportionate amount of time in a terminal or Emacs buffer). There just seems to be less reason <span style="font-weight:bold;">not</span> to install X these days, apart from personal preference.

<br /><br />

So I&#8217;m wondering, do you install X on your servers, or recommend it for your clients or employer? If so, why?

<br /><br />]]></content:encoded>
			<wfw:commentRss>http://blog.unixlore.net/2007/11/do-you-run-x-on-linux-or-unix-servers.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Can a small business afford not to run Linux?</title>
		<link>http://blog.unixlore.net/2007/11/can-small-business-afford-not-to-run.html</link>
		<comments>http://blog.unixlore.net/2007/11/can-small-business-afford-not-to-run.html#comments</comments>
		<pubDate>Tue, 13 Nov 2007 23:58:00 +0000</pubDate>
		<dc:creator>Doug</dc:creator>
		
		<category><![CDATA[small business]]></category>

		<category><![CDATA[windows]]></category>

		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://geekpit.net/?p=119</guid>
		<description><![CDATA[There&#8217;s an interesting article at ITWire on whether or not a small business afford not to run Linux. The conclusion of the author is that small business should be running Linux, both on the desktop and server. One part of the article caught my eye:
 I copped some flack from the Windows crowd for some [...]]]></description>
			<content:encoded><![CDATA[There&#8217;s an interesting article at ITWire on whether or not <a href="http://www.itwire.com.au/content/view/15298/1023/">a small business afford <span style="font-weight: bold">not</span> to run Linux</a>. The conclusion of the author is that small business should be running Linux, both on the desktop and server. One part of the article caught my eye:
<blockquote> I copped some flack from the Windows crowd for some comments in the prequel to this story in which I expressed my dismay at how slow my highly configured computer ran under Windows Home Server&#8230;Apparently, this was my fault according to those who serve Redmond. I should have configured and optimised my computer correctly, chosen my security package more wisely, so I was just an idiot and a dumbass who didn&#8217;t know what he was talking about&#8230;Believe it or not, like most people who use computers for work, I don&#8217;t have time to fiddle around to optimise my computers and network.</blockquote>
This is understandable, small-business owners don&#8217;t have time to waste tweaking server and desktop settings to get something usable. They want something that works out-of-the-box. Next comes this:
<blockquote> &#8230;how come when I partitioned my disk and installed a dual boot Ubuntu 7.10 system without any special tweaking, only then, when I had Linux up and running, did my computer give me the sort of performance I expected from the hardware?</blockquote>
This was the surprising part - for years, Windows advocates have picked on Linux for the need to configure and tweak it - largely true. It&#8217;s only been the last year or so that Linux distributions like Ubuntu and Fedora have garnered enough hardware and video support to make installation and configuration pretty painless. Witness the automatic printer configuration in Ubuntu 7.10, for example, or the automatic X-configuration that happens now under Xorg.]]></content:encoded>
			<wfw:commentRss>http://blog.unixlore.net/2007/11/can-small-business-afford-not-to-run.html/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
