<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>celsobarriga-dot-com &#187; Linux</title>
	<atom:link href="http://www.celsobarriga.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.celsobarriga.com</link>
	<description>Wasting bandwidth in style!</description>
	<lastBuildDate>Fri, 06 Nov 2009 14:14:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to determine DST time changes</title>
		<link>http://www.celsobarriga.com/2008/02/01/how-to-determine-dst-time-changes/</link>
		<comments>http://www.celsobarriga.com/2008/02/01/how-to-determine-dst-time-changes/#comments</comments>
		<pubDate>Fri, 01 Feb 2008 17:44:28 +0000</pubDate>
		<dc:creator>celso</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://www.barriga.net/2008/02/01/how-to-determine-dst-time-changes/</guid>
		<description><![CDATA[Here&#8217;s how to determine the dates when the Daylight Savings Time changes for a given year (I keep forgetting how to do this.):


zdump -v /etc/localtime&#124;grep 2008

/etc/localtime  Sun Mar  9 06:59:59 2008 UTC =
    Sun Mar 9 01:59:59 2008 EST isdst=0 gmtoff=-18000
/etc/localtime  Sun Mar  9 07:00:00 2008 UTC =
 [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to determine the dates when the Daylight Savings Time changes for a given year (I keep forgetting how to do this.):</p>
<pre><code>
<blockquote>
zdump -v /etc/localtime|grep 2008

/etc/localtime  Sun Mar  9 06:59:59 2008 UTC =
    Sun Mar 9 01:59:59 2008 EST isdst=0 gmtoff=-18000
/etc/localtime  Sun Mar  9 07:00:00 2008 UTC =
    Sun Mar 9 03:00:00 2008 EDT isdst=1 gmtoff=-14400
/etc/localtime  Sun Nov  2 05:59:59 2008 UTC =
    Sun Nov 2 01:59:59 2008 EDT isdst=1 gmtoff=-14400
/etc/localtime  Sun Nov  2 06:00:00 2008 UTC =
    Sun Nov 2 01:00:00 2008 EST isdst=0 gmtoff=-18000
</blockquote>

</code></pre>
<p>Obviously, change <strong>2008</strong> to whatever year you want.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2008/02/01/how-to-determine-dst-time-changes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find Out the Top 10 CPU Hogs</title>
		<link>http://www.celsobarriga.com/2007/08/29/find-out-the-top-10-cpu-hogs/</link>
		<comments>http://www.celsobarriga.com/2007/08/29/find-out-the-top-10-cpu-hogs/#comments</comments>
		<pubDate>Wed, 29 Aug 2007 21:48:23 +0000</pubDate>
		<dc:creator>celso</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://www.barriga.net/notes/2007/08/29/85/</guid>
		<description><![CDATA[I found this command useful in finding out which top 10 processes are hogging my CPU resources. Note that this command is specific to the Red Hat flavor of Linux. See the man page for ps for the correct output format to use for your specific platform:

ps -eo pcpu,pid,user,args &#124; sort -k1 -r &#124; head [...]]]></description>
			<content:encoded><![CDATA[<p>I found this command useful in finding out which top 10 processes are hogging my CPU resources. Note that this command is specific to the Red Hat flavor of Linux. See the man page for ps for the correct output format to use for your specific platform:</p>
<pre>
<blockquote><code>ps -eo pcpu,pid,user,args | sort -k1 -r | head -11</code></blockquote>
</pre>
<p>Substitue <code>pcpu</code> above with <code>pmem</code> to see the memory hogs instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2007/08/29/find-out-the-top-10-cpu-hogs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bourne Shell Logging Routine</title>
		<link>http://www.celsobarriga.com/2007/08/28/bourne-shell-logging-routine/</link>
		<comments>http://www.celsobarriga.com/2007/08/28/bourne-shell-logging-routine/#comments</comments>
		<pubDate>Wed, 29 Aug 2007 03:20:19 +0000</pubDate>
		<dc:creator>celso</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://www.barriga.net/notes/2007/08/28/84/</guid>
		<description><![CDATA[Here&#8217;s another logging routine, this one is written in Bourne shell:
#!/bin/sh

log_message() {
    echo `date "+%m/%d/%y %H:%M:%S %Z"` "$1" &#124; tee -a aaa.out
}

log_message "Hello there"
log_message "Goodbye"

Sample output:


08/28/07 23:16:13 EDT Hello there
08/28/07 23:16:13 EDT Goodbye


]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s another logging routine, this one is written in Bourne shell:</p>
<pre style='color:#000000;background:#ffffff;'><span style='color:#696969; '>#!/bin/sh</span>

log_message<span style='color:#808030; '>()</span> <span style='color:#800080; '>{</span>
    <span style='color:#bb7977; font-weight:bold; '>echo</span> <span style='color:#000000; background:#ffffe8; '>`date </span><span style='color:#0000e6; background:#ffffe8; '>"+%m</span><span style='color:#40015a; background:#ffffe8; '>/</span><span style='color:#0000e6; background:#ffffe8; '>%d</span><span style='color:#40015a; background:#ffffe8; '>/</span><span style='color:#0000e6; background:#ffffe8; '>%y %H:%M:%S %Z"</span><span style='color:#000000; background:#ffffe8; '>`</span> <span style='color:#0000e6; '>"</span><span style='color:#0000e6; '>$1</span><span style='color:#0000e6; '>"</span> <span style='color:#e34adc; '>|</span> tee <span style='color:#44aadd; '>-a</span> aaa<span style='color:#800000; font-weight:bold; '>.</span>out
<span style='color:#800080; '>}</span>

log_message <span style='color:#0000e6; '>"Hello there"</span>
log_message <span style='color:#0000e6; '>"Goodbye"</span>
</pre>
<p>Sample output:</p>
<blockquote><p><code>
<pre>
08/28/07 23:16:13 EDT Hello there
08/28/07 23:16:13 EDT Goodbye
</pre>
<p></code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2007/08/28/bourne-shell-logging-routine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Determining the External IP Address</title>
		<link>http://www.celsobarriga.com/2006/06/07/find-external-ip-address/</link>
		<comments>http://www.celsobarriga.com/2006/06/07/find-external-ip-address/#comments</comments>
		<pubDate>Wed, 07 Jun 2006 17:33:15 +0000</pubDate>
		<dc:creator>celso</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://www.barriga.net/2006/06/07/71/</guid>
		<description><![CDATA[Here&#8217;s how to find out your external IP address courtesy of this hint:
http://www.macosxhints.com/article.php?story=20060602180942480


curl --silent http://checkip.dyndns.org
    &#124; awk '{print $6}' &#124; cut -f 1 -d "]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to find out your external IP address courtesy of this hint:</p>
<p><a href="http://www.macosxhints.com/article.php?story=20060602180942480">http://www.macosxhints.com/article.php?story=20060602180942480</a></p>
<blockquote>
<pre><code>
curl --silent http://checkip.dyndns.org
    | awk '{print $6}' | cut -f 1 -d "<"
</code></pre>
</blockquote>
<p>If you are using Apple's Airport Extreme Basestation (mine is particularly the Time Capsule and this is where I have tested this), and you have the SNMP interface enabled, you can run the following command</p>
<pre><code>
prompt$ snmpwalk -Os -c public -v 1 192.168.63.1 ipAdEntAddr IpAddress \
    | grep -E -v '(127.0.0|169.254|192.168.63.1)' \
    | cut -d : -f 2 | sed 's/ //g'
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2006/06/07/find-external-ip-address/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Line Terminations</title>
		<link>http://www.celsobarriga.com/2006/04/13/line-terminations/</link>
		<comments>http://www.celsobarriga.com/2006/04/13/line-terminations/#comments</comments>
		<pubDate>Thu, 13 Apr 2006 21:11:13 +0000</pubDate>
		<dc:creator>celso</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://www.barriga.net/2006/04/13/66/</guid>
		<description><![CDATA[Line terminations for different operating systems:


unix
0&#215;0a
LF


Classic Mac
0&#215;0d
CR


Windows
0&#215;0d 0&#215;0a
CR LF


To convert a text file with DOS line termination to UNIX line termination:

tr -d '\015' < winfile.txt > unixfile.txt


or

sed s/.$// winfile.txt > unixfile.txt


To convert a unix file to a DOS file:

sed s/$/\x0d/ unixfile.txt > winfile.txt


]]></description>
			<content:encoded><![CDATA[<p>Line terminations for different operating systems:</p>
<table border="1">
<tr>
<td>unix</td>
<td>0&#215;0a</td>
<td>LF</td>
</tr>
<tr>
<td>Classic Mac</td>
<td>0&#215;0d</td>
<td>CR</td>
</tr>
<tr>
<td>Windows</td>
<td>0&#215;0d 0&#215;0a</td>
<td>CR LF</td>
</tr>
</table>
<p>To convert a text file with DOS line termination to UNIX line termination:</p>
<blockquote><pre><code>
tr -d '\015' < winfile.txt > unixfile.txt
</code></pre>
</blockquote>
<p>or</p>
<blockquote><pre><code>
sed s/.$// winfile.txt > unixfile.txt
</code></pre>
</blockquote>
<p>To convert a unix file to a DOS file:</p>
<blockquote><pre><code>
sed s/$/\x0d/ unixfile.txt > winfile.txt
</code></pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2006/04/13/line-terminations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run as root only</title>
		<link>http://www.celsobarriga.com/2005/11/18/run-as-root-only/</link>
		<comments>http://www.celsobarriga.com/2005/11/18/run-as-root-only/#comments</comments>
		<pubDate>Fri, 18 Nov 2005 17:48:08 +0000</pubDate>
		<dc:creator>celso</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://home.barriga.net/?p=37</guid>
		<description><![CDATA[To make sure that a script will be run by root only:

#!/bin/sh

if [ `id -u` != 0 ]; then
  echo "Permission denied, must be root"
  exit
fi

# Do the thing...


]]></description>
			<content:encoded><![CDATA[<p>To make sure that a script will be run by root only:</p>
<blockquote><pre><code>
#!/bin/sh

if [ `id -u` != 0 ]; then
  echo "Permission denied, must be root"
  exit
fi

# Do the thing...
</code></pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2005/11/18/run-as-root-only/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Authenticate Users</title>
		<link>http://www.celsobarriga.com/2005/11/10/authenticate-users/</link>
		<comments>http://www.celsobarriga.com/2005/11/10/authenticate-users/#comments</comments>
		<pubDate>Thu, 10 Nov 2005 21:17:22 +0000</pubDate>
		<dc:creator>celso</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Notes]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://home.barriga.net/?p=36</guid>
		<description><![CDATA[This snippet could authenticate users using their /etc/passwd or /etc/shadow entry. May have to run this with higher than normal privilege:

#!/usr/bin/env perl

print "Username: ";
chomp($uname = &#60;stdin&#62;);

$pwd = (getpwnam($uname))[1]; # get the user's pwd
die "invalid user\n" unless defined $pwd and length $pwd;
$salt = substr($pwd, 0, 2);

system "stty -echo";
print "Password: ";
chomp($word = &#60;stdin&#62;);
print "\n";
system "stty echo";

if (crypt($word, [...]]]></description>
			<content:encoded><![CDATA[<p>This snippet could authenticate users using their /etc/passwd or /etc/shadow entry. May have to run this with higher than normal privilege:</p>
<blockquote><pre><code>
#!/usr/bin/env perl

print "Username: ";
chomp($uname = &lt;stdin&gt;);

$pwd = (getpwnam($uname))[1]; # get the user's pwd
die "invalid user\n" unless defined $pwd and length $pwd;
$salt = substr($pwd, 0, 2);

system "stty -echo";
print "Password: ";
chomp($word = &lt;stdin&gt;);
print "\n";
system "stty echo";

if (crypt($word, $salt) ne $pwd) {
    die "Sorry...\n";
} else {
    print "ok\n";
}
</code></pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2005/11/10/authenticate-users/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Burn CDs</title>
		<link>http://www.celsobarriga.com/2005/11/09/how-to-burn-cd/</link>
		<comments>http://www.celsobarriga.com/2005/11/09/how-to-burn-cd/#comments</comments>
		<pubDate>Wed, 09 Nov 2005 22:41:54 +0000</pubDate>
		<dc:creator>celso</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://home.barriga.net/?p=33</guid>
		<description><![CDATA[For accomplishing other tasks such as copying CDs, etc., try carefully reading the cdrecord manual page and, if necessary, consulting the canonical CD recording FAQ at http://www.cdrfaq.org/.
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;
Creating a data CD:
Step 1: Make a directory to contain the files you want to place on the the CD.  &#8220;mkdir /image/userdir/&#8221; is the standard method.
Step 2: Copy [...]]]></description>
			<content:encoded><![CDATA[<p>For accomplishing other tasks such as copying CDs, etc., try carefully reading the cdrecord manual page and, if necessary, consulting the canonical CD recording FAQ at http://www.cdrfaq.org/.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Creating a data CD:</p>
<p>Step 1: Make a directory to contain the files you want to place on the the CD.  &#8220;mkdir /image/userdir/&#8221; is the standard method.</p>
<p>Step 2: Copy the files from wherever they are to the directory you just created.</p>
<p>Step 3: Create the ISO9660 image that will be burned on the CD. You do this using the mkisofs command. An example command is:</p>
<blockquote><pre><code>
csh> cd /image/userdir/
csh> mkisofs -o /image/burn-image/.iso
-l -R -L -V "" -P "" -p "" -A "" .

-o: the name of the file that will contain the
     image
-l: use long file names
-R: use Rock Ridge extensions. This means
     that long filenames will be used, file
     uid/gids and permissions will be preserved,
     symbolic links will be included, etc. In
     other words, the CD will try hard to
     emulate a Unix file system.
[-r: This is like the -R option, but file uid/gid
are set to 0, files will be readable by anyone
and all write permissions will be removed.
Use this switch if you anticipate needing to
read the CD in an environment where your
uid/gid do not exist. E.g., if you are sending
to CD to another institution.]

-L: Allow file names beginning with '.'.
-V, -P, -p, -A: See the mkisofs man page.

The final argument (in the example '.') is the
name of the top-level directory containing
file data.

See the mkisofs manual page for further details.
</code></pre>
</blockquote>
<p><span id="more-47"></span><br />
Mkisofs is fairly chatty about what it is doing, so you will know that progress is being made.</p>
<p>Step 4: Burn the just-created ISO9660 image onto the CD. First place a CD in drive (duh!). Then issue the command:</p>
<blockquote><pre></code>
csh> cdrecord -v speed=8 -pad -data \
        /image/burn-image/.iso
</code></pre>
</blockquote>
<p>The drive is capable of handling re-writable media. However, re-writing is slower than writing for the first time and cdrecord may downgrade your request for speed=8 to something lower. If your CD has been written before you may also need to &#8216;blank&#8217; it as well. In this case, the command line will be:</p>
<blockquote><pre><code>
csh> cdrecord -blank=fast -v speed=8 -pad \
     -data /image/burn-image/.iso
</code></pre>
</blockquote>
<p>Step 5: CLEAN UP AFTER YOURSELF. There is a limited amount of disk space available for data and images. Don&#8217;t leave your gunk laying around where someone will trip over it:</p>
<blockquote><pre><code>
csh> rm -r /image/userdir/
csh> rm /image/burn-image/.iso
</code></pre>
</blockquote>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Creating audio CDs:</p>
<p>Step 1: Make a directory to contain the files you want to place on the the CD. &#8220;mkdir /image/userdir/&#8221; is the standard method.</p>
<p>Step 2: Copy the files from wherever they are to the directory you just created. This example assumes that the audio is formatted as .WAV files; other formats can be used with a little extra work, see the cdrecord man page for details.</p>
<p>Step 3: Place a CD in drive (duh!). Then issue the command:</p>
<blockquote><pre><code>
csh> cdrecord -v speed=8 -pad \
         -audio /image/userdir/*.wav
</code></pre>
</blockquote>
<p>The drive is capable of handling re-writable media. However, re-writing is slower than writing for the first time. So if you are re-writing a CD, use &#8220;speed=4&#8243;.</p>
<p>Step 4: CLEAN UP AFTER YOURSELF. There is a limited amount of disk space available for data and images. Don&#8217;t leave your gunk laying around where someone will trip over it:</p>
<blockquote><pre><code>
csh> rm -r /image/userdir/
</code></pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2005/11/09/how-to-burn-cd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable single user mode using lilo</title>
		<link>http://www.celsobarriga.com/2005/11/09/disable-single-using-using-lilo/</link>
		<comments>http://www.celsobarriga.com/2005/11/09/disable-single-using-using-lilo/#comments</comments>
		<pubDate>Wed, 09 Nov 2005 22:38:31 +0000</pubDate>
		<dc:creator>celso</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://home.barriga.net/?p=32</guid>
		<description><![CDATA[In your LILO configuration section, write something like:

image = /vmlinuz
        label = Linux
        root = /dev/hda1
        password = wingedlizard
        restricted
        [...]]]></description>
			<content:encoded><![CDATA[<p>In your LILO configuration section, write something like:</p>
<blockquote><pre><code>
image = /vmlinuz
        label = Linux
        root = /dev/hda1
        password = wingedlizard
        restricted
        read-only
</code></pre>
</blockquote>
<p>Then chmod this file 600 (so nobody but root can read it) and re-run /sbin/lilo.</p>
<p>The &#8220;restricted&#8221; keyword means that LILO will stop and ask for a password if you try to boot this kernel with _any_ keywords such as &#8220;1&#8243; or &#8220;single&#8221; or &#8220;init=/bin/bash&#8221;.  A password won&#8217;t be required during normal (no-added-keywords) boots.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2005/11/09/disable-single-using-using-lilo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Determine Disk Usage</title>
		<link>http://www.celsobarriga.com/2004/09/07/determine-disk-usage/</link>
		<comments>http://www.celsobarriga.com/2004/09/07/determine-disk-usage/#comments</comments>
		<pubDate>Tue, 07 Sep 2004 20:37:43 +0000</pubDate>
		<dc:creator>celso</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://home.barriga.net/?p=13</guid>
		<description><![CDATA[This command will show the number of KBs used for all non-hidden files and folders in the current directory:
du -sk * &#124; sort -rn

]]></description>
			<content:encoded><![CDATA[<p>This command will show the number of KBs used for all non-hidden files and folders in the current directory:</p>
<blockquote><pre><code>du -sk * | sort -rn</code></pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2004/09/07/determine-disk-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
