<?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; BASH</title>
	<atom:link href="http://blog.nataprawira.com/tech/category/bash/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>Simple MySQL Backup with auto 3 days old file deletion</title>
		<link>http://blog.nataprawira.com/tech/2010/07/04/simple-mysql-backup-with-auto-3-days-old-file-deletion/</link>
		<comments>http://blog.nataprawira.com/tech/2010/07/04/simple-mysql-backup-with-auto-3-days-old-file-deletion/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 13:57:27 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Delete]]></category>

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

/usr/local/bin/mysql.backup.sh

#!/bin/bash
NOW=$(date +"%m-%d-%Y")
OLD=$(date +"%m-%d-%Y" --date="3 days ago")
PROJECT="project_name"
LOCATION="/home/backup"
FILE="$PROJECT.$NOW.sql"
FILE2="$FILE.gz"
FILEOLD="$PROJECT.$OLD.sql.gz"
EMAIL="youremail@domain.com"
$SQLUSER="username"
$SQLPASS="password"
$SQLNAME="database_name"
cd $LOCATION ; \
rm -f $FILEOLD ; \
mysqldump -u $SQLUSER --password=$SQLPASS $SQLNAME &#62; \
$LOCATION/$FILE ; \
gzip $LOCATION/$FILE ; \
echo "Backup location is in $LOCATION/$FILE2" &#124; \
mail -s "[$PROJECT] MySQL Backup" $EMAIL

Then you can put it on your cron (background process)
Below cron will execute the script on Saturday at 12AM:

0 0 [...]]]></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%2F04%2Fsimple-mysql-backup-with-auto-3-days-old-file-deletion%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2010%2F07%2F04%2Fsimple-mysql-backup-with-auto-3-days-old-file-deletion%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><strong>/usr/local/bin/mysql.backup.sh</strong></p>
<blockquote>
<pre><strong><span style="color: #000080">#!/bin/bash
NOW=$(date +"%m-%d-%Y")
OLD=$(date +"%m-%d-%Y" --date="3 days ago")
PROJECT="project_name"
LOCATION="/home/backup"
FILE="$PROJECT.$NOW.sql"
FILE2="$FILE.gz"
FILEOLD="$PROJECT.$OLD.sql.gz"
EMAIL="youremail@domain.com"
$SQLUSER="username"
$SQLPASS="password"
$SQLNAME="database_name"</span></strong></pre>
<pre><strong><span style="color: #000080">cd $LOCATION ; \
rm -f $FILEOLD ; \
mysqldump -u $SQLUSER --password=$SQLPASS $SQLNAME &gt; \
$LOCATION/$FILE ; \
gzip $LOCATION/$FILE ; \
echo "Backup location is in $LOCATION/$FILE2" | \
mail -s "[$PROJECT] MySQL Backup" $EMAIL</span></strong></pre>
</blockquote>
<p>Then you can put it on your cron (background process)</p>
<p>Below cron will execute the script on <strong>Saturday at 12AM</strong>:</p>
<blockquote>
<pre><strong><span style="color: #000080">0 0 * * 6 /usr/local/bin/mysql.backup.sh</span></strong></pre>
</blockquote>
<p>Good luck!</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%252Fd1O3YA%26amp%3Bt%3DSimple%2520MySQL%2520Backup%2520with%2520auto%25203%2520days%2520old%2520file%2520deletion';" 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%3DSimple%2520MySQL%2520Backup%2520with%2520auto%25203%2520days%2520old%2520file%2520deletion%26amp%3Blink%3Dhttp%253A%252F%252Fbit.ly%252Fd1O3YA';" 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%252Fd1O3YA%26amp%3Btitle%3DSimple%2520MySQL%2520Backup%2520with%2520auto%25203%2520days%2520old%2520file%2520deletion%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%252Fd1O3YA%26amp%3Bt%3DSimple%2520MySQL%2520Backup%2520with%2520auto%25203%2520days%2520old%2520file%2520deletion%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%3DSimple%2520MySQL%2520Backup%2520with%2520auto%25203%2520days%2520old%2520file%2520deletion%2520-%2520http%253A%252F%252Fbit.ly%252Fd1O3YA';" title="Twitter">Twitter</a></li>
</ul>
</div>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2010/07/04/simple-mysql-backup-with-auto-3-days-old-file-deletion/feed/</wfw:commentRss>
		<slash:comments>0</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>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>How To Create SVN Repository</title>
		<link>http://blog.nataprawira.com/tech/2009/06/30/how-to-create-svn-repository/</link>
		<comments>http://blog.nataprawira.com/tech/2009/06/30/how-to-create-svn-repository/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 11:52:42 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[SVN]]></category>
		<category><![CDATA[Repository]]></category>

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

How to get help with svn?
If you are looking for svn reference in man pages, you have gone to the wrong place. To check the references of svn commands, simple do this:
svn help

This will make svn list all the available functions, to get the function reference, let say checkout
svn help checkout
The same thing goes 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%2F06%2F30%2Fhow-to-create-svn-repository%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F06%2F30%2Fhow-to-create-svn-repository%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<p><strong>How to get help with svn?</strong></p>
<p>If you are looking for svn reference in man pages, you have gone to the wrong place. To check the references of svn commands, simple do this:</p>
<p style="padding-left: 30px"><strong>svn help</strong></p>
<p><span id="more-58"></span></p>
<p>This will make svn list all the available functions, to get the function reference, let say checkout</p>
<p style="padding-left: 30px"><strong>svn help checkout</strong></p>
<p>The same thing goes to other svn related commands, such as svnadmin<strong></strong></p>
<p style="padding-left: 30px"><strong>svnadmin help</strong><strong></strong></p>
<p><strong>How to create a svn repository?</strong></p>
<p>First of all what is repository? It is a core file for svn, or you can call it a centralized svn backup database. After created it, it is just a directory with its files. IMPORTANT! Do NOT try to modify or add something into the repository, unless you know what are you doing.</p>
<p>To create a svn repo, let say I wanna create a repo to store all my programming codes, I do this<strong></strong></p>
<p style="padding-left: 30px"><strong>svnadmin create /home/mysurface/repo/programming_repo</strong></p>
<p>Remember try to use absolute path for everything, sometimes the relative path is not going to work.</p>
<p><strong>How to import my existing directories into the new repo?</strong><strong></strong></p>
<p style="padding-left: 30px"><strong>svn import /home/mysurface/programming file:///home/mysurface/repo/programming_repo -m &#8220;Initial import&#8221;</strong></p>
<p>-m stand for log message, the first revision was created with log as “Initial import”. You need to specified URL for the repo, URL is the standard argument for svn. Therefore for local file, you need to specified with file://</p>
<p><strong>How to see what is inside the repo?</strong></p>
<p style="padding-left: 30px"><strong>svn list file:///home/mysurface/repo/programming_repo</strong></p>
<p>Another way of listing all the files and folder in the tree view, I use svnlook</p>
<p style="padding-left: 30px"><strong>svnlook tree programming_repo </strong></p>
<p>The difference between svn list and svnlook tree is one expect URL another one do not.</p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/06/30/how-to-create-svn-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to configure YUM/WGET to get through using PROXY ?</title>
		<link>http://blog.nataprawira.com/tech/2009/05/26/how-to-configure-yumwget-to-get-through-using-proxy/</link>
		<comments>http://blog.nataprawira.com/tech/2009/05/26/how-to-configure-yumwget-to-get-through-using-proxy/#comments</comments>
		<pubDate>Tue, 26 May 2009 10:01:43 +0000</pubDate>
		<dc:creator>Denie</dc:creator>
				<category><![CDATA[BASH]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[wget]]></category>
		<category><![CDATA[Yum]]></category>

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


Better answer &#8211; use /etc/profile.d/proxy.[csh,sh]


You just need to create the following files in /etc/profile.d, and then this will work in *any* shell for *any* user of the system:
#proxy.sh
export http_proxy=http://host.com:port/
export ftp_proxy=http://host.com:port/
export no_proxy=.domain.com
export HTTP_PROXY=http://host.com:port/
export FTP_PROXY=http://host.com:port/
#proxy.csh
setenv http_proxy http://host.com:port/
setenv ftp_proxy http://host.com:port/
setenv no_proxy .domain.com
setenv HTTP_PROXY http://host.com:port/
setenv FTP_PROXY http://host.com:port/




After that, you can run YUM/WGET  
 
]]></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%2F05%2F26%2Fhow-to-configure-yumwget-to-get-through-using-proxy%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.nataprawira.com%2Ftech%2F2009%2F05%2F26%2Fhow-to-configure-yumwget-to-get-through-using-proxy%2F" height="61" width="51" /></a></div>
<!-- ALL ADSENSE ADS DISABLED -->
<div id="post_message_4089">
<div class="smallfont"><strong>Better answer &#8211; use /etc/profile.d/proxy.[csh,sh]</strong></div>
<div class="smallfont">
</div>
<div id="post_message_4089">You just need to create the following files in /etc/profile.d, and then this will work in *any* shell for *any* user of the system:</div>
<p>#proxy.sh<br />
export http_proxy=http://host.com:port/<br />
export ftp_proxy=http://host.com:port/<br />
export no_proxy=.domain.com<br />
export HTTP_PROXY=http://host.com:port/<br />
export FTP_PROXY=http://host.com:port/</p>
<p>#proxy.csh<br />
setenv http_proxy <a href="http://host.com/" target="_blank">http://host.com:port/</a><br />
setenv ftp_proxy <a href="http://host.com/" target="_blank">http://host.com:port/</a><br />
setenv no_proxy .domain.com<br />
setenv HTTP_PROXY <a href="http://host.com/" target="_blank">http://host.com:port/</a><br />
setenv FTP_PROXY <a href="http://host.com/" target="_blank">http://host.com:port/</a></p>
</div>
<div></div>
<div>
</div>
<div>After that, you can run YUM/WGET <img src='http://blog.nataprawira.com/tech/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </div>
<p><!-- / message --> <!-- edit note --></p>
<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.nataprawira.com/tech/2009/05/26/how-to-configure-yumwget-to-get-through-using-proxy/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>
	</channel>
</rss>
