<?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>Denie&#039;s Tech Blog &#187; Tutorials</title>
	<atom:link href="http://blog.nataprawira.com/tech/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nataprawira.com/tech</link>
	<description>Information Technology for Life!</description>
	<lastBuildDate>Mon, 19 Jul 2010 09:20:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to DISABLE ipv6 in CentOS5 System</title>
		<link>http://blog.nataprawira.com/tech/2010/07/19/how-to-disable-ipv6-in-centos5-system/</link>
		<comments>http://blog.nataprawira.com/tech/2010/07/19/how-to-disable-ipv6-in-centos5-system/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 09:20:32 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[disable]]></category>
		<category><![CDATA[ipv6]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=163</guid>
		<description><![CDATA[

echo &#8220;NETWORKING_IPV6=no&#8221; &#62;&#62; /etc/sysconfig/network
echo &#8220;alias ipv6 off&#8221; &#62;&#62; /etc/modprobe.conf
echo &#8220;alias net-pf-10 off&#8221; &#62;&#62; /etc/modprobe.conf
reboot
# ifconfig
eth1      Link encap:Ethernet  HWaddr 00:1C:F0:BB:A7:28
inet addr:10.10.10.11  Bcast:10.10.10.255  Mask:255.255.255.0
 inet6 addr: fe80::21c:f0ff:febb:a728/64 Scope:Link
 UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:470449435 errors:1 dropped:0 overruns:0 frame:0
TX packets:464084402 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2563674692 (2.3 GiB)  TX bytes:2243518951 (2.0 GiB)
Interrupt:225 Base address:0&#215;2800
Don&#8217;t really [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F07%2F19%2Fhow-to-disable-ipv6-in-centos5-system%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F07%2F19%2Fhow-to-disable-ipv6-in-centos5-system%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<div id="_mcePaste" style="width: 1px;height: 1px">echo &#8220;NETWORKING_IPV6=no&#8221; &gt;&gt; /etc/sysconfig/network</div>
<div id="_mcePaste" style="width: 1px;height: 1px">echo &#8220;alias ipv6 off&#8221; &gt;&gt; /etc/modprobe.conf</div>
<div id="_mcePaste" style="width: 1px;height: 1px">echo &#8220;alias net-pf-10 off&#8221; &gt;&gt; /etc/modprobe.conf</div>
<div id="_mcePaste" style="width: 1px;height: 1px">reboot</div>
<p><strong># ifconfig</strong></p>
<blockquote><p>eth1      Link encap:Ethernet  HWaddr 00:1C:F0:BB:A7:28<br />
inet addr:10.10.10.11  Bcast:10.10.10.255  Mask:255.255.255.0<br />
<strong> inet6 addr: fe80::21c:f0ff:febb:a728/64 Scope:Link<br />
</strong> UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br />
RX packets:470449435 errors:1 dropped:0 overruns:0 frame:0<br />
TX packets:464084402 errors:0 dropped:0 overruns:0 carrier:0<br />
collisions:0 txqueuelen:1000<br />
RX bytes:2563674692 (2.3 GiB)  TX bytes:2243518951 (2.0 GiB)<br />
Interrupt:225 Base address:0&#215;2800</p></blockquote>
<div>Don&#8217;t really need of ipv6 to be run on your server. Want to disable it ?</div>
<p><span id="more-163"></span>Just run the following syntax&#8230;</p>
<p><em><span style="color: #993300">Make sure no such entries inside: </span></em><strong><em><span style="color: #333300">/etc/sysconfig/network</span></em></strong><em><span style="color: #993300"> and </span></em><strong><em><span style="color: #333300">/etc/modprobe.conf</span></em></strong><em><span style="color: #993300"> file <img src='http://blog.nataprawira.com/tech/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span></em></p>
<blockquote><p># echo &#8220;NETWORKING_IPV6=no&#8221; &gt;&gt; /etc/sysconfig/network<br />
# echo &#8220;alias ipv6 off&#8221; &gt;&gt; /etc/modprobe.conf<br />
# echo &#8220;alias net-pf-10 off&#8221; &gt;&gt; /etc/modprobe.conf<br />
# reboot <span style="color: #0000ff"> </span><em><span style="color: #0000ff">(your server to make affect)</span></em></p></blockquote>
<p>Once reboot-ed, do :</p>
<p># ifconfig</p>
<blockquote><p>eth1      Link encap:Ethernet  HWaddr 00:1C:F0:BB:A7:28<br />
inet addr:10.10.10.11  Bcast:10.10.10.255  Mask:255.255.255.0<br />
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br />
RX packets:470471884 errors:1 dropped:0 overruns:0 frame:0<br />
TX packets:464109169 errors:0 dropped:0 overruns:0 carrier:0<br />
collisions:0 txqueuelen:1000<br />
RX bytes:2574513731 (2.3 GiB)  TX bytes:2255015395 (2.1 GiB)<br />
Interrupt:225 Base address:0&#215;2800</p></blockquote>
<div></div>

<div class="bitly_links">
<div class="bitly_linkstext">
Share this on : 
</div>
<ul>
	<li class="bitly_linksfirst"><a rel="nofollow" id="facebook" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fbit.ly%252FbDLXEH%26amp%3Bt%3DHow%2520to%2520DISABLE%2520ipv6%2520in%2520CentOS5%2520System';" title="Facebook">Facebook</a></li>
	<li><a rel="nofollow" id="friendfeed" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.friendfeed.com%2Fshare%3Ftitle%3DHow%2520to%2520DISABLE%2520ipv6%2520in%2520CentOS5%2520System%26amp%3Blink%3Dhttp%253A%252F%252Fbit.ly%252FbDLXEH';" title="Friendfeed">Friendfeed</a></li>
	<li><a rel="nofollow" id="posterous" target="_blank" href="javascript:window.location='http%3A%2F%2Fposterous.com%2Fshare%3Flinkto%3Dhttp%253A%252F%252Fbit.ly%252FbDLXEH%26amp%3Btitle%3DHow%2520to%2520DISABLE%2520ipv6%2520in%2520CentOS5%2520System%26amp%3Bselection%3D';" title="Posterous">Posterous</a></li>
	<li><a rel="nofollow" id="tumblr" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.tumblr.com%2Fshare%3Fv%3D3%26amp%3Bu%3Dhttp%253A%252F%252Fbit.ly%252FbDLXEH%26amp%3Bt%3DHow%2520to%2520DISABLE%2520ipv6%2520in%2520CentOS5%2520System%26amp%3Bs%3D';" title="Tumblr">Tumblr</a></li>
	<li class="bitly_linkslast"><a rel="nofollow" id="twitter" target="_blank" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DHow%2520to%2520DISABLE%2520ipv6%2520in%2520CentOS5%2520System%2520-%2520http%253A%252F%252Fbit.ly%252FbDLXEH';" title="Twitter">Twitter</a></li>
</ul>
</div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2010/07/19/how-to-disable-ipv6-in-centos5-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scripting a MySQL InnoDB Engine Conversion</title>
		<link>http://blog.nataprawira.com/tech/2010/07/11/scripting-a-mysql-innodb-engine-conversion/</link>
		<comments>http://blog.nataprawira.com/tech/2010/07/11/scripting-a-mysql-innodb-engine-conversion/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 19:50:08 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Conversion]]></category>
		<category><![CDATA[InnoDB]]></category>
		<category><![CDATA[MyISAM]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=161</guid>
		<description><![CDATA[

0) Backup your database.
You should probably be doing this already.  Now’s a good time to make sure that your backups ran.
 
1) Create the script.
You’ll need the correct permissions to query the database. Here’s the command.  Be sure to change &#60;DATABASE_NAME&#62; as it fits.
# mysql -p -e "show tables in &#60;DATABASE_NAME&#62;;" &#124; \
tail --lines=+2 &#124; [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F07%2F11%2Fscripting-a-mysql-innodb-engine-conversion%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F07%2F11%2Fscripting-a-mysql-innodb-engine-conversion%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<h3 style="font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, sans-serif;font-weight: bold;font-size: 1.3em;color: #333333;text-decoration: none;margin-top: 30px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding: 0px"><span style="color: #000000;font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-weight: normal;font-size: 13px"><strong>0) Backup your database.<br />
</strong>You should probably be doing this already.  Now’s a good time to make sure that your backups ran.</span></h3>
<p><span style="color: #000000;font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-weight: normal;font-size: 13px"> </span></p>
<p><strong>1) Create the script.<br />
</strong>You’ll need the correct permissions to query the database. Here’s the command.  Be sure to change &lt;DATABASE_NAME&gt; as it fits.</p>
<p><code style="font: normal normal normal 1.1em/normal 'Courier New', Courier, Fixed"><strong><span style="color: #0000ff"># mysql -p -e "show tables in &lt;DATABASE_NAME&gt;;" | \<br />
tail --lines=+2 | \<br />
xargs -i echo "ALTER TABLE {} ENGINE=INNODB;" &gt; alter_table.sql</span></strong></code></p>
<p><strong>2) Run the script</strong>.</p>
<p><code style="font: normal normal normal 1.1em/normal 'Courier New', Courier, Fixed"><strong><span style="color: #0000ff"># mysql --database=&lt;DATABASE_NAME&gt; -p &lt; alter_table.sql</span></strong></code></p>
<p><strong>3) Verify</strong> it by running this command in mysql:</p>
<p><code style="font: normal normal normal 1.1em/normal 'Courier New', Courier, Fixed"><strong><span style="color: #0000ff">mysql&gt; show table status;</span></strong></code></p>
<p><span id="more-161"></span></p>
<p><strong><a title="http://technotes.twosmallcoins.com/?cat=268" href="http://technotes.twosmallcoins.com/?cat=268" target="_blank">SOURCE</a></strong></p>

<div class="bitly_links">
<div class="bitly_linkstext">
Share this on : 
</div>
<ul>
	<li class="bitly_linksfirst"><a rel="nofollow" id="facebook" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fbit.ly%252F90wNH0%26amp%3Bt%3DScripting%2520a%2520MySQL%2520InnoDB%2520Engine%2520Conversion';" title="Facebook">Facebook</a></li>
	<li><a rel="nofollow" id="friendfeed" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.friendfeed.com%2Fshare%3Ftitle%3DScripting%2520a%2520MySQL%2520InnoDB%2520Engine%2520Conversion%26amp%3Blink%3Dhttp%253A%252F%252Fbit.ly%252F90wNH0';" title="Friendfeed">Friendfeed</a></li>
	<li><a rel="nofollow" id="posterous" target="_blank" href="javascript:window.location='http%3A%2F%2Fposterous.com%2Fshare%3Flinkto%3Dhttp%253A%252F%252Fbit.ly%252F90wNH0%26amp%3Btitle%3DScripting%2520a%2520MySQL%2520InnoDB%2520Engine%2520Conversion%26amp%3Bselection%3D';" title="Posterous">Posterous</a></li>
	<li><a rel="nofollow" id="tumblr" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.tumblr.com%2Fshare%3Fv%3D3%26amp%3Bu%3Dhttp%253A%252F%252Fbit.ly%252F90wNH0%26amp%3Bt%3DScripting%2520a%2520MySQL%2520InnoDB%2520Engine%2520Conversion%26amp%3Bs%3D';" title="Tumblr">Tumblr</a></li>
	<li class="bitly_linkslast"><a rel="nofollow" id="twitter" target="_blank" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DScripting%2520a%2520MySQL%2520InnoDB%2520Engine%2520Conversion%2520-%2520http%253A%252F%252Fbit.ly%252F90wNH0';" title="Twitter">Twitter</a></li>
</ul>
</div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2010/07/11/scripting-a-mysql-innodb-engine-conversion/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How To Getting Yesterdays or Tomorrows day with shell date command</title>
		<link>http://blog.nataprawira.com/tech/2010/06/29/how-to-getting-yesterdays-or-tomorrows-day-with-shell-date-command/</link>
		<comments>http://blog.nataprawira.com/tech/2010/06/29/how-to-getting-yesterdays-or-tomorrows-day-with-shell-date-command/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 18:37:22 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Date]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=146</guid>
		<description><![CDATA[

When invoked without arguments, the date command displays the current date and time. Depending on the options specified, date will set the date and time or print it in a user defined way. I’ve seen many people writing a perl script for calculating yesterday or tomorrow. Computer loves numbers but we love relative terms like [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F06%2F29%2Fhow-to-getting-yesterdays-or-tomorrows-day-with-shell-date-command%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F06%2F29%2Fhow-to-getting-yesterdays-or-tomorrows-day-with-shell-date-command%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">When invoked without arguments, the date command displays the current date and time. Depending on the options specified, date will set the date and time or print it in a user defined way. I’ve seen many people writing a perl script for calculating yesterday or tomorrow. Computer loves numbers but we love relative terms like 2 days ago. Luckily GNU date command is designed to handle relative date calculation.<span id="more-146"></span></p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Why use relative date formats?</h3>
<ul style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 1.571em;padding: 0px">
<li>Ease of use</li>
<li>To write your own scripts</li>
<li>Automate task using cron (example run a job on last day of the month or Nth day of the month or 3rd Friday and so on)</li>
</ul>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">First, print today&#8217;s date:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ <strong>date</strong></code><br />
Sun Jun 17 12:17:24 CDT 2007</p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Now display Yesterday&#8217;s date:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date="1 days ago"</code><br />
OR try:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date="yesterday"</code><br />
Sat Jun 16 12:17:20 CDT 2007</p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Now display Tomorrow&#8217;s date:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date="-1 days ago"</code><br />
Or better try:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date="next day"</code><br />
Sat Jun 16 12:17:20 CDT 2007</p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Getting date in the future</h3>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">To get tomorrow and day after tomorrow (tomorrow+N) use <strong>day</strong> word to get date in the future.</p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Getting date in the past</h3>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">To get yesterday and earlier day in the past use string <strong>day ago</strong>:</p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Moving by whole years or months</h3>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">You can add year and months keywords to get more accurate date:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date='2 year ago' # past<br />
$ date --date='3 years' # go into future<br />
$ date --date='2 days' # future<br />
$ date --date='1 month ago' # past<br />
$ date --date='2 months' # future</code></p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Moving date using more precise units</h3>
<ul style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 1.571em;padding: 0px">
<li>You can use fortnight for 14 day</li>
<li>Week for 7 days</li>
<li>hour for 60 minutes</li>
<li>minute for 60 seconds</li>
<li>second for one second</li>
<li>You can also use this / now / today keywords to stress the meaning</li>
</ul>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">To print the date of this Friday:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date='this Friday'</code><br />
To print the date of the day six months and 15 day<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date='6 months 15 day'</code><br />
To print the date of the day two months and 5 days ago:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date='2 months 5 day ago'</code></p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">You can also use relative format to setup date and time. For example to set the system clock forward by 30 minutes, enter:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd"># date --set='+30 minutes'</code></p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">To display date in <a href="http://en.wikipedia.org/wiki/Unix_time">epoch time</a>:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date --date='1970-01-01 00:00:01 UTC +5 hours' +%s</code></p>
<h4 style="font-weight: bold;font-size: 1em;padding: 0px;margin: 0px"><a href="http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html" target="_blank">SOURCE</a></h4>

<div class="bitly_links">
<div class="bitly_linkstext">
Share this on : 
</div>
<ul>
	<li class="bitly_linksfirst"><a rel="nofollow" id="facebook" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fbit.ly%252Fbf3zaO%26amp%3Bt%3DHow%2520To%2520Getting%2520Yesterdays%2520or%2520Tomorrows%2520day%2520with%2520shell%2520date%2520command';" title="Facebook">Facebook</a></li>
	<li><a rel="nofollow" id="friendfeed" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.friendfeed.com%2Fshare%3Ftitle%3DHow%2520To%2520Getting%2520Yesterdays%2520or%2520Tomorrows%2520day%2520with%2520shell%2520date%2520command%26amp%3Blink%3Dhttp%253A%252F%252Fbit.ly%252Fbf3zaO';" title="Friendfeed">Friendfeed</a></li>
	<li><a rel="nofollow" id="posterous" target="_blank" href="javascript:window.location='http%3A%2F%2Fposterous.com%2Fshare%3Flinkto%3Dhttp%253A%252F%252Fbit.ly%252Fbf3zaO%26amp%3Btitle%3DHow%2520To%2520Getting%2520Yesterdays%2520or%2520Tomorrows%2520day%2520with%2520shell%2520date%2520command%26amp%3Bselection%3D';" title="Posterous">Posterous</a></li>
	<li><a rel="nofollow" id="tumblr" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.tumblr.com%2Fshare%3Fv%3D3%26amp%3Bu%3Dhttp%253A%252F%252Fbit.ly%252Fbf3zaO%26amp%3Bt%3DHow%2520To%2520Getting%2520Yesterdays%2520or%2520Tomorrows%2520day%2520with%2520shell%2520date%2520command%26amp%3Bs%3D';" title="Tumblr">Tumblr</a></li>
	<li class="bitly_linkslast"><a rel="nofollow" id="twitter" target="_blank" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DHow%2520To%2520Getting%2520Yesterdays%2520or%2520Tomorrows%2520day%2520with%2520shell%2520date%2520command%2520-%2520http%253A%252F%252Fbit.ly%252Fbf3zaO';" title="Twitter">Twitter</a></li>
</ul>
</div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2010/06/29/how-to-getting-yesterdays-or-tomorrows-day-with-shell-date-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to format date for display or to use in a shell script</title>
		<link>http://blog.nataprawira.com/tech/2010/06/29/how-to-format-date-for-display-or-to-use-in-a-shell-script/</link>
		<comments>http://blog.nataprawira.com/tech/2010/06/29/how-to-format-date-for-display-or-to-use-in-a-shell-script/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 18:35:12 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Date]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=144</guid>
		<description><![CDATA[

Q. How do I format date to display on screen on for my scripts as per my requirements?
A. You need to use standard date command to format date or time for output or to use in a shell script.
Syntax to specify format
date +FORMAT

Task: Display date in mm-dd-yy format
Type the command as follows:
$ date +"%m-%d-%y"
Output:
02-27-07
Turn on 4 [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F06%2F29%2Fhow-to-format-date-for-display-or-to-use-in-a-shell-script%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F06%2F29%2Fhow-to-format-date-for-display-or-to-use-in-a-shell-script%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Q. How do I format date to display on screen on for my scripts as per my requirements?</p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">A. You need to use standard date command to format date or time for output or to use in a shell script.</p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Syntax to specify format<br />
<strong>date <span style="color: #ff0000;padding: 0px;margin: 0px">+FORMAT<span id="more-144"></span><br />
</span></strong></p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Task: Display date in mm-dd-yy format</h3>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Type the command as follows:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date +"%m-%d-%y"</code><br />
Output:</p>
<pre style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;background-color: #eeeeee;clear: both;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;line-height: 1.5em;border: 1px solid #dddddd">02-27-07</pre>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Turn on 4 digit year display:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date +"%m-%d-%Y"</code><br />
Just display date as mm/dd/yy format:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date +"%D"</code></p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Task: Display time only</h3>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Type the command as follows:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date +"%T"</code><br />
Output:</p>
<pre style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;background-color: #eeeeee;clear: both;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;line-height: 1.5em;border: 1px solid #dddddd">19:55:04</pre>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Display locale’s 12-hour clock time<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date +"%r"</code><br />
Output:</p>
<pre style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;background-color: #eeeeee;clear: both;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;line-height: 1.5em;border: 1px solid #dddddd">07:56:05 PM</pre>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Display time in HH:MM format:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ date +"%H-%M"</code></p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">How do I save time/date format to a variable?</h3>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">Simply type command as follows at a shell prompt:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ NOW=$(date +"%m-%d-%Y")</code><br />
To display a variable use <a href="http://www.cyberciti.biz/faq/how-to-write-output-to-terminal/" target="_blank">echo / printf command</a>:<br />
<code style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;line-height: 1.5em;background-color: #eeeeee;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;border: 1px solid #dddddd">$ echo $NOW</code><br />
Sample shell script:</p>
<pre style="padding-top: 0.667em;padding-right: 0.917em;padding-bottom: 0.667em;padding-left: 0.917em;margin-top: 0px;margin-right: 0px;margin-bottom: 1.833em;margin-left: 0px;background-color: #eeeeee;clear: both;font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif;font-size: 0.857em;line-height: 1.5em;border: 1px solid #dddddd">#!/bin/bash
NOW=$(date +"%m-%d-%Y")
FILE="backup.$NOW.tar.gz"
# rest of script</pre>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">Complete list of FORMAT control characters supported by date command</h3>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">FORMAT controls the output.It can be the combination of any one of the following:</p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<dl>
<dt>%%</dt>
<dd>a literal %</dd>
<dt>%a</dt>
<dd>locale&#8217;s abbreviated weekday name (e.g., Sun)</dd>
<dt>%A</dt>
<dd>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">locale&#8217;s full weekday name (e.g., Sunday)</p>
</dd>
<dt>%b</dt>
<dd>locale&#8217;s abbreviated month name (e.g., Jan)</dd>
<dt>%B</dt>
<dd>locale&#8217;s full month name (e.g., January)</dd>
<dt>%c</dt>
<dd>locale&#8217;s date and time (e.g., Thu Mar 3 23:05:25 2005)</dd>
<dt>%C</dt>
<dd>century; like %Y, except omit last two digits (e.g., 21)</dd>
<dt>%d</dt>
<dd>day of month (e.g, 01)</dd>
<dt>%D</dt>
<dd>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">date; same as %m/%d/%y</p>
</dd>
<dt>%e</dt>
<dd>day of month, space padded; same as %_d</dd>
<dt>%F</dt>
<dd>full date; same as %Y-%m-%d</dd>
<dt>%g</dt>
<dd>last two digits of year of ISO week number (see %G)</dd>
<dt>%G</dt>
<dd>year of ISO week number (see %V); normally useful only with %V</dd>
<dt>%h</dt>
<dd>same as %b</dd>
<dt>%H</dt>
<dd>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">hour (00..23)</p>
</dd>
<dt>%I</dt>
<dd>hour (01..12)</dd>
<dt>%j</dt>
<dd>day of year (001..366)</dd>
<dt>%k</dt>
<dd>hour ( 0..23)</dd>
<dt>%l</dt>
<dd>hour ( 1..12)</dd>
<dt>%m</dt>
<dd>month (01..12)</dd>
<dt>%M</dt>
<dd>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">minute (00..59)</p>
</dd>
<dt>%n</dt>
<dd>a newline</dd>
<dt>%N</dt>
<dd>nanoseconds (000000000..999999999)</dd>
<dt>%p</dt>
<dd>locale&#8217;s equivalent of either AM or PM; blank if not known</dd>
<dt>%P</dt>
<dd>like %p, but lower case</dd>
<dt>%r</dt>
<dd>locale&#8217;s 12-hour clock time (e.g., 11:11:04 PM)</dd>
<dt>%R</dt>
<dd>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">24-hour hour and minute; same as %H:%M</p>
</dd>
<dt>%s</dt>
<dd>seconds since 1970-01-01 00:00:00 UTC</dd>
<dt>%S</dt>
<dd>second (00..60)</dd>
<dt>%t</dt>
<dd>a tab</dd>
<dt>%T</dt>
<dd>time; same as %H:%M:%S</dd>
<dt>%u</dt>
<dd>day of week (1..7); 1 is Monday</dd>
<dt>%U</dt>
<dd>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">week number of year, with Sunday as first day of week (00..53)</p>
</dd>
<dt>%V</dt>
<dd>ISO week number, with Monday as first day of week (01..53)</dd>
<dt>%w</dt>
<dd>day of week (0..6); 0 is Sunday</dd>
<dt>%W</dt>
<dd>week number of year, with Monday as first day of week (00..53)</dd>
<dt>%x</dt>
<dd>locale&#8217;s date representation (e.g., 12/31/99)</dd>
<dt>%X</dt>
<dd>locale&#8217;s time representation (e.g., 23:13:48)</dd>
<dt>%y</dt>
<dd>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">last two digits of year (00..99)</p>
</dd>
<dt>%Y</dt>
<dd>year</dd>
<dt>%z</dt>
<dd>+hhmm numeric timezone (e.g., <strong>-0400</strong>)</dd>
<dt>%:z</dt>
<dd>+hh:mm numeric timezone (e.g., <strong>-04</strong>:00)</dd>
<dt>%::z</dt>
<dd>+hh:mm:ss numeric time zone (e.g., <strong>-04</strong>:00:00)</p>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px">
</dd>
<dt>%:::z</dt>
<dd>numeric time zone with : to necessary precision (e.g., <strong>-04</strong>, +05:30)</dd>
<dt>%Z</dt>
<dd>alphabetic time zone abbreviation (e.g., EDT)</dd>
</dl>
<p style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 0px;padding: 0px"><a href="http://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/" target="_blank"><strong> SOURCE</strong></a></p>
<h3 style="margin-top: 1.833em;margin-right: 0px;margin-bottom: 0.611em;margin-left: 0px;font-weight: normal;font-size: 1.286em;line-height: 1.222em;padding: 0px">See also:</h3>
<ul style="margin-top: 0px;margin-right: 0px;margin-bottom: 1.571em;margin-left: 1.571em;padding: 0px">
<li><a href="http://www.cyberciti.biz/tips/shell-scripting-creating-reportlog-file-names-with-date-in-filename.html" target="_blank">Shell Scripting: Creating report/log file names with date in filename</a></li>
</ul>

<div class="bitly_links">
<div class="bitly_linkstext">
Share this on : 
</div>
<ul>
	<li class="bitly_linksfirst"><a rel="nofollow" id="facebook" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fbit.ly%252FcOtO14%26amp%3Bt%3DHow%2520to%2520format%2520date%2520for%2520display%2520or%2520to%2520use%2520in%2520a%2520shell%2520script';" title="Facebook">Facebook</a></li>
	<li><a rel="nofollow" id="friendfeed" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.friendfeed.com%2Fshare%3Ftitle%3DHow%2520to%2520format%2520date%2520for%2520display%2520or%2520to%2520use%2520in%2520a%2520shell%2520script%26amp%3Blink%3Dhttp%253A%252F%252Fbit.ly%252FcOtO14';" title="Friendfeed">Friendfeed</a></li>
	<li><a rel="nofollow" id="posterous" target="_blank" href="javascript:window.location='http%3A%2F%2Fposterous.com%2Fshare%3Flinkto%3Dhttp%253A%252F%252Fbit.ly%252FcOtO14%26amp%3Btitle%3DHow%2520to%2520format%2520date%2520for%2520display%2520or%2520to%2520use%2520in%2520a%2520shell%2520script%26amp%3Bselection%3D';" title="Posterous">Posterous</a></li>
	<li><a rel="nofollow" id="tumblr" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.tumblr.com%2Fshare%3Fv%3D3%26amp%3Bu%3Dhttp%253A%252F%252Fbit.ly%252FcOtO14%26amp%3Bt%3DHow%2520to%2520format%2520date%2520for%2520display%2520or%2520to%2520use%2520in%2520a%2520shell%2520script%26amp%3Bs%3D';" title="Tumblr">Tumblr</a></li>
	<li class="bitly_linkslast"><a rel="nofollow" id="twitter" target="_blank" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DHow%2520to%2520format%2520date%2520for%2520display%2520or%2520to%2520use%2520in%2520a%2520shell%2520script%2520-%2520http%253A%252F%252Fbit.ly%252FcOtO14';" title="Twitter">Twitter</a></li>
</ul>
</div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2010/06/29/how-to-format-date-for-display-or-to-use-in-a-shell-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up DomainKeys on Centos</title>
		<link>http://blog.nataprawira.com/tech/2010/03/09/setting-up-domainkeys-on-centos/</link>
		<comments>http://blog.nataprawira.com/tech/2010/03/09/setting-up-domainkeys-on-centos/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 14:30:22 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Sendmail]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[DKIM]]></category>
		<category><![CDATA[DomainKeys]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=140</guid>
		<description><![CDATA[

This is a quick walk through on how to set up domain keys on Centos 5 using sendmail. It should also be very similar for Redhat or Fedora.

Domainkeys is a method mostly used by yahoo to verify that the sender of an email is valid. I did notice that gmail changes the domainkeys header line [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F03%2F09%2Fsetting-up-domainkeys-on-centos%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F03%2F09%2Fsetting-up-domainkeys-on-centos%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<h2><span style="font-weight: normal;font-size: 13px">This is a quick walk through on how to set up domain keys on Centos 5 using sendmail. It should also be very similar for Redhat or Fedora.</span></h2>
<div>
<p>Domainkeys is a method mostly used by yahoo to verify that the sender of an email is valid. I did notice that gmail changes the domainkeys header line to a pass value but I don’t know if they block/accept mail based on that.<span id="more-140"></span></p>
<p>First install some dependencies.</p>
<blockquote><p><strong>yum install sendmail-devel openssl-devel</strong></p></blockquote>
<p>First download the latest version of dk-milter by going to http://sourceforge.net/projects/dk-milter/</p>
<blockquote><p><strong>cd /usr/src/<br />
wget http://downloads.sourceforge.net/dk-milter/dk-milter-1.0.0.tar.gz</strong></p></blockquote>
<p>Then extract it using the command</p>
<blockquote><p><strong>tar xzf dk-milter-1.0.0.tar.gz<br />
cd dk-milter-2.6.0</strong></p></blockquote>
<p>Start by copying the sample config file to the proper directory and the make/make installing</p>
<blockquote><p><strong>cp site.config.m4.dist devtools/Site/site.config.m4<br />
make; make install</strong></p>
<p><span> </span></p></blockquote>
<p>You may see a few errors during the install, as long as they are just about creating the man pages you should be alright. Now change back to a good working directory and create your new keys.</p>
<blockquote><p><strong>cd ~/ssl-gen<br />
openssl genrsa -out rsa.private 768<br />
openssl rsa -in rsa.private -out rsa.public -pubout -outform PEM</strong></p></blockquote>
<p>Make the directory and move the private key into it.</p>
<blockquote><p><strong>mkdir -p /var/db/domainkeys/<br />
cp rsa.private /var/db/domainkeys/mail.key.pem</strong></p></blockquote>
<p>Now we should set up our DNS TXT records with our public key. This is how it should look in a bind zone file. Put the public key only and not the “BEGIN RSA PRIVATE…” or “END RSA…” parts of the key with out parenthesis.</p>
<blockquote><p><strong>mail._domainkey.jkurtzman.com.         IN TXT  “k=rsa; t=y; p=(Paste the public key here)”<br />
_domainkey.jkurtzman.com.                 IN TXT  “t=y; o=~”</strong></p></blockquote>
<p>You can use the following command to verify that your TXT record was set up correctly.</p>
<blockquote><p><strong>dig +short mail._domainkey.jkurtzman.com TXT</strong></p></blockquote>
<p>Now we will need to make the init script so the it starts when the computer reboots. Put the following into a file called <strong>/etc/init.d/domainkeys</strong>. Of course be sure to change the domain to your own domain. Remember to fix any lines that have wrapped when copying. Especially the COMMAND line.</p>
<blockquote><p><strong>#!/bin/sh<br />
#<br />
# “/etc/rc.d/init.d/dk-filter”<br />
# Start/stop script for the dk-filter daemon on RedHat Linux<br />
#<br />
# chkconfig: – 79 31<br />
# description: Acts as the “dk-filter” InputMailFilter (milter) for the \<br />
# Sendmail MTA to provide DomainKeys service</strong></p>
<p><strong>############################################################<br />
#<br />
# Be sure to edit these values:<br />
#<br />
KEYFILE=”/var/db/domainkeys/mail.key.pem”<br />
DOMAIN=”jkurtzman.com”<br />
SELECTOR=”mail”<br />
USER=”domainkeys”<br />
#<br />
############################################################</strong></p>
<p><strong>PIDFILE=”/var/run/dk-milter/pid”<br />
SUBMISSION_DAEMON=”smtp”<br />
PORT=8891</strong></p>
<p><strong># Source function library. Provides the “status” option<br />
. /etc/init.d/functions</strong></p>
<p><strong>test -x `which dk-filter` || exit 0</strong></p>
<p><strong>RETVAL=0</strong></p>
<p><strong>start() {<br />
echo -n $”Starting dk-filter: ”<br />
COMMAND=”dk-filter -u $USER -b s -p inet:$PORT@localhost -l -P $PIDFILE -s $KEYFILE -d $DOMAIN -S $SELECTOR -m$SUBMISSION_DAEMON -c nofws”<br />
# echo -e “Now executing\n”$COMMAND”&#8221;<br />
daemon $COMMAND<br />
RETVAL=$?<br />
echo<br />
[ $RETVAL -eq 0 ] &amp;&amp; touch /var/lock/subsys/dk-filter<br />
return $RETVAL<br />
}</strong></p>
<p><strong>stop() {<br />
echo -n $”Stopping dk-filter: ”<br />
killproc dk-filter<br />
RETVAL=$?<br />
echo<br />
[ $RETVAL -eq 0 ] &amp;&amp; rm -f $PIDFILE /var/lock/subsys/dk-filter<br />
return $RETVAL<br />
}</strong></p>
<p><strong>restart() {<br />
stop<br />
start<br />
}</strong></p>
<p><strong>case “$1″ in<br />
start)<br />
start<br />
;;<br />
stop)<br />
stop<br />
;;<br />
status)<br />
status dk-filter<br />
;;<br />
restart)<br />
restart<br />
;;<br />
*)<br />
echo $”Usage: $0 {start|stop|status|restart}”<br />
exit 1<br />
esac</strong></p>
<p><strong>exit $?</strong></p></blockquote>
<p>Give your new file execute permisions, create a user for domain keys to run as, and start it</p>
<blockquote><p><strong>chmod +x /etc/init.d/domainkeys<br />
useradd domainkeys<br />
service domainkeys start</strong></p></blockquote>
<p>If everything work you should see that the dk-filter has started.<br />
Now run chkconfig so the service starts when you reboot.</p>
<blockquote><p><strong>chkconfig domainkeys on</strong></p></blockquote>
<p>Now add this to your /etc/mail/sendmail.mc file.</p>
<blockquote><p><strong>INPUT_MAIL_FILTER(`dk-filter’, `S=inet:8891@localhost’)</strong></p></blockquote>
<p>And make and restart sendmail.</p>
<blockquote><p><strong>cd /etc/mail<br />
make<br />
service sendmail restart</strong></p></blockquote>
<p>You should now be able to send email and be domainkey verified. If you are relaying mail through the mail server you will need to make sure you are using SMTP Authentication otherwise the  dk-filter will not add the header information.</p>
<p>Try sending an email to a yahoo account and see if you get secure icon.</p>
<p><span style="font-family: 'Trebuchet MS';font-size: x-small"> </span></p>
<h1><span style="font-family: 'Trebuchet MS'">Source:</span></h1>
<h1><span style="font-family: 'Trebuchet MS'"><a href="http://luxio.us/cMZ11e" target="_blank">http://luxio.us/cMZ11e </a></span></h1>
</div>

<div class="bitly_links">
<div class="bitly_linkstext">
Share this on : 
</div>
<ul>
	<li class="bitly_linksfirst"><a rel="nofollow" id="facebook" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fbit.ly%252F9eRCUw%26amp%3Bt%3DSetting%2520up%2520DomainKeys%2520on%2520Centos';" title="Facebook">Facebook</a></li>
	<li><a rel="nofollow" id="friendfeed" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.friendfeed.com%2Fshare%3Ftitle%3DSetting%2520up%2520DomainKeys%2520on%2520Centos%26amp%3Blink%3Dhttp%253A%252F%252Fbit.ly%252F9eRCUw';" title="Friendfeed">Friendfeed</a></li>
	<li><a rel="nofollow" id="posterous" target="_blank" href="javascript:window.location='http%3A%2F%2Fposterous.com%2Fshare%3Flinkto%3Dhttp%253A%252F%252Fbit.ly%252F9eRCUw%26amp%3Btitle%3DSetting%2520up%2520DomainKeys%2520on%2520Centos%26amp%3Bselection%3D';" title="Posterous">Posterous</a></li>
	<li><a rel="nofollow" id="tumblr" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.tumblr.com%2Fshare%3Fv%3D3%26amp%3Bu%3Dhttp%253A%252F%252Fbit.ly%252F9eRCUw%26amp%3Bt%3DSetting%2520up%2520DomainKeys%2520on%2520Centos%26amp%3Bs%3D';" title="Tumblr">Tumblr</a></li>
	<li class="bitly_linkslast"><a rel="nofollow" id="twitter" target="_blank" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DSetting%2520up%2520DomainKeys%2520on%2520Centos%2520-%2520http%253A%252F%252Fbit.ly%252F9eRCUw';" title="Twitter">Twitter</a></li>
</ul>
</div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2010/03/09/setting-up-domainkeys-on-centos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup a transparent proxy with 3 easy steps</title>
		<link>http://blog.nataprawira.com/tech/2009/12/18/setup-a-transparent-proxy-with-3-easy-steps/</link>
		<comments>http://blog.nataprawira.com/tech/2009/12/18/setup-a-transparent-proxy-with-3-easy-steps/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 14:57:30 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Squid]]></category>
		<category><![CDATA[Transparent Proxy]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=127</guid>
		<description><![CDATA[

First, Squid server installed (use up2date squid) and configured by adding following directives to file:
# vi /etc/squid/squid.conf


Modify or add following squid directives:
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
acl lan src 192.168.1.1 192.168.2.0/24
http_access allow localhost
http_access allow lan
Where,

httpd_accel_host virtual: Squid as an httpd accelerator
httpd_accel_port 80: 80 is port you want to act as a proxy
httpd_accel_with_proxy on: Squid act as [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F12%2F18%2Fsetup-a-transparent-proxy-with-3-easy-steps%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F12%2F18%2Fsetup-a-transparent-proxy-with-3-easy-steps%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>First, Squid server installed (use up2date squid) and configured by adding following directives to file:<br />
<strong><code># vi /etc/squid/squid.conf</code></strong></p>
<p><strong><span id="more-127"></span><br />
</strong></p>
<p>Modify or add following squid directives:<br />
<strong><code>httpd_accel_host <span style="color: #ff0000">virtual</span><br />
httpd_accel_port <span style="color: #ff0000">80</span><br />
httpd_accel_with_proxy <span style="color: #ff0000">on</span><br />
httpd_accel_uses_host_header <span style="color: #ff0000">on</span><br />
acl lan src <span style="color: #ff0000">192.168.1.1 192.168.2.0/24</span><br />
http_access allow <span style="color: #ff0000">localhost</span><br />
http_access allow <span style="color: #ff0000">lan</span></code></strong></p>
<p>Where,</p>
<ul>
<li>httpd_accel_host <span style="color: #ff0000">virtual</span>: Squid as an httpd accelerator</li>
<li>httpd_accel_port <span style="color: #ff0000">80</span>: 80 is port you want to act as a proxy</li>
<li>httpd_accel_with_proxy <span style="color: #ff0000">on</span>: Squid act as both a local httpd accelerator and as a proxy.</li>
<li>httpd_accel_uses_host_header <span style="color: #ff0000">on</span>: Header is turned on which is the hostname from the URL.</li>
<li>acl lan src <span style="color: #ff0000">192.168.1.1 192.168.2.0/24</span>: Access control list, only allow LAN computers to use squid</li>
<li>http_access allow <span style="color: #ff0000">localhost</span>: Squid access to LAN and localhost ACL only</li>
<li>http_access allow <span style="color: #ff0000">lan</span>: &#8212; same as above &#8211;</li>
</ul>
<p>Here is the complete listing of squid.conf for your reference (grep will remove all comments and sed will remove all empty lines, thanks to David Klein for quick hint ):<br />
<strong><code># grep -v "^#" /etc/squid/squid.conf | sed -e '/^$/d'</code></strong></p>
<p>OR, try out sed (thanks to <a href="http://www.cyberciti.biz/tips/linux-setup-transparent-proxy-squid-howto.html#comment-144">kotnik</a> for small sed trick)<br />
<strong><code># cat /etc/squid/squid.conf | sed '/ *#/d; /^ *$/d'</code></strong></p>
<p>Output:<br />
<strong><code>hierarchy_stoplist cgi-bin ?<br />
acl QUERY urlpath_regex cgi-bin \?<br />
no_cache deny QUERY<br />
hosts_file /etc/hosts<br />
refresh_pattern ^ftp:           1440    20%     10080<br />
refresh_pattern ^gopher:        1440    0%      1440<br />
refresh_pattern .               0       20%     4320<br />
acl all src 0.0.0.0/0.0.0.0<br />
acl manager proto cache_object<br />
acl localhost src 127.0.0.1/255.255.255.255<br />
acl to_localhost dst 127.0.0.0/8<br />
acl purge method PURGE<br />
acl CONNECT method CONNECT<br />
cache_mem 1024 MB<br />
http_access allow manager localhost<br />
http_access deny manager<br />
http_access allow purge localhost<br />
http_access deny purge<br />
http_access deny !Safe_ports<br />
http_access deny CONNECT !SSL_ports<br />
acl lan src 192.168.1.1  192.168.2.0/24<br />
http_access allow localhost<br />
http_access allow lan<br />
http_access deny all<br />
http_reply_access allow all<br />
icp_access allow all<br />
visible_hostname myclient.hostname.com<br />
httpd_accel_host virtual<br />
httpd_accel_port 80<br />
httpd_accel_with_proxy on<br />
httpd_accel_uses_host_header on<br />
coredump_dir /var/spool/squid</code></strong></p>
<h3>Iptables configuration</h3>
<p>Next, I had added following rules to forward all http requests (coming to port 80) to the Squid server port 3128 :<br />
<strong><code>iptables -t nat -A PREROUTING -i  <span style="color: #ff0000">eth1</span> -p tcp --dport <span style="color: #ff0000">80</span> -j DNAT --to 192.168.1.1:3128<br />
iptables -t nat -A PREROUTING -i  <span style="color: #ff0000">eth0</span> -p tcp --dport  <span style="color: #ff0000">80 -j REDIRECT --to-port 3128</span></code></strong></p>
<p>Here is complete shell script. Script first configure Linux system as router and forwards all http request to port 3128 (Download the <a href="http://www.cyberciti.biz/tips/wp-content/uploads/2006/06/fw.proxy.txt">fw.proxy</a> shell script):<br />
<strong><code><em><span style="color: #9a1900">#!/bin/sh</span></em><br />
<em><span style="color: #9a1900"># squid server IP</span></em><br />
SQUID_SERVER<span style="color: #990000">=</span><span style="color: #ff0000">"192.168.1.1"</span><br />
<em><span style="color: #9a1900"># Interface connected to Internet</span></em><br />
INTERNET<span style="color: #990000">=</span><span style="color: #ff0000">"eth0"</span><br />
<em><span style="color: #9a1900"># Interface connected to LAN</span></em><br />
LAN_IN<span style="color: #990000">=</span><span style="color: #ff0000">"eth1"</span><br />
<em><span style="color: #9a1900"># Squid port</span></em><br />
SQUID_PORT<span style="color: #990000">=</span><span style="color: #ff0000">"3128"</span><br />
<em><span style="color: #9a1900"># DO NOT MODIFY BELOW</span></em><br />
<em><span style="color: #9a1900"># Clean old firewall</span></em><br />
iptables <span style="color: #990000">-</span>F<br />
iptables <span style="color: #990000">-</span>X<br />
iptables <span style="color: #990000">-</span>t nat <span style="color: #990000">-</span>F<br />
iptables <span style="color: #990000">-</span>t nat <span style="color: #990000">-</span>X<br />
iptables <span style="color: #990000">-</span>t mangle <span style="color: #990000">-</span>F<br />
iptables <span style="color: #990000">-</span>t mangle <span style="color: #990000">-</span>X<br />
<em><span style="color: #9a1900"># Load IPTABLES modules for NAT and IP conntrack support</span></em><br />
modprobe ip_conntrack<br />
modprobe ip_conntrack_ftp<br />
<em><span style="color: #9a1900"># For win xp ftp client</span></em><br />
<em><span style="color: #9a1900">#modprobe ip_nat_ftp</span></em><br />
echo <span style="color: #993399">1</span> <span style="color: #990000">&gt;</span> /proc/sys/net/ipv4/<span style="color: #0000ff">ip_forward</span><br />
<em><span style="color: #9a1900"># Setting default filter policy</span></em><br />
iptables <span style="color: #990000">-</span>P INPUT DROP<br />
iptables <span style="color: #990000">-</span>P OUTPUT ACCEPT<br />
<em><span style="color: #9a1900"># Unlimited access to loop back</span></em><br />
iptables <span style="color: #990000">-</span>A INPUT <span style="color: #990000">-</span>i lo <span style="color: #990000">-</span>j ACCEPT<br />
iptables <span style="color: #990000">-</span>A OUTPUT <span style="color: #990000">-</span>o lo <span style="color: #990000">-</span>j ACCEPT<br />
<em><span style="color: #9a1900"># Allow UDP, DNS and Passive FTP</span></em><br />
iptables <span style="color: #990000">-</span>A INPUT <span style="color: #990000">-</span>i <span style="color: #009900">$INTERNET</span> <span style="color: #990000">-</span><span style="color: #0000ff">m</span> state <span style="color: #990000">-</span><span style="color: #990000">-</span>state ESTABLISHED<span style="color: #990000">,</span>RELATED <span style="color: #990000">-</span>j ACCEPT<br />
<em><span style="color: #9a1900"># set this system as a router for Rest of LAN</span></em><br />
iptables <span style="color: #990000">-</span><span style="color: #990000">-</span>table nat <span style="color: #990000">-</span><span style="color: #990000">-</span>append POSTROUTING <span style="color: #990000">-</span><span style="color: #990000">-</span>out<span style="color: #990000">-</span>interface <span style="color: #009900">$INTERNET</span> <span style="color: #990000">-</span>j MASQUERADE<br />
iptables <span style="color: #990000">-</span><span style="color: #990000">-</span>append FORWARD <span style="color: #990000">-</span><span style="color: #990000">-</span>in<span style="color: #990000">-</span>interface <span style="color: #009900">$LAN_IN</span> <span style="color: #990000">-</span>j ACCEPT<br />
<em><span style="color: #9a1900"># unlimited access to LAN</span></em><br />
iptables <span style="color: #990000">-</span>A INPUT <span style="color: #990000">-</span>i <span style="color: #009900">$LAN_IN</span> <span style="color: #990000">-</span>j ACCEPT<br />
iptables <span style="color: #990000">-</span>A OUTPUT <span style="color: #990000">-</span>o <span style="color: #009900">$LAN_IN</span> <span style="color: #990000">-</span>j ACCEPT<br />
<em><span style="color: #9a1900"># DNAT port 80 request comming from LAN systems to squid 3128 ($SQUID_PORT) aka transparent proxy</span></em><br />
iptables <span style="color: #990000">-</span>t nat <span style="color: #990000">-</span>A PREROUTING <span style="color: #990000">-</span>i <span style="color: #009900">$LAN_IN</span> <span style="color: #990000">-</span>p tcp <span style="color: #990000">-</span><span style="color: #990000">-</span>dport <span style="color: #993399">80</span> <span style="color: #990000">-</span>j DNAT <span style="color: #990000">-</span><span style="color: #990000">-</span>to <span style="color: #009900">$SQUID_SERVER</span><span style="color: #990000">:</span><span style="color: #009900">$SQUID_PORT</span><br />
<em><span style="color: #9a1900"># if it is same system</span></em><br />
iptables <span style="color: #990000">-</span>t nat <span style="color: #990000">-</span>A PREROUTING <span style="color: #990000">-</span>i <span style="color: #009900">$INTERNET</span> <span style="color: #990000">-</span>p tcp <span style="color: #990000">-</span><span style="color: #990000">-</span>dport <span style="color: #993399">80</span> <span style="color: #990000">-</span>j REDIRECT <span style="color: #990000">-</span><span style="color: #990000">-</span>to<span style="color: #990000">-</span>port <span style="color: #009900">$SQUID_PORT</span><br />
<em><span style="color: #9a1900"># DROP everything and Log it</span></em><br />
iptables <span style="color: #990000">-</span>A INPUT <span style="color: #990000">-</span>j LOG<br />
iptables <span style="color: #990000">-</span>A INPUT <span style="color: #990000">-</span>j DROP</code></strong></p>
<p>Save shell script. Execute script so that system will act as a router and forward the ports:<br />
<strong><code># chmod +x /etc/fw.proxy<br />
# /etc/fw.proxy<br />
# service iptables save<br />
# chkconfig iptables on</code></strong></p>
<p>Start or Restart the squid:<br />
<strong><code># /etc/init.d/squid restart<br />
# chkconfig squid on</code></strong></p>
<h3>Desktop / Client computer configuration</h3>
<p>Point all desktop clients to your eth1 IP address (192.168.2.1) as Router/Gateway (use DHCP to distribute this information). You do not have to setup up individual browsers to work with proxies.</p>
<h3>How do I test my squid proxy is working correctly?</h3>
<p>See access log file /var/log/squid/access.log:<br />
<strong><code># tail -f /var/log/squid/access.log</code></strong></p>
<p>Above command will monitor all incoming request and log them to /var/log/squid/access_log file. Now if somebody accessing a website through browser, squid will log information.</p>
<h3>Problems and solutions</h3>
<h4>(a) Windows XP FTP Client</h4>
<p>All Desktop client FTP session request ended with an error:<br />
Illegal PORT command.</p>
<p>I had loaded the ip_nat_ftp kernel module. Just type the following command press Enter and voila!<br />
<strong><code># modprobe ip_nat_ftp</code></strong></p>
<p>Please note that modprobe command is already added to a shell script (above).</p>
<h4>(b) Port 443 redirection</h4>
<p>I had block out all connection request from our router settings except for our proxy (192.168.1.1) server. So all ports including 443 (https/ssl) request denied. You cannot redirect port 443, from <a href="http://lists.debian.org/debian-user/2004/05/msg01434.html">debian mailing list</a>, &#8220;<em>Long answer: SSL is specifically designed to prevent &#8220;man in the middle&#8221; attacks, and setting up squid in such a way would be the same as such a &#8220;man in the middle&#8221; attack. You might be able to successfully achive this, but not without breaking the encryption and certification that is the point behind SSL</em>&#8220;.</p>
<p>Therefore, I had quickly reopen port 443 (router firewall) for all my LAN computers and problem was solved.</p>
<h4>(c) Squid Proxy authentication in a transparent mode</h4>
<p>You cannot use Squid authentication with a transparently intercepting proxy.</p>
<h3>Further reading:</h3>
<ul>
<li><a href="http://www.cyberciti.biz/nixcraft/vivek/blogger/2005/10/how-do-i-use-iptables-connection.html">How do I use Iptables connection tracking feature? </a></li>
<li><a href="http://www.cyberciti.biz/nixcraft/vivek/blogger/2005/10/how-do-i-build-simple-linux-firewall.html">How do I build a Simple Linux Firewall for DSL/Dial-up connection? </a></li>
<li><strong>Update:</strong> <a href="http://www.cyberciti.biz/nixcraft/forum/viewtopic.php?t=457">Forum topic discussion: Setting up a transparent proxy with Squid peering to ISP squid server</a></li>
<li><a href="http://squid-docs.sourceforge.net/latest/html/book1.html">Squid, a user&#8217;s guide</a></li>
<li><a href="http://www.squid-cache.org/Doc/FAQ/">Squid FAQ</a></li>
<li><a href="http://tldp.org/HOWTO/TransparentProxy.html">Transparent Proxy with Linux and Squid mini-HOWTO</a></li>
</ul>
<p><a title="http://www.cyberciti.biz/tips/linux-setup-transparent-proxy-squid-howto.html" href="http://www.cyberciti.biz/tips/linux-setup-transparent-proxy-squid-howto.html" target="_blank"><strong>Source</strong></a></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/12/18/setup-a-transparent-proxy-with-3-easy-steps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTPasswd Tutorial</title>
		<link>http://blog.nataprawira.com/tech/2009/11/24/htpasswd-tutorial/</link>
		<comments>http://blog.nataprawira.com/tech/2009/11/24/htpasswd-tutorial/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 02:35:18 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[HTaccess]]></category>
		<category><![CDATA[htpassword]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=119</guid>
		<description><![CDATA[

If you would like to have a set of web pages that are protected, requiring a username/password to gain access, this tutorial will show you how to set it up. This is geared towards the Unix Apache httpd servers used on holly, lamar, and www.colostate.edu. If you are using another web server, you&#8217;ll need to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F11%2F24%2Fhtpasswd-tutorial%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F11%2F24%2Fhtpasswd-tutorial%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<h1><span style="font-weight: normal;font-size: 13px">If you would like to have a set of web pages that are protected, requiring a username/password to gain access, this tutorial will show you how to set it up. This is geared towards the Unix Apache httpd servers used on holly, lamar, and www.colostate.edu. If you are using another web server, you&#8217;ll need to check that server&#8217;s documentation to see how to do this.</span></h1>
<p><span style="font-weight: normal;font-size: 13px"><span id="more-119"></span></span></p>
<p><span style="font-weight: normal;font-size: 13px"><strong>Steps to Password-protect a Directory</strong></span></p>
<p><span style="font-weight: normal;font-size: 13px"><strong><span style="font-weight: normal;font-size: 13px">First, create a subdirectory in your web area. For the sake of this tutorial, I have created the &#8220;protect&#8221; directory. Set the permissions on the directory so that the server has read/execute. I do this by using the local command chgrp-www to set the group to the www group. This is the group that the server runs under at Colorado State University for the lamar, holly and www servers. I have used the -sd flag which sets &#8220;set group id&#8221; for a directory. This will then force any files you create within the protect directory to the www group, so if you ftp files to this directory they will be automatically readable by the server but not by any other user on the system. I then cd into the protect directory. </span></strong></span></p>
<blockquote>
<pre><strong>cd ~ric/public_html
mkdir protect
chmod g+r,g+x,o-r,o-x protect
chgrp-www -sd protect
cd protect</strong></pre>
</blockquote>
<p>Next you must create a .htaccess file inside the directory you want protected. You can use either the vi or pico editors on the supported systems mentioned above or ftp the file to this directory. If you are new to unix or know little about vi then I suggest you use the pico editor or ftp the .htaccess file. The command to edit with pico is &#8220;pico .htaccess&#8221;. The .htaccess file should contain the following lines. The items in <strong>bold</strong> are things you will want to change depending on the location of the AuthUserFile and content of AuthName.</p>
<blockquote>
<pre><strong>AuthUserFile /z/ric/secret/.htpasswd
AuthGroupFile /dev/null
AuthName "Ric's protected files"
AuthType Basic

&lt;Limit GET&gt;
require valid-user
&lt;/Limit&gt;</strong></pre>
</blockquote>
<p>The <strong>AuthName</strong> is what the user will see when they&#8217;re prompted for a password &#8211; something to the effect of &#8220;Enter the username for Ric&#8217;s Protected files&#8221;. The <strong>AuthUserFile</strong> is location of the password file and should be not accessible with a url on the server for security reasons. This is a full unix path and the permissions should be set up like the &#8220;protect&#8221; directory using the chmod and chgrp-www commands above so the only one that can read this file is the owner and the server. To get the full path of a directory, cd to that directory and enter the command &#8220;pwd&#8221; to print the working directory path.</p>
<p>Now you&#8217;ll have to set up the password file. You&#8217;ll need to use the <strong>htpasswd</strong> program. It is included with the Apache httpd server.</p>
<p>First cd to the directory that contains the password file. In this example the password file is called .htpasswd and is in the directory /z/ric/secret/ as indicated by the AuthUserFile file entry in the .htaccess file. For every username you want to add to the password file, enter the following. (the -c is only required the first time; it indicates that you want to create the .htpasswd file).</p>
<blockquote>
<pre><strong>
$~ cd
$~ mkdir secret
$~ cd secret
$~ htpasswd -c .htpasswd pumpkin
<span style="font-weight: normal"><span style="color: #333399">
[ you're prompted for the password for pumpkin]
[ if you have other users enter the following. Don't use the -c]
</span></span>
$~ htpasswd .htpasswd user2
$~ htpasswd .htpasswd user3
</strong></pre>
</blockquote>
<p>Again, make sure the permissions are set up like the &#8220;protect&#8221; directory using the chmod and chgrp-www commands above so the only one that can read files in the &#8220;secret&#8221; directory is the owner and the server.</p>
<p>Here is the <a href="http://www.colostate.edu/~ric/protect/your.html" target="_blank">protected page</a> using the above setup to password protect this page. The username is &#8220;pumpkin&#8221; and password is &#8220;pie&#8221;.</p>
<p>[<a href="http://www.colostate.edu/~ric/htpass.html" target="_blank">source</a>]</p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/11/24/htpasswd-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Web/Linux IP Address Lookup</title>
		<link>http://blog.nataprawira.com/tech/2009/10/22/ip-address-lookup/</link>
		<comments>http://blog.nataprawira.com/tech/2009/10/22/ip-address-lookup/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 17:58:01 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[IP Address]]></category>
		<category><![CDATA[Lookup]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=106</guid>
		<description><![CDATA[

If you&#8217;re going to be doing a lot of Geotargeting or IP Address  Lookups, please take a feed instead which will preserve both our bandwidth and  your bandwidth.
Simple GET
That said, there is an easy HTTP oriented API to locate IP  addresses and Geocode them. If you don&#8217;t supply the &#8220;?ip=aa.bb.cc.dd&#8221;  bit, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F10%2F22%2Fip-address-lookup%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F10%2F22%2Fip-address-lookup%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>If you&#8217;re going to be doing a lot of Geotargeting or IP Address  Lookups, please take a feed instead which will preserve both our bandwidth and  your bandwidth.</p>
<h1>Simple GET</h1>
<p>That said, there is an easy HTTP oriented API to locate <strong>IP  addresses</strong> and <strong>Geocode</strong> them. If you don&#8217;t supply the &#8220;?ip=aa.bb.cc.dd&#8221;  bit, then the ip address lookup of the calling machine will be located instead  (here, the aa,bb,cc,dd are decimal digits). If you add &amp;position=true to the  end of the URL then latitude and longitude will be returned also. Both HTML and  XML formats are supplied for your convenience.</p>
<blockquote><p><strong>http://api.hostip.info/country.php</strong><br />
US</p>
<p><strong>http://api.hostip.info/get_html.php?ip=12.215.42.19</strong><br />
Country: UNITED STATES (US)<br />
City: Sugar Grove, IL</p>
<p><strong>http://api.hostip.info/get_html.php?ip=12.215.42.19&amp;position=true</strong><br />
Country: UNITED STATES (US)<br />
City: Sugar Grove, IL<br />
Latitude: 41.7696<br />
Longitude: -88.4588</p>
<p><strong>http://api.hostip.info/?ip=12.215.42.19</strong><br />
[use the URL above for an example - XML too long to paste below]</p></blockquote>
<h1><span id="more-106"></span>Country Flag</h1>
<p>Paste the following code into your HTML to get a country  flag of the ip address. The database is significantly more accurate (it ought to  be 100%) for countries than for cities. It would be nice if y&#8217;all would make the  flag a link to the www.hostip.info home page (http://www.hostip.info/) so they  can come by if they&#8217;re interested &#8211; it&#8217;ll only benefit you in the long run.  After all, the results get more accurate as more visitors submit their IP  addresses!<br />
Flag of visitor&#8217;s location:</p>
<blockquote><p><strong>&lt;A HREF=&#8221;http://www.hostip.info&#8221;&gt;<br />
&lt;IMG SRC=&#8221;http://api.hostip.info/flag.php&#8221; BORDER=&#8221;0&#8243; ALT=&#8221;IP Address Lookup&#8221;&gt;<br />
&lt;/A&gt;</strong></p></blockquote>
<p>Flag of any IP address:</p>
<blockquote><p><strong>&lt;A HREF=&#8221;http://www.hostip.info&#8221;&gt;<br />
&lt;IMG SRC=&#8221;http://api.hostip.info/flag.php?ip=12.215.42.19&#8243; ALT=&#8221;IP Address Lookup&#8221;&gt;<br />
&lt;/A&gt;</strong></p></blockquote>
<h1>Embedded Applet</h1>
<p>The following is designed to be embedded within another HTML page using the OBJECT tag. This will reproduce the zoom-in applet, (or an explanatory message with a link to fix, if the IP address lookup is unknown). Which means you can embed the applet in your own site without needing to have the local database and map data (which runs to a few gigabytes&#8230;)</p>
<p>All you need do is include the OBJECT block below in your HTML.  Note, you can also add &#8220;?ip=aaa.bbb.ccc.ddd&#8221; to the frame.html url below to map a specific IP address.</p>
<blockquote>
<pre>&lt;OBJECT DATA='http://www.hostip.info/map/frame.html'

  TYPE='text/html' BORDER=0

  WIDTH=610 HEIGHT=330 HSPACE=0 VSPACE=0&gt;

&lt;/OBJECT&gt;</pre>
</blockquote>
<h1>*NIX Shell Script</h1>
<p>You can use the following shell script to call in your  favorite *NIX environment.</p>
<blockquote><p><strong>#!/bin/bash<br />
lynx -dump &#8220;http://api.hostip.info/get_html.php?ip=$1&#8243;</strong></p></blockquote>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/10/22/ip-address-lookup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to tune Apache and Mysql</title>
		<link>http://blog.nataprawira.com/tech/2009/07/25/how-to-tune-apache-and-mysql/</link>
		<comments>http://blog.nataprawira.com/tech/2009/07/25/how-to-tune-apache-and-mysql/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 17:29:43 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[tune]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=66</guid>
		<description><![CDATA[

By default, Apache comes preconfigured to serve a maximum of 256 clients simultaneously. This particular configuration setting can be found in the file /etc/httpd/conf/httpd.conf
If your server has 2 GB of RAM, and you’re sharing your server with MySQL(true in my case), you’ll want to reserve about half of it for Apache (1 GB)

MaxClients: here is [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F07%2F25%2Fhow-to-tune-apache-and-mysql%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F07%2F25%2Fhow-to-tune-apache-and-mysql%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>By default, Apache comes preconfigured to serve a maximum of 256 clients simultaneously. This particular configuration setting can be found in the file <strong>/etc/httpd/conf/httpd.conf</strong></p>
<p>If your server has 2 GB of RAM, and you’re sharing your server with MySQL(true in my case), you’ll want to reserve about half of it for Apache (1 GB)</p>
<p><span id="more-66"></span></p>
<p>MaxClients: here is the process of determining MaxClients. type<strong> </strong></p>
<p style="padding-left: 30px"><strong>ps -U apache -u apache u</strong></p>
<p>See the number of apache process running in you command prompt.<strong></strong></p>
<p style="padding-left: 30px"><strong>USER       PID %CPU %MEM    VSZ     RSS  TTY    STAT START   TIME COMMAND<br />
apache     7694     0.0     0.3       42704  6680    ?        S       18:30   0:00 /usr/sbin/httpd</strong></p>
<p>The above indicates that a single httpd process is using 6.6 MB of RSS (Resident Set Size) memory (or non-swapped physical memory) and that it is using 42 MB of VSZ (Virtual Size) memory. This depends on the number of modules you have loaded and running in Apache.</p>
<p>As shared libraries are included in this number, it’s not 100 percent accurate. We can assume that half the RSS number is “real” memory. Let’s assume that each httpd process is using (6.6/2=3.3) 4 MB of memory. So if you have 1 GB ram then divide it with 4 MB of memory, which leaves room for around 256 concurrent httpd processes.</p>
<p style="padding-left: 30px"><strong>Set MaxClients 256</strong></p>
<p>Or</p>
<p>Somebody prefers to set MaxClients using following rule<strong></strong></p>
<p style="padding-left: 30px"><strong>MaxClients = 150 x RAM (GB) </strong></p>
<p>So for example if you have 2 GB RAM (dedicated for apache) set this value to 300. In my case IT WILL BE 150</p>
<p>Or</p>
<p>Some individuals maintain that each httpd thread uses about 5 MB of “real” memory. So they determine by the following way..</p>
<p>Or</p>
<p style="padding-left: 30px"><code>MaxClients = RAM(MB)/5</code></p>
<p><code>So for example if you have 2 GB RAM (dedicated for apache) set this value to 409. In my case IT WILL BE 204(1 GB for apache)</code><em></em></p>
<p><em>Note:</em> There is no reason for you to set it any higher unless you have a specific problem with this value. A high value can lead to a complete server hang in case of a DOS attack. A value too low can create timeout problems for your clients if the limit is reached</p>
<p><strong>StartServers</strong> &#8211; Sets the number of child server processes created on startup. This setting depends greatly on the type of webserver you run. If you run low traffic websites on that server set it low to something like 5. If you have resource intensive websites on that server you should set it close to MaxClients.</p>
<p><strong>MaxRequestsPerChild</strong> &#8211; Controls the number of request the a child serves before the child is killed. This should not be set too low as it will put an unnecessary load on the apache server to recreate the child. I suggest setting it to 1000.</p>
<p>But we are going to use 2000 for handling heavy traffic load properly.</p>
<p><strong>MinSpareServers and MaxSpareServers</strong> &#8211; MaxSpareServers and MinSpareServers control how many spare (unused) child-processes Apache will keep alive while waiting for more requests to put them to use. Each child-process consumes resources, so having MaxSpareServers set too high can cause resource problems. On the other hand, if the number of unused servers drops below MinSpareServers, Apache will fork. Leave those values to: MinSpareServers 5 MaxSpareServers 10</p>
<p><strong>ServerLimit</strong>: Its better to keep Server limit same as the value of MaxClients.<strong></strong></p>
<p><strong>MaxRequestsPerChild</strong>: I’ve Kept default apache value for this one.</p>
<p>So few changes need to be made in httpd.conf file which is located in /etc/httpd/conf/ directory<strong></strong></p>
<p style="padding-left: 30px"><strong>&lt;IfModule prefork.c&gt;<br />
StartServers     140<br />
MinSpareServers    5<br />
MaxSpareServers   10<br />
ServerLimit      150<br />
MaxClients       150<br />
MaxRequestsPerChild  4000<br />
&lt;/IfModule&gt;</strong></p>
<p>[Note]: Response time depends on MaxClients. If you increase the MaxClients number, server will response more quickly for each request but  a high value can lead to a complete server hang.</p>
<p>Ab is a tool for benchmarking the performance of your Apache HyperText Transfer Protocol (HTTP) server. It does this by giving you an indication of how many requests per second your Apache installation can serve.</p>
<p>uptime command in your root login should not yield a load average above 1, and the server should respond to commands quickly<strong></strong></p>
<p style="padding-left: 30px"><strong>ab -n 10000 -c 200 -k http://your_url<br />
-c = concurrent connections<br />
-t = time limit<br />
-n = # of requests</strong></p>
<p>Keep tuning until you hit your maximum desired load average. For servers used interactively often, having a load above 3 is way too much to use the server comfortably. For servers used mostly as real servers, a maximum load average of 10 should be acceptable. More than that, and you’ll find yourself needing to reboot the server when experiencing heavy traffic conditions, because no terminal or remote console will respond quickly to commands, and managing the server will be impossible.</p>
<p><strong>How to configure few things in php.ini file for supporting huge traffic</strong></p>
<p>* Enable the compression of HTML by putting in your php.ini:<strong></strong></p>
<p style="padding-left: 30px"><strong>output_handler = ob_gzhandler</strong></p>
<p>** Switch from file based sessions to shared memory sessions. Compile PHP with the –with-mm option and<strong></strong></p>
<p style="padding-left: 30px"><strong>set session.save_handler=mm</strong></p>
<p><strong>Configure mysql. Change my.cnf file for better performance.</strong></p>
<p>The database parameters are tuned for systems with 1 GB RAM (for ISO CD images). If you have higher RAM, please change the following in the “my.cnf” MySQL configuration file under /etc/mysql or /etc directory.<strong></strong></p>
<p><strong>For a machine running with 512 MB of RAM, you can set these to:</strong></p>
<p style="padding-left: 30px"><strong>key_buffer=128M table_cache=1024 sort_buffer=64M read_buffer=2M record_buffer=4M</strong></p>
<p><strong>For a machine running with 1 GB of RAM, you can set these to:</strong></p>
<p style="padding-left: 30px"><strong>key_buffer=256M table_cache=2048 sort_buffer=128M read_buffer=2M record_buffer=8M</strong></p>
<p><strong>For a machine running with 2 GB of RAM, you can set these to:</strong></p>
<p style="padding-left: 30px"><strong>key_buffer=512M table_cache=3072 sort_buffer=256M read_buffer=2M record_buffer=8M</strong></p>
<p><strong>For a machine running with 4 GB of RAM, you can set these to:</strong></p>
<p style="padding-left: 30px"><strong>key_buffer=1G table_cache=4096 sort_buffer=512M read_buffer=2M record_buffer=8M</strong></p>
<p><strong><a title="http://blog.shabuz.com/?p=54" href="http://blog.shabuz.com/?p=54" target="_blank">Original Post</a><br />
</strong></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/07/25/how-to-tune-apache-and-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Necessary commands (tips) to tune apache</title>
		<link>http://blog.nataprawira.com/tech/2009/07/25/necessary-commands-tips-to-tune-apache/</link>
		<comments>http://blog.nataprawira.com/tech/2009/07/25/necessary-commands-tips-to-tune-apache/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 17:24:26 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=64</guid>
		<description><![CDATA[

To search in the current directory and all sub directories for a file named httpd.conf
find . -name “httpd.conf” -print
To find some string or text, type
find . -exec grep “MaxClients” ‘{}’ \; -print
This command will search in the current directory and all sub directories. All files that contain the string with the path.
If you want to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F07%2F25%2Fnecessary-commands-tips-to-tune-apache%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F07%2F25%2Fnecessary-commands-tips-to-tune-apache%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>To search in the current directory and all sub directories for a file named httpd.conf</p>
<p style="padding-left: 30px"><strong>find . -name “httpd.conf” -print</strong></p>
<p>To find some string or text, type</p>
<p style="padding-left: 30px"><strong>find . -exec grep “MaxClients” ‘{}’ \; -print</strong></p>
<p><span id="more-64"></span>This command will search in the current directory and all sub directories. All files that contain the string with the path.</p>
<p>If you want to just find each file then pass it on for processing use the -q grep option. This finds the first occurrance of the search string. It then signals success to find and find continues searching for more files.</p>
<p style="padding-left: 30px"><strong>find . -exec grep -q “www.athabasca” ‘{}’ \; -print</strong></p>
<p>Send 1000 Request to apache using apache benchmark</p>
<p style="padding-left: 30px"><strong>ab -n 1000 -c 200 -k YOUR_URL</strong></p>
<p>To view error log of httpd. type</p>
<p style="padding-left: 30px"><strong>grep -i maxclient /var/log/httpd/error_log*</strong></p>
<p>To view Process status type and load average type top and uptime respectively.</p>
<p>To open a file and search something(Here Example is: MaxClients) from there type</p>
<p style="padding-left: 30px"><strong>vi +/MaxClients /etc/httpd/conf/httpd.conf</strong></p>
<p>To view total memory used by httpd, type</p>
<p style="padding-left: 30px"><strong>ps -ylC httpd –sort:rss</strong></p>
<p><strong><a title="http://blog.shabuz.com/?p=55" href="http://blog.shabuz.com/?p=55" target="_blank">Original Post</a></p>
<p></strong></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/07/25/necessary-commands-tips-to-tune-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Howto: HTACCESS Authentication restriction, but allow some IPs to get thru</title>
		<link>http://blog.nataprawira.com/tech/2009/06/22/howto-htaccess-authentication-restriction-but-allow-some-ips-to-get-thru/</link>
		<comments>http://blog.nataprawira.com/tech/2009/06/22/howto-htaccess-authentication-restriction-but-allow-some-ips-to-get-thru/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 11:29:55 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[HTaccess]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=57</guid>
		<description><![CDATA[

Easy part, just create like below .htaccess file on your web folder :
AuthName &#8220;My Protected Site&#8221;
AuthUserFile /home/apache/.htpasswd
AuthType basic
Require valid-user
Order Deny,Allow
Deny from all
Allow from 192.168.1. 192.168.2.
Satisfy Any
Good luck!
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F06%2F22%2Fhowto-htaccess-authentication-restriction-but-allow-some-ips-to-get-thru%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F06%2F22%2Fhowto-htaccess-authentication-restriction-but-allow-some-ips-to-get-thru%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>Easy part, just create like below .htaccess file on your web folder :</p>
<p style="padding-left: 30px">AuthName &#8220;My Protected Site&#8221;<br />
AuthUserFile /home/apache/.htpasswd<br />
AuthType basic<br />
Require valid-user<br />
Order Deny,Allow<br />
Deny from all<br />
Allow from 192.168.1. 192.168.2.<br />
Satisfy Any</p>
<p>Good luck!</p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/06/22/howto-htaccess-authentication-restriction-but-allow-some-ips-to-get-thru/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Add Godaddy SSL Site Seal Image</title>
		<link>http://blog.nataprawira.com/tech/2009/06/01/how-to-add-godaddy-ssl-site-seal-image/</link>
		<comments>http://blog.nataprawira.com/tech/2009/06/01/how-to-add-godaddy-ssl-site-seal-image/#comments</comments>
		<pubDate>Sun, 31 May 2009 17:26:40 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Godaddy]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[Site Seal]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=52</guid>
		<description><![CDATA[

We have 2 ways, to get this done. You just need to choose, which way is suitable for you  

Long Way:
1. Log in to your Account Manager.
2. Visit: https://certs.godaddy.com/ManageProducts.do
3. On &#8220;Manage SSL Certificates&#8221;, click on your domain name.
4. Click on &#8220;SITE SEAL&#8221; tab to manage your site seal
5. Choose &#8220;Site Seal Image Size&#8221;
6. Click [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F06%2F01%2Fhow-to-add-godaddy-ssl-site-seal-image%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F06%2F01%2Fhow-to-add-godaddy-ssl-site-seal-image%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>We have 2 ways, to get this done. You just need to choose, which way is suitable for you <img src='http://blog.nataprawira.com/tech/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-52"></span></p>
<p><span style="text-decoration: underline"><strong>Long Way:</strong></span></p>
<p>1. Log in to your Account Manager.</p>
<p>2. Visit: <a href="https://certs.godaddy.com/ManageProducts.do" target="_blank"><strong>https://certs.godaddy.com/ManageProducts.do</strong></a></p>
<p>3. On &#8220;Manage SSL Certificates&#8221;, click on your domain name.</p>
<p>4. Click on &#8220;SITE SEAL&#8221; tab to manage your site seal</p>
<p>5. Choose &#8220;Site Seal Image Size&#8221;</p>
<p>6. Click on Submit button.</p>
<p>7. On the right side box, copy-paste the javascript provided, into your sidebar website.</p>
<p>8. Done.</p>
<p><span style="text-decoration: underline"><strong>Easy way:</strong></span></p>
<p>1. Log in to your Account Manager.</p>
<p>2. Visit Manage Site Seal page: <a href="https://certs.godaddy.com/ManageSiteSeal.do" target="_blank"><strong>https://certs.godaddy.com/ManageSiteSeal.do</strong></a></p>
<p>3. Choose &#8220;Site Seal Image Size&#8221;</p>
<p>4. Click on Submit button.</p>
<p>5. On the right side box, copy-paste the javascript provided, into your sidebar website.</p>
<p>6. Done.</p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/06/01/how-to-add-godaddy-ssl-site-seal-image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Securing Linux</title>
		<link>http://blog.nataprawira.com/tech/2009/04/12/securing-linux/</link>
		<comments>http://blog.nataprawira.com/tech/2009/04/12/securing-linux/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 00:49:07 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Secure]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=48</guid>
		<description><![CDATA[



Mod_security(ModSecurity is an open source intrusion detection and prevention engine for web applications)
Features 
•	filtering POST and GET requests (including hearders)
•	filters inheritance and ability to add filters in each vhosts configuration file, and    per directory
•	include a way to chroot apache in an easiest way
•	ability to fake apache output (like telling &#8220;Microsoft IIS&#8221; on error page or [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F04%2F12%2Fsecuring-linux%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F04%2F12%2Fsecuring-linux%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<div id="matter_container">
<div class="matter_matter">
<h1 class="title">Mod_security(ModSecurity is an open source intrusion detection and prevention engine for web applications)</h1>
<h2><span class="content_title_blue">Features </span></h2>
<p><span class="content_text">•	filtering POST and GET requests (including hearders)<br />
•	filters inheritance and ability to add filters in each vhosts configuration file, and    per directory<br />
•	include a way to chroot apache in an easiest way<br />
•	ability to fake apache output (like telling &#8220;Microsoft IIS&#8221; on error page or whatever    you want to display)<br />
•	can store uploaded files in a tmp directory and call an anti-virus scan like clamav on     these files </span></p>
<p><span id="more-48"></span></p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.modsecurity.org/download/modsecurity-apache_1.9.4.tar.gz<br />
tar zxvf modsecurity-apache_1.9.4.tar.gz<br />
cd modsecurity-apache_1.9.4<br />
/usr/local/apache/bin/apxs -cia mod_security.c<br />
/usr/local/apache/bin/apachectl stop<br />
/usr/local/apache/bin/apachectl start</p>
<p class="content_text">Add required modsecurity directives in httpd.conf</p>
<h1 class="title">Mod_evasive( mod_evasive is intended to avoid DDOS attacks by baning IPs that have reached a configured limit of requests during a laps of time)</h1>
<h2><span class="content_title_blue">Features </span></h2>
<p><span class="content_text">•	Its quite easy to deploy on a webserver and can be very usefull.<br />
•	IP addresses of trusted clients can be whitelisted to insure they are never denied<br />
• This tool is excellent at fending off request-based DoS attacks or scripted<br />
attacks, and brute force attack </span></p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.zdziarski.com/projects/mod_evasive/mod_evasive_1.10.1.tar.gz<br />
1. Extract this archive into src/modules in the Apache source tree<br />
2. Run ./configure &#8211;add-module=src/modules/evasive/mod_evasive.c<br />
3. make, install<br />
4. Restart Apache<br />
With DSO Support, Ensim, or CPanel:<br />
1. /usr/local/apache/bin/apxs -iac mod_evasive.c<br />
2. Restart Apache</p>
<p class="content_text">Add required directive in httpd.conf</p>
<h1 class="title">Mod_limitipconn(mod_limitipconn allows web server administrators to limit the number of simultaneous downloads permitted from a single IP address)</h1>
<h2><span class="content_title_blue">Features </span></h2>
<p class="content_text">•	Allows inclusion and exclusion of files based on MIME type.<br />
•	Partially fixes the problem of dangling browser connections counting towards the    download limit</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget<br />
http://dominia.org/djao/limit/mod_limitipctar xzvf mod_limitipconn-0.04.tar.gz<br />
tar xzvf mod_limitipconn-0.04.tar.gz<br />
cd apache_1.3.27<br />
patch -p1 &lt; /root/mod_limitipconn-0.04/apachesrc.diff<br />
cp /root/mod_limitipconn-0.04/mod_limitipconn.c src/modules/extra/<br />
./configure &#8211;activate-module=src/modules/extra/mod_limitipconn.c &#8211;with-forward<br />
make ,install</p>
<p class="content_text"><strong>With DSO Support, Ensim, or CPanel:</strong><br />
1.cd mod_limitipconn-0.04<br />
2.make<br />
3.make install</p>
<p class="content_text">add required directives in httpd.conf</p>
<h1 class="title">APF (Advanced Policy Firewall is a policy based iptables firewall system designed for ease of use and configuration)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text">- detailed and well commented configuration file<br />
- granular inbound and outbound network filtering<br />
- user id based outbound network filtering<br />
- application based network filtering<br />
- trust based rule files with an optional advanced syntax<br />
- global trust system where rules can be downloaded from a central management<br />
server<br />
- debug mode provided for testing new features and configuration setups<br />
- fast load feature that allows for 1000+ rules to load in under 1 second<br />
- inbound and outbound network interfaces can be independently configured<br />
- global tcp/udp port &amp; icmp type filtering with multiple methods of excuting<br />
filters (drop, reject, prohibit)<br />
- configurable policies for each ip on the system with convenience variables to<br />
import settings<br />
- packet flow rate limiting that prevents abuse on the most widely abused<br />
protocol, icmp<br />
- prerouting and postrouting rules for optimal network performance<br />
- dshield.org block list support to ban networks exhibiting suspicious activity<br />
- spamhaus Don&#8217;t Route Or Peer List support to ban known &#8220;hijacked zombie&#8221; IP<br />
blocks<br />
- antidos subsystem to stop attacks before they become a significant threat<br />
- any number of additional interfaces may be configured as firewalled<br />
(untrusted) or trusted (not firewalled)<br />
- additional firewalled interfaces can have there own unique firewall policies<br />
applied<br />
- intelligent route verification to prevent embarrassing configuration errors<br />
- advanced packet sanity checks to make sure traffic coming and going meets<br />
- filter attacks such as fragmented UDP, port zero floods, stuffed routing,<br />
arp poisoning and more<br />
- configurable type of service options to dictate the priority of different types<br />
of network traffic<br />
- intelligent default settings to meet every day server setups<br />
- dynamic configuration of your servers local DNS revolvers into the firewall<br />
- optional filtering of common p2p applications<br />
- optional filtering of private &amp; reserved IP address space<br />
- optional implicit blocks of the ident service<br />
- configurable connection tracking settings to scale the firewall to the size of<br />
your network<br />
- configurable kernel hooks (ties) to harden the system further to syn-flood<br />
attacks &amp; routing abuses<br />
- advanced network control such as explicit congestion notification and overflow<br />
control<br />
- special chains that are aware of the state of FTP DATA and SSH connections to<br />
prevent client side issues<br />
- control over the rate of logged events, want only 30 filter events a minute?<br />
300 a minute? &#8211; you are the boss<br />
- logging subsystem that allows for logging data to user space programs or<br />
standard syslog files<br />
- logging that details every rule added and a comprehensive set of error checks<br />
to prevent config errors<br />
- if you are familiar with netfilter you can create your own rules in any of<br />
the policy files<br />
- pluggable and ready advanced use of QoS algorithms provided by the Linux</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.rfxnetworks.com/downloads/apf-current.tar.gz<br />
tar -xvzf apf-current.tar.gz<br />
cd apf-0.9.6-2/<br />
./install.sh</p>
<p class="content_text">configure apf(/etc/apf/conf.apf) upon requrements</p>
<p class="content_text">then  start apf<br />
/usr/local/sbin/apf -s</p>
<h1 class="title">BFD( Brute Force Detection is a modular shell script for parsing applicable logs and checking for authentication</h1>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.rfxnetworks.com/downloads/bfd-current.tar.gz<br />
tar -xvzf bfd-current.tar.gz<br />
cd bfd-0.7<br />
./install.sh</p>
<p>configure bfd (/usr/local/bfd/conf.bfd ) upon requirements</p>
<p>to start bdf running<br />
/usr/local/sbin/bfd -s</p>
<h1 class="title">SIM (System Integrity Monitor is a system and services monitor for ‘SysVinit’ systems. It is designed to be intuitive and modular in nature)</h1>
<h2><span class="content_title_blue">Features </span></h2>
<p><span class="content_text">- Service monitoring of HTTP, FTP, DNS, SSH, MYSQL &amp; more<br />
- Event tracking and alert system<br />
- Auto restart ability for downed services<br />
- Checks against network sockets &amp; process list to ensure services are online<br />
- HTTP log size monitor, to avoid segfaults from apache due to large logs<br />
- URL Aware monitoring, to ensure HTTP does not &#8216;lockup&#8217;<br />
- System load monitor with customizable warning levels, actions, and more&#8230;<br />
- Informative command line status display<br />
- Easily customizable configuration file<br />
- Auto configuration script<br />
- Auto cronjob setup feature<br />
- Caching feature for ps/netstat output, to ease on runtime load<br />
- Simple &amp; Informative installation script<br />
- Integrated auto-update feature</span></p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.r-fx.org/downloads/sim-current.tar.gz<br />
tar -xzvf sim-current.tar.gz<br />
cd sim-2.5-4/<br />
./setup -i<br />
Then press &#8220;Enter&#8221;<br />
Then when it says MORE press the &#8220;space bar&#8221;<br />
Then press &#8220;Enter&#8221;<br />
Then when it says MORE press the &#8220;space bar&#8221;<br />
Now you will press ENTER one more time to do the auto-configuration script for SIM</p>
<p class="content_text">To add a cron.<br />
Type: ./setup -c<br />
If it says &#8220;Removed SIM cronjob.&#8221; then you must type it again.<br />
Type: ./setup -c</p>
<h1 class="title">Portsentry(  PortSentry is a tcpwrapper that listens for port scans, which can be used to send back fake ping replys)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text">-help us to protect our network from unsolicited intrusions<br />
-we can choose which ports we want to be open and which one&#8217;s we dont</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.macosxunleashed.com/downloads/portsentry-1.0.tar.gz<br />
tar zxvfx portsentry-1.0.tar.gz<br />
cd  portsentry-1.0<br />
make linux<br />
make install</p>
<p class="content_text">conf file( /usr/local/psionic/portsentry/portsentry.conf)make relevant changes</p>
<h1 class="title">chkrootkit (it is a tool to locally check for signs of a rootkit)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text"><strong>*</strong> chkrootkit: shell script that checks system binaries for rootkit modification.<br />
<strong>*</strong> ifpromisc.c: checks if the interface is in promiscuous mode.<br />
<strong>*</strong> chklastlog.c: checks for lastlog deletions.<br />
<strong>*</strong> chkwtmp.c: checks for wtmp deletions.<br />
<strong>*</strong> check_wtmpx.c: checks for wtmpx deletions. (Solaris only)<br />
<strong>* </strong>chkproc.c: checks for signs of LKM trojans.<br />
<strong>*</strong> chkdirs.c: checks for signs of LKM trojans.<br />
<strong>*</strong> strings.c: quick and dirty strings replacement.<br />
<strong>*</strong> chkutmp.c: checks for utmp deletions.</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz<br />
tar zxvf chkrootkit.tar.gz<br />
cd chkrootkit-0.47/<br />
make sense<br />
./chkrootkit</p>
<p class="content_text">configure reporting cronjob:-</p>
<p class="content_text">cd /etc/cron.daily<br />
vi chkrootkit.cron<br />
#!/bin/bash<br />
cd /root/chkrootkit-0.47/<br />
./chkrootkit 2&gt;&amp;1 | mail –s “chkrootkit daily report” ndztest@gmail.com</p>
<p class="content_text">Save &amp; exit<br />
chmod +x chkrootkit.cron</p>
<h1 class="title">RKHunter (RootKit Hunter Is a security scanning tool which will scan for rootkits, backdoors, and local exploits)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text">It runs many tests, including MD5 hash comparisons, default filenames used by rootkits, wrong file permissions for binaries, and suspicious strings in LKM and KLD modules</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://downloads.rootkit.nl/rkhunter-1.1.4.tar.gz<br />
tar -xzvf rkhunter-1.1.4.tar.gz<br />
cd rkhunter<br />
./installer.sh</p>
<p class="content_text">configure reporting cronjob:-<br />
cd /etc/cron.daily<br />
vi rkhunter.cron<br />
#!/bin/bash<br />
/usr/local/bin/rkhunter -c &#8211;cronjob 2&gt;&amp;1 | mail -s &#8220;RKhunter Scan Details&#8221; ndztest@gmail.com</p>
<p class="content_text">Save  &amp; exit<br />
chmod +x rkhunter.cron</p>
<h1 class="title">Snort(Snort is an open source network intrusion detection and prevention system)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text">* capable of performing real-time traffic analysis, alerting, blocking and packet    logging on IP networks<br />
* Protocol Analysis<br />
* Content searching / matching<br />
* Real-time alerting capability<br />
* Can read in a TCPDump trace and run against a rule set<br />
* Flexible rules language to describe traffic that it should collect or pass</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.snort.org/dl/current/snort-2.6.1.5.tar.gz<br />
tar zxvf snort-2.6.1.5.tar.gz<br />
cd snort-2.6.1.5<br />
./configure<br />
make<br />
make install</p>
<p class="content_text">mkdir /etc/snort<br />
cp -rf etc/* /etc/snort</p>
<p class="content_text">change /etc/snort/snort.conf according to your requirements</p>
<h1 class="title">Tripwire(Tripwire data integrity assurance software monitors the reliability of critical system files and directories by identifying changes made to them)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text">*  Centralized management console with web interface<br />
*  Centralized database that stores historical changes<br />
*  Tailorable reports and dashboards<br />
*  Customizable roles and permissions to ensure a secure audit trail<br />
*  Integration with change management systems, providing automated change     reconciliation</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">yum install tripwire</p>
<p class="content_text">/usr/sbin/tripwire-setup-keyfiles</p>
<p class="content_text">To generate database<br />
/usr/sbin/tripwire &#8211;init</p>
<p class="content_text">To view Tripwire database<br />
/usr/sbin/twprint -m d &#8211;print-dbfile | less</p>
<h1 class="title">libsafe(Libsafe is a library that try to prevent buffer overflow attack)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text">* Detection and protection against stack smashing attacks</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://fresh.t-systems-sfr.com/linux/src/libsafe-2.0-16.tgz<br />
tar zxvfp libsafe-2.0-16.tgz<br />
cd libsafe-2.0-16<br />
make<br />
make install<br />
cd exploits<br />
make<br />
./int.sh t1<br />
- hit carraige return  and watch</p>
<p class="content_text">./int.sh t3<br />
- hit carraige return  and watch</p>
<p class="content_text">./int.sh t4<br />
- hit carraige return  and watch</p>
<p class="content_text">./xlock -nolock</p>
<p class="content_text">./canary-exploit</p>
<p class="content_text">./exploit-non-exec-stack</p>
<p class="content_text">Enable libsafe</p>
<p class="content_text">export LD_PRELOAD=/lib/libsafe.so.2</p>
<p class="content_text">Permanently install libsafe</p>
<p class="content_text">vi  /etc/profile<br />
export LD_PRELOAD=/lib/libsafe.so.2</p>
<h1 class="title">PHP mail() header patch(This patch attempts to address this weakness by inserting an informational header to messages sent from PHP via the mail() function)</h1>
<h2><span class="content_title_blue">Features</span></h2>
<p class="content_text">* The header identifies both the script and the apparent IP address that called it<br />
* This can make it difficult to trace misuse, even if you have comprehensive mail and    webserver logs</p>
<h2><span class="content_title_blue">Installation</span></h2>
<p class="content_text">wget http://www.lancs.ac.uk/~steveb/patches/php-mail-header-patch/php5-mail-header.patch</p>
<p class="content_text">cd /root/php-5.2.1<br />
patch -p1 &lt; ../php5-mail-header.patch</p>
<p class="content_text">Recompile Php</p>
<h1 class="title">Limit compiler and fetch utilities access to root only</h1>
<p class="content_text">chmod 700 /usr/bin/gcc<br />
chmod 700 /usr/bin/wget</p>
<h1 class="title">Ensure OpenSSH protocol is only using protocol 2</h1>
<p class="content_text">vi /etc/ssh/ssh_config<br />
Find the line #Protocol 2, 1 and change it to Protocol 2</p>
<h1 class="title">Disable DNS recursion</h1>
<p class="content_text">vi /etc/named.conf<br />
Give &#8220;recursion no;&#8221; in the &#8220;options&#8221; clause</p>
<p class="content_text">If you need to enable recursion for your local network<br />
give  allow-recursion { 192.168.1.1;192.168.1.20;192.168.1.21;192.168.1.59;192.168.1.22; } in &#8220;options&#8221; section</p>
<h1 class="title">Disable used services(eg:telnet)</h1>
<p class="content_text">vi /etc/xinetd.d/telnet<br />
replace &#8220;disable = no&#8221; and with &#8220;disable = yes&#8221;<br />
/etc/init.d/xinetd restart<br />
chkconfig telnet off<br />
chkconfig &#8211;del telnet<br />
Scan server to ensure port 23 is closed<br />
nmap -sT -O localhost</p>
<h1 class="title">Disable IP source routing</h1>
<p class="content_text">vi /etc/sysctl.conf</p>
<p class="content_text">net.ipv4.conf.default.accept_source_route = 0</p>
<h1 class="title">Ensure cannot SSH directly to root. Must SSH to admin first</h1>
<p class="content_text">For cPanel make sure you add your admin user to the ‘wheel’ group so that you will be able to ’su -’ to root<br />
After that<br />
vi /etc/ssh/sshd_config<br />
PermitRootLogin no</p>
<h1 class="title">Disable ICMP Redirect Acceptance  <span class="content_title_hash">(When hosts use a non-optimal or defunct route to a particular destination, an ICMP redirect packet is used by routers to inform the hosts what the correct route should be. If an attacker is able to forge ICMP redirect packets, he or she can alter the routing tables on the host and possibly subvert the security of the host by causing traffic to flow via a path you didn&#8217;t intend. It&#8217;s strongly recommended to disable ICMP Redirect Acceptance to protect your server from this hole.)</span></h1>
<p class="content_text">vi /etc/sysctl.conf<br />
net.ipv4.conf.all.accept_redirects = 0<br />
/etc/init.d/network restart</p>
<h1 class="title">Enforce noexec &amp; nosuid on temporary directories /tmp and /var/tmp</h1>
<p class="content_text">vi /etc/fstab<br />
LABEL=/tmp /tmp ext3 noexec,nosuid,rw 0 0<br />
/dev/shm /dev/shm tmpfs   noexec,nosuid defaults 0 0</p>
<p class="content_text">chmod 0777 /tmp</p>
<p class="content_text">umount /dev/shm<br />
mount /dev/shm<br />
rm -rf /var/tmp/<br />
ln -s /tmp/ /var/</p>
<h1 class="title">Enable IP spoofing protection( The spoofing protection prevents your network from being the source of spoofed i.e. forged communications that are often used in DoS attacks)</h1>
<p class="content_text">vi /etc/sysctl.conf<br />
net.ipv4.conf.all.rp_filter = 1<br />
/etc/init.d/network restart</p>
<h1 class="title">Enable syncookie protection</h1>
<p class="content_text">vi /etc/sysctl.conf<br />
net.ipv4.tcp_syncookies = 1<br />
/etc/init.d/network restart</p>
<h1 class="title">Disable certain php functions (system, exec, shell_exec)</h1>
<p class="content_text">vi /usr/local/lib/php.ini<br />
disable_functions = system, exec, shell_exec</p>
<h1 class="title">Harden host.conf</h1>
<p class="content_text">vi /etc/host.conf<br />
order hosts,bind<br />
nospoof on<br />
/etc/init.d/network restart</p>
<h1 class="title">Email spoofing prevention ( Email spoofing is the practice of changing your name in email so that it looks like the email came from somewhere or someone else.)</h1>
<p class="content_text"><strong>Router filtering</strong><br />
Putting a filter on your router is the first preventive step. By using an Access Control List, you can block private IP addresses.</p>
<p class="content_text"><strong>Encryption and authentication</strong><br />
By using encryption and authentication, you can reduce spoofing attacks. Ensuring the right authentication procedures are in place with a secure network will make it much more difficult for an attack to take place.</p>
<h1 class="title">Upgrade kernal to latest OS release</h1>
<p class="content_text">wget http://download.openvz.org/kernel/branches/2.6.20/2.6.20-ovz005.1<br />
//kernel-2.6.20-ovz005.1.i686.rpm<br />
rpm -ivh kernel-2.6.20-ovz005.1.i686.rpm</p>
</div>
</div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/04/12/securing-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mixing PHP and SSI</title>
		<link>http://blog.nataprawira.com/tech/2009/03/24/mixing-php-and-ssi/</link>
		<comments>http://blog.nataprawira.com/tech/2009/03/24/mixing-php-and-ssi/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 03:54:53 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Mixing PHP and SSI]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=45</guid>
		<description><![CDATA[

This information is ONLY relevant to PHP4 and Apache 1.3. (BUT possible can be work also in PHP 5.x and Apache 2.x ) We historically used PHP for all our web work. We have decided to migrate to ruby for lots of reasons for all our new web development but we still have lots of [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F03%2F24%2Fmixing-php-and-ssi%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F03%2F24%2Fmixing-php-and-ssi%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><strong>This information is ONLY relevant to PHP4 and Apache 1.3</strong>. <em><strong>(BUT possible can be work also in PHP 5.x and Apache 2.x )</strong></em> We historically used PHP for all our web work. We have decided to migrate to <a href="http://www.zytrax.com/tech/lang/ruby/" target="_blank">ruby</a> for lots of reasons for all our new web development but we still have lots of PHP stuff hanging around.</p>
<h3>Background</h3>
<p>We regularly mix PHP and SSIs for the following reasons:</p>
<ul>
<li>Laziness &#8211; we have a lot of historic SSI stuff lying around and do not want to change it. We prefer evolution to revolution.</li>
<li>Appropriateness. Not all systems are good at everything. We find that conditionally selecting &#8216;lumps&#8217; of code to deliver browser specific pages (see <a href="http://www.zytrax.com/tech/web/browser_sniffing.html" target="_blank">server side browser sniffing</a>) is a lot cleaner and easier with SSI. That does not take away from either technology.</li>
</ul>
<h3>Nesting PHP and SSI</h3>
<p>The rules go like this (PHP4 and Apache 1.3 &#8211; we understand that Apache 2 is more flexible but have not yet made the transition):</p>
<ol>
<li>You can invoke SSI files from within PHP but must use the PHP <strong>virtual()</strong> function not <strong>include()</strong>. Variables set within PHP are NOT available to SSI so our favorite &#8216;wheeze&#8217; of supplying last modified dates to a standard footer do not work.</li>
<li>You can include SSI files using the <a href="http://www.zytrax.com/tech/web/ssi.htm#include" target="_blank">include virtual</a> SSI directive but the SSI filename must have a .shtml extension even if the XBitHack is being used.</li>
<li>You cannot include PHP files using the <a href="http://www.zytrax.com/tech/web/ssi.htm#include" target="_blank">include virtual</a> SSI directive.</li>
<li>Variables set within the General Apache section (we use this <a href="http://www.zytrax.com/tech/web/browser_sniffing.html" target="_blank">technique for server side bowser sniffing</a>) are available to both .php and .shtml files no matter how they are called.</li>
</ol>
<p><strong>Note:</strong> We would guess that the Apache environment for each type of file (.php and .shtml) is initialised to the same state as when the page is first called, whereas a nested .php files uses the same php environment and therefore reflects any dynamic changes.</p>
<p><span id="more-45"></span></p>
<h2>Examples</h2>
<p>The following is our standard level 1 template implemented in SSI first and then PHP.</p>
<h3>SSI Version</h3>
<pre>&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Language" content="en-us"&gt;
&lt;meta http-equiv="Content-Type" content="text/html"&gt;
&lt;meta name="GENERATOR" content="company"&gt;
&lt;!--#include virtual="/templates/meta.html" --&gt;
&lt;title&gt;Level 1 template&lt;/title&gt;
&lt;!-- conditionally generated style sheet --&gt;
&lt;!--#include virtual="/templates/styles.shtml" --&gt;
&lt;!-- conditionally generated javascript code --&gt;
&lt;!--#include virtual="/scripts/javascript.shtml" --&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;!-- banner/page headings --&gt;
&lt;!--#include virtual="/templates/level_1.shtml" --&gt;
&lt;div class="page-content"&gt;

&lt;!-- unique page contents go here --&gt;

&lt;/div&gt;
&lt;!--#config timefmt="%B %d %Y" --&gt;
&lt;!--#set var="real_date" value="$LAST_MODIFIED" --&gt;
&lt;!--#include virtual="/templates/footer.shtml" --&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3>PHP Version</h3>
<pre>&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Language" content="en-us"&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=windows-1252"&gt;
&lt;meta name="GENERATOR" content="company"&gt;
&lt;meta name="keywords" content="blah, blah"&gt;
&lt;title&gt;Cool Tools&lt;/title&gt;
&lt;?php
&lt;!-- conditionally generated style sheet --&gt;
  virtual ("/templates/styles.shtml");
&lt;!-- conditionally generated javascript code --&gt;
  virtual ("/scripts/javascript.shtml");
?&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?php
&lt;!-- banner/page headings --&gt;
  virtual ("/templates/level_1.shtml");
?&gt;
&lt;div class="page-content"&gt;

&lt;!-- unique page contents go here --&gt;

&lt;/div&gt;
&lt;?php
  $real_date = date("F d, Y.", getlastmod());
  include ("../templates/footer.php");
?&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p><strong>Notes:</strong></p>
<ol>
<li>You will notice that the styles, javascript and standard page navigation header use the PHP <strong>virtual()</strong> function because they contain SSI directives but the files are otherwise unchanged.</li>
<li>Our SSI &#8216;last modified&#8217; date &#8216;wheeze&#8217; for the footer does not work in a mixed PHP/SSI environment (because you cannot pass variables between PHP and SSI). Instead we have to create a &#8220;footer.php&#8221; file and set the variable &#8216;real_date&#8217; using the PHP <strong>date()</strong> and  <strong>getlastmod()</strong> functions. This file is invoked with the <strong>include()</strong> function because it is a standard PHP file. In &#8216;footer.php&#8217; we just use &#8216;echo $real_date&#8217; to place our last modified date in the output stream. Yes its simpler in PHP but now we have to maintain two versions of our standard footer.</li>
</ol>
<p><strong><a title="http://www.zytrax.com/tech/php/php_ssi.htm" href="http://www.zytrax.com/tech/php/php_ssi.htm" target="_blank">Original</a></strong></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/03/24/mixing-php-and-ssi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use .htaccess to block a range of IP</title>
		<link>http://blog.nataprawira.com/tech/2009/03/21/use-htaccess-to-block-a-range-of-ip/</link>
		<comments>http://blog.nataprawira.com/tech/2009/03/21/use-htaccess-to-block-a-range-of-ip/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 10:05:46 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Block IP]]></category>
		<category><![CDATA[HTaccess]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=44</guid>
		<description><![CDATA[

Question:
I am having troubles with serverpronto bots attacking my site in droves.
How would I block this range of ip address in .htaccess using deny:
69.60.114.0 &#8211; 69.60.125.255
for example, to block one ip I would have:
Deny from 64.251.14.99
But how would I block the whole range given?
Thank you in advance
jdMorgan
Answer:

Denying 69.60.114.0 &#8211; 69.60.125.255
Any of the following:
Deny from 64.251.114
Deny [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F03%2F21%2Fuse-htaccess-to-block-a-range-of-ip%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F03%2F21%2Fuse-htaccess-to-block-a-range-of-ip%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><strong>Question:</strong></p>
<blockquote><p>I am having troubles with serverpronto bots attacking my site in droves.</p>
<p>How would I block this range of ip address in .htaccess using deny:</p>
<p>69.60.114.0 &#8211; 69.60.125.255</p>
<p>for example, to block one ip I would have:<br />
Deny from 64.251.14.99</p>
<p>But how would I block the whole range given?</p>
<p>Thank you in advance<br />
jdMorgan</p></blockquote>
<p><strong>Answer:</strong></p>
<p><span id="more-44"></span></p>
<p>Denying 69.60.114.0 &#8211; 69.60.125.255</p>
<p>Any of the following:</p>
<blockquote><p>Deny from 64.251.114<br />
Deny from 64.251.115<br />
Deny from 64.251.116<br />
Deny from 64.251.117<br />
Deny from 64.251.118<br />
Deny from 64.251.119<br />
Deny from 64.251.120<br />
Deny from 64.251.121<br />
Deny from 64.251.122<br />
Deny from 64.251.123<br />
Deny from 64.251.124<br />
Deny from 64.251.125</p></blockquote>
<p>-or-</p>
<blockquote><p># Deny 69.60.114.0 &#8211; 69.60.115.255 (512 addresses)<br />
Deny from 69.60.114.0/23<br />
# Deny 69.60.116.0 &#8211; 69.60.119.255 (1024 addresses)<br />
Deny from 69.60.116.0/22<br />
# Deny 69.60.120.0 &#8211; 69.60.123.255 (1024 addresses)<br />
Deny From 69.60.120.0/22<br />
# Deny 69.60.124.0 &#8211; 69.60.125.255 (512 addresses)<br />
Deny from 69.60.124.0/23</p></blockquote>
<p>-or-</p>
<blockquote><p># Deny 69.60.114.0 &#8211; 69.60.115.255 (512 addresses)<br />
Deny from 69.60.114.0/255.255.254.0<br />
# Deny 69.60.116.0 &#8211; 69.60.119.255 (1024 addresses)<br />
Deny from 69.60.116.0/255.255.252.0<br />
# Deny 69.60.120.0 &#8211; 69.60.123.255 (1024 addresses)<br />
Deny From 69.60.120.0/255.255.252.0<br />
# Deny 69.60.124.0 &#8211; 69.60.125.255 (512 addresses)<br />
Deny from 69.60.124.0/255.255.254.0</p></blockquote>
<p>-or-</p>
<blockquote><p>Setenvif Remote-Addr &#8220;^69\.60\.1(1[4-9]¦2[0-5])\.&#8221; getout<br />
Deny from getout</p></blockquote>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/03/21/use-htaccess-to-block-a-range-of-ip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP configuration inside httpd.conf</title>
		<link>http://blog.nataprawira.com/tech/2009/03/13/php-configuration-inside-httpdconf/</link>
		<comments>http://blog.nataprawira.com/tech/2009/03/13/php-configuration-inside-httpdconf/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 13:53:34 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[httpd.conf]]></category>
		<category><![CDATA[PHP Configuration]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=43</guid>
		<description><![CDATA[

How to set PHP error notice hidden in httpd.conf (vhost):

&#60;VirtualHost *:80&#62;
  ...
  php_flag display_startup_errors off
  php_flag display_errors off
  php_flag html_errors off
  ...
&#60;/VirtualHost&#62;

How to set individual php.ini in httpd.conf (vhost):

&#60;VirtualHost *:80&#62;
  ...
  PHPIniDir '/path/to/php/conf/php-foo.ini'
  ...
&#60;/VirtualHost&#62;

How to set individual PHPError.log in httpd.conf (vhost):

&#60;VirtualHost *:80&#62;
  ...
  php_flag  [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F03%2F13%2Fphp-configuration-inside-httpdconf%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F03%2F13%2Fphp-configuration-inside-httpdconf%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><strong>How to set PHP error notice hidden in httpd.conf (vhost):</strong></p>
<blockquote>
<pre>&lt;VirtualHost *:80&gt;
  ...
  php_flag display_startup_errors off
  php_flag display_errors off
  php_flag html_errors off
  ...
&lt;/VirtualHost&gt;</pre>
</blockquote>
<p><strong>How to set individual php.ini in httpd.conf (vhost):</strong></p>
<blockquote>
<pre>&lt;VirtualHost *:80&gt;
  ...
  PHPIniDir '/path/to/php/conf/php-foo.ini'
  ...
&lt;/VirtualHost&gt;</pre>
</blockquote>
<p><strong>How to set individual PHPError.log in httpd.conf (vhost):</strong></p>
<blockquote>
<pre>&lt;VirtualHost *:80&gt;
  ...
  php_flag  log_errors on
  php_value error_log  /path/to/site/PHPerror.log
  ...
&lt;/VirtualHost&gt;</pre>
</blockquote>
<p><a title="http://perishablepress.com/press/2007/12/17/how-to-enable-php-error-logging-via-htaccess/" rel="nofollow" href="http://perishablepress.com/press/2007/12/17/how-to-enable-php-error-logging-via-htaccess/" target="_blank">Complete Information</a></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/03/13/php-configuration-inside-httpdconf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install FFmpeg in Linux (RPM Version)</title>
		<link>http://blog.nataprawira.com/tech/2009/02/27/install-ffmpeg-in-linux-rpm-version/</link>
		<comments>http://blog.nataprawira.com/tech/2009/02/27/install-ffmpeg-in-linux-rpm-version/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 10:57:06 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[RPM]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[DAG]]></category>
		<category><![CDATA[FFMPEG]]></category>
		<category><![CDATA[FFMPEG-PHP]]></category>
		<category><![CDATA[FlvTool2]]></category>
		<category><![CDATA[GLIBC]]></category>
		<category><![CDATA[Mencoder]]></category>
		<category><![CDATA[Mplayer]]></category>
		<category><![CDATA[Repo]]></category>
		<category><![CDATA[RPM Installation]]></category>
		<category><![CDATA[RPMFORGE]]></category>
		<category><![CDATA[RUBY]]></category>
		<category><![CDATA[Yum]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=42</guid>
		<description><![CDATA[

How to Install FFmpeg in Linux ~The Easy Way~
Original Post
FFmpeg is so important    if you are planning to run a video website with streaming with conversion of    video files to different video formats. This tutorial is intended for Centos/Redhat    versions of Linux where any novice user [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F27%2Finstall-ffmpeg-in-linux-rpm-version%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F27%2Finstall-ffmpeg-in-linux-rpm-version%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<h1>How to Install FFmpeg in Linux ~The Easy Way~</h1>
<p><strong><a title="http://www.mysql-apache-php.com/ffmpeg-install.htm" href="http://www.mysql-apache-php.com/ffmpeg-install.htm" target="_blank"><em>Original Post</em></a></strong></p>
<p><a href="http://ffmpeg.mplayerhq.hu/" target="_blank">FFmpeg</a> is so important    if you are planning to run a video website with streaming with conversion of    video files to different video formats. This tutorial is intended for Centos/Redhat    versions of Linux where any novice user can install ffmpeg without compiling    the source which is a more traditional way of installing the FFmpeg software    on linux servers. In this tutorial i will show you the easy way to install ffmpeg    and ffmpeg-php (php extension) with just yum rather than compiling ffmpeg from    source files.</p>
<blockquote><p>FFmpeg (<a href="http://ffmpeg.mplayerhq.hu/" target="_blank">http://ffmpeg.mplayerhq.hu</a>)<br />
Mplayer + Mencoder (<a href="http://www.mplayerhq.hu/design7/dload.html" target="_blank">http://www.mplayerhq.hu/design7/dload.html</a>)<br />
Flv2tool (<a href="http://inlet-media.de/flvtool2" target="_blank">http://inlet-media.de/flvtool2</a>)<br />
Libogg + Libvorbis (<a href="http://www.xiph.org/downloads" target="_blank">http://www.xiph.org/downloads</a>)<br />
LAME MP3 Encoder (<a href="http://lame.sourceforge.net/" target="_blank">http://lame.sourceforge.net</a>)<br />
FlowPlayer &#8211; A Free Flash Video Player &#8211; <a href="http://flowplayer.org/" target="_blank">http://flowplayer.org/</a></p></blockquote>
<h1>Installing FFMpeg</h1>
<p><span id="more-42"></span></p>
<blockquote><p><strong>yum install ffmpeg ffmpeg-devel</strong></p></blockquote>
<p>If you get <strong>package not found, </strong>then you will need to add few    lines in the yum repository for dag packages installation. Create a file named    <strong>dag.repo</strong> in <strong>/etc/yum.repos.d</strong> with the following    contents on it</p>
<blockquote><p><strong>[dag]<br />
name=Dag RPM Repository for Red Hat Enterprise Linux<br />
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag<br />
gpgcheck=1<br />
enabled=1</strong></p></blockquote>
<p>then</p>
<blockquote><p><strong>yum install ffmpeg ffmpeg-devel</strong></p></blockquote>
<p>If everything is fine, then the installation should proceed smoothly. If not    you will get something like warning GPG public key missing .</p>
<h2>Common Errors</h2>
<p><strong>To fix rpmforge GPG key warning: </strong></p>
<blockquote><p><strong>rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm</strong></p></blockquote>
<p>For more information refer to <a href="http://dag.wieers.com/rpm/FAQ.php#B4" target="_blank"><strong>this    faq </strong></a>depending on Centos version</p>
<p><strong>Missing Dependency Error:</strong></p>
<p>If you get missing dependency error like shown below, in the middle of ffmpeg    installation</p>
<blockquote><p><strong><span class="box">Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed    by package ffmpeg<br />
Error: Missing Dependency: libtheora.so.0(libtheora.so.1.0) is needed by package    ffmpeg<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package ffmpeg<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package imlib2<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package a52dec<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package imlib2<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package gsm<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package x264<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package xvidcore<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package lame<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package a52dec<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package faad2<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package x264<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package lame<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package xvidcore<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package faac<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package faad2<br />
Error: Missing Dependency: libgif.so.4 is needed by package imlib2<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package faac<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package gsm<br />
Error: Missing Dependency: libpng12.so.0(PNG12_0) is needed by package imlib2<br />
Error: Missing Dependency: rtld(GNU_HASH) is needed by package libmp4v2<br />
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package libmp4v2</span></strong></p></blockquote>
<p>then most commonly you have GLIB 2.3 installed instead of GLIB 2.4 version.    To check the current GLIB version installed on your server. just use:</p>
<blockquote><p><strong>yum list glib*</strong></p></blockquote>
<p>and it should list the latest GLIB package version.</p>
<p>The reason i was getting this error was my rpmforge packages was pointed to    centos 5 versions instead of centos 4.6.</p>
<p><strong>To fix dependency error:</strong></p>
<p>To fix this error, you might need to check your rpmforge packages compatible    to the release of your existing CentOS version.<br />
Check the file <strong>/etc/yum.repos.d/rpmforge.repo </strong>and it should    look like for Centos 4.6(Final). If you have lines like <strong>http://apt.sw.be/redhat/<span style="color: #0000ff">el5</span>/en/mirrors-rpmforge </strong> you might need to make changes to the <strong>rpmforge.repos</strong> like shown below</p>
<blockquote><p><strong>Note:</strong> Backup the original<strong> rpmforge.repo</strong> file    before you edit its content.</p></blockquote>
<blockquote><p><strong><span class="box">[rpmforge]<br />
name = Red Hat Enterprise $releasever &#8211; RPMforge.net &#8211; dag<br />
#baseurl = http://apt.sw.be/redhat/<span style="color: #0000ff">el4</span>/en/$basearch/dag<br />
mirrorlist = http://apt.sw.be/redhat/<span style="color: #0000ff">el4</span>/en/mirrors-rpmforge<br />
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge<br />
enabled = 1<br />
protect = 0<br />
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag<br />
gpgcheck = 1</span></strong></p></blockquote>
<p><strong>To know what linux type and version you are running </strong></p>
<blockquote><p><strong>cat /etc/redhat-release</strong></p></blockquote>
<p>Once this is done, do again:  <strong>yum install ffmpeg. </strong></p>
<p>This trick resolved the problem in my linux box running Centos 4.6 and this    is the <em>only way</em> i found to install ffmpeg using yum.</p>
<h2>To check the FFmpeg working:</h2>
<p>Finally, check the ffmpeg whether it is working or not.</p>
<blockquote><p><strong>&gt; ffmpeg<br />
&gt; ffmpeg -formats<br />
&gt; ffmpeg &#8211;help<br />
</strong>// This lists path of mpeg, its modules and other path information</p></blockquote>
<blockquote><p><strong> ffmpeg -i Input.file Output.file</strong></p></blockquote>
<h2>To check what audi/video formats are supported</h2>
<blockquote><p><strong>ffmpeg -formats &gt; ffmpeg-format.txt</strong></p></blockquote>
<p>Open the <strong>ffmpeg-formats.txt</strong> to see the ooutput</p>
<blockquote><p><strong>D means decode<br />
E means encode<br />
V means video<br />
A means audio<br />
T = Truncated</strong></p></blockquote>
<h1>Install FFMPEG-PHP Extension</h1>
<p><a href="http://ffmpeg-php.sourceforge.net/" target="_blank">FFmpeg-php</a> is a very good extension and wrapper for PHP which can pull useful information    about video through API interface. Inorder to install it you will need to download    the source file and then compile and install extension in your server. You can    download the source tarball : <a href="http://ffmpeg-php.sourceforge.net/" target="_blank">http://ffmpeg-php.sourceforge.net/</a></p>
<blockquote><p><strong>wget /path/to/this/file/ffmpeg-php-0.5.2.1.tbz2</strong></p>
<p><strong>tar -xjf ffmpeg-0.5.2.1.tbz2</strong></p>
<p><strong>phpize</strong></p>
<p><strong>./configure<br />
make<br />
make install</strong></p></blockquote>
<p><strong>Common Errors</strong></p>
<p><strong>1.</strong> If you get <strong>command not found error</strong> for    phpize, then you will need to do <strong>yum install php-devel</strong></p>
<p><strong>2.</strong> If you get error like <strong>&#8220;ffmpeg headers not    found&#8221;</strong> while configuring the source.</p>
<blockquote><p><strong>configure: error: ffmpeg headers not found. Make sure ffmpeg is    compiled as shared libraries using the &#8211;enable-shared option</strong></p></blockquote>
<p>then it means you have not installed<strong> ffmpeg-devel</strong> packages.</p>
<p><strong>To Fix:</strong> Just install <strong>ffmpeg-devel</strong> using</p>
<blockquote><p><strong>yum install ffmpeg-devel</strong></p></blockquote>
<p><strong>3. </strong>If you get an error like shared libraries not found problem    and the program halts in the middle, then you must specify the ffmpeg installed    path explicitly to the ./configure.</p>
<blockquote><p><strong>configure: error: ffmpeg shared libraries not found. Make sure    ffmpeg is compiled as shared libraries using the &#8211;enable-shared option</strong></p></blockquote>
<p><strong>To Fix:</strong></p>
<p>1. First find out the ffmpeg path with <strong>ffmpeg &#8211;help</strong> command.    The prefix default path should be like <strong>/usr/local/cpffmpeg</strong><br />
2. Configure the FFmpeg-php with &#8211;with-ffmpeg option</p>
<blockquote><p><strong>./configure &#8211;with-ffmpeg=/usr/local/cpffmpeg</strong></p></blockquote>
<p>That should resolve the problem!</p>
<h2>Editing PHP.INI</h2>
<p>Once you have done that without any problems then you will see the php extension    file <strong>/usr/local/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so</strong> and you will need mention that extension in php.ini file</p>
<blockquote><p><strong>nano /usr/local/lib/php.ini</strong></p></blockquote>
<p>Put the below two lines at the end of the <strong>php.ini</strong> file</p>
<blockquote><p><strong>[ffmpeg]<br />
extension=ffmpeg.so</strong></p></blockquote>
<p>Then restart the server <strong>service httpd restart</strong></p>
<p>To check whether <strong>ffmpeg enabled with php</strong>, point your browser    to <strong>test.php</strong> file. It should show the confirmation of installed    ffmpeg php extension</p>
<blockquote><p><strong>// #test.php</strong></p>
<p><strong> &lt;?php</strong></p>
<p><strong>phpinfo()</strong></p>
<p><strong>?&gt;</strong></p></blockquote>
<p>If any case the ffmpeg does not show in the phpinfo() test make sure that php.ini    path to ffmpeg.so is correct. Still the problem occurs, the reason could be    you might be using older versions of ffmpeg-php which is buggy. Just download    the latest version of ffmpeg-php source then compile it.</p>
<h1>Installing Mplayer + Mencoder</h1>
<p>Just issue the following yum commands to install the rest of the packages.</p>
<blockquote><p><strong>yum install mplayer mencoder</strong></p></blockquote>
<h1>Installing FlvTool2</h1>
<p>Flvtool2 is a flash video file manipulation tool. It can calculate metadata    and can cut and edit cue points for flv files.</p>
<p>If you are on Centos 5 try <strong>yum install flvtool2</strong> with dag    repository and if you get package not found you will need to manually download    and compile the flvtool2. You can download latest version of flvtool2 here:    <a href="http://rubyforge.org/projects/flvtool2/" target="_blank">http://rubyforge.org/projects/flvtool2/</a></p>
<blockquote><p><strong>wget &lt;url-link&gt;</strong></p>
<p><strong>ruby setup.rb config<br />
ruby setup.rb setup<br />
sudo ruby setup.rb install</strong></p></blockquote>
<p>If you get <strong>command not found</strong> error, it probably means that    you dont have ruby installed.</p>
<blockquote><p><strong>yum install ruby</strong></p></blockquote>
<p>Thats it! Once ffmpeg works fine with php extension, download a sample video,    convert to .flv format in the command line and plug it to <strong><a href="http://flowplayer.org/" target="_blank">flowplayer</a></strong> to see it work on your web browser. Try also to download the video file offline    and see whether the converted flv file works well with both audio and video.</p>
<h2>Useful Links</h2>
<ul>
<li>FFmpeg (<a href="http://ffmpeg.mplayerhq.hu/" target="_blank">http://ffmpeg.mplayerhq.hu</a>)</li>
<li>Mplayer + Mencoder (<a href="http://www.mplayerhq.hu/design7/dload.html" target="_blank">http://www.mplayerhq.hu/design7/dload.html</a>)</li>
<li>Flv2tool (<a href="http://inlet-media.de/flvtool2" target="_blank">http://inlet-media.de/flvtool2</a>)</li>
<li>Libogg + Libvorbis (<a href="http://www.xiph.org/downloads" target="_blank">http://www.xiph.org/downloads</a>)</li>
<li>LAME MP3 Encoder (<a href="http://lame.sourceforge.net/" target="_blank">http://lame.sourceforge.net</a>)</li>
<li>FlowPlayer &#8211; A Free Flash Video Player &#8211; <a href="http://flowplayer.org/" target="_blank">http://flowplayer.org/</a></li>
<li>Install FFmpeg from Compiling Source (<a href="http://rshagrawal.blogspot.com/2007/12/howt-o-for-installing-ffmpeg.html" target="_blank">Tutorial    Link</a>)</li>
<li>Nice FFmpeg Installation Tutorial (<a href="http://forums.theplanet.com/index.php?showtopic=64541" target="_blank">click    here</a>)</li>
<li>Important Audio Codecs (<a href="http://www.mplayerhq.hu/DOCS/HTML/en/audio-codecs.html" target="_blank">http://www.mplayerhq.hu/DOCS/HTML/en/audio-codecs.html</a>)</li>
<li>Common Errors &amp; Fixes while Installing FFmpeg (<a href="http://www.webmasterpals.com/forumdisplay.php?f=6" target="_blank">click    here</a>)</li>
</ul>
<p><!-- Kontera ContentLink(TM);--></p>
<p><!-- Kontera ContentLink(TM) --></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/02/27/install-ffmpeg-in-linux-rpm-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling PHP 5.2.x / cannot find -lltdl</title>
		<link>http://blog.nataprawira.com/tech/2009/02/26/compiling-php-52x-cannot-find-lltdl/</link>
		<comments>http://blog.nataprawira.com/tech/2009/02/26/compiling-php-52x-cannot-find-lltdl/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 10:35:11 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[cannot find -lltdl]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=41</guid>
		<description><![CDATA[

 When compiling PHP from source, some of the CentOS users reported that they getting errors like below:

/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status

What you need to do, is just follow the below steps.

Verify that the libtool and libtool-ltdl packages are installed.
Symlink libltdl.so to libltdl.so.x.x.x

If libtool and libtool-ltdl already exist, you may go [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F26%2Fcompiling-php-52x-cannot-find-lltdl%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F26%2Fcompiling-php-52x-cannot-find-lltdl%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<hr size="1" /><!-- / icon and title --> <!-- message -->When compiling PHP from source, some of the CentOS users reported that they getting errors like below:</p>
<div style="margin: 5px 20px 20px">
<pre style="border: 1px inset;margin: 0px;padding: 6px;width: 640px;height: 50px;text-align: left"><strong>/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status</strong></pre>
</div>
<p>What you need to do, is just follow the below steps.</p>
<ol>
<li><strong>Verify that the libtool and libtool-ltdl packages are installed.</strong></li>
<li><strong>Symlink libltdl.so to libltdl.so.x.x.x</strong></li>
</ol>
<p>If libtool and libtool-ltdl already exist, you may go to Step Two.<br />
<strong> Step One</strong></p>
<div style="margin: 5px 20px 20px">
<pre style="border: 1px inset;margin: 0px;padding: 6px;width: 640px;height: 34px;text-align: left">[root@banzaibill ~]# <strong>yum install libtool-ltdl libtool</strong></pre>
</div>
<p>Now you have <strong>libtool</strong> installed. To check it out, do:</p>
<div style="margin: 5px 20px 20px">
<pre style="border: 1px inset;margin: 0px;padding: 6px;width: 640px;height: 34px;text-align: left">[root@banzaibill ~]# <strong>yum info libtool*</strong></pre>
</div>
<p><strong> Step Two</strong></p>
<p>PHP looks for the libltdl library only at <strong>/usr/lib/libltdl.so</strong></p>
<p>The symlink to this file is not included in the libtool packages. Do below commands:</p>
<div style="margin: 5px 20px 20px">
<pre style="border: 1px inset;margin: 0px;padding: 6px;width: 640px;height: 50px;text-align: left">[root@banzaibill ~]# <strong>cd /usr/lib</strong>
[root@banzaibill lib]# <strong>ln -s libltdl.so.3.1.4 libltdl.so</strong></pre>
</div>
<p>And that&#8217;s it. PHP should configure and compile without error.</p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/02/26/compiling-php-52x-cannot-find-lltdl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Firewalls with IPTABLES (Good Tutorials)</title>
		<link>http://blog.nataprawira.com/tech/2009/02/23/linux-firewalls-with-iptables-good-tutorials/</link>
		<comments>http://blog.nataprawira.com/tech/2009/02/23/linux-firewalls-with-iptables-good-tutorials/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 14:39:06 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Firewall]]></category>
		<category><![CDATA[IPTables]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=38</guid>
		<description><![CDATA[

I found good examples for this.
- Quick HOWTO (from LinuxHomeNetworking.com) &#8211; download
- Sample IPTABLES Configuration (RedHat/CentOS) &#8211; download
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F23%2Flinux-firewalls-with-iptables-good-tutorials%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F23%2Flinux-firewalls-with-iptables-good-tutorials%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>I found good examples for this.</p>
<p>- <strong><a title="Quick HOWTO" href="http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch14_:_Linux_Firewalls_Using_iptables" target="_blank">Quick HOWTO</a></strong> (from LinuxHomeNetworking.com) &#8211; <a title="DOWNLOAD" href="http://blog.nataprawira.com/tech/files/2009/02/linux-firewalls-using-iptables.pdf" target="_blank">download</a></p>
<p>- <strong><a title="Sample IPTables Configuration" href="http://www.liniac.upenn.edu/sysadmin/security/iptables.html" target="_blank">Sample IPTABLES Configuration</a></strong> (RedHat/CentOS) &#8211; <a title="DOWNLOAD" href="http://blog.nataprawira.com/tech/files/2009/02/sample-iptables-configuration-redhat.pdf" target="_blank">download</a></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/02/23/linux-firewalls-with-iptables-good-tutorials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Be your own Certificate Authority (CA)</title>
		<link>http://blog.nataprawira.com/tech/2009/02/18/be-your-own-certificate-authority-ca/</link>
		<comments>http://blog.nataprawira.com/tech/2009/02/18/be-your-own-certificate-authority-ca/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 05:04:10 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CA]]></category>
		<category><![CDATA[Certificate Authority]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=34</guid>
		<description><![CDATA[

I declare from the beginning that I am no authority on digital certificates.
This document is a summary of all the articles I have read about openssl. It describes in short how to become your own Certificate Authority (CA) and how to create and sign your own certificate requests. Make no mistake, these certificates are good [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F18%2Fbe-your-own-certificate-authority-ca%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F18%2Fbe-your-own-certificate-authority-ca%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><a title="ORIGINAL POST" href="http://www.g-loaded.eu/2005/11/10/be-your-own-ca/" target="_blank">I declare from the beginning that I am no authority on digital <strong>certificates</strong>.</a></p>
<blockquote><p>This document is a summary of all the articles I have read about <strong>openssl</strong>. It describes in short how to become your own <strong>Certificate Authority</strong> (CA) and how to create and sign your own <strong>certificate requests</strong>. Make no mistake, these certificates are good only for personal use or for use in your intranet in order to provide a secure way to login or communicate with your services, so that passwords or other data is not transmitted in the clear. Noone else will or should trust these certificates.</p></blockquote>
<h4>Prerequisites</h4>
<p>The package <strong>openssl</strong> should be installed in the machine you will use to manage your certificates or create the certificate requests.</p>
<h4>First things first…</h4>
<p><span id="more-34"></span></p>
<p>The <strong>openssl</strong> package comes with some scripts that can help you create your server certificates fast, but here I will describe how to set things up from scratch in a new directory, so that you can customize things later if you like or delete everything without touching openssl’s or the system’s default files. This article is based on a Fedora installation, but will do for all distributions.</p>
<h5>Creating the necessary directories</h5>
<p>First of all we will create a directory tree where all certificate stuff will be kept. Fedora’s default directory is <strong>/etc/pki/tls/</strong>. So, as root, we create our own directories:</p>
<pre># mkdir -m 0755 /etc/pki_jungle</pre>
<p>And then we create our CA’s directory tree:</p>
<pre># mkdir -m 0755 \
     /etc/pki_jungle/myCA \
     /etc/pki_jungle/myCA/private \
     /etc/pki_jungle/myCA/certs \
     /etc/pki_jungle/myCA/newcerts \
     /etc/pki_jungle/myCA/crl</pre>
<ul>
<li><strong>myCA</strong> is our Certificate Authority’s directory.</li>
<li><strong>myCA/certs</strong> directory is where our server certificates will be placed.</li>
<li><strong>myCA/newcerts</strong> directory is where openssl puts the created certificates in PEM (unencrypted) format and in the form <em>cert_serial_number.pem</em> (eg 07.pem). Openssl needs this directory, so we create it.</li>
<li><strong>myCA/crl</strong> is where our certificate revokation list is placed.</li>
<li><strong>myCA/private</strong> is the directory where our private keys are placed. Be sure that you set restrictive permissions to all your private keys so that they can be read only by root, or the user with whose priviledges a server runs. If anyone steals your private keys, then things get really bad.</li>
</ul>
<h5>Initial openssl configuration</h5>
<p>We are going to copy the default openssl configuration file (<strong>openssl.cnf</strong>) to our CA’s directory. In Fedora, this file exists in <strong>/etc/pki/tls</strong>. So, we copy it to our CA’s dir and name it <strong>openssl.my.cnf</strong>. As root:</p>
<pre># cp /etc/pki/tls/openssl.cnf /etc/pki_jungle/myCA/openssl.my.cnf</pre>
<p>This file does not need to be world readable, so we change its attributes:</p>
<pre># chmod 0600 /etc/pki_jungle/myCA/openssl.my.cnf</pre>
<p>We also need to create two other files. This file serves as a database for openssl:</p>
<pre># touch /etc/pki_jungle/myCA/index.txt</pre>
<p>The following file contains the next certificate’s serial number. Since we have not created any certificates yet, we set it to &#8220;<strong>01</strong>&#8220;:</p>
<pre># echo '01' &gt; /etc/pki_jungle/myCA/serial</pre>
<h4>Things to remember</h4>
<p>Here is a small legend with <strong>file extensions</strong> we will use for the created files and their meaning. All files that will be created will have one of these extensions:</p>
<ul>
<li><strong>KEY</strong> &#8211; Private key (Restrictive permissions should be set on this)</li>
<li><strong>CSR</strong> &#8211; Certificate Request (This will be signed by our CA in order to create the server certificates. Afterwards it is not needed and can be deleted)</li>
<li><strong>CRT</strong> &#8211; Certificate (This can be publicly distributed)</li>
<li><strong>PEM</strong> &#8211; We will use this extension for files that contain both the Key and the server Certificate (Some servers need this). Permissions should be restrictive on these files.</li>
<li><strong>CRL</strong> &#8211; Certificate Revokation List (This can be publicly distributed)</li>
</ul>
<h4>Create the CA Certificate and Key</h4>
<p>Now, that all initial configuration is done, we may create a self-signed certificate, that will be used as our CA’s certificate. In other words, we will use this to sign other certificate requests.</p>
<p>Change to our CA’s directory. <span style="text-decoration: underline">This is where we should issue all the openssl commands because here is our openssl’s configuration file (openssl.my.cnf).</span> As root:</p>
<pre># cd /etc/pki_jungle/myCA/</pre>
<p>And then create your CA’s Certificate and Private Key. As root:</p>
<pre># openssl req -config openssl.my.cnf -new -x509 -extensions v3_ca -keyout private/myca.key -out certs/myca.crt -days 1825</pre>
<p>This creates a self-signed certificate with the default CA extensions which is valid for 5 years. You will be prompted for a <strong>passphrase</strong> for your CA’s private key. <span style="text-decoration: underline">Be sure that you set a strong passphrase.</span> Then you will need to provide some info about your CA. Fill in whatever you like. Here is an example:</p>
<pre>Country Name (2 letter code) [GB]:GR
State or Province Name (full name) [Berkshire]:Greece
Locality Name (eg, city) [Newbury]:Thessaloniki
Organization Name (eg, company) [My Company Ltd]:My Network
Organizational Unit Name (eg, section) []:My Certificate Authority
Common Name (eg, your name or your server's hostname) []:server.example.com
Email Address []:whatever@server.example.com</pre>
<p>Two files are created:</p>
<ul>
<li><strong>certs/myca.crt</strong> &#8211; This is your CA’s certificate and can be publicly available and of course world readable.</li>
<li><strong>private/myca.key</strong> &#8211; This is your CA’s private key. Although it is protected with a passphrase you should restrict access to it, so that only root can read it:
<pre># chmod 0400 /etc/pki_jungle/myCA/private/myca.key</pre>
</li>
</ul>
<h4>More openssl configuration (mandatory)</h4>
<p>Because we use a custom directory for our certificates’ management, some modifications to <strong>/etc/pki_jungle/myCA/openssl.my.cnf</strong> are necessary. Open it in your favourite text editor as root and find the following part (around line 35):</p>
<pre>[ CA_default ]

dir     = ../../CA      # Where everything is kept
certs       = $dir/certs        # Where the issued certs are kept
crl_dir     = $dir/crl      # Where the issued crl are kept
database    = $dir/index.txt    # database index file.
#unique_subject = no            # Set to 'no' to allow creation of
                    # several ctificates with same subject.
new_certs_dir   = $dir/newcerts     # default place for new certs.

certificate = $dir/cacert.pem   # The CA certificate
serial      = $dir/serial       # The current serial number
#crlnumber  = $dir/crlnumber    # the current crl number must be
                    # commented out to leave a V1 CRL
crl     = $dir/crl.pem      # The current CRL
private_key = $dir/private/cakey.pem    # The private key
RANDFILE    = $dir/private/.rand    # private random number file

x509_extensions = usr_cert      # The extentions to add to the cert</pre>
<p>You should modify the following settings in order to coform to our custom directory and our custom CA key and certificate:</p>
<pre>[ CA_default ]

dir     = <strong>.</strong>                # <strong>&lt;--CHANGE THIS</strong>
certs       = $dir/certs
crl_dir     = $dir/crl
database    = $dir/index.txt
#unique_subject = no

new_certs_dir   = $dir/newcerts

certificate = $dir/<strong>certs/myca.crt</strong>   # <strong>&lt;--CHANGE THIS</strong>
serial      = $dir/serial
#crlnumber  = $dir/crlnumber

crl     = $dir/crl.pem
private_key = $dir/private/<strong>myca.key</strong>    # <strong>&lt;--CHANGE THIS</strong>
RANDFILE    = $dir/private/.rand

x509_extensions = usr_cert</pre>
<h4>Create a Server certificate</h4>
<p>Further openssl.my.cnf file’s customization is possible, so that we define our policy for certificate creation and signing or define our desired extensions for the new certificates. I may add this info to a future version of this document. It’s easy though, just try to familiarize yourself with the openssl.cnf’s structure and you’ll figure it out.</p>
<p>Anyway, the certificates we are going to create, without customizing openssl.my.cnf any further, are <strong>general purpose certificates</strong> and their usage in not restricted to server authentication only. One thing that you should take a note of is that <strong>the private keys will not be protected by a passphrase</strong>, so that when the services are restarted they do not ask for a passphrase. This means that you should <strong>set restrictive permissions on the private keys</strong>, so that only root or the user under whose priviledges a server runs can read these files.</p>
<h5>Generate a Certificate Request</h5>
<p>First, we change to our CA’s directory:</p>
<pre># cd /etc/pki_jungle/myCA/</pre>
<p>Then we create the certificate request:</p>
<pre># openssl req -config openssl.my.cnf -new -nodes -keyout private/server.key -out server.csr -days 365</pre>
<p>The <strong>-nodes</strong> option is needed so that the private key is not protected with a passphrase. If you do not intend to use the certificate for server authentication, you should not include it in the above command.<br />
You can customize the number of days you want this certificate to be valid for.</p>
<p>You will be prompted for the certificate’s info. Here is an example:</p>
<pre>Country Name (2 letter code) [GB]:GR
State or Province Name (full name) [Berkshire]:Greece
Locality Name (eg, city) [Newbury]:Thessaloniki
Organization Name (eg, company) [My Company Ltd]:My Network
Organizational Unit Name (eg, section) []:My Web Server
Common Name (eg, your name or your server's hostname) []:www.server.example.com
Email Address []:whatever@server.example.com</pre>
<p>The <strong>Common Name (CN)</strong> is the info that uniquely distinguishes your service, so be sure that you type it correctly.</p>
<p>When prompted for some extra attributes (challenge password, optional company name) just hit the [Enter] key.<br />
Two files are created:</p>
<ul>
<li><strong>server.csr</strong> &#8211; this is the certificate request.</li>
<li><strong>private/server.key</strong> &#8211; this is the private key, which is not protected with a passphrase.</li>
</ul>
<p>Set restrictive permissions on the private key. Only root or the user that is used to run the server should be able to read it. For example:</p>
<pre># chown root.root /etc/pki_jungle/myCA/private/server.key
# chmod 0400 /etc/pki_jungle/myCA/private/server.key</pre>
<p>Or:</p>
<pre># chown root.apache /etc/pki_jungle/myCA/private/server.key
# chmod 0440 /etc/pki_jungle/myCA/private/server.key</pre>
<h5>Sign the Certificate Request</h5>
<p>Now we are going to sign the certificate request and generate the server’s certificate.</p>
<p>First, we change to our CA’s directory:</p>
<pre># cd /etc/pki_jungle/myCA/</pre>
<p>Then we sign the certificate request:</p>
<pre># openssl ca -config openssl.my.cnf -policy policy_anything -out certs/server.crt -infiles server.csr</pre>
<p>You will need to supply the CA’s private key in order to sign the request. You can check the openssl.my.cnf file about what <strong>policy_anything</strong> means. In short, the fields about the Country, State or City is not required to match those of your CA’s certificate.</p>
<p>After all this is done two new files are created:</p>
<ul>
<li><strong>certs/server.crt</strong> &#8211; this is the server’s certificate, which can be made available publicly.</li>
<li><strong>newcerts/01.pem</strong> &#8211; This is exactly the same certificate, but with the certificate’s serial number as a filename. It is not needed.</li>
</ul>
<p>You can now delete the certificate request (server.csr). It’s no longer needed:</p>
<pre># rm -f /etc/pki_jungle/myCA/server.csr</pre>
<h5>Verify the certificate</h5>
<p>You can see the certificate’s info with the following:</p>
<pre># openssl x509 -subject -issuer -enddate -noout -in /etc/pki_jungle/myCA/certs/server.crt</pre>
<p>Or the following:</p>
<pre># openssl x509 -in certs/server.crt -noout -text</pre>
<p>And verify that the certificate is valid for server authentication with the following:</p>
<pre># openssl verify -purpose sslserver -CAfile /etc/pki_jungle/myCA/certs/myca.crt /etc/pki_jungle/myCA/certs/server.crt</pre>
<h5>Server certificate and key in one file</h5>
<p>Some servers, for example vsftpd, require that both the private key and the certificate exist in the same file. In a situation like that just do the following:</p>
<pre># cat certs/server.crt private/server.key &gt; private/server-key-cert.pem</pre>
<p>You should restrict access to the final file and delete server.crt and server.key since thay are no longer needed.</p>
<pre># chown root.root private/server-key-cert.pem
# chmod 0400 private/server-key-cert.pem
# rm -f certs/server.crt
# rm -f private/server.key</pre>
<h4>Revoke a Server Certificate</h4>
<p>If you do not want a certificate to be valid any more, you have to revoke it. This is done with the command:</p>
<pre># openssl ca -config openssl.my.cnf -revoke certs/server.crt</pre>
<p>Then you should generate a new CRL (Certificate Revokation List):</p>
<pre># openssl ca -config openssl.my.cnf -gencrl -out crl/myca.crl</pre>
<p>The CRL file is <strong>crl/myca.crl</strong>.</p>
<h4>Distribute your certificates and CRL</h4>
<p>Your CA’s certificate and your servers’ certificates should be distributed to those who trust you so they can import them in their client software (web browsers, ftp clients, email clients etc). The CRL should also be published.</p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/02/18/be-your-own-certificate-authority-ca/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sendmail Problem</title>
		<link>http://blog.nataprawira.com/tech/2009/02/13/sendmail-problem/</link>
		<comments>http://blog.nataprawira.com/tech/2009/02/13/sendmail-problem/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 07:27:40 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Sendmail]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=33</guid>
		<description><![CDATA[

There are often problems with sendmail once it has been installed due to the  tightening up of sendmail to stop spammers

Sendmail-8.11.6-15 Connection refused
Sendmail &#38; tcp wrapper rejection
Cannot relay from valid  ip address (Outlook)


 1) Sendmail-8.11.6-15 Connection refused
Cannot telnet to port 25, then Sendmail has not been corretly set up. This is a problem [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F13%2Fsendmail-problem%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F13%2Fsendmail-problem%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p class="text">There are often problems with sendmail once it has been installed due to the  tightening up of sendmail to stop spammers</p>
<blockquote>
<p class="head3"><a href="http://mail.access-info.co.nz/docs/?postid=11#sendmail-8.11.6-15%20Connection%20refused" target="_blank">Sendmail-8.11.6-15 Connection refused</a></p>
<p class="head3"><a href="http://mail.access-info.co.nz/docs/?postid=11#Sendmail%20&amp;%20tcpwrappers%20rejection" target="_blank">Sendmail &amp; tcp wrapper rejection</a></p>
<p class="head3"><a href="http://mail.access-info.co.nz/docs/?postid=11#Cannot%20relay%20from%20valid%20ip%20address%20%28Outlook%29" target="_blank">Cannot relay from valid  ip address (Outlook)</a></p>
</blockquote>
<p class="head2"><span id="more-33"></span></p>
<p class="head2"><strong> 1) <a name="sendmail-8.11.6-15 Connection refused">Sendmail-8.11.6-15 Connection refused</a></strong></p>
<p class="text">Cannot telnet to port 25, then Sendmail has not been corretly set up. This is a problem with RedHat 7.3 or more where Sendmail by default is set to only send from the localhost, you could say this is Good as Sendmail can not spew when set up on a system that is not going to use it.</p>
<p class="head3">File: <span style="text-decoration: underline"><strong>/etc/sendmail.cf</strong></span></p>
<p class="text">Did you make the DAEMON_OPTIONS change mentioned in the release notes? Your sendmail.cf should *NOT* have this line:</p>
<blockquote>
<p class="commands"><strong> O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA</strong></p>
</blockquote>
<p class="text">It needs to be hashed out to this:</p>
<blockquote>
<p class="head3"><strong> #O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA</strong></p>
</blockquote>
<p class="head3">
<p class="head3">File: <span style="text-decoration: underline"><strong>/etc/mail/sendmail.mc</strong></span></p>
<p class="text">You can also change sendmail.mc, but this is just the configuration file that is used to create sendmail.cf. You can either delete it or change the .mc file from</p>
<blockquote>
<p class="commands"><strong> DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA&#8217;)</strong></p>
</blockquote>
<p class="text">to:</p>
<blockquote>
<p class="commands"><strong> dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA&#8217;)</strong></p>
</blockquote>
<p class="text">You do not need to rebuild sendmail.cf if you make the changes directly to sendmail.cf.</p>
<p class="text">To rebuild sendmail.cf is a headache so better to edit sendmail.cf and restart sendmail.</p>
<p class="text">
<p class="head2"><strong> 2) <a name="Sendmail &amp; tcpwrappers rejection">Sendmail &amp; tcpwrappers rejection</a></strong></p>
<p class="head3">File: <span style="text-decoration: underline"><strong>/etc/hosts.allow</strong></span></p>
<blockquote>
<p class="commands"><strong> sendmail: ALL EXCEPT \<br />
203.204. \<br />
218. </strong></p>
</blockquote>
<p class="head2">
<p class="head2"><strong>3) <a name="Cannot relay from valid ip address (Outlook)"> Cannot relay from valid ip address (Outlook)</a></strong></p>
<p class="text">Sendmail has been installed and the above patches have been  appilied, email is being sent fine from with in Horde, but as soon as a valid  client (ip address) seeks to send emails through the server using a client mail  program (outlook), we get a Relaying Rejected message.</p>
<p class="text">The answer to this problem was archived when researching this  page on sendmail.org.<br />
<a href="http://www.sendmail.org/%7Eca/email/relayingdenied.html" target="_blank"> http://www.sendmail.org/~ca/email/relayingdenied.html</a></p>
<p class="commands"><strong>Feb 24 08:39:20 mail sendmail[17602]: i1NJdKCq017602:  ruleset=check_rcpt, arg1=&lt;someone@someone.co.nz&gt;, relay=me.somehereelse.co.nz  [192.168.xx.19], reject=550 5.7.1 &lt;someone@someone.co.nz&gt;&#8230; Relaying denied</strong><br />
<em> (parts of message changed for security)</em></p>
<p class="text">Generally the /etc/mail/access file only has allowed client ip  addresses for relaying. Now with new versions of Sendmail I have found it  necessary to put in the allowed name that the PCs are giving to sendmail.</p>
<p class="head3">File: <span style="text-decoration: underline"><strong>/etc/mail/access</strong></span></p>
<blockquote>
<p class="commands"><strong>access-info.co.nz                  RELAY</strong></p>
</blockquote>
<p class="text">This lines is needed in /etc/mail/access to enable name  resolution.</p>
<p class="text">You may also need the following line in hosts to also enable dns  ip lookup</p>
<p class="head3">File: <span style="text-decoration: underline"><strong>/etc/hosts</strong></span></p>
<blockquote>
<p class="commands"><strong>192.168.xx.xx    laptop.access-info.co.nz     laptop</strong></p>
</blockquote>
<p class="text">Replace xs with valid ip address for the PC trying to send via  outlook.</p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/02/13/sendmail-problem/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CSS Underscore Hack</title>
		<link>http://blog.nataprawira.com/tech/2009/02/06/css-underscore-hack/</link>
		<comments>http://blog.nataprawira.com/tech/2009/02/06/css-underscore-hack/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 04:08:07 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Underscore Hack]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=32</guid>
		<description><![CDATA[

Original Post



 Update: note that this article is from 2003. The CSS hack described is outdated and (maybe) shouldn’t be used.
I learned another CSS hack today – the underscore hack. You can read all about it in detail, but in essence it’s very simple.
Browsers are supposed to simply ignore CSS properties that they don’t understand. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F06%2Fcss-underscore-hack%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F06%2Fcss-underscore-hack%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><abbr class="updated" title="00"><em><strong><a title="Original Post" href="http://allinthehead.com/retro/150/" target="_blank">Original Post</a></strong></em><br />
</abbr></p>
<div class="entry-content">
<blockquote><p><strong><br />
<em> </em>Update:</strong> note that this article is from 2003. The <span class="caps">CSS</span> hack described is outdated and (maybe) shouldn’t be used.</p></blockquote>
<p>I learned another <span class="caps">CSS</span> hack today – the underscore hack. You can <a title="The Underscore Hack" href="http://www.pixy.cz/blogg/clanky/cssunderscorehack/" target="_blank">read all about it in detail</a>, but in essence it’s very simple.</p>
<p>Browsers are supposed to simply ignore <span class="caps">CSS</span> properties that they don’t understand. This much should be obvious. However, IE/Win does its usual trick of trying too hard to cope with user error and will read and process any valid <span class="caps">CSS</span> property with an underscore tacked on to the front. All other browsers will ignore the mystery property. Example:</p>
<pre><strong><code>p{
   color: black;
   _color: blue;
}</code></strong></pre>
<p>All browsers save IE/Win will display the paragraph text as black – IE/Win displays it as blue. It reads the <strong><code>_color</code></strong> property and allows it to replace the one that came before.</p>
<p>I discovered this technique whilst looking for a solution to IE’s lack of support for <code>min-height</code> to specify the minimum height of an object. Decent browsers like Mozilla support this property, but IE doesn’t. Thanks to another IE bug (one that results in <strong><code>overflow</code> </strong>being treated strangely), it’s possible to set a minimum height for both IE and proper browsers in a fashion such as this:</p>
<pre><strong><code>div#content{
    height: auto;
    min-height: 400px;
    _height: 400px;
}</code></strong></pre>
<p>Not a new technique, but new to me, and helped me out of a layout problem. Be sure to read <a title="Simon Willison - The Underscore Hack" href="http://simon.incutio.com/archive/2003/11/23/underscore" target="_blank">Simon’s discussion</a> of the pros and cons. With the appropriate care, it’s a useful tool to add to your hack list.</p>
</div>
<address> &#8211; <a href="http://allinthehead.com/retro/150/#about" target="_blank">Drew McLellan</a> </address>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/02/06/css-underscore-hack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Schedule Tasks in Windows Server 2003</title>
		<link>http://blog.nataprawira.com/tech/2009/02/02/how-to-schedule-tasks-in-windows-server-2003/</link>
		<comments>http://blog.nataprawira.com/tech/2009/02/02/how-to-schedule-tasks-in-windows-server-2003/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 03:54:51 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Schedule Tasks]]></category>
		<category><![CDATA[Server]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=30</guid>
		<description><![CDATA[

In Windows Server 2003, you can use Scheduled Tasks in 		  Control Panel to create, delete, configure, or display scheduled tasks. You can 		  also use Schtasks.exe to schedule tasks manually.
Back to the top
Overview of the 				Schtasks.exe Tool

loadTOCNode(2, &#8217;summary&#8217;);
Schtasks schedules commands and programs to run periodically or at 		  a specific time. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F02%2Fhow-to-schedule-tasks-in-windows-server-2003%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F02%2F02%2Fhow-to-schedule-tasks-in-windows-server-2003%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>In Windows Server 2003, you can use Scheduled Tasks in 		  Control Panel to create, delete, configure, or display scheduled tasks. You can 		  also use Schtasks.exe to schedule tasks manually.</p>
<div class="topOfPage"><a href="http://support.microsoft.com/kb/814596#top"><img src="http://support.microsoft.com/library/images/support/kbgraphics/public/en-us/uparrow.gif" alt="" />Back to the top</a></div>
<h3>Overview of the 				Schtasks.exe Tool</h3>
<p><span id="more-30"></span></p>
<p>loadTOCNode(2, &#8217;summary&#8217;);<br />
Schtasks schedules commands and programs to run periodically or at 		  a specific time. Schtasks adds and removes tasks from the schedule, starts and 		  stops tasks on demand, and displays and changes scheduled tasks.</p>
<div class="topOfPage"><a href="http://support.microsoft.com/kb/814596#top"><img src="http://support.microsoft.com/library/images/support/kbgraphics/public/en-us/uparrow.gif" alt="" />Back to the top</a></div>
<h3>Syntax and Parameters</h3>
<p>loadTOCNode(2, &#8217;summary&#8217;);<br />
The following is a list of the syntax and parameters that you can 		  use with Schtasks.exe:</p>
<ul>
<li>
<h4>Schtasks /Create</h4>
<p>loadTOCNode(3, &#8217;summary&#8217;);<br />
Creates a new scheduled task.</p>
<ul>
<li><strong>Syntax</strong>:<br />
<strong>schtasks /create</strong><strong>/tn </strong><em>TaskName </em><strong>/tr </strong><em>TaskRun </em><strong>/sc </strong><em>schedule </em>[<strong>/mo </strong><em>modifier</em>] [<strong>/d </strong><em>day</em>] [<strong>/m </strong><em>month</em>[,<em>month</em>...] [<strong>/i </strong><em>IdleTime</em>] [<strong>/st </strong><em>StartTime</em>] [<strong>/sd </strong><em> StartDate</em>] [<strong>/ed </strong><em>EndDate</em>] [<strong>/du </strong><em>duration</em>] [<strong>/s </strong><em>computer</em> [<strong>/u </strong> [<em>domain\]user </em><strong>/p </strong><em>password</em>]] [<strong>/ru </strong> {[<em>Domain\]User</em> | <em>&#8220;System&#8221;</em>} [<strong>/rp </strong><em>Password</em>]] <strong>/?</strong></li>
<li><strong>Parameters</strong>:
<ul>
<li><strong>/tn </strong><em>TaskName</em> Specifies a name for the task.</li>
<li><strong>/tr </strong><em>TaskRun</em> Specifies the program or command that the task runs. Type the 						  fully qualified path and file name of an executable file, script file, or batch 						  file. If you omit the path, Schtasks.exe assumes that the file is in the 						  Systemroot\System32 folder.</li>
<li><strong>/sc </strong><em>schedule</em> Specifies the schedule type. Valid values are MINUTE, HOURLY, 						  DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE.</li>
<li><strong>/mo </strong><em> modifier</em> Specifies how frequently the task runs in its schedule type. This 						  parameter is required for a MONTHLY schedule. This parameter is valid, but 						  optional, for a MINUTE, HOURLY, DAILY, or WEEKLY schedule. The default value is 						  1.</li>
<li><strong>/d </strong><em> day</em> Specifies a day of the week or a day of a month. Valid only with 						  a WEEKLY or MONTHLY schedule.</li>
<li><strong>/m </strong><em>month</em>[,<em>month</em>...] Specifies a month of the year. Valid values are JAN &#8211; DEC and 						  * (every month). The <strong>/m </strong> parameter is valid only with a MONTHLY schedule. It is required 						  when the LASTDAY modifier is used. Otherwise, it is optional and the default 						  value is * (every month).</li>
<li><strong>/i </strong><em>IdleTime</em> Specifies how many minutes the computer is idle before the task 						  starts. Type a whole number from 1 to 999. This parameter is valid only with an 						  ONIDLE schedule, and then it is required.</li>
<li><strong>/st </strong><em>StartTime</em> Specifies the time of day that the task starts in HH:MM:SS 						  24-hour format. The default value is the current local time when the command 						  completes. The <strong>/st </strong> parameter is valid with MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, 						  and ONCE schedules. It is required with a ONCE schedule.</li>
<li><strong>/sd </strong><em>StartDate</em> Specifies the date that the task starts in MM/DD/YYYY format. The 						  default value is the current date. The <strong>/sd </strong> parameter is valid with all schedules, and is required for a ONCE 						  schedule.</li>
<li><strong>/ed </strong><em>EndDate</em> Specifies the last date that the task is scheduled to run. This 						  parameter is optional. It is not valid in a ONCE, ONSTART, ONLOGON, or ONIDLE 						  schedule. By default, schedules have no ending date.</li>
<li><strong>/du</strong><em> Duration</em> Specifies a maximum length of time for a minute or hourly schedule in the <em> HHHH:MM</em> 24-hour format. After the specified time elapses, Schtasks does not start the task again until the start time happens again. By default, task schedules have no maximum duration. This parameter is optional and valid only with a MINUTE or HOURLY schedule.</li>
<li><strong>/s </strong><em>Computer</em> Specifies the name or IP address of a remote computer, with or 						  without backslash characters. The default is the local computer.</li>
<li><strong>/u </strong> [<em>domain\</em>]<em>user</em> Runs the command with the permissions of the specified user 						  account. By default, the command runs with the permissions of the user who is 						  logged on to the computer that is running Schtasks.</li>
<li><strong>/p </strong><em>password</em> Specifies the password of the user account that you specified in 						  the /u parameter. This parameter is required when the <strong>/u </strong><em>parameter</em> is used.</li>
<li><strong>/ru </strong> {[<em>Domain</em>\]<em>User</em> | <em>&#8220;System&#8221;</em>} Runs the tasks with the permission of the specified user 						  account. By default, the task runs with the permissions of the user who is 						  logged on to the computer that is running Schtasks.</li>
<li><strong>/rp </strong><em>Password</em> Specifies the password of the user account that is specified in 						  the <strong>/ru </strong> parameter. If you omit this parameter when you specify a user 						  account, Schtasks.exe prompts you for the password and obscures the text you 						  type. Tasks that run with permissions of the NT Authority\System account do not 						  require a password and Schtasks.exe does not prompt for one.</li>
<li><strong>/? </strong> Displays help at the command prompt.</li>
</ul>
</li>
</ul>
<p><span><a href="http://support.microsoft.com/kb/814596#1">back to the 				top</a></span></li>
<li>
<h4>Schtasks /Change</h4>
<p>loadTOCNode(3, &#8217;summary&#8217;);<br />
Changes one or more of the following properties of a task:</p>
<ul>
<li>The program that the task runs (<strong>/tr </strong>).</li>
<li>The user account under which the task runs (<strong>/ru </strong>).</li>
<li>The password for the user account (<strong>/rp </strong>).</li>
</ul>
<ul>
<li><strong>Syntax</strong>:<strong>schtasks /change /tn </strong> TaskName [<strong>/s </strong><em>computer</em> [<em>/u [domain\]user</em><strong> /p </strong><em>password</em>]] [<strong>/tr </strong> TaskRun] [<strong>/ru </strong> [<em>Domain\]User | &#8220;System&#8221;</em>] [<strong>/rp </strong><em>Password</em>]</li>
<li><strong>Parameters</strong>:
<ul>
<li><strong>/tn </strong><em> TaskName</em> Identifies the task to be changed. Type the task name.</li>
<li><strong>/s </strong><em>Computer</em> Specifies the name or IP address of a remote computer with or 						  without backslash characters. The default is the local computer.</li>
<li><strong>/u </strong> [<em>domain\</em>]<em>user </em>Runs the command with the permissions of the specified user 						  account. By default, the command runs with the permissions of the user who is 						  logged on to the computer that is running Schtasks.</li>
<li><strong>/p </strong><em>password </em>Specifies the password of the user account that you specified in 						  the /u parameter. This parameter is required when the /u parameter is used.</li>
<li><strong>/tr </strong><em>TaskRun </em>Changes the program that the task runs. Type the fully qualified 						  path and file name of an executable file, script file, or batch file. If you 						  omit the path, Schtasks.exe assumes that the file is in the Systemroot\System32 						  folder. The specified program replaces the original program that is run by the 						  task.</li>
<li><strong>/ru </strong> [<em>Domain\</em>]<em>User | &#8220;System&#8221;</em> Changes the user account for the task.</li>
<li><strong>/rp </strong><em>Password </em>Changes the account password for the task. Type the new password.</li>
<li><strong>/? </strong> Displays help at the command prompt.</li>
</ul>
</li>
</ul>
<p><span><a href="http://support.microsoft.com/kb/814596#1">back to the 				top</a></span></li>
<li>
<h4>Schtasks /Run</h4>
<p>loadTOCNode(3, &#8217;summary&#8217;);<br />
Starts a scheduled task immediately. The run operation ignores the 				schedule, but uses the program file location, user account, and password that 				are saved in the task to run the task immediately.</p>
<ul>
<li><strong>Syntax</strong>:<strong>schtasks /run /tn </strong><em>TaskName </em>[<strong>/s </strong><em>computer </em>[<strong>/u </strong> [<em>domain\</em>]<em>user </em><strong>/p</strong><em> password</em>]] <strong>/? </strong></li>
<li><strong>Parameters</strong>:
<ul>
<li><strong>/tn </strong><em>TaskName </em>Identifies the task. This parameter is required.</li>
<li><strong>/s </strong><em>Computer </em>Specifies the name or IP address of a remote computer with or 						  without backslash characters. The default is the local computer.</li>
<li><strong>/u </strong> [<em>domain\</em>]<em>user </em>Runs the command with the permissions of the specified user 						  account. By default, the command runs with the permissions of the user who it 						  logged on to the computer that is running Schtasks.</li>
<li><strong>/p </strong><em>password </em>Specifies the password of the user account that you specified in 						  the /u parameter. This parameter is required when the /u parameter is used.</li>
<li><strong>/? </strong> Displays help at the command prompt.</li>
</ul>
</li>
</ul>
<p><span><a href="http://support.microsoft.com/kb/814596#1">back to the 				top</a></span></li>
<li>
<h4>Schtasks /End</h4>
<p>loadTOCNode(3, &#8217;summary&#8217;);<br />
Stops a program that was started by a task.</p>
<ul>
<li><strong>Syntax</strong>: <strong>schtasks /end /tn </strong><em>TaskName </em>[<strong>/s </strong><em>computer</em> [<strong>/u </strong> [<em>domain\</em>]<em>user </em><strong>/p </strong><em>password</em>]] <strong>/? </strong></li>
<li><strong>Parameters</strong>:
<ul>
<li><strong>/tn </strong><em>TaskName </em>Identifies the task that started the program. This parameter is 						  required.</li>
<li><strong>/s </strong><em>Computer </em>Specifies the name or IP address of a remote computer with or 						  without backslash characters. The default is the local computer.</li>
<li><strong>/u </strong> [<em>domain\</em>]<em>user</em> Runs the command with the permissions of the specified user 						  account. By default, the command runs with the permissions of the user who is 						  logged on to the computer that is running Schtasks.</li>
<li><strong>/p </strong><em>password</em> Specifies the password of the user account that is specified in 						  the <strong>/u </strong> parameter. This parameter is required when the <strong>/u </strong> parameter is used. <strong>/? </strong> Displays help.</li>
</ul>
</li>
</ul>
<p><span><a href="http://support.microsoft.com/kb/814596#1">back to the 				top</a></span></li>
<li>
<h4>Schtasks /Delete</h4>
<p>loadTOCNode(3, &#8217;summary&#8217;);<br />
Deletes a scheduled task.</p>
<ul>
<li><strong>Syntax</strong>:<strong>schtasks /delete /tn </strong><em>{TaskName</em> |<em> *</em>} [<strong>/f </strong>] [<strong>/s </strong><em>computer</em> [<strong>/u </strong> [<em>domain</em>\]<em>user</em><strong>/p </strong><em>password</em>]] [<strong>/? </strong>]</li>
<li><strong>Parameters</strong>:
<ul>
<li><strong>/tn </strong> {<em>TaskName</em> |<em> *</em>} Identifies the task being deleted. This parameter is required.
<ul>
<li><em>TaskName</em> Deletes the named task.</li>
<li><em>*</em> Deletes all the scheduled tasks on the computer.</li>
</ul>
</li>
<li><strong>/f </strong>Suppresses the confirmation message. The task is deleted without 						  warning.</li>
<li><strong>/s </strong><em>Computer</em> Specifies the name or IP address of a remote computer with or 						  without backslash characters. The default is the local computer.</li>
<li><strong>/u </strong> [<em>domain</em>\]<em>user</em> Runs the command with the permissions of the specified user 						  account. By default, the command runs with the permissions of the user who is 						  logged on to the computer that is running Schtasks.</li>
<li><strong>/p </strong><em>password</em> Specifies the password of the user account that you specified in 						  the <strong>/u </strong> parameter. This parameter is required when the <strong>/u </strong>parameter is used.</li>
<li><strong>/? </strong> Displays help at the command prompt.</li>
</ul>
</li>
</ul>
<p><span><a href="http://support.microsoft.com/kb/814596#1">back to the 				top</a></span></li>
<li>
<h4>Schtasks /Query</h4>
<p>loadTOCNode(3, &#8217;summary&#8217;);<br />
Displays all the tasks that are scheduled to run on the computer, 				including those that are scheduled by other users:</p>
<ul>
<li><strong>Syntax</strong>:<strong>schtasks</strong> [<strong>/query</strong>] [<strong>/fo </strong> {<em>TABLE</em> | <em>LIST</em> | <em>CSV</em>}] [<strong>/nh </strong>] [<strong>/v</strong>] [<strong>/s </strong><em>computer</em> [<strong>/u </strong> [<em>domain</em>\]<em>user</em><strong>/p </strong><em>password</em>]]</li>
<li><strong>Parameters</strong>:[<strong>/query</strong>] The operation name is optional. Typing 					 <span class="userInput">schtasks</span> without any parameters performs a query.</li>
<li><strong>/fo </strong> {<em>TABLE</em> |<em> LIST</em> | <em>CSV</em>} Specifies the output format. <em>TABLE</em> is the default. <strong>/nh </strong> Omits column headings from the table display. This parameter is 					 valid with the <em>TABLE</em> and <em>CSV</em> output formats.</li>
<li><strong>/v </strong>Adds advanced properties of the tasks to the display. Queries 					 using <strong>/v </strong> should be formatted as LIST or CSV.</li>
<li><strong>/s </strong><em>Computer</em> Specifies the name or IP address of a remote computer with or 					 without backslash characters. The default is the local computer.</li>
<li><strong>/u </strong> [<em>domain</em>\]<em>user</em> Runs the command with the permissions of the specified user 					 account. By default, the command runs with the permissions of the user who is 					 logged on to the computer that is running Schtasks.</li>
<li><strong>/p </strong><em>password</em> Specifies the password of the user account that is specified in 					 the <strong>/u </strong> parameter. This parameter is required when the <strong>/u </strong> parameter is used.</li>
<li><strong>/? </strong> Displays help at the command prompt.</li>
</ul>
</li>
</ul>
<div class="topOfPage"><a href="http://support.microsoft.com/kb/814596#top"><img src="http://support.microsoft.com/library/images/support/kbgraphics/public/en-us/uparrow.gif" alt="" />Back to the top</a></div>
<h3>How to Create a Scheduled Task</h3>
<p>loadTOCNode(2, &#8217;summary&#8217;);<br />
To create a scheduled task:</p>
<ol>
<li>Click <strong>Start</strong>, click <strong>Run</strong>, 				type <span class="userInput">cmd</span>, and then click <strong>OK</strong>.</li>
<li>At the command prompt, type <span class="userInput">net 				start</span>, and then press ENTER to display a list of currently running 				services. If Task Scheduler is not displayed in the list, type <strong>net 				start &#8220;task scheduler&#8221;</strong>, and then press ENTER.</li>
<li>At the command prompt, type <span class="userInput">schtasks /create /tn 				&#8220;<var>Application_Name</var>&#8221; /tr 				c:\apps\<var>Application_Name</var> /sc 				<var>Value</var> /st <var>HH:MM:SS</var> /ed 				<var>MM/DD/YYYY</var></span>, and then press ENTER. Note 				that you may have to change the parameters for your situation. For example, you 				might type <span class="userInput">schtasks /create /tn &#8220;My App&#8221; /tr c:\apps\myapp.exe /sc 				daily /st 08:00:00 /ed 12/31/2004 </span> This example schedules the MyApp 				program to run once a day, every day, at 8:00 A.M. until December 31, 2004. 				Because it omits the /mo parameter, the default interval of 1 is used to run 				the command every day.</li>
</ol>
<div class="topOfPage"><a href="http://support.microsoft.com/kb/814596#top"><img src="http://support.microsoft.com/library/images/support/kbgraphics/public/en-us/uparrow.gif" alt="" />Back to the top</a></div>
<h3>How to Change a Scheduled Task</h3>
<p>loadTOCNode(2, &#8217;summary&#8217;);<br />
To change a scheduled task:</p>
<ol>
<li>Click <strong>Start</strong>, click <strong>Run</strong>, 				type <span class="userInput">cmd</span>, and then click <strong>OK</strong>.</li>
<li>At the command prompt, type<span class="userInput">net 				start</span>, and then press ENTER to display a list of currently running 				services. If Task Scheduler is not displayed in the list, type <strong>net 				start &#8220;task scheduler&#8221;</strong>, and then press ENTER.</li>
<li>At the command prompt, type<span class="userInput">schtasks /change /tn <em>TaskName</em> [/s <em>computer</em> [/u [<em>domain</em>\]<em>user</em> /p <em>password</em>]] [/tr <em>TaskRun</em>] [/ru [<em>Domain</em>\]<em>User</em> | &#8220;System&#8221;] [/rp <em>Password</em>] </span>, and then press ENTER. Note that you may have to 				change the parameters for your situation. For example, to change the program 				that a task runs, type: <span class="userInput">schtasks /change /tn &#8220;Application_Name&#8221; /tr 				C:\File_Path\Application_Name.exe</span></li>
</ol>
<div class="topOfPage"><a href="http://support.microsoft.com/kb/814596#top"><img src="http://support.microsoft.com/library/images/support/kbgraphics/public/en-us/uparrow.gif" alt="" />Back to the top</a></div>
<h3>How to Run a Scheduled Task</h3>
<p>loadTOCNode(2, &#8217;summary&#8217;);<br />
To manually run a scheduled task outside its schedule:</p>
<ol>
<li>Click <strong>Start</strong>, click <strong>Run</strong>, 				type <span class="userInput">cmd</span>, and then click <strong>OK</strong>.</li>
<li>At the command prompt, type <span class="userInput">net 				start</span>, and then press ENTER to display a list of currently running 				services. If Task Scheduler is not displayed in the list, type <strong>net 				start &#8220;task scheduler&#8221;</strong>, and then press ENTER.</li>
<li>At the command prompt, type <span class="userInput">schtasks /run /tn <em>TaskName</em> [/s <em>computer</em> [/u [<em>domain</em>\]<em>user</em> /p<em> password</em>]] </span>, and then press ENTER. Note that you may have to 				change the parameters for your situation. For example, to run a task on the 				local computer, type <span class="userInput"> schtasks /run /tn 				&#8220;<var>Task_Name</var>&#8221; </span>.</li>
</ol>
<div class="topOfPage"><a href="http://support.microsoft.com/kb/814596#top"><img src="http://support.microsoft.com/library/images/support/kbgraphics/public/en-us/uparrow.gif" alt="" />Back to the top</a></div>
<h3>How to End a Scheduled Task</h3>
<p>loadTOCNode(2, &#8217;summary&#8217;);<br />
To end a scheduled task:</p>
<ol>
<li>Click <strong>Start</strong>, click <strong>Run</strong>, 				type <span class="userInput">cmd</span>, and then click <strong>OK</strong>.</li>
<li>At the command prompt, type <span class="userInput">net 				start</span>, and then press ENTER to display a list of currently running 				services. If Task Scheduler is not displayed in the list, type <strong>net 				start &#8220;task scheduler&#8221;</strong>, and then press ENTER.</li>
<li>At the command prompt, type <span class="userInput"><strong>schtasks /end /tn </strong>TaskName [<strong>/s</strong> computer [<strong>/u</strong> [domain\]user <strong>/p</strong> password]] </span>, and then press ENTER. For example, to 				end the instances of a program that was started by a scheduled task on a local 				computer, type <span class="userInput">schtasks /end /tn 				&#8220;<var>Task_Name</var>&#8220;</span>.</li>
</ol>
<div class="topOfPage"><a href="http://support.microsoft.com/kb/814596#top"><img src="http://support.microsoft.com/library/images/support/kbgraphics/public/en-us/uparrow.gif" alt="" />Back to the top</a></div>
<h3>How to Delete a Scheduled Task</h3>
<p>loadTOCNode(2, &#8217;summary&#8217;);<br />
To delete a scheduled task:</p>
<ol>
<li>Click <strong>Start</strong>, click <strong>Run</strong>, 				type <span class="userInput">cmd</span>, and then click <strong>OK</strong>.</li>
<li>At the command prompt, type <span class="userInput">net 				start</span>, and then press ENTER to display a list of currently running 				services. If Task Scheduler is not displayed in the list, type <strong>net 				start &#8220;task scheduler&#8221;</strong>, and then press ENTER.</li>
<li>At the command prompt, type <span class="userInput"><strong>schtasks /delete /tn</strong> {TaskName | *} [<strong>/f</strong>] [<strong>/s</strong> computer [<strong>/u</strong> [domain\]user <strong>/p</strong> password]]</span>, and then press ENTER. For example, to 				delete all tasks scheduled for the local computer, type <span class="userInput">schtasks 				/delete /tn * /f</span>.</li>
</ol>
<div class="topOfPage"><a href="http://support.microsoft.com/kb/814596#top"><img src="http://support.microsoft.com/library/images/support/kbgraphics/public/en-us/uparrow.gif" alt="" />Back to the top</a></div>
<h3>How to Perform a Query of Scheduled Tasks</h3>
<p>loadTOCNode(2, &#8217;summary&#8217;);<br />
To perform a query of scheduled tasks:</p>
<ol>
<li>Click <strong>Start</strong>, click <strong>Run</strong>, 				type <span class="userInput">cmd</span>, and then click <strong>OK</strong>.</li>
<li>At the command prompt, type <span class="userInput">net 				start</span>, and then press ENTER to display a list of currently running 				services. If Task Scheduler is not displayed in the list, type <strong>net 				start &#8220;task scheduler&#8221;</strong>, and then press ENTER.</li>
<li>At the command prompt, type <span class="userInput">schtasks /query </span>, and then press ENTER. Output from this example displays a table 				of tasks that have been scheduled to run.</li>
</ol>
<p>For more information about how to use Schtasks.exe, search for 		  Schtasks.exe in Windo</p>
<div class="indent">After the specified time elapses, Schtasks does not start the task again until the start time recurs. By default, task schedules have no maximum duration. This parameter is optional and valid only with a MINUTE or HOURLY schedule.</div>
<p>ws Server 2003 Help.</p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/02/02/how-to-schedule-tasks-in-windows-server-2003/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Data Recovery on Linux and ext3</title>
		<link>http://blog.nataprawira.com/tech/2009/01/21/data-recovery-on-linux-and-ext3/</link>
		<comments>http://blog.nataprawira.com/tech/2009/01/21/data-recovery-on-linux-and-ext3/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 04:42:20 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[ext3]]></category>
		<category><![CDATA[Recovery]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=29</guid>
		<description><![CDATA[

By: Abe Getchell 2008-10-03
This article discusses the process of recovering deleted data from an ext3 partition, on a system running Linux, using a process called data carving. This basic technique is useful in any number of situations, such as recovering data that has been accidentally deleted by a user, information removed in an attempt to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F01%2F21%2Fdata-recovery-on-linux-and-ext3%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F01%2F21%2Fdata-recovery-on-linux-and-ext3%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><em>By: Abe Getchell 2008-10-03</em></p>
<p>This article discusses the process of recovering deleted data from an ext3 partition, on a system running Linux, using a process called data carving. This basic technique is useful in any number of situations, such as recovering data that has been accidentally deleted by a user, information removed in an attempt to erase signs of a system intrusion that could be used to track the source, or data erased by an end-user attempting to cover up an acceptable use policy infraction.</p>
<p><span id="more-29"></span></p>
<p>This article assumes that you have a basic understanding of ext3 and the inner workings of filesystems. It is important to note that there is a certain amount of risk associated with this process. When performed improperly, the data you are attempting to recover, or other data stored on the system, could be permanently lost. While this technique is quite accurate most of the time, and very useful in any number of different situations, it is not &#8220;forensically sound&#8221; and will not hold up legally for use in court. Special software, hardware, and procedures &#8212; or professional services &#8212; are a must in situations when legal action is required.</p>
<p>The tools used in this article are freely available and can be downloaded from their respective websites.</p>
<p><strong>The basic recovery process</strong></p>
<p>In this section we will go step-by-step through the data recovery process and describe the tools, and their options, in detail. We start by listing a directory below.</p>
<p>[abe@abe-laptop test]$ ls -al<br />
total 27<br />
drwxrwxr-x 2 abe abe 4096 2008-03-29 17:48 .<br />
drwx&#8212;&#8212; 71 abe abe 4096 2008-03-29 17:47 ..<br />
-rwxr&#8211;r&#8211; 1 abe abe 42736 2008-03-29 17:47 weimaraner1.jpg</p>
<p>In the listing above we can see that there is a file named weimaraner1.jpg in the test directory. This is a picture of my dog. I don&#8217;t want to delete it. I like my dog.</p>
<p>[abe@abe-laptop test]$ rm -f *</p>
<p>Here we can see I am deleting it. Whoops! Sorry buddy. Let&#8217;s gather some basic information about the system so we can begin the recovery process.</p>
<p>[abe@abe-laptop test]$ df -h<br />
Filesystem Size Used Avail Use% Mounted on<br />
/dev/sda2 71G 14G 53G 21% /<br />
/dev/sda1 99M 19M 76M 20% /boot<br />
tmpfs 1007M 12K 1007M 1% /dev/shm<br />
/dev/sdb1 887M 152M 735M 18% /media/PUBLIC</p>
<p>Here we see that the full path to the test directory (which is /home/abe/test) is part of the / filesystem, represented by the device file /dev/sda2.</p>
<p>[abe@abe-laptop test]$ su -<br />
Password:<br />
[root@abe-laptop ~]# debugfs /dev/sda2</p>
<p>Using su to gain root access, we can start the debugfs program giving it the target of /dev/sda2. The debugfs program is an interactive file system debugger that is installed by default with most common Linux distributions. This program is used to manually examine and change the state of a filesystem. In our situation, we&#8217;re going to use this program to determine the inode which stored information about the deleted file and to what block group the deleted file belonged.</p>
<p>debugfs 1.40.4 (31-Dec-2007)<br />
debugfs: cd /home/abe/test<br />
debugfs: ls -d<br />
1835327 (12) . 65538 (4084) .. &lt;1835328&gt; (4072) weimaraner1.jpg</p>
<p>After debugfs starts, we cd into /home/abe/test and run the ls -d command. This command shows us all deleted entries in the current directory. The output shows us that we have one deleted entry and that its inode number is 1835328 &#8212; that is, the number between the angular brackets.</p>
<p>debugfs: imap &lt;1835328&gt;<br />
Inode 1835328 is part of block group 56<br />
located at block 1835019, offset 0&#215;0f80</p>
<p>The next command we want to run is imap, giving it the inode number above so we can determine to which block group the file belonged. We see by the output that it belonged to block group 56.</p>
<p>debugfs: stats<br />
[...lots of output...]<br />
Blocks per group: 32768<br />
[...lots of output...]<br />
debugfs: q</p>
<p>Running the stats command will generate a lot of output. The only data we are interested in from this list, however, is the number of blocks per group. In this case, and most cases, it’s 32768. Now we have enough data to be able to determine the specific set of blocks in which the data resided. We&#8217;re done with debugfs now, so we type q to quit.</p>
<p>[root@abe-laptop ~]# dls /dev/sda2 1835008-1867775 &gt; /media/PUBLIC/block.dat</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>The next thing we need to do is pull all unallocated blocks from block group 56 so we can examine their content. The dls program, from The Sleuth Kit (TSK), allows us to do just that. We simply need to know the device file, a range of blocks, and have enough space in the appropriate place to output this data. Using the information above, we can calculate the block range by multiplying the block group number and the block group size and then multiplying the block group number plus one by the blocks per group minus one. In this case, the formula would look like this:</p>
<p>(56 x 32768) through ((56 + 1) x 32768 &#8211; 1)</p>
<p>This would give us a range of 1835008 through 1867775. It&#8217;s very important that the destination of the output does not reside on the same partition as the data you&#8217;re attempting to recover. What will most likely be a large amount of data being written to disk from the output of this command could potentially overwrite the data you are trying to recover (as the blocks which stored the data from the deleted file have already been marked unallocated). You want as little disk activity as possible on the partition you&#8217;re working with. In this example, I&#8217;m using a USB thumb drive (located on /media/PUBLIC) as a location to store this data.</p>
<p>[root@abe-laptop ~]# mkdir /media/PUBLIC/output<br />
[root@abe-laptop ~]# foremost -dv -t jpg -i /media/PUBLIC/block.dat -o /media/PUBLIC/output/</p>
<p>Next we need to attempt to extract this data from the unallocated blocks we extracted with the dls command above. To do this, we are going to use Foremost. This program is used to recover files based on header information, footer information, and internal data structures. This is the process, mentioned earlier, called data carving. First we are going to create a directory to store the foremost output (again, this should be on a separate partition). Next we are going to run the foremost command giving it the file type of jpg (which is an internally recognized type &#8211; more on custom types below), the input file, and the output directory. The output from this command is listed below.</p>
<p>Foremost version 1.5.3 by Jesse Kornblum, Kris Kendall, and Nick Mikus<br />
Audit File</p>
<p>Foremost started at Sat Mar 29 18:02:29 2008<br />
Invocation: foremost -dv -t jpg -i /media/PUBLIC/block.dat -o /media/PUBLIC/output/<br />
Output directory: /media/PUBLIC/output<br />
Configuration file: /usr/local/etc/foremost.conf<br />
Processing: /media/PUBLIC/block.dat<br />
|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
File: /media/PUBLIC/block.dat<br />
Start: Sat Mar 29 18:02:29 2008<br />
Length: 110 MB (115941376 bytes)</p>
<p>Num Name (bs=512) Size File Offset Comment</p>
<p>0: 00033272.jpg 26 KB 17035264<br />
1: 00033328.jpg 184 KB 17063936<br />
2: 00033704.jpg 58 KB 17256448<br />
3: 00033824.jpg 62 KB 17317888</p>
<p>[...]</p>
<p>*46: 00210136.jpg 2 KB 107589632<br />
47: 00210144.jpg 3 KB 107593728<br />
48: 00210392.jpg 6 KB 107720704<br />
*<br />
Finish: Sat Mar 29 18:02:29 2008</p>
<p>49 FILES EXTRACTED</p>
<p>jpg:= 49<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Foremost finished at Sat Mar 29 18:02:29 2008<br />
[root@abe-laptop ~]#</p>
<p>As we can see, Foremost found forty-nine previously deleted jpg files (this output is also saved in a file named audit.txt in the root of the specified output directory). How do we know which is the file we are trying to recover? We could, as is most commonly done, open all of these files and see their contents. Another option is to simply compare file sizes. We know from our directory listing above that the jpg file we are looking for is 41k in size. There&#8217;s only one file that foremost extracted into the output directory that&#8217;s 41k, and indeed, 00114144.jpg is the file we are attempting to recover. Comparing size only works, of course, if you &#8220;know your data&#8221;. Integrity checking programs such as Tripwire play a big role in a recovery operation as you can identify the recovered data without ever inspecting the content, as well as verify its integrity. This becomes quite useful if the information you&#8217;re attempting to recover is confidential and you are not authorized to view the data.</p>
<p><strong>Defining custom types in <em>Foremost</em></strong></p>
<p>As of Foremost v1.5.3, the internally supported data types that the program will recover without custom rules are jpg, gif, png, bmp, avi, exe, mpg, wav, riff, wmv, mov, pdf, ole, doc, zip, rar, htm, and cpp. If you need to recover data beyond these built-in data types, you will need to define custom types in Foremost&#8217;s configuration file (foremost.conf).</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>An entry that defines a type in the foremost configuration file (as explained in the documentation at the beginning of foremost.conf or in the manpage) consists of several columns: extension, case sensitivity, maximum size, header and footer (optional), and special keywords (optional). As an example that most should be familiar with, here is the entry for an html file:</p>
<p>htm n 50000 &lt;html &lt;/html&gt;</p>
<p>We see here that the file extension is htm (NONE can be specified if no file extension should be used during the output of extracted data), the header and footer are not case sensitive, the maximum file size is 50k bytes (which means that 50k bytes after the header will be recovered if no footer is specified or 50k bytes will be recovered if that amount of data is recovered before the defined footer is detected), the recovered file should start with &#8220;&lt;html&#8221; (header) and end with &#8220;&lt;/html&gt;&#8221; (footer).</p>
<p>The ASCII keyword can also be used when attempting to recover ASCII files. Specifying this keyword at the end of an entry will tell Foremost to extract all ASCII printable characters before and after the keyword defined. An example of this would be a type to recover a perl script. If, for example, you need to recover a perl script that you know included Crypt::CBC, you could use the following type definition:</p>
<p>pl y 100000 Crypt::CBC Crypt::CBC ASCII</p>
<p>Note that Crypt::CBC is listed in both the header and footer fields. This is done so that Foremost will recognize this as the string to search around when the ASCII keyword is used. A more general type to find perl scripts could be defined as follows:</p>
<p>pl n 100000 #!/usr/bin/perl #!/usr/bin/perl ASCII</p>
<p>When attempting to recover files that are not ASCII, hexadecimal and octal notation can be used by specifying \x[0-f][0-f] or \[0-3][0-7][0-7], respectively. Below is an example of hexadecimal notation describing the header and footers of a gif file:</p>
<p>gif y 155000000 \x47\x49\x46\x38\x37\x61 \x00\x3b</p>
<p>As you may have realized by now, Foremost is a very powerful tool. Learn its intricacies and it can be a wonderfully flexible tool in data recovery and computer security forensic operations. Read the Foremost man page or consult the configuration file for a complete guide to creating custom data types.</p>
<p><strong>ext2 vs ext3 Data Recover </strong></p>
<p>You may be asking yourself why this process is so much more difficult with ext3 than it is with ext2? This question is answered by one of the ext3 developers in the Linux ext3 FAQ:</p>
<p>Q: How can I recover (undelete) deleted files from my ext3 partition?<br />
Actually, you can&#8217;t! This is what one of the developers, Andreas Dilger, said about it:</p>
<p>In order to ensure that ext3 can safely resume an unlink after a crash, it actually zeros out the block pointers in the inode, whereas ext2 just marks these blocks as unused in the block bitmaps and marks the inode as &#8220;deleted&#8221; and leaves the block pointers alone.<br />
Your only hope is to &#8220;grep&#8221; for parts of your files that have been deleted and hope for the best.</p>
<p>The process, as described in this article, is the &#8220;grep&#8221; that Andreas is referring to. Hopefully, as ext3 is developed further, some effort will be put in to making this process easier and more reliable.</p>
<p><strong>Conclusion</strong></p>
<p>While going through this process may be necessary to recover information lost in any number of situations, it’s not a process you want to go through on a Monday morning to recover your organization&#8217;s payroll data after an administrator fat-fingers an rm command. The single most important piece of information you should take away from this article, in that vein, is to keep current, tested backups of business critical data that reside on the systems you manage. Regardless of the reason for its use, the process covered in this article is something that every system administrator and security analyst should have in their toolbelt.</p>
<p><a href="http://www.securityfocus.com/infocus/1902/1" target="_blank"><em><strong>Source</strong></em></a></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/01/21/data-recovery-on-linux-and-ext3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to remove / delete  `sqmdataXX.sqm` files on my drive C:\ ?</title>
		<link>http://blog.nataprawira.com/tech/2009/01/19/how-to-remove-delete-sqmdataxxsqm-files-on-my-drive-c/</link>
		<comments>http://blog.nataprawira.com/tech/2009/01/19/how-to-remove-delete-sqmdataxxsqm-files-on-my-drive-c/#comments</comments>
		<pubDate>Sun, 18 Jan 2009 17:35:09 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[.sqm]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MSN]]></category>
		<category><![CDATA[Software Quality Metrics]]></category>
		<category><![CDATA[Windows Live Messenger]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=27</guid>
		<description><![CDATA[

.SQM files are created by a number of Microsoft applications, most commonly Windows Live Messenger (previously known as MSN).
According to Microsoft, SQM files (standing for Software Quality Metrics) are used as part of their &#8220;Microsoft Customer Experience Program&#8221; and help improve their products by anonymously monitoring usage habits and reporting software errors/bugs.
To stop these files [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F01%2F19%2Fhow-to-remove-delete-sqmdataxxsqm-files-on-my-drive-c%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F01%2F19%2Fhow-to-remove-delete-sqmdataxxsqm-files-on-my-drive-c%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><strong>.SQM</strong> files are created by a number of Microsoft applications, most commonly Windows Live Messenger (previously known as MSN).</p>
<p>According to Microsoft, SQM files (standing for Software Quality Metrics) are used as part of their &#8220;Microsoft Customer Experience Program&#8221; and help improve their products by anonymously monitoring usage habits and reporting software errors/bugs.</p>
<p>To stop these files being created, you will need to disable the option in Windows Live Messenger. You can do this through the options menu:</p>
<p>1. Click HELP.<br />
2. Select &#8216;Customer Experience Improvement Program&#8217;.<br />
3. Tick on &#8216;I don&#8217;t want to participate right now&#8217; box.<br />
4. Click OK.</p>
<p>Please take note, that .SQM files are NOT viruses and do not contain spyware/malware and do not contain any personal information.</p>
<p>SQM files have a naming convention such as &#8220;sqmnoopt00.sqm&#8221;. They are normally found in the root folder of your hard-drive (C:) and more recently, the &#8220;Documents and settings/Application Data/Microsoft/MSN Messenger/&#8221; folder.</p>
<p>Dot What!? visitors have found that deleting SQM files is safe. Although probably true, we advise you to backup the files first.</p>
<p style="text-align: center">################### Simple Story ###################</p>
<p style="text-align: center">By default, you participate in a data-gathering program. Open Live Messenger, click on Help, then on Customer Experience Improvement Program, then de-check the radio button which says you want to participate. Try that. It will almost certainly work, and it&#8217;s not dangerous.</p>
<p style="text-align: center">####################################################</p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/01/19/how-to-remove-delete-sqmdataxxsqm-files-on-my-drive-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SMTP AUTH and STARTTLS with sendmail (RedHat, Centos, Fedora)</title>
		<link>http://blog.nataprawira.com/tech/2009/01/07/using-smtp-auth-and-starttls-with-sendmail-redhat-centos-fedora/</link>
		<comments>http://blog.nataprawira.com/tech/2009/01/07/using-smtp-auth-and-starttls-with-sendmail-redhat-centos-fedora/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 07:34:00 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Sendmail]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=26</guid>
		<description><![CDATA[

Step 1: Back up important files
Red Hat has finally placed sendmail.cf in /etc/mail, where it belongs. To verify the location of your configuration file, type this command:
sendmail -d0.20 -bv &#124; grep sendmail.cf
The default installation outputs this:
Conf file: /etc/mail/sendmail.cf (default for MTA)
Conf file: /etc/mail/sendmail.cf (selected)
Be sure to use this path when generating your new sendmail.cf from [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F01%2F07%2Fusing-smtp-auth-and-starttls-with-sendmail-redhat-centos-fedora%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F01%2F07%2Fusing-smtp-auth-and-starttls-with-sendmail-redhat-centos-fedora%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><strong>Step 1: Back up important files</strong></p>
<p>Red Hat has finally placed sendmail.cf in /etc/mail, where it belongs. To verify the location of your configuration file, type this command:</p>
<p>sendmail -d0.20 -bv | grep sendmail.cf</p>
<p>The default installation outputs this:</p>
<p>Conf file: /etc/mail/sendmail.cf (default for MTA)<br />
Conf file: /etc/mail/sendmail.cf (selected)</p>
<p>Be sure to use this path when generating your new sendmail.cf from sendmail.mc, or no changes will take place. Back up your current sendmail.cf and the m4 file that generated it (probably /etc/mail/sendmail.mc):</p>
<p>cp /etc/mail/sendmail.cf /etc/mail/sendmail.cf~<br />
cp /etc/mail/sendmail.mc /etc/mail/sendmail.mc~</p>
<p><strong>Step 2: Make your certificate</strong></p>
<p><span id="more-26"></span></p>
<p>We are also setting up STARTTLS, which allows sendmail to communicate over an encrypted layer using TLS. This is very important, as it allows us to use the LOGIN or PLAIN authentication mechanisms without transferring the password in plain text. It also allows the entire message to remain encrypted from the user&#8217;s machine to the mail server. If sendmail relays the message to another server that offers STARTTLS, the message will be encrypted again. But the most important advantage of this approach is that we get to authenticate using regular system logins and passwords, with no need to maintain a separate user database.</p>
<p>Red Hat&#8217;s openssl package includes a Makefile that makes it extremely easy to generate a certificate (note that on Fedora Core 4 the location is now /etc/pki/tls/certs):</p>
<p>cd /usr/share/ssl/certs<br />
make sendmail.pem</p>
<p>Just follow the prompts and be sure to use the fully qualified domain name of the mail server for the Common Name prompt. Users will still be warned that the certificate is self-signed or not trusted, but you will prevent a warning that the certificate doesn&#8217;t match the host offering it. This certificate is suitable for testing, but you may want to investigate further about the use of certificates before deploying it in a production environment, a topic that is beyond the scope of this howto.</p>
<p><strong>Step 3: Edit sendmail.mc<br />
</strong><br />
If you take a look at the sendmail.mc provided by Red Hat, you will notice that the necessary directives are already present but have been commented out (m4 doesn&#8217;t use the # symbol for comments, it starts a line with dnl, which stands for &#8220;delete until new line&#8221;). Since we want the easiest method possible, without sacrificing security, we need to edit these lines. Don&#8217;t cut &amp; paste from this web page, or you may introduce unwanted characters into your configuration file that will prevent sendmail from starting.</p>
<p>The confAUTH_OPTIONS macro allows you to instruct sendmail not to offer plain text authentication until after a secure mechanism such as TLS is active (the p option). We are also prohibiting anonymous logins (the y option). The A option is a workaround for broken MTAs:</p>
<p>define(`confAUTH_OPTIONS&#8217;, `A p y&#8217;)dnl</p>
<p>Now we define which authentication mechanisms we will trust and use:</p>
<p>TRUST_AUTH_MECH(`LOGIN PLAIN&#8217;)dnl<br />
define(`confAUTH_MECHANISMS&#8217;, `LOGIN PLAIN&#8217;)dnl</p>
<p>Next, we tell sendmail where to find the certificates:</p>
<p>define(`confCACERT_PATH&#8217;,`/usr/share/ssl/certs&#8217;)<br />
define(`confCACERT&#8217;,`/usr/share/ssl/certs/ca-bundle.crt&#8217;)<br />
define(`confSERVER_CERT&#8217;,`/usr/share/ssl/certs/sendmail.pem&#8217;)<br />
define(`confSERVER_KEY&#8217;,`/usr/share/ssl/certs/sendmail.pem&#8217;)</p>
<p>And finally, it may be useful to increase the log level for debugging purposes (delete or comment out this line after everything is working properly):</p>
<p>define(`confLOG_LEVEL&#8217;, `14&#8242;)dnl</p>
<p>Use the m4 command to generate a new sendmail.cf:</p>
<p>m4 /etc/mail/sendmail.mc &gt; /etc/mail/sendmail.cf</p>
<p>Be sure to use the right location for sendmail.cf, as determined earlier. Alternatively, you can use the following command in a stock Red Hat 9.0 or Fedora Core installation:</p>
<p>make -C /etc/mail sendmail.cf</p>
<p>This uses the commands in /etc/mail/Makefile to generate the new sendmail.cf configuration file.</p>
<p><strong>Step 4: Test the configuration<br />
</strong><br />
This is where things get really interesting. sendmail must be restarted before it can use the new configuration file. Rather than simply restarting sendmail with our fingers crossed, we can test it to verify that every thing works properly. You can stop sendmail and then start it with command line options that cause it to log to a specified file. There are various ways to stop sendmail on a Red Hat/Fedora system:</p>
<p>service sendmail stop</p>
<p>or</p>
<p>cd /etc/mail<br />
make stop</p>
<p>or</p>
<p>make -C /etc/mail stop</p>
<p>or</p>
<p>/etc/init.d/sendmail stop</p>
<p>We want to start sendmail with arguments to make it log the SMTP transaction to a special file while we are testing it:</p>
<p>sendmail -bD -X /tmp/test.log</p>
<p>Now, try to send a message from an e-mail client on another computer that does not have relay access, using your server as the outgoing mail server. You should be denied relaying. Edit your preferences so that the client uses authentication, with a login and password (not Secure Password Authentication, or SPA, which is something completely different). You should still be denied access. The last thing you need to do is to instruct the client to use SSL or TLS with the outgoing mail server (there is no need to specify a special port). After making this change, you should be able to send mail (you will be prompted to accept the certificate, however, which you might want to install to prevent further prompts). Now hit ctrl-c to stop sendmail. Restart it normally:</p>
<p>service sendmail restart</p>
<p>Now it&#8217;s time to look at the log. After the first EHLO, sendmail offers something like this:</p>
<p>30245 &gt;&gt;&gt; 250-ENHANCEDSTATUSCODES<br />
30245 &gt;&gt;&gt; 250-PIPELINING<br />
30245 &gt;&gt;&gt; 250-8BITMIME<br />
30245 &gt;&gt;&gt; 250-SIZE<br />
30245 &gt;&gt;&gt; 250-DSN<br />
30245 &gt;&gt;&gt; 250-ETRN<br />
30245 &gt;&gt;&gt; 250-STARTTLS<br />
30245 &gt;&gt;&gt; 250-DELIVERBY<br />
30245 &gt;&gt;&gt; 250 HELP</p>
<p>The important thing is that AUTH is not offered here, because the channel isn&#8217;t encrypted. If you see AUTH in the first exchange, and it offers PLAIN or LOGIN, something is wrong. Look at your logs, go over the previous steps, and make sure that you generated a new sendmail.cf in the right location. The next entries in our log show that TLS is activated:</p>
<p>30245 &lt;&lt;&lt; STARTTLS<br />
30245 &gt;&gt;&gt; 220 2.0.0 Ready to start TLS</p>
<p>Another EHLO takes place, followed by something like this:</p>
<p>30245 &gt;&gt;&gt; 250-ENHANCEDSTATUSCODES<br />
30245 &gt;&gt;&gt; 250-PIPELINING<br />
30245 &gt;&gt;&gt; 250-8BITMIME<br />
30245 &gt;&gt;&gt; 250-SIZE<br />
30245 &gt;&gt;&gt; 250-DSN<br />
30245 &gt;&gt;&gt; 250-ETRN<br />
30245 &gt;&gt;&gt; 250-AUTH LOGIN PLAIN<br />
30245 &gt;&gt;&gt; 250-DELIVERBY<br />
30245 &gt;&gt;&gt; 250 HELP</p>
<p>Now AUTH is offered with the allowed mechanisms (but not STARTTLS, which isn&#8217;t needed here, as the channel is already encrypted). Authentication takes place, and the message is relayed to its destination.</p>
<p>It&#8217;s interesting to note that the username and password is Base64 encoded by the client, so it isn&#8217;t really sent as clear text:</p>
<p>30245 &lt;&lt;&lt; AUTH PLAIN AHJvYmVydABzbHVncw==<br />
30245 &gt;&gt;&gt; 235 2.0.0 OK Authenticated</p>
<p>Nevertheless, it would be trivial to decode the string into the correct username/login pair (robert/slugs, in this case). Therefore, it is best to secure the transaction with TLS. If you want to verify that the transaction is encrypted, open another terminal for root, and run tcpdump:</p>
<p>tcpdump -s 1500 -vvxX port 25</p>
<p>Send a mail with easy to identify strings. You shouldn&#8217;t see your login or the message in tcpdump&#8217;s output.</p>
<p>Note that the certificate will be exchanged in plain text before TLS is enabled. If the mail is relayed to another server that doesn&#8217;t offer STARTTLS, you will see the content of the outgoing message in plain text.</p>
<p><em><strong><a href="http://www.joreybump.com/code/howto/smtpauth.html" target="_blank">Source</a></strong></em></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/01/07/using-smtp-auth-and-starttls-with-sendmail-redhat-centos-fedora/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE ignores custom error pages</title>
		<link>http://blog.nataprawira.com/tech/2008/12/18/ie-ignores-custom-error-pages/</link>
		<comments>http://blog.nataprawira.com/tech/2008/12/18/ie-ignores-custom-error-pages/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 04:10:45 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=20</guid>
		<description><![CDATA[

if you use php to create custom error  pages (such as header('HTTP/1.1 500 Internal Server Error');) Internet Explorer  ignores you custom page unless it is at least 512 (or sometimes 1024 bytes)
IE ignores custom error pages that are less than 512 (or from what i've  read 1024) bytes.
just place this before any [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F12%2F18%2Fie-ignores-custom-error-pages%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F12%2F18%2Fie-ignores-custom-error-pages%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<div class="phpcode"><code><span class="html">if you use php to create custom error  pages (such as header('HTTP/1.1 500 Internal Server Error');) Internet Explorer  ignores you custom page unless it is at least 512 (or sometimes 1024 bytes)</p>
<p>IE ignores custom error pages that are less than 512 (or from what i've  read 1024) bytes.</p>
<p>just place this before any output on your custom error  page--- and be sure that your custom error page includes proper html tags (it  must have a &lt;/body&gt; for this specific example to work)</p>
<p><span class="default">&lt;?php<br />
</span><span class="comment">// set your custom error  header --- example --- header('HTTP/1.1 503 Service Unavailable');</p>
<p></span><span class="keyword">function </span><span class="default">padding</span><span class="keyword">(</span><span class="default">$html</span><span class="keyword">){<br />
return (</span><span class="default">$padding</span><span class="keyword">=</span><span class="default">1024</span><span class="keyword">-</span><span class="default">ob_get_length</span><span class="keyword">()) &gt; </span><span class="default">0 </span><span class="keyword">? </span><span class="default">str_replace</span><span class="keyword">(</span><span class="string">'&lt;/body&gt;'</span><span class="keyword">,</span><span class="string">'&lt;!--'</span><span class="keyword">. (</span><span class="default">$padding</span><span class="keyword">&gt;</span><span class="default">8</span><span class="keyword">?</span><span class="default">str_repeat</span><span class="keyword">(</span><span class="string">'  '</span><span class="keyword">,</span><span class="default">$padding</span><span class="keyword">-</span><span class="default">8</span><span class="keyword">)  :</span><span class="default">null </span><span class="keyword">).</span><span class="string">'--&gt;'</span><span class="keyword">.</span><span class="string">"\n"</span><span class="keyword">.</span><span class="string">'&lt;/body&gt;'</span><span class="keyword">,</span><span class="default">$html</span><span class="keyword">) : </span><span class="default">$html</span><span class="keyword">;<br />
}</p>
<p></span><span class="default">ob_start</span><span class="keyword">(</span><span class="string">'padding'</span><span class="keyword">);<br />
</span><span class="default">?&gt;<br />
</span><br />
and then place this somewhere within the html  error page output</p>
<p>&lt;!-- ---- --&gt;</p>
<p>that will auto-adjust to  pad the file to 1024 bytes to override the default Internet Explorer error  pages.</span> </code></div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2008/12/18/ie-ignores-custom-error-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to show image file that&#8217;s not accessible to public ?</title>
		<link>http://blog.nataprawira.com/tech/2008/12/17/how-to-show-image-file-thats-not-accessible-to-public/</link>
		<comments>http://blog.nataprawira.com/tech/2008/12/17/how-to-show-image-file-thats-not-accessible-to-public/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 07:03:40 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=19</guid>
		<description><![CDATA[

You can use below script to show the image file for public access, but public don&#8217;t have direct access to the file itself. Because its located outside of the public folder.
&#60;?php
/* Read local file from /home/bar */
$localfile = file_get_contents("/home/userX/foo.jpg");
echo $localfile;
?&#62;
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F12%2F17%2Fhow-to-show-image-file-thats-not-accessible-to-public%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F12%2F17%2Fhow-to-show-image-file-thats-not-accessible-to-public%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>You can use below script to show the image file for public access, but public don&#8217;t have direct access to the file itself. Because its located outside of the public folder.</p>
<p><code><span style="color: #000000"><span style="color: #0000bb">&lt;?php<br />
</span><span style="color: #ff8000">/* Read local file from /home/bar */<br />
</span><span style="color: #0000bb">$localfile </span><span style="color: #007700">= </span><span style="color: #0000bb"><span style="color: #ffffff">file_get_contents</span></span><span style="color: #007700">(</span><span style="color: #dd0000">"/home/userX/foo.jpg"</span><span style="color: #007700">);</span></span></code></p>
<p><code><span style="color: #000000"><span style="color: #0000bb">echo $localfile;</span></span></code><br />
<span style="color: #0000bb">?&gt;</span></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2008/12/17/how-to-show-image-file-thats-not-accessible-to-public/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to know ID number that inserted by the mysql insert query ?</title>
		<link>http://blog.nataprawira.com/tech/2008/12/17/mysql_insert_id-example/</link>
		<comments>http://blog.nataprawira.com/tech/2008/12/17/mysql_insert_id-example/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 06:52:44 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=18</guid>
		<description><![CDATA[

Use below scripts :
mysql_insert_id() example
&#60;?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('mydb');
mysql_query("INSERT INTO mytable (product) values ('kossu')");
printf("Last inserted record has id %d\n", mysql_insert_id());
?&#62; 
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F12%2F17%2Fmysql_insert_id-example%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F12%2F17%2Fmysql_insert_id-example%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p>Use below scripts :</p>
<p><strong><strong>mysql_insert_id()</strong> example</strong></p>
<div class="example-contents"><code><span style="color: #000000"><span style="color: #0000bb">&lt;?php<br />
$link </span><span style="color: #007700">= </span><span style="color: #0000bb">mysql_connect</span><span style="color: #007700">(</span><span style="color: #dd0000">'localhost'</span><span style="color: #007700">, </span><span style="color: #dd0000">'mysql_user'</span><span style="color: #007700">, </span><span style="color: #dd0000">'mysql_password'</span><span style="color: #007700">);<br />
if (!</span><span style="color: #0000bb">$link</span><span style="color: #007700">) {<br />
die(</span><span style="color: #dd0000">'Could not connect: ' </span><span style="color: #007700">. </span><span style="color: #0000bb">mysql_error</span><span style="color: #007700">());<br />
}<br />
</span><span style="color: #0000bb">mysql_select_db</span><span style="color: #007700">(</span><span style="color: #dd0000">'mydb'</span><span style="color: #007700">);</p>
<p></span><span style="color: #0000bb">mysql_query</span><span style="color: #007700">(</span><span style="color: #dd0000">"INSERT INTO mytable (product) values ('kossu')"</span><span style="color: #007700">);<br />
</span><span style="color: #0000bb">printf</span><span style="color: #007700">(</span><span style="color: #dd0000">"Last inserted record has id %d\n"</span><span style="color: #007700">, </span><span style="color: #0000bb">mysql_insert_id</span><span style="color: #007700">());<br />
</span><span style="color: #0000bb">?&gt;</span> </span></code></div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2008/12/17/mysql_insert_id-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to fetch data(s) using mysql_fetch_assoc ?</title>
		<link>http://blog.nataprawira.com/tech/2008/12/17/an-expanded-mysql_fetch_assoc-example/</link>
		<comments>http://blog.nataprawira.com/tech/2008/12/17/an-expanded-mysql_fetch_assoc-example/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 06:50:46 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.nataprawira.com/tech/?p=17</guid>
		<description><![CDATA[


mysql_fetch_assoc — Fetch a result row as an associative array


&#60;?php
$conn
= mysql_connect("localhost", "mysql_user", "mysql_password");
if (!
$conn) {
echo "Unable to connect to DB: " . mysql_error();
exit;
}
if (!
mysql_select_db("mydbname")) {
echo "Unable to select mydbname: " . mysql_error();
exit;
}
$sql = "SELECT id as userid, fullname, userstatus
FROM   sometable
WHERE  userstatus = 1";
$result = mysql_query($sql);
if (!
$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (
mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you'll
//       then create $userid, $fullname, and $userstatus

while ($row = mysql_fetch_assoc($result)) {
echo $row["userid"];
echo $row["fullname"];
echo $row["userstatus"];
}
mysql_free_result($result);
?&#62; 
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F12%2F17%2Fan-expanded-mysql_fetch_assoc-example%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2008%2F12%2F17%2Fan-expanded-mysql_fetch_assoc-example%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<div class="example-contents">
<p><strong>mysql_fetch_assoc</strong> — Fetch a result row as an associative array</p>
</div>
<div class="example-contents"></div>
<div class="example-contents"><code><span style="color: #000000"><span style="color: #0000bb">&lt;?php</p>
<p>$conn</p>
<p></span><span style="color: #007700">= </span><span style="color: #0000bb">mysql_connect</span><span style="color: #007700">(</span><span style="color: #dd0000">"localhost"</span><span style="color: #007700">, </span><span style="color: #dd0000">"mysql_user"</span><span style="color: #007700">, </span><span style="color: #dd0000">"mysql_password"</span><span style="color: #007700">);</p>
<p>if (!</p>
<p></span><span style="color: #0000bb">$conn</span><span style="color: #007700">) {<br />
echo </span><span style="color: #dd0000">"Unable to connect to DB: " </span><span style="color: #007700">. </span><span style="color: #0000bb">mysql_error</span><span style="color: #007700">();<br />
exit;<br />
}</p>
<p>if (!</p>
<p></span><span style="color: #0000bb">mysql_select_db</span><span style="color: #007700">(</span><span style="color: #dd0000">"mydbname"</span><span style="color: #007700">)) {<br />
echo </span><span style="color: #dd0000">"Unable to select mydbname: " </span><span style="color: #007700">. </span><span style="color: #0000bb">mysql_error</span><span style="color: #007700">();<br />
exit;<br />
}</p>
<p></span><span style="color: #0000bb">$sql </span><span style="color: #007700">= </span><span style="color: #dd0000">"SELECT id as userid, fullname, userstatus<br />
FROM   sometable<br />
WHERE  userstatus = 1"</span><span style="color: #007700">;</p>
<p></span><span style="color: #0000bb">$result </span><span style="color: #007700">= </span><span style="color: #0000bb">mysql_query</span><span style="color: #007700">(</span><span style="color: #0000bb">$sql</span><span style="color: #007700">);</p>
<p>if (!</p>
<p></span><span style="color: #0000bb">$result</span><span style="color: #007700">) {<br />
echo </span><span style="color: #dd0000">"Could not successfully run query ($sql) from DB: " </span><span style="color: #007700">. </span><span style="color: #0000bb">mysql_error</span><span style="color: #007700">();<br />
exit;<br />
}</p>
<p>if (</p>
<p></span><span style="color: #0000bb">mysql_num_rows</span><span style="color: #007700">(</span><span style="color: #0000bb">$result</span><span style="color: #007700">) == </span><span style="color: #0000bb">0</span><span style="color: #007700">) {<br />
echo </span><span style="color: #dd0000">"No rows found, nothing to print so am exiting"</span><span style="color: #007700">;<br />
exit;<br />
}</p>
<p></span><span style="color: #ff8000">// While a row of data exists, put that row in $row as an associative array<br />
// Note: If you're expecting just one row, no need to use a loop<br />
// Note: If you put extract($row); inside the following loop, you'll<br />
//       then create $userid, $fullname, and $userstatus</span></span></code></div>
<div class="example-contents"><code><span style="color: #000000"><span style="color: #ff8000"><br />
</span><span style="color: #007700">while (</span><span style="color: #0000bb">$row </span><span style="color: #007700">= </span><span style="color: #0000bb">mysql_fetch_assoc</span><span style="color: #007700">(</span><span style="color: #0000bb">$result</span><span style="color: #007700">)) {<br />
echo </span><span style="color: #0000bb">$row</span><span style="color: #007700">[</span><span style="color: #dd0000">"userid"</span><span style="color: #007700">];<br />
echo </span><span style="color: #0000bb">$row</span><span style="color: #007700">[</span><span style="color: #dd0000">"fullname"</span><span style="color: #007700">];<br />
echo </span><span style="color: #0000bb">$row</span><span style="color: #007700">[</span><span style="color: #dd0000">"userstatus"</span><span style="color: #007700">];<br />
}</p>
<p></span><span style="color: #0000bb">mysql_free_result</span><span style="color: #007700">(</span><span style="color: #0000bb">$result</span><span style="color: #007700">);</p>
<p></span><span style="color: #0000bb">?&gt;</span> </span></code></div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2008/12/17/an-expanded-mysql_fetch_assoc-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
