<?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"
	>

<channel>
	<title>Walker News &#187; Linux</title>
	<atom:link href="http://www.walkernews.net/category/software/operating-system/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.walkernews.net</link>
	<description>A capsule of walker's experience in life...</description>
	<pubDate>Fri, 03 Oct 2008 03:00:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>GNU Date Generates Consistent UNIX Epoch Time Between Time Zones</title>
		<link>http://www.walkernews.net/2008/08/30/gnu-date-generates-consistent-unix-epoch-time-between-time-zones/</link>
		<comments>http://www.walkernews.net/2008/08/30/gnu-date-generates-consistent-unix-epoch-time-between-time-zones/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 02:21:10 +0000</pubDate>
		<dc:creator>Walker</dc:creator>
		
		<category><![CDATA[Howto]]></category>

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

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

		<category><![CDATA[Date Arithmetic]]></category>

		<category><![CDATA[Dummy Guide]]></category>

		<category><![CDATA[Epoch Time]]></category>

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

		<category><![CDATA[GNU Date]]></category>

		<category><![CDATA[Julian Time]]></category>

		<category><![CDATA[Linux Command]]></category>

		<category><![CDATA[POSIX Time]]></category>

		<category><![CDATA[Shell Script]]></category>

		<category><![CDATA[Time Zone]]></category>

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

		<category><![CDATA[Unix Time]]></category>

		<guid isPermaLink="false">http://www.walkernews.net/?p=1046</guid>
		<description><![CDATA[Why the GNU date produces Unix Epoch time or Julian time differently among time zones? How to resolve this "inconsistency"?]]></description>
			<content:encoded><![CDATA[<p>GNU date is easier for Linux administrators who write <a href="http://www.walkernews.net/2008/07/07/linux-dummy-guide-how-to-send-email-with-content-and-attachment/" title="How to send email with attachment in Linux command prompt?" rel="bookmark">shell script</a> that involves <a href="http://www.walkernews.net/2008/08/29/gnu-coreutils-gnu-date-is-easier-for-date-time-calculation-in-linux-shell-script/" title="How easy is to write a date calculation shell script in Linux with the help of GNU date?" rel="bookmark">Unix Epoch time or Julian time</a> (Julian time is the common term we used to refer this UNIX time in our IT office).<br />
<!--more--><br />
However, the GNU date program <span class="subhead2">might</span> produces &#8220;different&#8221; set of date-to-Julian or Julian-to-date conversion for the same input but having it executed at different <a href="http://www.walkernews.net/2008/07/14/world-time-clock-how-many-time-zones-are-used-in-usa-or-russia/" title="How many time zones are used in your country?" rel="bookmark">time zones</a>. It <span class="subhead2">might not</span> happen so if the appropriate GNU date option switch is used for the &#8220;Unix Epoch time and date&#8221; conversion.</p>
<p><div style="float:left;margin:0px 10px 1px 0;"><script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
google_alternate_color = "000000";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text_image";
//2007-10-25: Walkernews-LeftHeadBig
google_ad_channel = "2967014332";
google_color_border = "000000";
google_color_bg = "000000";
google_color_link = "FFA303";
google_color_text = "CACACA";
google_color_url = "CACACA";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Here are some GNU date examples that perform date-to-Julian and Julian-to-date conversion in two different time zones, e.g. a server at London with BST time zone (British Summer Time) and another server at Utah with MDT time zone (Mountain Daylight Time).</p>
<p>Take note of the GNU date output that appears in &#8220;blue color&#8221; text (will be explained later):</p>
<p><span class="subhead">GNU Date: Convert date to Unix Epoch time / Julian time</span></p>
<p><span class="subhead2">UK, London, BST time zone at this time of writing</span>:</p>
<pre>walker@walkernews.net # <span style="color:#FF6666;">date -d "2008-08-08 20:08:08" +%s</span>
1218222488
walker@walkernews.net # <span style="color:#FF6666;">date -u -d "2008-08-08 20:08:08" +%s</span>
<span style="color:#66FFFF;">1218226088</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "2008-08-08 20:08:08 UTC" +%s</span>
<span style="color:#66FFFF;">1218226088</span></pre>
<p><span class="subhead2">US, Utah, MTD time zone at this time of writing</span>:</p>
<pre>walker@walkernews.net # <span style="color:#FF6666;">date -d "2008-08-08 20:08:08" +%s</span>
1218247688
walker@walkernews.net # <span style="color:#FF6666;">date -u -d "2008-08-08 20:08:08" +%s</span>
<span style="color:#66FFFF;">1218226088</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "2008-08-08 20:08:08 UTC" +%s</span>
<span style="color:#66FFFF;">1218226088</span></pre>
<p><span class="subhead">GNU Date: Convert Unix Epoch time / Julian time to date</span></p>
<p><span class="subhead2">UK, London, BST time zone at this time of writing</span>:</p>
<pre>walker@walkernews.net # <span style="color:#FF6666;">date -u -d "1970-01-01 1218226088 secs"</span>
<span style="color:#66FFFF;">Fri Aug  8 20:08:08 UTC 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "UTC 1970-01-01 1218226088 secs"</span>
Fri Aug  8 21:08:08 BST 2008
walker@walkernews.net # <span style="color:#FF6666;">date -d "UTC 1970-01-01 1218226088 secs" +"%Y-%m-%d %H:%M:%S %z"</span>
2008-08-08 21:08:08 +0100
walker@walkernews.net # <span style="color:#FF6666;">date -d "1970-01-01 1218226088 secs"</span>
Fri Aug  8 20:08:08 BST 2008
walker@walkernews.net # <span style="color:#FF6666;">date -d "1970-01-01 1218222488 secs"</span>
Fri Aug  8 19:08:08 BST 2008
walker@walkernews.net # <span style="color:#FF6666;">date -u -d "1970-01-01 1218222488 secs"</span>
Fri Aug  8 19:08:08 UTC 2008</pre>
<p><span class="subhead2">US, Utah, with MTD time zone at this time of writing</span>:</p>
<pre>walker@walkernews.net # <span style="color:#FF6666;">date -u -d "1970-01-01 1218226088 secs"</span>
<span style="color:#66FFFF;">Fri Aug  8 20:08:08 UTC 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "UTC 1970-01-01 1218226088 secs"</span>
Fri Aug  8 14:08:08 MDT 2008
walker@walkernews.net # <span style="color:#FF6666;">date -d "UTC 1970-01-01 1218226088 secs" +"%Y-%m-%d %H:%M:%S %z"</span>
2008-08-08 14:08:08 -0600
walker@walkernews.net # <span style="color:#FF6666;">date -d "1970-01-01 1218226088 secs"</span>
Fri Aug  8 21:08:08 MDT 2008
walker@walkernews.net # <span style="color:#FF6666;">date -d "1970-01-01 1218247688 secs"</span>
Sat Aug  9 03:08:08 MDT 2008
walker@walkernews.net # <span style="color:#FF6666;">date -u -d "1970-01-01 1218247688 secs"</span>
Sat Aug  9 02:08:08 UTC 2008</pre>
<p><br /><script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
google_alternate_color = "000000";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
//2007-10-29: WakerNews-Banner
google_ad_channel = "9409943921";
google_color_border = "000000";
google_color_bg = "000000";
google_color_link = "99CC33";
google_color_text = "CACACA";
google_color_url = "CACACA";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br /><br />
<span class="subhead">Have the GNU date to display/output consistent Unix Epoch time at different time zones</span></p>
<p>So, the question now is about how to have GNU date <span class="subhead2">directly</span> output a <span class="subhead2">portable and consistent</span> Julian-to-date or date-to-Julian conversion, especially when date calculation shell script is running on multiple servers that distributed at different time zones?</p>
<p>As you can see from the GNU date examples with &#8220;blue text&#8221; of output, the <code>-u</code> can <span class="subhead2">directly</span> produces a portable and consistent result of:</p>
<ul>
<li>Unix Epoch time/Julian time of the given date &#8220;8 Aug 2008 8:08PM and 8 seconds&#8221;</li>
<li>Date converted from the Julian time of &#8220;8 Aug 2008 8:08PM and 8 seconds&#8221;</li>
</ul>
<p>Although specify <code>UTC</code> in the date string given to -d option switch produces the same Unix Epoch time/Julian time, the Julian-to-date conversion results are not consistent.</p>
<p>There is nothing wrong with GNU date. It&#8217;s not a GNU date bug that causes it to produce different result at different time zones. Indeed, it&#8217;s the behaviour of the GNU date option switches!</p>
<p>For example, when the <code>-u</code> is not used, GNU date produces output that requires additional conversion from the given time zones offset.</p>
<p>So, the output of</p>
<pre>date -d "UTC 1970-01-01 1218226088 secs" +"%Y-%m-%d %H:%M:%S %z"</pre>
<p>indicates the converted time is displayed as &#8220;21:08:08 +0100&#8243;, meaning that the &#8220;correct&#8221; time should be &#8220;21:08:08 minus 1 hour&#8221;.</p>
<blockquote><p>
In <a href="http://www.walkernews.net/2007/02/28/tune2fs-increase-linux-free-disk-space/" title="How to use tune2fs to temporarily increase Linux filesystem free disk space?" rel="bookmark">Linux command prompt</a>, type <code>info date</code> and browse to the GNU date examples section, the difference between <code>-u</code> and <code>UTC</code> is mentioned.</p>
<p>You can also access to these examples at the official GNU Coreutils <a href="http://www.gnu.org/software/coreutils/manual/html_node/Examples-of-date.html" title="Official GNU date online documentation and examples." target="_blank" rel="bookmark">online documentation</a>.
</p></blockquote>
<p><span class="subhead">Verdict</span></p>
<p>Specify the <code>-u</code> option switch when executing GNU date for &#8220;date to Unix Epoch time&#8221; or &#8220;Unix Epoch time to date&#8221; conversion, e.g.</p>
<pre>date -u -d "2008-12-25 12:25:08" +%s
date -u -d "1970-01-01 1230207908 secs"</pre>
<p>These two GNU date commands generate same output in UTC time, regardless of the <a href="http://www.walkernews.net/2008/06/23/windows-vista-date-and-time-matter/" title="Windows Vista can display multiple clocks of different time zone." rel="bookmark">local time zone</a> where the GNU date is executed.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
google_alternate_color = "000000";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text_image";
//2007-05-22: walkernews-mid-3
google_ad_channel = "3198031927";
google_color_border = "000000";
google_color_bg = "000000";
google_color_link = "FFA303";
google_color_text = "CACACA";
google_color_url = "CACACA";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br /></p>
<br /><strong>Similar Articles:</strong><br />&raquo; <a href="http://www.walkernews.net/2008/08/29/gnu-coreutils-gnu-date-is-easier-for-date-time-calculation-in-linux-shell-script/" title="GNU Coreutils: GNU Date Is Easier For Date Time Calculation In Linux Shell Script">GNU Coreutils: GNU Date Is Easier For Date Time Calculation In Linux Shell Script</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/07/linux-dummy-guide-how-to-send-email-with-content-and-attachment/" title="Linux Dummy Guide: How To Send Email With Content And Attachment?">Linux Dummy Guide: How To Send Email With Content And Attachment?</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/06/how-to-create-iso-image-of-directory-or-filesystem-in-linux/" title="How To Create An ISO Image Of Directory / Filesystem In Linux">How To Create An ISO Image Of Directory / Filesystem In Linux</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/05/how-to-read-iso-image-file-in-linux/" title="How To Read ISO Image File In Linux">How To Read ISO Image File In Linux</a><br />&raquo; <a href="http://www.walkernews.net/2008/05/17/direct-download-fedora-and-red-hat-linux-iso-cd-image/" title="Direct Download Fedora And Red Hat Linux ISO CD Image">Direct Download Fedora And Red Hat Linux ISO CD Image</a><br />&raquo; <a href="http://www.walkernews.net/2008/01/30/differentiate-between-single-and-multi-core-cpu-in-linux/" title="How To Differentiate Between Single And Multi-core CPU In Linux">How To Differentiate Between Single And Multi-core CPU In Linux</a><br />&raquo; <a href="http://www.walkernews.net/2007/06/03/date-arithmetic-in-linux-shell-scripts/" title="Date Arithmetic In Linux Shell Scripts">Date Arithmetic In Linux Shell Scripts</a><br />]]></content:encoded>
			<wfw:commentRss>http://www.walkernews.net/2008/08/30/gnu-date-generates-consistent-unix-epoch-time-between-time-zones/feed/</wfw:commentRss>
		</item>
		<item>
		<title>GNU Coreutils: GNU Date Is Easier For Date Time Calculation In Linux Shell Script</title>
		<link>http://www.walkernews.net/2008/08/29/gnu-coreutils-gnu-date-is-easier-for-date-time-calculation-in-linux-shell-script/</link>
		<comments>http://www.walkernews.net/2008/08/29/gnu-coreutils-gnu-date-is-easier-for-date-time-calculation-in-linux-shell-script/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 15:47:21 +0000</pubDate>
		<dc:creator>Walker</dc:creator>
		
		<category><![CDATA[Howto]]></category>

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

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

		<category><![CDATA[Date Arithmetic]]></category>

		<category><![CDATA[Date Time]]></category>

		<category><![CDATA[Dummy Guide]]></category>

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

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

		<category><![CDATA[GNU Coreutils]]></category>

		<category><![CDATA[GNU Date]]></category>

		<category><![CDATA[Julian Time]]></category>

		<category><![CDATA[Open Source]]></category>

		<category><![CDATA[POSIX Time]]></category>

		<category><![CDATA[Red Hat]]></category>

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

		<category><![CDATA[Shell Script]]></category>

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

		<category><![CDATA[Unix Time]]></category>

		<guid isPermaLink="false">http://www.walkernews.net/?p=1027</guid>
		<description><![CDATA[Do you know how easy to write date time calculation related shell script in Linux, if you've GNU date installed?]]></description>
			<content:encoded><![CDATA[<p>I mentioned about <a href="http://www.walkernews.net/2007/06/03/date-arithmetic-in-linux-shell-scripts/" title="How to query Linux yesterday or tomorrow date? How to perform date arithmetic in Linux shell script?" rel="bookmark">date time calculation shell script</a> in an earlier post. Though, the GNU date examples related to Unix Epoch time (a.k.a. Unix time, POSIX time, Julian time) in that post aren&#8217;t really successful (so as the Julian time calculation in <a href="http://www.walkernews.net/2007/06/14/high-performance-compiler-for-intel-based-system/" title="Intel C++ Compiler ensure high performance program code to run on Intel-based processors." rel="bookmark">C program code</a>) :-(<br />
<!--more--><br />
(Time is not an easy-to-understand topic, especially people who keen on &#8220;A Brief History Of Time&#8221; that written by Stephen Hawking).</p>
<p><div style="float:left;margin:0px 10px 1px 0;"><script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
google_alternate_color = "000000";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text_image";
//2007-10-25: Walkernews-LeftHeadBig
google_ad_channel = "2967014332";
google_color_border = "000000";
google_color_bg = "000000";
google_color_link = "FFA303";
google_color_text = "CACACA";
google_color_url = "CACACA";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>OK, put aside that Physics topic about time. Back to the question: How easy is to do date time calculation in Linux shell script (and not about <a href="http://www.walkernews.net/2008/06/23/windows-vista-date-and-time-matter/" title="Knows more about the Windows Vista date and time features." rel="bookmark">Windows Vista Date Time Matter</a>)?</p>
<p>First of all, GNU date is one of the many Linux programs that grouped in a great package, with a given name GNU Coreutils.</p>
<p><a href="http://www.gnu.org/software/coreutils/" title="The official site of GNU Coreutils" rel="bookmark" target="_blank">GNU Coreutils</a> is bundled with <a href="http://www.walkernews.net/2008/05/17/direct-download-fedora-and-red-hat-linux-iso-cd-image/" title="Directly download Red Hat CD image from Red Hat FTP server" rel="bookmark">Red Hat Linux distribution</a>, and is believed being a ubiquitous GNU package among Linux distributions.</p>
<p>For example, in my <a href="http://www.walkernews.net/2008/01/15/how-to-install-rhel4-in-hp-netserver-lh3000/" title="How do I install RHEL4 in an aging HP LH3000 Netserver?" rel="bookmark">RHEL4 machine</a>, <code>ls -laSh /bin/date</code> shows it&#8217;s only 47KB in size and the <code>rpm -qf /bin/date</code> shows it&#8217;s part of the coreutils-5.2.1-31 package.</p>
<p>This GNU date can either set or change the current system date/time or to display date/time format according to user queries. For those serious programmers who use Julian time, you should happy to know that GNU date understands UNIX Epoch time too!</p>
<blockquote><p>
<span class="subhead">What is that Epoch Time exactly?</span></p>
<p>The computer times are represented as a count of seconds since an epoch, i.e. a well-defined point of time (hence, it&#8217;s called <span class="subhead2">Epoch time</span>).</p>
<p>On GNU and POSIX systems, the epoch time is defined as 1970-01-01 00:00:00 UTC. Thus, it&#8217;s also known as <span class="subhead2">UNIX time</span>, <span class="subhead2">POSIX time</span>, or some simply calls it <span class="subhead2">Julian time</span>.
</p></blockquote>
<p>Here are some GNU <strong>date arithmetic and time calculation</strong> examples, which I&#8217;ve referred to the official <a href="http://www.gnu.org/software/coreutils/manual/html_node/Examples-of-date.html" title="The official GNU date examples" target="_blank" rel="bookmark">GNU date documentation</a> (also appears in <code>info date</code>):</p>
<pre>walker@walkernews.net # <span style="color:#FF6666;">date</span>
<span style="color:#66FFFF;">Thu Aug 28 17:10:38 BST 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "3 hours ago"</span>
<span style="color:#66FFFF;">Thu Aug 28 14:10:41 BST 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "+3 hours"</span>
<span style="color:#66FFFF;">Thu Aug 28 20:12:01 BST 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "last month"</span>
<span style="color:#66FFFF;">Mon Jul 28 17:13:11 BST 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "next month"</span>
<span style="color:#66FFFF;">Sun Sep 28 17:14:15 BST 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "+2 months"</span>
<span style="color:#66FFFF;">Tue Oct 28 17:14:56 GMT 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "2 months ago"</span>
<span style="color:#66FFFF;">Sat Jun 28 17:16:44 BST 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "yesterday"</span>
<span style="color:#66FFFF;">Wed Aug 27 17:13:35 BST 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "tomorrow"</span>
<span style="color:#66FFFF;">Fri Aug 29 17:13:55 BST 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "3 days ago"</span>
<span style="color:#66FFFF;">Mon Aug 25 17:22:42 BST 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "+3 days"</span>
<span style="color:#66FFFF;">Sun Aug 31 17:23:08 BST 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "last friday"</span>
<span style="color:#66FFFF;">Fri Aug 22 00:00:00 BST 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "2008-08-22 +3 days"</span>
<span style="color:#66FFFF;">Mon Aug 25 00:00:00 BST 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "2008-08-22 -5 days"</span>
<span style="color:#66FFFF;">Sun Aug 17 00:00:00 BST 2008</span></pre>
<p><br /><script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
google_alternate_color = "000000";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
//2007-10-29: WakerNews-Banner
google_ad_channel = "9409943921";
google_color_border = "000000";
google_color_bg = "000000";
google_color_link = "99CC33";
google_color_text = "CACACA";
google_color_url = "CACACA";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br /><br />
<span class="subhead">How to format the GNU date output format? For example, to get the day, weekday, month, year of 23 days ago can be coded as such:</span></p>
<pre>walker@walkernews.net # <span style="color:#FF6666;">date -d "23 days ago"</span>
<span style="color:#66FFFF;">Tue Aug  5 18:23:24 BST 2008</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "23 days ago" +%e</span>
<span style="color:#66FFFF;"> 5</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "23 days ago" +%d</span>
<span style="color:#66FFFF;">05</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "23 days ago" +%m</span>
<span style="color:#66FFFF;">08</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "23 days ago" +%-m</span>
<span style="color:#66FFFF;">8</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "23 days ago" +%b</span>
<span style="color:#66FFFF;">Aug</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "23 days ago" +%B</span>
<span style="color:#66FFFF;">August</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "23 days ago" +"%e-%-m-%Y, %B"</span>
<span style="color:#66FFFF;"> 5-8-2008, August</span>
walker@walkernews.net # <span style="color:#FF6666;">date -d "23 days ago" +"%e-%m-%Y, %B"</span>
<span style="color:#66FFFF;"> 5-08-2008, August</span></pre>
<p>You may refer to <code>man date</code> for detail list of GNU date output format modifiers. Also, take note the difference of <code>+%m</code> and <code>+%-m</code> is that the later remove the zero padding. </p>
<blockquote><p>
The zero-padding looks neatly when display in string format. However, zero-padded numeric is not valid in Bash shell script arithmetic interpretation, i.e. 08 - 05 will fail as the valid syntax is 8 - 5.
</p></blockquote>
<p><span class="subhead">Unix Epoch time calculation examples with GNU date</span> </p>
<p>The <code>+%s</code> is another GNU date output modifier, i.e. to output number of seconds since Unix Epoch. And, the date/time format for <code>-d</code> option switch is close to ISO 8601 date/time format, i.e. YYYY-MM-DD HH:MM:SS (it&#8217;s not a strict <a href="http://wwp.greenwichmeantime.com/info/iso.htm" rel="bookmark" target="_blank">ISO 8601 Date/Time format</a>, but close to it).</p>
<p>For example, the UNIX time of 25th of December 2008 at 12:25PM 08 seconds is given as this:</p>
<pre>walker@walkernews.net # <span style="color:#FF6666;">date -u -d "2008-12-25 12:25:08" +%s</span>
<span style="color:#66FFFF;">1230207908</span></pre>
<p>So, the Julian time of 2008-08-08 20:08:08 (the date and time of Beijing Olympic Opening Ceremony) is as such:</p>
<pre>walker@walkernews.net # <span style="color:#FF6666;">date -u -d "2008-08-08 20:08:08" +%s</span>
<span style="color:#66FFFF;">1218226088</span></pre>
<p>That&#8217;s 1218226088 seconds elapsed since Unix Epoch time at 2008-08-08 20:08:08. </p>
<p>To convert UNIX Epoch time or Julian time to human readable date/time format:</p>
<pre>walker@walkernews.net # <span style="color:#FF6666;">date -u -d "1970-01-01 1218226088 secs"</span>
<span style="color:#66FFFF;">Fri Aug  8 20:08:08 UTC 2008</span></pre>
<p><script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
google_alternate_color = "000000";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text_image";
//2007-05-22: walkernews-mid-3
google_ad_channel = "3198031927";
google_color_border = "000000";
google_color_bg = "000000";
google_color_link = "FFA303";
google_color_text = "CACACA";
google_color_url = "CACACA";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br /></p>
<br /><strong>Similar Articles:</strong><br />&raquo; <a href="http://www.walkernews.net/2008/08/30/gnu-date-generates-consistent-unix-epoch-time-between-time-zones/" title="GNU Date Generates Consistent UNIX Epoch Time Between Time Zones">GNU Date Generates Consistent UNIX Epoch Time Between Time Zones</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/07/linux-dummy-guide-how-to-send-email-with-content-and-attachment/" title="Linux Dummy Guide: How To Send Email With Content And Attachment?">Linux Dummy Guide: How To Send Email With Content And Attachment?</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/06/mysql-dummy-guide-how-to-output-sql-results-to-a-log-file/" title="MySQL Dummy Guide: How To Output SQL Results To A Log File?">MySQL Dummy Guide: How To Output SQL Results To A Log File?</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/05/how-to-read-iso-image-file-in-linux/" title="How To Read ISO Image File In Linux">How To Read ISO Image File In Linux</a><br />&raquo; <a href="http://www.walkernews.net/2008/06/09/configure-secured-private-key-for-password-less-ssh-login/" title="Configure Secured Private Key For Password-less SSH Login">Configure Secured Private Key For Password-less SSH Login</a><br />&raquo; <a href="http://www.walkernews.net/2008/06/06/how-to-setup-non-interactive-ssh-login/" title="How To Setup Non-Interactive SSH Login">How To Setup Non-Interactive SSH Login</a><br />&raquo; <a href="http://www.walkernews.net/2008/05/17/direct-download-fedora-and-red-hat-linux-iso-cd-image/" title="Direct Download Fedora And Red Hat Linux ISO CD Image">Direct Download Fedora And Red Hat Linux ISO CD Image</a><br />]]></content:encoded>
			<wfw:commentRss>http://www.walkernews.net/2008/08/29/gnu-coreutils-gnu-date-is-easier-for-date-time-calculation-in-linux-shell-script/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Linux Dummy Guide: How To Send Email With Content And Attachment?</title>
		<link>http://www.walkernews.net/2008/07/07/linux-dummy-guide-how-to-send-email-with-content-and-attachment/</link>
		<comments>http://www.walkernews.net/2008/07/07/linux-dummy-guide-how-to-send-email-with-content-and-attachment/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 15:42:51 +0000</pubDate>
		<dc:creator>Walker</dc:creator>
		
		<category><![CDATA[Howto]]></category>

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

		<category><![CDATA[Dummy Guide]]></category>

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

		<category><![CDATA[Know-how]]></category>

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

		<category><![CDATA[Open Source]]></category>

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

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

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

		<guid isPermaLink="false">http://www.walkernews.net/?p=814</guid>
		<description><![CDATA[How to use uuencode and uudecode to send an email with both the content and attachment in Linux system?]]></description>
			<content:encoded><![CDATA[<p>For those who are using graphical-based email client should have no problem on how to <a href="http://www.walkernews.net/2008/06/25/how-to-email-executable-program-file-in-gmail-or-hotmail/" title="How to email program files as attachment in Gmail or Windows Live Mail?" rel="bookmark">send an email with attachment</a>.<br />
<!--more--><br />
<div style="float:left;margin:0px 10px 1px 0;"><script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
/* 250x250, created 7/2/08 */
google_ad_slot = "1128449464";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>This <a href="http://www.walkernews.net/tag/Dummy-Guide/" title="All posts related to Dummy Guide in WalkerNews.net" rel="bookmark">dummy guide</a> is for those who want to <a href="http://www.walkernews.net/2008/06/24/bypass-exchange-server-attachment-filtering-system/" title="How to bypass Exchange server attachment filtering system to email program files as attachment?" rel="bookmark">send an email with content and attachment</a> at the same time in Linux command prompt, not at the Linux Desktop.</p>
<p>But, why you need to do so when there are plenty of email clients appear with intuitive GUI (graphical user interface)?</p>
<p>Well, system administrators or programmers who write Linux shell script to send email with attachments of log file, report, music, picture, etc, will find it easier if working with command-line email client (e.g. <code>sendmail</code> or <code>mail</code> program).</p>
<p><span class="subhead2">How to send email with attachment in Linux command prompt?</span></p>
<p>Basically, you need two programs for this topic, i.e. an email client (e.g. <code>mail</code> that bundled with most Linux distributions) and a binary file encoder (e.g. <code>uuencode</code> which is bundled with sharutils package).</p>
<p>For example, to write an <a href="http://www.walkernews.net/2008/01/16/how-to-setup-email-alias-in-red-hat-linux/" title="How to setup email alias name in Linux?" rel="bookmark">email</a> message that&#8217;s attached with Logo.JPG:</p>
<pre>
(echo "This is the content of email and it's attached with a jpeg file called Logo.JPG"; uuencode /tmp/1.JPG Logo.JPG) | mail -s "This is email subject" walker@walkernews.net
</pre>
<p>The parenthesis groups the both <code>echo</code> and <code>uunencode</code> commands to run as subshell processes, where the output of subshell appears as single input to the <codeL>mail</code> client.</p>
<p>The <code>uuencode</code> encodes the binary picture file (i.e. /tmp/1.JPG) to ASCII format (i.e. Logo.JPG), which is then sent as email attachment.</p>
<p>If you just want to email attachments without writing the content/message, then the command will be as this:</p>
<pre>
uuencode /tmp/1.JPG Logo.JPG | mail -s "This is email subject" walker@walkernews.net &lt;/dev/null
</pre>
<p>So, it&#8217;s your choice, whether to email attachment with content/message or not. But, those two options are available.<br />
<br /><script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
google_alternate_color = "000000";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
//2007-10-29: WakerNews-Banner
google_ad_channel = "9409943921";
google_color_border = "000000";
google_color_bg = "000000";
google_color_link = "99CC33";
google_color_text = "CACACA";
google_color_url = "CACACA";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br /></p>
<br /><strong>Similar Articles:</strong><br />&raquo; <a href="http://www.walkernews.net/2008/08/29/gnu-coreutils-gnu-date-is-easier-for-date-time-calculation-in-linux-shell-script/" title="GNU Coreutils: GNU Date Is Easier For Date Time Calculation In Linux Shell Script">GNU Coreutils: GNU Date Is Easier For Date Time Calculation In Linux Shell Script</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/06/mysql-dummy-guide-how-to-output-sql-results-to-a-log-file/" title="MySQL Dummy Guide: How To Output SQL Results To A Log File?">MySQL Dummy Guide: How To Output SQL Results To A Log File?</a><br />&raquo; <a href="http://www.walkernews.net/2008/10/03/how-to-send-program-file-as-attachment-in-gmail/" title="How To Send Program File As Attachment In Gmail?">How To Send Program File As Attachment In Gmail?</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/06/mysql-dummy-guide-how-to-display-long-sql-output-in-page-by-page/" title="MySQL Dummy Guide: How To Display Long SQL Output In Page By Page Fashion?">MySQL Dummy Guide: How To Display Long SQL Output In Page By Page Fashion?</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/05/dummy-guide-introduce-simple-mysql-commands/" title="Dummy Guide: Introduce Some Simple MySQL Commands">Dummy Guide: Introduce Some Simple MySQL Commands</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/05/how-to-read-iso-image-file-in-linux/" title="How To Read ISO Image File In Linux">How To Read ISO Image File In Linux</a><br />&raquo; <a href="http://www.walkernews.net/2008/06/09/configure-secured-private-key-for-password-less-ssh-login/" title="Configure Secured Private Key For Password-less SSH Login">Configure Secured Private Key For Password-less SSH Login</a><br />]]></content:encoded>
			<wfw:commentRss>http://www.walkernews.net/2008/07/07/linux-dummy-guide-how-to-send-email-with-content-and-attachment/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How To Create An ISO Image Of Directory / Filesystem In Linux</title>
		<link>http://www.walkernews.net/2008/07/06/how-to-create-iso-image-of-directory-or-filesystem-in-linux/</link>
		<comments>http://www.walkernews.net/2008/07/06/how-to-create-iso-image-of-directory-or-filesystem-in-linux/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 06:27:40 +0000</pubDate>
		<dc:creator>Walker</dc:creator>
		
		<category><![CDATA[Freeware]]></category>

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

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

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

		<category><![CDATA[ISO-9660]]></category>

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

		<category><![CDATA[Know-how]]></category>

		<category><![CDATA[Linux Command]]></category>

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

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

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

		<guid isPermaLink="false">http://www.walkernews.net/?p=812</guid>
		<description><![CDATA[There is a simple and efficient Linux command line program to create ISO image file of a directory or filesystem in Linux.]]></description>
			<content:encoded><![CDATA[<p>Another post related to <a href="http://www.walkernews.net/2007/09/22/how-to-create-cd-iso-image-in-linux/" title="How simple is to create a CD image from CD-ROM in Linux system?" rel="bookmark">CD image and Linux system</a>. Do you know there is a simple and efficient Linux command line program to create <a href="http://www.walkernews.net/2008/05/17/direct-download-fedora-and-red-hat-linux-iso-cd-image/" title="Direct download Red Hat Linux and Fedora Core CD ISO image" rel="bookmark">ISO image</a> of a directory or filesystem?<br />
<!--more--><br />
<div style="float:left;margin:0px 10px 1px 0;"><script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
/* 250x250, created 7/2/08 */
google_ad_slot = "1128449464";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Most Linux distributions, including <a href="http://www.walkernews.net/2008/01/15/how-to-install-rhel4-in-hp-netserver-lh3000/" title="How to install RHEL4 Update 4 in an aging HP NetServer LH-3000?" rel="bookmark">RHEL4 that power my aging HP NetServer</a> come with a mkisofs package. </p>
<p>The mkisofs package comprises of few tiny but really useful programs to deal with CD image, i.e. isodebug, isodump, isoinfo, isovfy, mkhybrid, and mkisofs.</p>
<p>Out of all these programs, mkisofs is particularly useful in this post, i.e. its ability to efficiently <span class="subhead2">create CD image of directories or filesystem in Linux</span>.</p>
<p><em>This is not about creating ISO image from a CD-ROM, which can be easily accomplished with dd command (a simple, legacy command in most Linux/Unix system).</em></p>
<blockquote><p>Some of the points to dump a directory content into an ISO image format:</p>
<ol>
<li>You could easily burn the ISO image format of directory content onto a CD-ROM<br />
&nbsp;</li>
<li>It&#8217;s much efficient to manage the ISO image of directories that contain few thousands of tiny files, either to transfer it over the network (via <a href="http://www.walkernews.net/2008/06/05/configure-putty-to-support-password-less-ssh-login/" title="How to configure Putty to support password-less SSH login?" rel="bookmark">scp command</a>, <a href="http://www.walkernews.net/2007/05/08/auto-file-transfer-via-ftp-batch-scripts/" title="How to create auto-ftp Linux shell script or Windows batch file?" rel="bookmark">ftp protocol</a>, <a href="http://www.walkernews.net/2007/07/25/map-linux-network-drive-with-shfs-module/" title="How to map or mount or remote Linux server directory as network drive in Linux system with secure shell file system or SHFS module?" rel="bookmark">shfs system</a>, samba file sharing, etc) or copy between local filesystem, as there is less overheat of maintaining transfer status for those few thousands files in the session.</li>
</ol>
</blockquote>
<p><span class="subhead2">Simple example of using mkisofs</span></p>
<p>For example, to dump the content of <a href="http://www.walkernews.net/2008/03/01/excel-trend-line-to-predict-db2-tablespaces-free-page/" title="DB2 administration: How to use Excel trend line to predict DB2 tablespace usage or growth rate?" rel="bookmark">DB2 Workgroup v81</a> directory into a standard CD ISO-9660 filesystem image with file name called DB2Wkg.iso:</p>
<pre>mkisofs -o DB2Wkg81.iso DB2Wkg81</pre>
<p>To create CD ISO image of directories that contain long file name or non-8.3 format (particularly if you want to burn the CD image for use in Windows system), use the -J option switch that generates Joliet directory records in addition to regular iso9660 file names. For example, to create CD image of <a href="http://www.walkernews.net/2008/05/12/direct-download-vista-sp1-mui-pack-and-vista-ultimate-extras/" title="Direct download Vista SP1 MUI Packs and Vista Ultimate Extras" rel="bookmark">Vista SP1</a> directory:</p>
<pre>mkisofs -o VitaSP1.iso -J VistaSP1</pre>
<p>In my test, mkisofs takes less than 10 seconds to dump a directory that contains 4870 files totalled to 328MB.<br />
<br /><script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
google_alternate_color = "000000";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
//2007-10-29: WakerNews-Banner
google_ad_channel = "9409943921";
google_color_border = "000000";
google_color_bg = "000000";
google_color_link = "99CC33";
google_color_text = "CACACA";
google_color_url = "CACACA";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br /></p>
<br /><strong>Similar Articles:</strong><br />&raquo; <a href="http://www.walkernews.net/2008/07/05/how-to-read-iso-image-file-in-linux/" title="How To Read ISO Image File In Linux">How To Read ISO Image File In Linux</a><br />&raquo; <a href="http://www.walkernews.net/2008/06/20/configure-vnc-server-to-auto-start-up-in-red-hat-linux/" title="Configure VNC Server To Auto Start Up In Red Hat Linux">Configure VNC Server To Auto Start Up In Red Hat Linux</a><br />&raquo; <a href="http://www.walkernews.net/2008/06/05/configure-putty-to-support-password-less-ssh-login/" title="Configure Putty To Support Password-less SSH Login">Configure Putty To Support Password-less SSH Login</a><br />&raquo; <a href="http://www.walkernews.net/2008/03/01/excel-trend-line-to-predict-db2-tablespaces-free-page/" title="Excel Trend Line To Predict DB2 Tablespaces Free Page">Excel Trend Line To Predict DB2 Tablespaces Free Page</a><br />&raquo; <a href="http://www.walkernews.net/2008/02/24/db2-sql-to-query-tablespace-free-pages-statistics/" title="DB2 SQL To Query Tablespace Free Pages Statistics">DB2 SQL To Query Tablespace Free Pages Statistics</a><br />&raquo; <a href="http://www.walkernews.net/2008/02/18/how-to-log-db2-tablespaces-free-pages-statistics/" title="How To Log DB2 Tablespaces Free Pages Statistics">How To Log DB2 Tablespaces Free Pages Statistics</a><br />&raquo; <a href="http://www.walkernews.net/2008/01/30/differentiate-between-single-and-multi-core-cpu-in-linux/" title="How To Differentiate Between Single And Multi-core CPU In Linux">How To Differentiate Between Single And Multi-core CPU In Linux</a><br />]]></content:encoded>
			<wfw:commentRss>http://www.walkernews.net/2008/07/06/how-to-create-iso-image-of-directory-or-filesystem-in-linux/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How To Read ISO Image File In Linux</title>
		<link>http://www.walkernews.net/2008/07/05/how-to-read-iso-image-file-in-linux/</link>
		<comments>http://www.walkernews.net/2008/07/05/how-to-read-iso-image-file-in-linux/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 08:42:19 +0000</pubDate>
		<dc:creator>Walker</dc:creator>
		
		<category><![CDATA[Howto]]></category>

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

		<category><![CDATA[CD Image]]></category>

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

		<category><![CDATA[Know-how]]></category>

		<category><![CDATA[Linux Command]]></category>

		<category><![CDATA[Red Hat]]></category>

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

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

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

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

		<guid isPermaLink="false">http://www.walkernews.net/?p=809</guid>
		<description><![CDATA[A simple step to mount and access CD ISO image file in Linux system.]]></description>
			<content:encoded><![CDATA[<p>Windows OS doesn&#8217;t build in file system to access CD image file, not even the latest <a href="http://www.walkernews.net/tag/windows-vista/" title="All posts related to Windows Vista in WalkerNews.net" rel="bookmark">Windows Vista Ultimate</a> or Windows Server 2008. Although, there is plenty of Windows <a href="http://www.walkernews.net/tag/freeware/" title="All posts related to Freeware in WalkerNews.net" rel="bookmark">freeware</a> that function as <a href="http://www.walkernews.net/2008/06/20/using-magicdisc-emulator-to-read-cd-image/" title="MagicDisc: My favourite CD drive emulator freeware that used to read and create CD image in Windows Vista." rel="bookmark">CD drive emulator</a> or CD image file reader.<br />
<!--more--><br />
<div style="float:left;margin:0px 10px 1px 0;"><script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
google_alternate_color = "000000";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text_image";
//2007-10-25: Walkernews-LeftHeadBig
google_ad_channel = "2967014332";
google_color_border = "000000";
google_color_bg = "000000";
google_color_link = "FFA303";
google_color_text = "CACACA";
google_color_url = "CACACA";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>That&#8217;s Windows. How about Linux? Do you have to install CD drive emulator or CD image file reader? Where could you get one of them?</p>
<p>Well, you don&#8217;t have to look for any Linux software if you simply want to mount and read ISO image file! </p>
<p>Linux build in <a href="http://www.walkernews.net/2007/07/01/create-linux-loopback-file-system-on-disk-file/" title="What could you do with Linux Loopback device?" rel="bookmark">loopback device</a> that allows user to easily <a href="http://www.walkernews.net/2007/08/19/how-to-mount-and-read-cd-iso-image-in-linux/" title="How to use loopback device to mount and read CD image in Linux?" rel="bookmark">mount and access CD image files</a>. No complicated installation or configuration is required to use the loopback device. </p>
<p><span class="subhead2">How to mount an CD image file (ISO format) in Linux?</span></p>
<ol>
<li>Login with root user ID<br />
&nbsp;</li>
<li>Create a directory to serve as mount point. You may also skip the directory creation by using default directory that created during Linux installation (e.g. /media/cdrom or /mnt/cdrom in some Red Hat Linux editions). <span style="text-decoration:line-through;">Whichever way, make sure the directory mount point is on a Linux file system that has sufficient free disk space for the size of ISO image file.</span> [ My mistake. The Linux mount point doesn't take up space but the CD ISO image is. For example, if the root filesystem left only 100MB free disk space, the /media/cdrom that resides in root filesystem is able to mount a 650MB CD image that kept in /tmp filesystem. ]<br />
&nbsp;</li>
<li>Suppose you want to mount /ISO/rhel4-cd1.iso image file to /media/cdrom directory mount point, execute this mount command
<pre>mount -o loop -t iso9660 /ISO/rhel4-cd1.iso /media/cdrom</pre>
</li>
<li>Now, you can read / access the CD image file that is mounted to /media/cdrom directory, as if you&#8217;re accessing the physical CD-ROM loaded into hardware drive.<br />
&nbsp;</li>
<li>To un-mount the loaded CD image file, simply execute <code>umount /media/cdrom</code> or <code>eject /media/cdrom</code> command will do.</li>
</ol>
<p>Isn&#8217;t it the Linux loopback device rocks? This method allows Linux users to easily accessing CD image files at the speed of hard disk access time (which is so much faster than any optical disk drives in the market, even the current Blue-ray technology can&#8217;t compete with a <a href="http://www.walkernews.net/2007/03/13/optimize-windows-vista-sata-driver-performance/" title="Optimize SATA drive performance in Windows Vista" rel="bookmark">SATA hard disk drive</a> in term of access time)!<br />
<br /><script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
google_alternate_color = "000000";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
//2007-10-29: WakerNews-Banner
google_ad_channel = "9409943921";
google_color_border = "000000";
google_color_bg = "000000";
google_color_link = "99CC33";
google_color_text = "CACACA";
google_color_url = "CACACA";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br /></p>
<br /><strong>Similar Articles:</strong><br />&raquo; <a href="http://www.walkernews.net/2008/10/03/how-to-send-program-file-as-attachment-in-gmail/" title="How To Send Program File As Attachment In Gmail?">How To Send Program File As Attachment In Gmail?</a><br />&raquo; <a href="http://www.walkernews.net/2008/06/30/how-to-edit-and-rewrite-post-slug-or-permalink-in-wordpress-25/" title="How To Edit And Rewrite Post Slug / Permalink In WordPress 2.5?">How To Edit And Rewrite Post Slug / Permalink In WordPress 2.5?</a><br />&raquo; <a href="http://www.walkernews.net/2008/06/18/how-to-check-windows-last-boot-up-time/" title="How To Check Windows Last Boot Up Time">How To Check Windows Last Boot Up Time</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/06/how-to-create-iso-image-of-directory-or-filesystem-in-linux/" title="How To Create An ISO Image Of Directory / Filesystem In Linux">How To Create An ISO Image Of Directory / Filesystem In Linux</a><br />&raquo; <a href="http://www.walkernews.net/2008/06/12/how-to-cut-mp3-as-mobile-phone-ringtone/" title="How To Cut MP3 As Mobile Phone Ringtone">How To Cut MP3 As Mobile Phone Ringtone</a><br />&raquo; <a href="http://www.walkernews.net/2008/06/11/tweak-windows-media-player-to-display-chinese-characters/" title="Tweak Windows Media Player To Display Chinese Characters">Tweak Windows Media Player To Display Chinese Characters</a><br />&raquo; <a href="http://www.walkernews.net/2008/09/22/open-facebook-in-stealth-mode-appears-offline-after-login/" title="Open Facebook In Stealth Mode - Appears Offline After Login">Open Facebook In Stealth Mode - Appears Offline After Login</a><br />]]></content:encoded>
			<wfw:commentRss>http://www.walkernews.net/2008/07/05/how-to-read-iso-image-file-in-linux/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Configure VNC Server To Auto Start Up In Red Hat Linux</title>
		<link>http://www.walkernews.net/2008/06/20/configure-vnc-server-to-auto-start-up-in-red-hat-linux/</link>
		<comments>http://www.walkernews.net/2008/06/20/configure-vnc-server-to-auto-start-up-in-red-hat-linux/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 09:08:38 +0000</pubDate>
		<dc:creator>Walker</dc:creator>
		
		<category><![CDATA[Howto]]></category>

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

		<category><![CDATA[3-Minutes]]></category>

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

		<category><![CDATA[Know-how]]></category>

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

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

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

		<category><![CDATA[Red Hat]]></category>

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

		<category><![CDATA[Remote Access]]></category>

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

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

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

		<guid isPermaLink="false">http://www.walkernews.net/?p=771</guid>
		<description><![CDATA[How to get VNC server auto start up after Red Hat Linux reboot? Read this setup guide to get the job done in less than 3 minutes! ]]></description>
			<content:encoded><![CDATA[<p>Last year, I wrote a post on <a href="http://www.walkernews.net/2007/07/05/how-to-setup-linux-vnc-server/" title="How to setup Linux VNC Server?" rel="bookmark">how to configure VNC server in Red Hat Linux system</a>. But, that <a href="http://www.walkernews.net/?s=3-minutes" title="Search all posts related to 3-minutes guide in WalkerNews.net" rel="bookmark">3-minutes</a> setup guide doesn&#8217;t mention about how to auto start <a href="http://www.walkernews.net/2007/07/22/ssh-remote-port-forwarding-in-3-minutes/" title="How to secure or encrypt VNC connection with SSH port forwarding technique?" rel="bookmark">VNC server</a> when Linux boots up.<br />
<!--more--><br />
Again, don&#8217;t expect this is a complex setup. Indeed, you probably need less than a minute to get this job done!<br />
<script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
google_alternate_color = "000000";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text_image";
//2007-02-15: walkernews-midpost
google_ad_channel = "1891269234";
google_color_border = "000000";
google_color_bg = "000000";
google_color_link = "FFA303";
google_color_text = "CACACA";
google_color_url = "CACACA";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br /><br />
<span class="subhead">How to auto start VNC server in Red Hat Linux after system reboot?</span></p>
<p>My testing environment is a machine running on Red Hat Enterprise Linux 4 Update 4, with the bundled VNC Server (i.e. vnc-server-4.0-8.1). Also assume that a Linux user account called &#8220;walker&#8221; needs the VNC server to start up automatically when Linux boots up.</p>
<ol>
<li>The Linux user account that needs VNC server to automatically start up after system reboot, must have a VNC password. To create a new (or reset a forgotten) VNC password, just login or su (switch user) with that Linux user account and execute this simple command:
<pre>vncpasswd</pre>
<p>Enter a password when prompted, which is used for VNC authentication.</li>
<li>A hidden directory named .vnc is created in the user home directory by the vncpasswd command (if it&#8217;s not current exists). Execute <code>ls -la $HOME/.vnc</code> command to check if there is a file called xstartup. If this file is not exists, bring up VNC server with another simple command:
<pre>vncserver :1</pre>
<p>If you get this similar message &#8220;A VNC server is already running as :1&#8243;, meaning that there is another instance of VNC server running with the same display number. To resolve this, just try to replace the :1 with :2, :3, etc. Alternatively, you may execute this <a href="http://www.walkernews.net/2007/05/27/linux-commands-to-check-network-connection/" title="Linux netstat - how useful is this networking command in Linux?" rel="bookmark">netstat command</a> with root user privilege:</p>
<pre>[root@walkernews ~]# netstat -tulpan | grep vnc
tcp    0    0 0.0.0.0:5801    0.0.0.0:*   LISTEN   3402/Xvnc
tcp    0    0 0.0.0.0:5802    0.0.0.0:*   LISTEN   8447/Xvnc
tcp    0    0 0.0.0.0:5901    0.0.0.0:*   LISTEN   3402/Xvnc
tcp    0    0 0.0.0.0:5902    0.0.0.0:*   LISTEN   8447/Xvnc
tcp    0    0 0.0.0.0:6001    0.0.0.0:*   LISTEN   3402/Xvnc
tcp    0    0 0.0.0.0:6002    0.0.0.0:*   LISTEN   8447/Xvnc</pre>
<p>The netstat output shows that there are two VNC servers running with display number 1 and 2. So, for the 3rd VNC server to start, the command should be <code>vncserver :3</code>.<br />
&nbsp;</li>
<li>Edit $HOME/.vnc/xstartup file with your favourite editor, to un-comment these two lines in order to get the &#8220;normal&#8221; Linux Desktop view:
<pre>unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc</pre>
</li>
<li>Switch user to root account (i.e. <code> su - root</code>), edit /etc/sysconfig/vncservers with your favourite editor, append the display number and Linux user account information to the VNCSERVERS (an array variable). This configuration file defines who can start up VNC server with what display number via the VNCSERVERS array (that&#8217;s read by Linux start up scripts /etc/init.d/vncserver). For example,
<pre>VNCSERVERS="1:root 2:tester 3:walker"</pre>
<p>That means there are three Linux user accounts (root, tester, and walker) will start up VNC server with display number 1, 2, and 3 respecitively, as Linux boots up.</p>
<p><span class="subhead2">Note:</span> Don&#8217;t simply add more than one VNCSERVERS array in /etc/sysconfig/vncserver configuration file. Otherwise, only the last VNCSERVERS array will be used.<br />
&nbsp;</li>
<li>Make sure VNC server (the daemon or server process) is set to auto run upon system boots up to your runlevel. For example,
<pre>[root@walkernews ~]# chkconfig &#8211;&#8211;list | grep vnc
vncserver  0:off  1:off  2:off  3:off  4:off  5:on  6:off</pre>
<p>The &#8211;&#8211;list option of chkconfig shows VNC server is set to auto run in Linux runlevel 5 (the default multi-user runlevel with Linux Desktop console). To configure VNC server to auto run when Linux boots into runlevel 5, use the &#8211;&#8211;level with on option switch:</p>
<pre>chkconfig --level 5 vncserver on</pre>
</li>
</ol>
<p>Ok, that&#8217;s all you need. You should have the VNC server automatically running when Red Hat Linux boots up at runlevel 5. Although the guide might looks lengthy to you, but works involve shouldn&#8217;t take you more than 3 minutes after you get used with Linux!<br />
<script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
google_alternate_color = "000000";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text_image";
//2007-05-22: walkernews-mid-3
google_ad_channel = "3198031927";
google_color_border = "000000";
google_color_bg = "000000";
google_color_link = "FFA303";
google_color_text = "CACACA";
google_color_url = "CACACA";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br /></p>
<br /><strong>Similar Articles:</strong><br />&raquo; <a href="http://www.walkernews.net/2008/06/05/configure-putty-to-support-password-less-ssh-login/" title="Configure Putty To Support Password-less SSH Login">Configure Putty To Support Password-less SSH Login</a><br />&raquo; <a href="http://www.walkernews.net/2008/06/04/auto-ssh-login-by-using-public-key-cryptography/" title="Auto SSH Login By Using Public-key Cryptography">Auto SSH Login By Using Public-key Cryptography</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/06/how-to-create-iso-image-of-directory-or-filesystem-in-linux/" title="How To Create An ISO Image Of Directory / Filesystem In Linux">How To Create An ISO Image Of Directory / Filesystem In Linux</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/05/how-to-read-iso-image-file-in-linux/" title="How To Read ISO Image File In Linux">How To Read ISO Image File In Linux</a><br />&raquo; <a href="http://www.walkernews.net/2008/06/09/configure-secured-private-key-for-password-less-ssh-login/" title="Configure Secured Private Key For Password-less SSH Login">Configure Secured Private Key For Password-less SSH Login</a><br />&raquo; <a href="http://www.walkernews.net/2008/06/06/how-to-setup-non-interactive-ssh-login/" title="How To Setup Non-Interactive SSH Login">How To Setup Non-Interactive SSH Login</a><br />&raquo; <a href="http://www.walkernews.net/2008/05/17/direct-download-fedora-and-red-hat-linux-iso-cd-image/" title="Direct Download Fedora And Red Hat Linux ISO CD Image">Direct Download Fedora And Red Hat Linux ISO CD Image</a><br />]]></content:encoded>
			<wfw:commentRss>http://www.walkernews.net/2008/06/20/configure-vnc-server-to-auto-start-up-in-red-hat-linux/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Auto SSH Login By Using Public-key Cryptography</title>
		<link>http://www.walkernews.net/2008/06/04/auto-ssh-login-by-using-public-key-cryptography/</link>
		<comments>http://www.walkernews.net/2008/06/04/auto-ssh-login-by-using-public-key-cryptography/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 04:10:56 +0000</pubDate>
		<dc:creator>Walker</dc:creator>
		
		<category><![CDATA[Howto]]></category>

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

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

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

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

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

		<category><![CDATA[Private-key]]></category>

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

		<category><![CDATA[Public-key]]></category>

		<category><![CDATA[Red Hat]]></category>

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

		<category><![CDATA[Remote Access]]></category>

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

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

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

		<category><![CDATA[SSH-Keygen]]></category>

		<guid isPermaLink="false">http://www.walkernews.net/?p=733</guid>
		<description><![CDATA[How could you get an automatic SSH login to remote SSH server, so-called password-less SSH login.]]></description>
			<content:encoded><![CDATA[<p>Auto SSH login or password-less SSH login is the answer to replace those legacy rlogin and rcp protocols that are without encryption feature.<br />
<!--more--><br />
Thus, password-less SSH login is extremely useful in writing <strong>secured</strong> <a href="http://www.walkernews.net/2007/05/08/auto-file-transfer-via-ftp-batch-scripts/" title="How to write a Linux shell script or Windows batch file to automate file transfer via the insecure FTP protocol?" rel="bookmark">shell scripts</a> that need to automatically (non-interactively) login remote server and then initiates file transfer or trigger some other commands.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
google_alternate_color = "000000";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text_image";
//2007-02-15: walkernews-midpost
google_ad_channel = "1891269234";
google_color_border = "000000";
google_color_bg = "000000";
google_color_link = "FFA303";
google_color_text = "CACACA";
google_color_url = "CACACA";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br /><br />
<span class="subhead">How to setup non-interactive or password-less SSH login in Linux?</span></p>
<blockquote><p>SSH server supports two modes of authentication where remote SSH client could be authenticated via <span style="text-decoration:underline;">legacy system login ID and password</span> or with the <span style="text-decoration:underline;">public-key cryptography</span> method (that provides non-interactive or password-less SSH login capability)</p></blockquote>
<p><span style="color:#FF6666;font-weight:bold;">Assumption made for this example:</span></p>
<ul>
<li>System user walker-a at Linux server WalkerNews-A needs a password-less, non-interactive SSH login to walker-b at Linux server WalkerNews-B.<br />
&nbsp;</li>
<li>Both Linux servers are running on <a href="http://www.walkernews.net/2008/01/15/how-to-install-rhel4-in-hp-netserver-lh3000/" title="How to tweak the aging HP Netserver LH3000 for RHEL 4 update 5 installation?" rel="bookmark">RHEL 4 update 5</a> bundled with openssh-server-3.9p1-8.RHEL4.1 and openssh-clients-3.9p1-8.RHEL4.1
</li>
</ul>
<p><span style="text-decoration:underline;font-weight:bold;">At WalkerNews-A Linux command prompt:</span></p>
<ul>
<li>Execute <code>ssh-keygen -t dsa</code> to create a pair of DSA-based public key and private key for SSH public-key cryptography authentication.
<pre>WalkerNews-A [/home/walker-a]$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/walker-a/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/walker-a/.ssh/id_dsa.
Your public key has been saved in /home/walker-a/.ssh/id_dsa.pub.</pre>
<p>First, ssh-keygen prompts user to specify a path to save the generated key. You can simply accept the default path by pressing ENTER key.</p>
<p>When comes to enter passphrase (password to decode the keys), again just press ENTER key to accept the default value, i.e. empty for no passphrase. Additional steps are required for password-less SSH login, if a passphrase is entered to secure the keys (I should cover this in next post for clarity).<br />
&nbsp;</li>
<li>Now, copy the generated public key (i.e. /home/walker-a/.ssh/id_dsa.pub) to walker-b home directory at WalkerNews-B.
</ul>
<p><span style="text-decoration:underline;font-weight:bold;">At WalkerNews-B Linux command prompt:</span></p>
<ul>
<li>Create a .ssh (hidden directory) in walker-b home directory (if it&#8217;s not currently exist) and make sure the directory access mode set to 700. E.g.
<pre>mkdir .ssh
chmod 700 .ssh</pre>
</li>
<li>Create a text file called authorized_keys in $HOME/.ssh directory (if the file is not currently exist) and make sure this file access mode is restricted to 600. E.g.
<pre>cd $HOME/.ssh
touch authorized_keys
chmod 600 authorized_keys</pre>
</li>
<li>Append the walker-a&#8217;s public key (id_dsa.pub) to the authorized_keys file. E.g.
<pre>cat $HOME/id_dsa.pub >> $HOME/.ssh/authorized_keys</pre>
</li>
</ul>
<p>Now, back to walker-a at WalkerNews-A, each of the subsequent ssh or scp connection initiated here to walker-b at WalkerNews-B will be automatically authenticated via public-key cryptography, i.e. without having to interactively enter password.</p>
<p>For example, login as walker-a at WalkerNews-A and execute these at Linux command prompt:</p>
<ul>
<li><code>ssh walker-b@WalkerNews-B</code> will get ssh automatically login as walker-b at WalkerNews-B, without entering a password. (The insecure legacy protocol to accomplish this task is called rlogin)<br />
&nbsp;</li>
<li><code>scp sourcefile walker-b@WalkerNews-B:temp/new.log</code> will get scp automatically transfer sourcefile to walker-b&#8217;s $HOME/temp directory and saved with a new file name as new.log. (The insecure legacy protocol to accomplish this task is called rcp) </li>
</ul>
<p>If you would like to troubleshoot or understand the SSH public-key cryptography authentication processes, specify the verbose option switch (-v) in ssh command:</p>
<p><code>ssh -v walker-b@WalkerNews-B</code><br />
<script type="text/javascript"><!--
google_ad_client = "pub-9150838093899057";
google_alternate_color = "000000";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text_image";
//2007-05-22: walkernews-mid-3
google_ad_channel = "3198031927";
google_color_border = "000000";
google_color_bg = "000000";
google_color_link = "FFA303";
google_color_text = "CACACA";
google_color_url = "CACACA";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br /></p>
<br /><strong>Similar Articles:</strong><br />&raquo; <a href="http://www.walkernews.net/2008/06/05/configure-putty-to-support-password-less-ssh-login/" title="Configure Putty To Support Password-less SSH Login">Configure Putty To Support Password-less SSH Login</a><br />&raquo; <a href="http://www.walkernews.net/2008/06/06/how-to-setup-non-interactive-ssh-login/" title="How To Setup Non-Interactive SSH Login">How To Setup Non-Interactive SSH Login</a><br />&raquo; <a href="http://www.walkernews.net/2008/06/09/configure-secured-private-key-for-password-less-ssh-login/" title="Configure Secured Private Key For Password-less SSH Login">Configure Secured Private Key For Password-less SSH Login</a><br />&raquo; <a href="http://www.walkernews.net/2008/06/20/configure-vnc-server-to-auto-start-up-in-red-hat-linux/" title="Configure VNC Server To Auto Start Up In Red Hat Linux">Configure VNC Server To Auto Start Up In Red Hat Linux</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/21/where-does-putty-keeps-ssh-host-key-fingerprint-in-windows-registry/" title="Where Does Putty Keeps SSH Host Key Fingerprint In Windows Registry?">Where Does Putty Keeps SSH Host Key Fingerprint In Windows Registry?</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/06/how-to-create-iso-image-of-directory-or-filesystem-in-linux/" title="How To Create An ISO Image Of Directory / Filesystem In Linux">How To Create An ISO Image Of Directory / Filesystem In Linux</a><br />&raquo; <a href="http://www.walkernews.net/2008/07/05/how-to-read-iso-image-file-in-linux/" title="How To Read ISO Image File In Linux">How To Read ISO Image File In Linux</a><br />]]></content:encoded>
			<wfw:commentRss>http://www.walkernews.net/2008/06/04/auto-ssh-login-by-using-public-key-cryptography/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
