<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>loopkid: Category Linux</title>
    <link>http://loopkid.net/articles/category/linux</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>sad songs make me happy</description>
    <item>
      <title>predefined character classes in grep</title>
      <description>&lt;blockquote&gt;
    &lt;p&gt;Many regex implementations have &amp;#8220;macros&amp;#8221; for various character classes. In Perl, for example, \d matches any digit ([0-9]) and \w matches any &amp;#8220;word character&amp;#8221; ([a-zA-Z0-9_]). Grep uses a slightly different notation for the same thing: [:digit:] for digits and [:alnum:] for alphanumeric characters. (&lt;a href="http://www.bsd.org/regexintro.html"&gt;BSD&lt;/a&gt;)&lt;/p&gt;
    
    &lt;p&gt;Finally,  certain  named classes of characters are predefined within bracket expressions, as follows. Their names are self explanatory, and they are [:alnum:], [:alpha:], [:cntrl:], [:digit:], [:graph:], [:lower:], [:print:], [:punct:], [:space:], [:upper:], and [:xdigit:].  For example, [[:alnum:]] means [0-9A-Za-z]. (&lt;a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?grep"&gt;grep man page&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Was unter Ruby&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;line = "length 1450"
puts line if line =~ /\d{4}/
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;heißt wird also unter der bash mit grep zu&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;export line="length 1450"
echo $line | egrep [[:digit:]]{4}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;was zwar die regulären Ausdrücke unnötig aufbläht, aber immerhin die gleiche Funktionalität zur Verfügung stellt.&lt;/p&gt;</description>
      <pubDate>Sun, 06 Jul 2008 15:54:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:b2ca6c21-592f-47f8-a7b7-d788580bd74f</guid>
      <author>Stefan</author>
      <link>http://loopkid.net/articles/2008/07/06/predefined-character-classes-in-grep</link>
      <category>Mac OS X</category>
      <category>Linux</category>
      <category>Ruby</category>
      <trackback:ping>http://loopkid.net/articles/trackback/8551</trackback:ping>
    </item>
    <item>
      <title>beautiful network monitoring</title>
      <description>&lt;p&gt;Monitoring networks with &lt;a href="http://www.tcpdump.org/"&gt;tcpdump&lt;/a&gt; works fine, but even in quiet mode tcpdump outputs too much information if you&amp;#8217;re interested in application layer protocols like HTTP or IMAP. A nice alternative on the command line is &lt;a href="http://ngrep.sourceforge.net/"&gt;ngrep&lt;/a&gt; which has a much more readable output. ngrep filters all tcp packets with an empty data part and strips the header of non-empty tcp packets. The only beauty flaw in my eyes is the dot ngrep inserts for every tab and for every carriage return. In my opinion it should offer an option to specify the tabulator size and just ignore the carriage returns.&lt;/p&gt;

&lt;p&gt;But see for yourself, here the tcpdump output of an IMAP session,&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo tcpdump -i en1 -A -s 0 -qtn port imap
tcpdump: verbose output suppressed,
use -v or -vv for full protocol decode
listening on en1, link-type EN10MB (Ethernet),
capture size 65535 bytes
IP 192.168.2.22.50556 &amp;gt; 80.237.145.78.143: tcp 0
E..@..@.@.......P..N.|...7.n........Go.............
/!..........
IP 80.237.145.78.143 &amp;gt; 192.168.2.22.50556: tcp 0
E..&amp;lt;..@.9...P..N.......|.....7.o...............
w.A./!......
IP 192.168.2.22.50556 &amp;gt; 80.237.145.78.143: tcp 0
E..4..@.@.......P..N.|...7.o...............
/!..w.A.
IP 80.237.145.78.143 &amp;gt; 192.168.2.22.50556: tcp 21
E..I..@.9...P..N.......|.....7.o...........
w.A./!..* OK Dovecot ready.

IP 192.168.2.22.50556 &amp;gt; 80.237.145.78.143: tcp 0
E..4.P@.@..j....P..N.|...7.o...............
/!..w.A.
IP 192.168.2.22.50556 &amp;gt; 80.237.145.78.143: tcp 33
E..U.8@.@..`....P..N.|...7.o...............
/!.2w.A.1 LOGIN foo@bar.net password

IP 80.237.145.78.143 &amp;gt; 192.168.2.22.50556: tcp 0
E..4..@.9...P..N.......|.....7.......&amp;lt;.....
w.F'/!.2
IP 80.237.145.78.143 &amp;gt; 192.168.2.22.50556: tcp 17
E..E..@.9...P..N.......|.....7......c......
w.F./!.21 OK Logged in.

IP 192.168.2.22.50556 &amp;gt; 80.237.145.78.143: tcp 0
E..4.0@.@.......P..N.|...7.....?.....D.....
/!.&amp;gt;w.F.
IP 192.168.2.22.50556 &amp;gt; 80.237.145.78.143: tcp 14
E..B.#@.@.......P..N.|...7.....?...........
/!.cw.F.1 LIST """%"

IP 80.237.145.78.143 &amp;gt; 192.168.2.22.50556: tcp 0
E..4..@.9...P..N.......|...?.7.............
w.H./!.c
IP 80.237.145.78.143 &amp;gt; 192.168.2.22.50556: tcp 513
E..5..@.9...P..N.......|...?.7.............
w.H./!.c* LIST (\HasChildren) "." "Trash"
* LIST (\HasNoChildren) "." "Sent"
* LIST (\HasNoChildren) "." "Spam"
* LIST (\HasNoChildren) "." "Sent Messages"
* LIST (\HasNoChildren) "." "Drafts"
* LIST (\HasNoChildren) "." "Spamtraining"
* LIST (\HasNoChildren) "." "Hamtraining"
* LIST (\HasNoChildren) "." "Spamtesting"
* LIST (\HasNoChildren) "." "Hamtesting"
* LIST (\HasNoChildren) "." "Deleted Messages"
* LIST (\HasNoChildren) "." "Spamverdacht"
* LIST (\HasNoChildren) "." "INBOX"
1 OK List completed.

IP 192.168.2.22.50556 &amp;gt; 80.237.145.78.143: tcp 0
E..4]'@.@.8.....P..N.|...7.....@...........
/!.cw.H.
IP 192.168.2.22.50556 &amp;gt; 80.237.145.78.143: tcp 10
E..&amp;gt;.L@.@..c....P..N.|...7.....@.....N.....
/!..w.H.1 LOGOUT

IP 80.237.145.78.143 &amp;gt; 192.168.2.22.50556: tcp 19
E..G..@.9...P..N.......|...@.7.............
w.IP/!..* BYE Logging out

IP 192.168.2.22.50556 &amp;gt; 80.237.145.78.143: tcp 0
E..4.I@.@..p....P..N.|...7.....S.....%.....
/!..w.IP
IP 80.237.145.78.143 &amp;gt; 192.168.2.22.50556: tcp 24
E..L..@.9...P..N.......|...S.7.............
w.IP/!..1 OK Logout completed.

IP 192.168.2.22.50556 &amp;gt; 80.237.145.78.143: tcp 0
E..4C#@.@.R.....P..N.|...7.....l...........
/!..w.IP
IP 192.168.2.22.50556 &amp;gt; 80.237.145.78.143: tcp 0
E..4.;@.@.......P..N.|...7.....l...........
/!..w.IP
IP 80.237.145.78.143 &amp;gt; 192.168.2.22.50556: tcp 0
E..4..@.9...P..N.......|...l.7.......j.....
w.IQ/!..

20 packets captured
28 packets received by filter
0 packets dropped by kernel
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;compared with the corresponding ngrep output.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo ngrep -d en1 -W byline port imap
interface: en1 (192.168.2.0/255.255.255.0)
filter: (ip) and ( port imap )
####
T 80.237.145.78:143 -&amp;gt; 192.168.2.22:50556 [AP]
* OK Dovecot ready..

##
T 192.168.2.22:50556 -&amp;gt; 80.237.145.78:143 [AP]
1 LOGIN foo@bar.net password.

##
T 80.237.145.78:143 -&amp;gt; 192.168.2.22:50556 [AP]
1 OK Logged in..

##
T 192.168.2.22:50556 -&amp;gt; 80.237.145.78:143 [AP]
1 LIST """%".

##
T 80.237.145.78:143 -&amp;gt; 192.168.2.22:50556 [AP]
* LIST (\HasChildren) "." "Trash".
* LIST (\HasNoChildren) "." "Sent".
* LIST (\HasNoChildren) "." "Spam".
* LIST (\HasNoChildren) "." "Sent Messages".
* LIST (\HasNoChildren) "." "Drafts".
* LIST (\HasNoChildren) "." "Spamtraining".
* LIST (\HasNoChildren) "." "Hamtraining".
* LIST (\HasNoChildren) "." "Spamtesting".
* LIST (\HasNoChildren) "." "Hamtesting".
* LIST (\HasNoChildren) "." "Deleted Messages".
* LIST (\HasNoChildren) "." "Spamverdacht".
* LIST (\HasNoChildren) "." "INBOX".
1 OK List completed..

##
T 192.168.2.22:50556 -&amp;gt; 80.237.145.78:143 [AP]
1 LOGOUT.

#
T 80.237.145.78:143 -&amp;gt; 192.168.2.22:50556 [AP]
* BYE Logging out.

##
T 80.237.145.78:143 -&amp;gt; 192.168.2.22:50556 [AFP]
1 OK Logout completed..

28 received, 0 dropped
&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Fri, 27 Jun 2008 17:10:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:5b8805e4-8fbb-448a-80a6-cc5b9e934bf1</guid>
      <author>Stefan</author>
      <link>http://loopkid.net/articles/2008/06/27/beautiful-network-monitoring</link>
      <category>English</category>
      <category>Mac OS X</category>
      <category>Linux</category>
      <trackback:ping>http://loopkid.net/articles/trackback/8419</trackback:ping>
    </item>
    <item>
      <title>tcpdump: packets dropped by kernel</title>
      <description>&lt;p&gt;tcpdump is a really nice tool, but it may render useless with it&amp;#8217;s default settings.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo tcpdump -i en1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In my case led to&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;80 packets captured
7705 packets received by filter
6794 packets dropped by kernel
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To solve the issue I had to turn off address translation.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo tcpdump -i en1 -n
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now the results look as expected.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;6941 packets captured
7011 packets received by filter
0 packets dropped by kernel
&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Wed, 25 Jun 2008 09:49:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:169ab5cb-2ba5-4fc8-952d-04ee4782e17b</guid>
      <author>Stefan</author>
      <link>http://loopkid.net/articles/2008/06/25/tcpdump-packets-dropped-by-kernel</link>
      <category>English</category>
      <category>Mac OS X</category>
      <category>Linux</category>
      <trackback:ping>http://loopkid.net/articles/trackback/8350</trackback:ping>
    </item>
    <item>
      <title>memory allocation error in aptitude</title>
      <description>&lt;p&gt;If you encounter the following error while searching with aptitude or apt-cache&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
Aborted
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;you might be able to resolve the situation easily with a&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo aptitude clean
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;which at least helped in my case.&lt;/p&gt;</description>
      <pubDate>Tue, 17 Jun 2008 23:33:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:aff0de56-42ca-424d-a914-e50948a0ecaa</guid>
      <author>Stefan</author>
      <link>http://loopkid.net/articles/2008/06/17/memory-allocation-error-in-aptitude</link>
      <category>Linux</category>
      <category>Debian</category>
      <trackback:ping>http://loopkid.net/articles/trackback/8202</trackback:ping>
    </item>
    <item>
      <title>documentation style</title>
      <description>&lt;blockquote&gt;
    &lt;p&gt;Meine Dokumentationen sehen oft nicht anders aus als Auszüge aus der .bash_history zusammen mit Listings oder Diffs von Konfigurations-Dateien und einigen Erklärungen dazu. Zum Beispiel warum eine bestimmte Version einer Software eingesetzt werden musste oder dergleichen.&lt;br/&gt;
    (&lt;a href="http://www.arnebrodowski.de/blog/423-Dokumentation-ist-alles.html"&gt;Arne Brodowski&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Es ist immer schön, wenn man das Gefühl hat nicht allein da draußen zu sein.&lt;/p&gt;</description>
      <pubDate>Fri, 08 Feb 2008 17:46:43 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:7dc5357d-ad02-4851-8186-bc9246459990</guid>
      <author>Stefan</author>
      <link>http://loopkid.net/articles/2008/02/08/documentation-style</link>
      <category>Mac OS X</category>
      <category>Linux</category>
    </item>
    <item>
      <title>wiki is a foreign word for ruby</title>
      <description>&lt;p&gt;Wieso gibt es eigentlich in Ruby im Gegensatz zu &lt;a href="http://wiki.splitbrain.org/wiki:dokuwiki"&gt;PHP&lt;/a&gt; oder &lt;a href="http://moinmo.in/"&gt;Phython&lt;/a&gt; eigentlich keine ausgereifte Wikiengine ? Als die einzigen halbwegs ernstzunehmenden Kandidaten erscheinen mir &lt;a href="http://www.instiki.org/"&gt;Instiki&lt;/a&gt; und &lt;a href="http://pandora.rubyveil.com/"&gt;Pandora&lt;/a&gt;, wobei ersteres immer noch keine Löschfunktion für einzelne Wiki-Seiten oder Wiki-Bereiche besitzt und bei letzterem die Entwicklung eingefroren scheint.&lt;/p&gt;</description>
      <pubDate>Sat, 17 Nov 2007 16:59:32 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:c1f31720-1624-4cea-8b2c-e36edf849020</guid>
      <author>Stefan</author>
      <link>http://loopkid.net/articles/2007/11/17/wiki-is-a-foreign-word-for-ruby</link>
      <category>Software</category>
      <category>Linux</category>
    </item>
    <item>
      <title>finding large directories</title>
      <description>&lt;p&gt;Every once in a while there is the need to clear out the system. The question that inevitably pops up is: Where has all the disk space gone ? The solution of course lies in locating the largest directories. With &lt;a href="http://www.id-design.com/software/whatsize/"&gt;WhatSize&lt;/a&gt; and &lt;a href="http://www.omnigroup.com/applications/omnidisksweeper/"&gt;OmniDiskSweeper&lt;/a&gt; there are two great tools on Mac OS X. There are also feasible Tools on Linux like &lt;a href="http://www.methylblue.com/filelight/"&gt;Filelight&lt;/a&gt;, but if you&amp;#8217;re administering a remote server and you don&amp;#8217;t want to use remote x11 access you need a solution that can be controlled either on the command line or via browser. Of course you could use sturdy old du.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
# Find all directories with the largest directories on top
$ sudo du -Sx / | sort -nr | less
# Find directories over 100MB with the largest directories on top
$ sudo du -Sh / | grep ^[1-9][0-9][0-9][0-9\.]*M | sort -nr
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or you could hack together some fancy &lt;a href="http://www.macosxhints.com/article.php?story=20070912091217207"&gt;perl&lt;/a&gt; &lt;a href="http://www.itworld.com/Comp/3380/nls_unixscrounge102104/index.html"&gt;script&lt;/a&gt;, but wouldn&amp;#8217;t it be nice to have an interactive graphical visualisation through which you could comfortably navigate ? This is where &lt;a href="http://zevv.nl/code/philesight/"&gt;Philesight&lt;/a&gt; pops in, which offers both command line and browserbased control. Putting it up on Debian is a breeze. Just install cairo and berkley db and their ruby bindings and then get rolling.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
$ wget http://zevv.nl/code/philesight/philesight-2035.tgz
$ tar xvfz philesight-2035.tgz
$ sudo apt-get install libcairo2 libcairo-ruby
$ sudo apt-get install libdb4.2 libdb4.2-ruby1.8
# Generate index
$ sudo ./philesight --db base.db --index /
# Check if image is correctly generated
$ ./philesight --db base.db --path / --draw base.png
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Firing up the web interface is just three small steps further. First configure the CGI-File.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
# philelight.cgi
db = "./base.db"
default_path = "/"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then create a reasonably named subdomain and after that just add a few lines to your lighttpd configuration file (or the corresponding lines to the webserver of your choice).&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
$HTTP["host"] =~ "philesight.yourdomain.net" {
  cgi.assign = ( ".cgi" =&gt; "/usr/bin/ruby" )
  alias.url = ( "/" =&gt; "/path/to/philesight/philesight.cgi")
  server.document-root = "/path/to/philesight"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That&amp;#8217;s all there&amp;#8217;s to it. Have fun.&lt;/p&gt;</description>
      <pubDate>Tue, 30 Oct 2007 23:49:25 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:90409df3-5f23-456d-a411-726536c84683</guid>
      <author>Stefan</author>
      <link>http://loopkid.net/articles/2007/10/30/finding-large-directories</link>
      <category>English</category>
      <category>Software</category>
      <category>Mac OS X</category>
      <category>Linux</category>
    </item>
  </channel>
</rss>
