<?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>Winn &#187; Command Line</title>
	<atom:link href="http://winn.ws/archives/category/development/command-line/feed" rel="self" type="application/rss+xml" />
	<link>http://winn.ws</link>
	<description>Standards-based design &#38; development</description>
	<lastBuildDate>Wed, 01 Feb 2012 05:30:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Basic Firewall</title>
		<link>http://winn.ws/archives/818</link>
		<comments>http://winn.ws/archives/818#comments</comments>
		<pubDate>Wed, 29 Dec 2010 19:31:12 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=818</guid>
		<description><![CDATA[After securing your Ubuntu server it's now time to setup a basic firewall. For this tutorial I'll use a great Ubuntu article as the basis for our basic firewall. You can find this article here: <a href="https://help.ubuntu.com/community/IptablesHowTo">https://help.ubuntu.com/community/IptablesHowTo</a>.]]></description>
			<content:encoded><![CDATA[<p>After securing your Ubuntu server it&#8217;s now time to setup a basic firewall. For this tutorial I&#8217;ll use a great Ubuntu article as the basis for our basic firewall. You can find this article here: <a href="https://help.ubuntu.com/community/IptablesHowTo">https://help.ubuntu.com/community/IptablesHowTo</a>.</p>
<p>The following steps will setup each part of a basic firewall configuration. Once we have all of the rules applied we&#8217;ll save the rules and set them to start up at boot. </p>
<p><span id="more-818"></span></p>
<h3>Allow established connections</h3>
<p>The first thing we need to do is allow any established traffic to come into the server. This will allow our SSH traffic to continue functioning while we work on our firewall. Type the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT</pre></div></div>

<h3>Allow SSH traffic </h3>
<p>Next we need to include a rule to enable SSH traffic. Type the following rule to allow incoming SSH connections:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">iptables -A INPUT -p tcp --dport ssh -j ACCEPT</pre></div></div>

<p>If we were to look at our rules at this point by typing iptables -L we would see something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;"># iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh 
&nbsp;
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
&nbsp;
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination</pre></div></div>

<p>While this looks like it may be complete, we still need to add a few additional rules. Let&#8217;s continue on.</p>
<h3>Allow HTTP traffic</h3>
<p>If you intend to host a web server you will need to include a rule to <strong>accept HTTP (port 80) traffic.</strong> Type the following rule to do this: </p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">iptables -A INPUT -p tcp --dport 80 -j ACCEPT</pre></div></div>

<p>Note: You will still be required to install a web server such as Apache! </p>
<h3>Drop all remaining traffic</h3>
<p>Now we need to setup our final rule to drop all remaining traffic that is not destined for our server. </p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">iptables -A INPUT -j DROP</pre></div></div>

<h3>Allow loopback traffic </h3>
<p>Now that we&#8217;ve worked on the rules for our external traffic we need to allow internal loopback traffic for inter-server communication. Type the following rule to allow this: </p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">iptables -I INPUT 1 -i lo -j ACCEPT</pre></div></div>

<h3>Check your rules </h3>
<p>Now if we look at our rules by typing <strong>iptables -L -v</strong> you should see something similar to this:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;"># iptables -L -v
Chain INPUT (policy ACCEPT 355 packets, 26896 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  lo     any     anywhere             anywhere            
  323 24560 ACCEPT     all  --  any    any     anywhere             anywhere            state RELATED,ESTABLISHED 
    1    48 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:ssh 
    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:www 
    0     0 DROP       all  --  any    any     anywhere             anywhere 
&nbsp;
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
&nbsp;
Chain OUTPUT (policy ACCEPT 372 packets, 38968 bytes)
 pkts bytes target     prot opt in     out     source               destination</pre></div></div>

<h3>Saving your rules </h3>
<p>Now that we have a basic firewall configuration we need to go ahead and save it. The command iptables-save will save your IPtables configuration. By default it will send it to the console so we need to &#8216;pipe&#8217; it to a file. Type the following to save the file to /etc/iptables.rules: </p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">iptables-save &gt; /etc/iptables.rules</pre></div></div>

<h3>Set your rules to apply at boot</h3>
<p>Finally we need to make sure that our iptables rules are applied when we boot up the server. The method that Ubuntu suggests is to apply them to your interfaces file but because of the tight integration with our Control Panel we do not recommend that. Our suggested method is to create a service that applies the rules.</p>
<p>To create the startup service file type the following command: </p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">nano /etc/network/if-pre-up.d/iptaload</pre></div></div>

<p>You&#8217;ll see the nano text editor load up. Paste in the following text: </p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">#!/bin/sh
iptables-restore &lt; /etc/iptables.rules
exit 0</pre></div></div>

<p>Save the file by pressing CTRL-X, then Y and Enter.</p>
<p>Next we need to create a service that will run when the server is shut down. This file will save our rules so any changes we have made will be applied at next boot. Type the following to create the service file:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">nano /etc/network/if-post-down.d/iptasave</pre></div></div>

<p>Once the nano editor has appeared, paste in the following text: </p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">#!/bin/sh
if [ -f /etc/iptables.downrules ]; then
   iptables-restore &lt; /etc/iptables.downrules
fi
iptables-save -c &gt; /etc/iptables.save
exit 0</pre></div></div>

<p>Save the file as you did before.</p>
<p>Now we need to make sure these scripts are executable. Type the following: </p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">chmod +x /etc/network/if-post-down.d/iptasave</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">chmod +x /etc/network/if-pre-up.d/iptaload</pre></div></div>

<h3>Test your setup </h3>
<p>You may reboot your server and run <strong>iptables -L</strong> to make sure that your firewall rules applied successfully. </p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/818/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install Postfix</title>
		<link>http://winn.ws/archives/704</link>
		<comments>http://winn.ws/archives/704#comments</comments>
		<pubDate>Mon, 11 Oct 2010 21:41:16 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Postfix]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=704</guid>
		<description><![CDATA[Some dread this step in server setup. It does not have to be a pain, just follow the steps below and I hope you get the same success i did! There are, of course, alternatives to postfix, each with advantages and disadvantages and, without going into the differences, I have chosen Postfix due its <em>relative ease of configuration</em>.]]></description>
			<content:encoded><![CDATA[<p>Some dread this step in server setup. It does not have to be a pain, just follow the steps below and I hope you get the same success i did! There are, of course, alternatives to postfix, each with advantages and disadvantages and, without going into the differences, I have chosen Postfix due its <em>relative ease of configuration</em>.</p>
<p>With all that out of the way, let&#8217;s go ahead and install Postfix! In this example I am using Ubuntu 10.04.</p>
<p><span id="more-704"></span></p>
<p>Installation is very easy. We&#8217;ll be using aptitude to install the software itself. </p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">sudo aptitude install postfix telnet mailx</pre></div></div>

<p>Note that we also install telnet and mailx as they contain several tools we&#8217;ll use to test and configure postfix.<br />
During the installation you will be asked the general type of mail configuration: </p>
<p style="text-align:center;"><a class="colorbox" href="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2010/10/postfix1.jpg"><img src="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2010/10/postfix1-300x149.jpg" alt="" title="postfix1" width="300" height="149" class="aligncenter size-medium wp-image-705" /></a></p>
<p>Choose the &#8216;Internet Site&#8217;</p>
<p>You will then need to enter your main domain name (this should match the hostname).</p>
<p style="text-align:center;"><a class="colorbox" href="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2010/10/postfixinstall.jpg"><img src="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2010/10/postfixinstall-300x119.jpg" alt="" title="postfixinstall" width="300" height="119" class="aligncenter size-medium wp-image-706" /></a></p>
<p>At this stage, you can send emails from your application. The settings shown above during the postfix installation mean that the very basics are already done.</p>
<h3>Test It</h3>
<p>let&#8217;s conduct a quick test to see if postfix is actually sending mail. You will need to send an email to a working email address using the &#8216;mail&#8217; command: </p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">mail You@example.com</pre></div></div>

<p><em>Replace the email address with one of your choosing (remember this must be a working email address). </em></p>
<ul>
<li>The output asks for the subject of the email. Once done, press enter/return. </li>
<li>Next enter the subject of the email. Once done, press enter/return and then a single period (.) &#8211; the period lets mail know the body is finished.</li>
<li>Finally press enter/return again to send the email (you may need to do this twice so you skip the &#8216;CC:&#8217; entry. </li>
</ul>
<p><strong>NOTE:</strong> No confirmation is given that the email has been sent (the logs will show the details) but check the receiving email address and voila! a nice, fresh email with the subject &#8216;test email from yourserver.tld&#8217;.</p>
<p>For many people, that is all you need to send mail from your application &#8211; especially if the only emails are notifications to the site administrator. I hope the article helped you install Postfix on your Ubuntu 10.04 server.</p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/704/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHP/MySQL after 2010-005</title>
		<link>http://winn.ws/archives/492</link>
		<comments>http://winn.ws/archives/492#comments</comments>
		<pubDate>Sat, 28 Aug 2010 07:22:27 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=492</guid>
		<description><![CDATA[After applying Security Update 2010-05, some users have reported PHP and MySQL problems, including an inability to connect to MySQL databases. Apple reports that the following procedure resolves the database connection issue: In the Terminal type sudo nano /etc/php.ini (Terminal will ask you for your password) Change: mysql.default_socket = to: mysql.default_socket = /tmp/mysql.sock Press Ctrl-O, [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2011/01/phpicon.jpg" class="codeicon" alt="php" /></p>
<p>After applying Security Update 2010-05, some users have reported PHP and MySQL problems, including an inability to connect to MySQL databases. Apple reports that the following procedure resolves the database connection issue:</p>
<ol>
<li>In the Terminal type sudo nano /etc/php.ini (Terminal will ask you for your password)</li>
<li>Change: mysql.default_socket = to: mysql.default_socket = /tmp/mysql.sock</li>
<li>Press Ctrl-O, then Enter to save</li>
<li>Type sudo apachectl graceful</li>
</ol>
<p>Note that you may need to duplicate the original install php.ini.default file, just simply copy the contents of the file and create a php.ini. (cp php.ini.default php.ini)</p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/492/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Website is down!</title>
		<link>http://winn.ws/archives/157</link>
		<comments>http://winn.ws/archives/157#comments</comments>
		<pubDate>Wed, 03 Sep 2008 20:40:45 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.winn.ws/?p=157</guid>
		<description><![CDATA[This is something we all hear but it&#8217;s only 60% true most of the time. This one will make you cry&#8230; Get to a private place for viewing! Tech: &#8220;Did you reboot?&#8221; Sales: &#8220;Yeah dude, three times just like you always tell me too&#8221; The Website Is Down!]]></description>
			<content:encoded><![CDATA[<p>This is something we all hear but it&#8217;s only 60% true most of the time. This one will make you cry&#8230; Get to a private place for viewing!</p>
<blockquote><p>
Tech: &#8220;Did you reboot?&#8221;<br />
Sales: &#8220;Yeah dude, three times just like you always tell me too&#8221;
</p></blockquote>
<p><a href="http://thewebsiteisdown.com/">The Website Is Down!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/157/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I think i am in Stack Love&#8230;</title>
		<link>http://winn.ws/archives/154</link>
		<comments>http://winn.ws/archives/154#comments</comments>
		<pubDate>Wed, 13 Aug 2008 14:50:07 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[BitNami]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Stacks]]></category>

		<guid isPermaLink="false">http://www.winn.ws/?p=154</guid>
		<description><![CDATA[I am talking about BitNami Open Source Stacks! This was something i found and started using right away! I dont get &#8220;jump up and down&#8221; happy too often but, this is one of the times! I have been using BitNami for about 3 weeks and i dont know how i got along without it! Trust [...]]]></description>
			<content:encoded><![CDATA[<p>I am talking about <a href="http://bitnami.org/">BitNami</a> Open Source Stacks! This was something i found and started using right away! I dont get &#8220;jump up and down&#8221; happy too often but, this is one of the times! I have been using BitNami for about 3 weeks and i dont know how i got along without it! <strong>Trust me, if your a developer you will love this!!!</strong> Stop wasting your time with installing each item for testing, just use BitNami form now on. You will thank me later.</p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/154/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install wget on your mac.</title>
		<link>http://winn.ws/archives/139</link>
		<comments>http://winn.ws/archives/139#comments</comments>
		<pubDate>Mon, 07 Apr 2008 18:26:34 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[wget]]></category>

		<guid isPermaLink="false">http://www.winn.ws/?p=139</guid>
		<description><![CDATA[Ok, i am not sure why it is not included with the mac bash but i have installed wget for my mac. This is an easy process to do and then to start using! First we need to download the wget files to your Desktop. Download Download wget for Mac OS X (124 KB) Install [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, i am not sure why it is not included with the mac bash but i have installed wget for my mac. This is an easy process to do and then to start using! First we need to download the wget files to your Desktop.</p>
<h4>Download</h4>
<p><a href="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2008/04/wget.zip">Download wget for Mac OS X (124 KB)</a></p>
<h4>Install wget</h4>
<p><strong>For normal mac setups.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="code" style="font-family:monospace;"># Open Terminal: Applications/Utilitys/Terminal
# This is assuming the wget folder is in Downloads
cd Downloads
cd wget
sudo mv wget /usr/local/bin
password:
sudo mv wget.1 /usr/local/man/man1
sudo mv wgetrc /usr/local/etc
&nbsp;
# Close then reopen your terminal
# Now lets test! Simply do:
wget
&nbsp;
 # Output
wget: missing URL
Usage: wget [OPTION]... [URL]...
&nbsp;
Try `wget --help' for more options.</pre></div></div>

<p>This will work 99% of the time, but i have seen one case that this did not work. When calling &#8220;sudo mv wget.1 /usr/local/man/man1&#8243; and it responds &#8220;No such file or directory&#8221; do not freak out! I have the solution for you, below is for users that received an error after trying to move the wget.1 to man1 folder.</p>
<h4>Install wget (option 2)</h4>
<p><strong>For other mac setups.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="code" style="font-family:monospace;"># ONLY IF YOU GOT AN ERROR &quot;No such file or directory: MAN1&quot;
# DO NOT USE THIS IF THE CODE ABOVE WORKED AND YOU CAN USE WGET
# May need to re-download
sudo mv wget /usr/bin
password:
sudo mv wget.1 /usr/share/man/man1
sudo mv wgetrc /usr/local/etc
&nbsp;
# Close then reopen your terminal
# Now lets test! Simply do:
wget
&nbsp;
# Output
wget: missing URL
Usage: wget [OPTION]... [URL]...
&nbsp;
Try `wget --help' for more options.</pre></div></div>

<p>So now thats installed, what do we use it for? Well are you wanting to download my lasted version of the Winn Guestbook? You can easily download it with wget now! Let me show you how!</p>

<div class="wp_syntax"><div class="code"><pre class="code" style="font-family:monospace;"># Download the latest version of the Winn Grestbook (v2.2.9)
# First 'cd' to the directory you want it to download too.
wget http://winn.ws/downloads/guestbook_v2-2-9.zip
&nbsp;
# done!</pre></div></div>

<p>Works great! Leran more about using wget and other commands with this book from amazon.com: <a href="http://www.amazon.com/gp/product/0470478365?ie=UTF8&#038;tag=winnws-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0470478365">MAC OS X UNIX Toolbox: 1000+ Commands for the Mac OS X</a><img src="http://www.assoc-amazon.com/e/ir?t=winnws-20&#038;l=as2&#038;o=1&#038;a=0470478365" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/139/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Database Caching 2/31 queries in 0.028 seconds using disk: basic
Object Caching 470/531 objects using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: d45jz936mo8n8.cloudfront.net

Served from: winn.ws @ 2012-02-07 20:02:22 -->
