<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>andrewault.net</title>
	
	<link>http://www.andrewault.net</link>
	<description>bloggy blog</description>
	<lastBuildDate>Sun, 05 Sep 2010 23:59:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/andrewault" /><feedburner:info uri="andrewault" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Perl script to get video details</title>
		<link>http://feedproxy.google.com/~r/andrewault/~3/7HByvWZMaGE/</link>
		<comments>http://www.andrewault.net/2010/07/09/perl-script-to-get-video-details/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 16:48:15 +0000</pubDate>
		<dc:creator>Andrew Ault</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[command line]]></category>

		<guid isPermaLink="false">http://www.andrewault.net/?p=682</guid>
		<description><![CDATA[<p>This is a command line Perl script I made a while back to simply show details about a specified video. It is tested on Ubuntu.</p>
<p>You can modify it for your specific requirements or grab some code for another use.</p>

#!/usr/bin/perl -w
use strict;
use warnings;

use IPC::Open3;

# example
my $filename  = $ARGV[0];
my %videoInfo = videoInfo($filename);
print &#34;duration: &#34; . $videoInfo{&#039;duration&#039;} . [...]]]></description>
			<content:encoded><![CDATA[<p>This is a command line Perl script I made a while back to simply show details about a specified video. It is tested on Ubuntu.</p>
<p>You can modify it for your specific requirements or grab some code for another use.</p>
<pre class="brush: php">
#!/usr/bin/perl -w
use strict;
use warnings;

use IPC::Open3;

# example
my $filename  = $ARGV[0];
my %videoInfo = videoInfo($filename);
print &quot;duration: &quot; . $videoInfo{&#039;duration&#039;} . &quot;\n&quot;;
print &quot;durationsecs: &quot; . $videoInfo{&#039;durationsecs&#039;} . &quot;\n&quot;;
print &quot;bitrate: &quot; . $videoInfo{&#039;bitrate&#039;} . &quot;\n&quot;;
print &quot;vcodec: &quot; . $videoInfo{&#039;vcodec&#039;} . &quot;\n&quot;;
print &quot;vformat: &quot; . $videoInfo{&#039;vformat&#039;} . &quot;\n&quot;;
print &quot;acodec: &quot; . $videoInfo{&#039;acodec&#039;} . &quot;\n&quot;;
print &quot;asamplerate: &quot; . $videoInfo{&#039;asamplerate&#039;} . &quot;\n&quot;;
print &quot;achannels: &quot; . $videoInfo{&#039;achannels&#039;} . &quot;\n&quot;;

#
# returns media information in a hash
sub videoInfo {
	# ffmpeg command
	my $ffmpeg = &#039;/usr/local/bin/ffmpeg&#039;;

	my %finfo = (
				  &#039;duration&#039;     =&gt; &quot;00:00:00.00&quot;,
				  &#039;durationsecs&#039; =&gt; &quot;0&quot;,
				  &#039;bitrate&#039;      =&gt; &quot;0&quot;,
				  &#039;vcodec&#039;       =&gt; &quot;&quot;,
				  &#039;vformat&#039;      =&gt; &quot;&quot;,
				  &#039;acodec&#039;       =&gt; &quot;&quot;,
				  &#039;asamplerate&#039;   =&gt; &quot;0&quot;,
				  &#039;achannels&#039;       =&gt; &quot;0&quot;,
	);

	my $file = shift;

	# escaping characters
	$file =~ s/(\W)/\\$1/g;

	open3( &quot;&lt;/dev/null&quot;, &quot;&gt;/dev/null&quot;, \*ERPH, &quot;$ffmpeg -i $file&quot; ) or die &quot;can&#039;t run $ffmpeg\n&quot;;
	my @res = &lt;ERPH&gt;;

	# parse ffmpeg output
	foreach (@res) {
        print;

		# duration
		if (m!Duration: ([0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9])!) {
			$finfo{&#039;duration&#039;} = $1;
		}

		# bitrate
		if (m!bitrate: (\d*) kb/s!) {
			$finfo{&#039;bitrate&#039;} = $1;
		}

		# vcodec and vformat
		if (/Video: (\w*), (\w*),/) {
			$finfo{&#039;vcodec&#039;}  = $1;
			$finfo{&#039;vformat&#039;} = $2;
		}

        # Stream #0.1(und): Audio: aac, 48000 Hz, 1 channels, s16, 64 kb/s

		# acodec, samplerate, stereo and audiorate
		if (m!Audio: (\w*), (\d*) Hz, (\d*)!) {
			$finfo{&#039;acodec&#039;}     = $1;
			$finfo{&#039;asamplerate&#039;} = $2;
			$finfo{&#039;achannels&#039;}     = $3;
		}
	}

	my $tenths  = substr( $finfo{&#039;duration&#039;}, 9, 2 );
	my $seconds = substr( $finfo{&#039;duration&#039;}, 6, 2 );
	my $minutes = substr( $finfo{&#039;duration&#039;}, 3, 2 );
	my $hours   = substr( $finfo{&#039;duration&#039;}, 0, 2 );
	$finfo{&#039;durationsecs&#039;} = ( $tenths * .01 ) + $seconds + ( $minutes * 60 ) + ( $hours * 360 );

	return %finfo;
}
</pre>



share and enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F09%2Fperl-script-to-get-video-details%2F&amp;partner=sociable" title="Print"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F09%2Fperl-script-to-get-video-details%2F&amp;title=Perl%20script%20to%20get%20video%20details&amp;bodytext=This%20is%20a%20command%20line%20Perl%20script%20I%20made%20a%20while%20back%20to%20simply%20show%20details%20about%20a%20specified%20video.%20It%20is%20tested%20on%20Ubuntu.%0D%0A%0D%0AYou%20can%20modify%20it%20for%20your%20specific%20requirements%20or%20grab%20some%20code%20for%20another%20use.%0D%0A%0D%0A%5Bsourcecode%5D%0D%0A%23%21%2Fusr%2Fbin%2Fperl%20-w%0D" title="Digg"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F09%2Fperl-script-to-get-video-details%2F" title="Sphinn"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F09%2Fperl-script-to-get-video-details%2F&amp;title=Perl%20script%20to%20get%20video%20details&amp;notes=This%20is%20a%20command%20line%20Perl%20script%20I%20made%20a%20while%20back%20to%20simply%20show%20details%20about%20a%20specified%20video.%20It%20is%20tested%20on%20Ubuntu.%0D%0A%0D%0AYou%20can%20modify%20it%20for%20your%20specific%20requirements%20or%20grab%20some%20code%20for%20another%20use.%0D%0A%0D%0A%5Bsourcecode%5D%0D%0A%23%21%2Fusr%2Fbin%2Fperl%20-w%0D" title="del.icio.us"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F09%2Fperl-script-to-get-video-details%2F&amp;t=Perl%20script%20to%20get%20video%20details" title="Facebook"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F09%2Fperl-script-to-get-video-details%2F&amp;title=Perl%20script%20to%20get%20video%20details" title="Mixx"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F09%2Fperl-script-to-get-video-details%2F&amp;title=Perl%20script%20to%20get%20video%20details&amp;annotation=This%20is%20a%20command%20line%20Perl%20script%20I%20made%20a%20while%20back%20to%20simply%20show%20details%20about%20a%20specified%20video.%20It%20is%20tested%20on%20Ubuntu.%0D%0A%0D%0AYou%20can%20modify%20it%20for%20your%20specific%20requirements%20or%20grab%20some%20code%20for%20another%20use.%0D%0A%0D%0A%5Bsourcecode%5D%0D%0A%23%21%2Fusr%2Fbin%2Fperl%20-w%0D" title="Google Bookmarks"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a  href="http://blogplay.com" title="Blogplay"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Perl%20script%20to%20get%20video%20details&amp;u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F09%2Fperl-script-to-get-video-details%2F" title="Fark"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F09%2Fperl-script-to-get-video-details%2F&amp;title=Perl%20script%20to%20get%20video%20details" title="Reddit"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=Perl%20script%20to%20get%20video%20details&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F09%2Fperl-script-to-get-video-details%2F" title="Slashdot"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F09%2Fperl-script-to-get-video-details%2F&amp;title=Perl%20script%20to%20get%20video%20details" title="StumbleUpon"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Perl%20script%20to%20get%20video%20details%20-%20http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F09%2Fperl-script-to-get-video-details%2F" title="Twitter"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/>
<p><a href="http://feedads.g.doubleclick.net/~a/1GDkAhTBJOr5Oovt7V043q8rTzk/0/da"><img src="http://feedads.g.doubleclick.net/~a/1GDkAhTBJOr5Oovt7V043q8rTzk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/1GDkAhTBJOr5Oovt7V043q8rTzk/1/da"><img src="http://feedads.g.doubleclick.net/~a/1GDkAhTBJOr5Oovt7V043q8rTzk/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/andrewault/~4/7HByvWZMaGE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.andrewault.net/2010/07/09/perl-script-to-get-video-details/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.andrewault.net/2010/07/09/perl-script-to-get-video-details/</feedburner:origLink></item>
		<item>
		<title>Create a Drupal site on an Ubuntu Server</title>
		<link>http://feedproxy.google.com/~r/andrewault/~3/5ecB-s5tWKc/</link>
		<comments>http://www.andrewault.net/2010/07/06/create-a-drupal-site-on-an-ubuntu-server/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 22:11:53 +0000</pubDate>
		<dc:creator>Andrew Ault</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.andrewault.net/?p=660</guid>
		<description><![CDATA[<p>This will help you quickly install a Drupal site on an Ubuntu server.</p>
<p>This is my script for this purpose. Use it as you will. This procedure assumes that you have already installed Apache, MySQL, phpMyAdmin and PHP. It also assumes that you are familiar with everything. This is probably not a beginner&#8217;s guide, but an aid [...]]]></description>
			<content:encoded><![CDATA[<p>This will help you quickly install a Drupal site on an Ubuntu server.</p>
<p>This is my script for this purpose. Use it as you will. This procedure assumes that you have already installed Apache, MySQL, phpMyAdmin and PHP. It also assumes that you are familiar with everything. This is probably not a beginner&#8217;s guide, but an aid to someone more experienced that wants to install Drupal quickly.</p>
<h3>Create and run a shell script to create your site</h3>
<p>Use this template to create a shell script that will create your site. Create a text file from the following template called &#8220;make_dru.sh&#8221; (in your home directory is fine). Modify lines 7 to 17 for your installation. Then use &#8220;chmod +x make_dru.sh&#8221; and execute the script with &#8220;sudo ./make_dru.sh&#8221;.</p>
<pre class="brush: php">
#!/bin/bash
#
# make drupal project
#

#
OWNER=&quot;andrew&quot; 			# change to your username
GROUP=&quot;staff&quot;			# change to your username or the group that will work on the site
DRUPAL_URL=&quot;http://ftp.drupal.org/files/projects/drupal-6.17.tar.gz&quot; # update to the current version, if there is one
SITESROOT=&quot;/usr/local/var/www&quot;  # change to the directory where you put website directories
URL=&quot;www.sitename.com&quot;		# change to your site&#039;s address

# database.php parameters
DBUSER=&quot;sitename&quot;		# change to something meaningful
DBPWD=&quot;passwordgoeshere&quot;		# change to a long password
DBHOST=&quot;localhost&quot;		# leave alone
DBDATABASE=$DBUSER		# leave alone

#
# make sure this is run as root
#
if [[ $UID -ne 0 ]]; then
    echo &quot;Not running as root&quot;
    exit
fi

if [ ! -d $SITESROOT ]; then
	echo &quot;$SITESROOT directory does not exist&quot;
	exit
fi

#
# check for existence of the specified user owner
#
/bin/egrep  -i &quot;^$OWNER&quot; /etc/passwd &gt; /dev/null
if [ ! $? -eq 0 ]; then
   echo &quot;User $OWNER, which is specified as the owner, does not exist in /etc/passwd&quot;
   exit
fi

#
# check for existence of the specified group
#
/bin/egrep -i &quot;^$GROUP&quot; /etc/group &gt; /dev/null
if [ ! $? -eq 0 ]; then
   echo &quot;$GROUP, which is specified as the group to use, does not exist in /etc/group&quot;
   exit
fi

#
# change to the siteroot directory
#
cd $SITESROOT

if [ -d $URL ]; then
	echo &quot;$SITESROOT/$URL directory already exists&quot;
	exit
fi 

mkdir $URL
chown $OWNER:$GROUP $URL
cd $URL

#
# get Drupal
#
echo &#039;get Drupal&#039;
wget -O drupal.tgz $DRUPAL_URL
tar -xzvf drupal.tgz
find . -maxdepth 1 -type d -name &#039;drupal*&#039; -exec mv {} public \;
sudo chown -R $OWNER:$GROUP public
find . -type d -exec chmod g+ws {} \;

#
# temporarily allow write to settings
#
cp public/sites/default/default.settings.php public/sites/default/settings.php
chmod a+w public/sites/default/settings.php
chmod a+w public/sites/default

#
# logs
#
echo &quot;set up logs&quot;
mkdir logs
sudo chown $OWNER:www-data logs
chmod g+ws logs
touch logs/error.log
touch logs/combined.log

#
# create Apache virtual site
#
echo creating Apache virtual site file in /etc/apache2/sites-available
echo &quot;&lt;VirtualHost *:80&gt;
	ServerName $URL
	DocumentRoot $SITESROOT/$URL/public
	DirectoryIndex index.php
	LogLevel warn
	ErrorLog $SITESROOT/$URL/logs/error.log
	CustomLog $SITESROOT/$URL/logs/combined.log combined
&lt;/VirtualHost&gt;
&quot; &gt; /etc/apache2/sites-available/$URL

#
# finish up
#
echo -e &quot;Drupal website was created in: $SITESROOT/$URL\n&quot;
echo -e &quot;To finish, do the following:\n&quot;
echo &quot;1. Enable site with: sudo a2ensite $URL&quot;
echo &quot;2. Restart Apache with: sudo /etc/init.d/apache2 restart&quot;
echo &quot;3. Make a crontab entry (&#039;sudo crontab -e&#039;) like: 0 * * * * wget -O - -q -t 1 http://$URL/cron.php&quot;
echo -e &quot;4. Create a MySQL database with:\n&quot;
echo -e &quot;\t     user: $DBUSER&quot;
echo -e &quot;\t      pwd: $DBPWD&quot;
echo -e &quot;\t     host: $DBHOST&quot;
echo -e &quot;\t database: $DBDATABASE&quot;
echo &quot;5. Open the site in your browser and finish the set-up.&quot;
echo &quot;6. Remove write privileges with: sudo chmod og-w public/sites/default/settings.php&quot;
echo &quot;   ..and: sudo chmod og-w public/sites/default&quot;
</pre>
<h3>Create the database and user with phpMyAdmin</h3>
<ul>
<li>click the &#8220;Privileges&#8221; tab and add a new user</li>
<li>in the &#8220;User name&#8221; field, enter the sitename that you entered for DBUSER in the script</li>
<li>in the Host field, select &#8220;Local&#8221;</li>
<li>enter or generate a password &#8211; make it a long one, like 20 characters</li>
<li>in the Database for User list, select &#8220;Create database with same name and grant all privileges&#8221;</li>
<li>click Go</li>
</ul>
<h3>Enable the new Drupal website</h3>
<p>This will tell Apache to enable the virtual site that was made in the script and then restart Apache.</p>
<pre class="brush: php">
sudo a2ensite www.sitename.com
sudo /etc/init.d/apache2 restart
</pre>
<h3>Configure the site</h3>
<p>Open site in browser and configure it</p>
<h3>Remove temporary write privileges</h3>
<p>During site creation, write privileges were needed, after site set-up, remove them. In a shell, while in the sites directory (where the public directory is run these commands:</p>
<pre class="brush: php">
sudo chmod og-w public/sites/default/settings.php
sudo chmod og-w public/sites/default
</pre>



share and enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F06%2Fcreate-a-drupal-site-on-an-ubuntu-server%2F&amp;partner=sociable" title="Print"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F06%2Fcreate-a-drupal-site-on-an-ubuntu-server%2F&amp;title=Create%20a%20Drupal%20site%20on%20an%20Ubuntu%20Server&amp;bodytext=This%20will%20help%20you%20quickly%20install%20a%20Drupal%20site%20on%20an%20Ubuntu%20server.%0D%0A%0D%0AThis%20is%20my%20script%20for%20this%20purpose.%20Use%20it%20as%20you%20will.%20This%20procedure%20assumes%20that%20you%20have%20already%20installed%20Apache%2C%20MySQL%2C%20phpMyAdmin%20and%20PHP.%20It%20also%20assumes%20that%20you%20are%20fa" title="Digg"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F06%2Fcreate-a-drupal-site-on-an-ubuntu-server%2F" title="Sphinn"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F06%2Fcreate-a-drupal-site-on-an-ubuntu-server%2F&amp;title=Create%20a%20Drupal%20site%20on%20an%20Ubuntu%20Server&amp;notes=This%20will%20help%20you%20quickly%20install%20a%20Drupal%20site%20on%20an%20Ubuntu%20server.%0D%0A%0D%0AThis%20is%20my%20script%20for%20this%20purpose.%20Use%20it%20as%20you%20will.%20This%20procedure%20assumes%20that%20you%20have%20already%20installed%20Apache%2C%20MySQL%2C%20phpMyAdmin%20and%20PHP.%20It%20also%20assumes%20that%20you%20are%20fa" title="del.icio.us"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F06%2Fcreate-a-drupal-site-on-an-ubuntu-server%2F&amp;t=Create%20a%20Drupal%20site%20on%20an%20Ubuntu%20Server" title="Facebook"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F06%2Fcreate-a-drupal-site-on-an-ubuntu-server%2F&amp;title=Create%20a%20Drupal%20site%20on%20an%20Ubuntu%20Server" title="Mixx"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F06%2Fcreate-a-drupal-site-on-an-ubuntu-server%2F&amp;title=Create%20a%20Drupal%20site%20on%20an%20Ubuntu%20Server&amp;annotation=This%20will%20help%20you%20quickly%20install%20a%20Drupal%20site%20on%20an%20Ubuntu%20server.%0D%0A%0D%0AThis%20is%20my%20script%20for%20this%20purpose.%20Use%20it%20as%20you%20will.%20This%20procedure%20assumes%20that%20you%20have%20already%20installed%20Apache%2C%20MySQL%2C%20phpMyAdmin%20and%20PHP.%20It%20also%20assumes%20that%20you%20are%20fa" title="Google Bookmarks"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a  href="http://blogplay.com" title="Blogplay"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Create%20a%20Drupal%20site%20on%20an%20Ubuntu%20Server&amp;u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F06%2Fcreate-a-drupal-site-on-an-ubuntu-server%2F" title="Fark"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F06%2Fcreate-a-drupal-site-on-an-ubuntu-server%2F&amp;title=Create%20a%20Drupal%20site%20on%20an%20Ubuntu%20Server" title="Reddit"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=Create%20a%20Drupal%20site%20on%20an%20Ubuntu%20Server&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F06%2Fcreate-a-drupal-site-on-an-ubuntu-server%2F" title="Slashdot"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F06%2Fcreate-a-drupal-site-on-an-ubuntu-server%2F&amp;title=Create%20a%20Drupal%20site%20on%20an%20Ubuntu%20Server" title="StumbleUpon"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Create%20a%20Drupal%20site%20on%20an%20Ubuntu%20Server%20-%20http%3A%2F%2Fwww.andrewault.net%2F2010%2F07%2F06%2Fcreate-a-drupal-site-on-an-ubuntu-server%2F" title="Twitter"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/>
<p><a href="http://feedads.g.doubleclick.net/~a/8rGgXWNRR-3hNVaZAvgCsNV-5t0/0/da"><img src="http://feedads.g.doubleclick.net/~a/8rGgXWNRR-3hNVaZAvgCsNV-5t0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/8rGgXWNRR-3hNVaZAvgCsNV-5t0/1/da"><img src="http://feedads.g.doubleclick.net/~a/8rGgXWNRR-3hNVaZAvgCsNV-5t0/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/andrewault/~4/5ecB-s5tWKc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.andrewault.net/2010/07/06/create-a-drupal-site-on-an-ubuntu-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.andrewault.net/2010/07/06/create-a-drupal-site-on-an-ubuntu-server/</feedburner:origLink></item>
		<item>
		<title>Linux command line language translator</title>
		<link>http://feedproxy.google.com/~r/andrewault/~3/fViCQDPhjFM/</link>
		<comments>http://www.andrewault.net/2010/06/23/linux-command-line-language-translator/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 18:46:11 +0000</pubDate>
		<dc:creator>Andrew Ault</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.andrewault.net/?p=653</guid>
		<description><![CDATA[<p>I wanted a command language translator that can be used in bash shell scripts. There are a couple of options available, but none that were versatile enough. A little research resulted in finding that Google Translate offered what I wanted and that there was a JSON interface, which I could use with Perl&#8217;s JSON module.</p>
<p>I added [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted a command language translator that can be used in bash shell scripts. There are a couple of options available, but none that were versatile enough. A little research resulted in finding that <a href="http://translate.google.com/">Google Translate</a> offered what I wanted and that there was a JSON interface, which I could use with Perl&#8217;s <a href="http://search.cpan.org/~makamaka/JSON-2.21/lib/JSON.pm">JSON module</a>.</p>
<p>I added a few niceties such as help, multiple source options and a listing of available languages.</p>
<p>Entering:</p>
<p><strong>tranny -t de &#8216;I am a citizen of Berlin&#8217;</strong></p>
<p>gets this result:</p>
<p><strong>Ich bin ein Bürger von Berlin</strong></p>
<p>and entering:</p>
<p><strong>tranny &#8216;Ich bin ein Bürger von Berlin&#8217;</strong></p>
<p>results:</p>
<p><strong>I am a citizen of Berlin</strong></p>
<p>I created a Google Code project for tranny at: <a href="http://code.google.com/p/tranny/">http://code.google.com/p/tranny/</a></p>
<p>If you need a scriptable translator, give it a try. If you run into trouble or would like to suggest changes, leave comments here or at the <a href="http://code.google.com/p/tranny/">project</a>.</p>
<pre class="brush: php">
#!/usr/bin/perl
#
# what:      tranny, a language translator
# project:   https://code.google.com/p/tranny/
# copyright: Copyright 2010, Andrew Ault
# license:   This content is released under the  http://code.google.com/p/tranny/wiki/license MIT License.
#
# Uses the JSON module from CPAN. To install: &quot;sudo cpan JSON&quot;
#

use strict;
use warnings;
use POSIX;
use Getopt::Std;
use JSON;
use LWP;

require &#039;sys/ioctl.ph&#039;;
die &quot;no TIOCGWINSZ &quot; unless defined &amp;TIOCGWINSZ;

my $original;
my $winsize;
my $has_tty = 1;
my ( $screen_rows, $screen_cols, $screen_xpixels, $screen_ypixels );

my %languages = (
				  &#039;afrikaans&#039;      =&gt; &#039;af&#039;,
				  &#039;albanian&#039;       =&gt; &#039;sq&#039;,
				  &#039;amharic&#039;        =&gt; &#039;am&#039;,
				  &#039;arabic&#039;         =&gt; &#039;ar&#039;,
				  &#039;armenian&#039;       =&gt; &#039;hy&#039;,
				  &#039;azerbaijani&#039;    =&gt; &#039;az&#039;,
				  &#039;basque&#039;         =&gt; &#039;eu&#039;,
				  &#039;belarusian&#039;     =&gt; &#039;be&#039;,
				  &#039;bengali&#039;        =&gt; &#039;bn&#039;,
				  &#039;bihari&#039;         =&gt; &#039;bh&#039;,
				  &#039;breton&#039;         =&gt; &#039;br&#039;,
				  &#039;bulgarian&#039;      =&gt; &#039;bg&#039;,
				  &#039;burmese&#039;        =&gt; &#039;my&#039;,
				  &#039;catalan&#039;        =&gt; &#039;ca&#039;,
				  &#039;cherokee&#039;       =&gt; &#039;chr&#039;,
				  &#039;chinese&#039;        =&gt; &#039;zh&#039;,
				  &#039;chinese simp&#039;   =&gt; &#039;zh-cn&#039;,
				  &#039;chinese trad&#039;   =&gt; &#039;zh-tw&#039;,
				  &#039;corsican&#039;       =&gt; &#039;co&#039;,
				  &#039;croatian&#039;       =&gt; &#039;hr&#039;,
				  &#039;czech&#039;          =&gt; &#039;cs&#039;,
				  &#039;danish&#039;         =&gt; &#039;da&#039;,
				  &#039;dhivehi&#039;        =&gt; &#039;dv&#039;,
				  &#039;dutch&#039;          =&gt; &#039;nl&#039;,
				  &#039;english&#039;        =&gt; &#039;en&#039;,
				  &#039;esperanto&#039;      =&gt; &#039;eo&#039;,
				  &#039;estonian&#039;       =&gt; &#039;et&#039;,
				  &#039;faroese&#039;        =&gt; &#039;fo&#039;,
				  &#039;filipino&#039;       =&gt; &#039;tl&#039;,
				  &#039;finnish&#039;        =&gt; &#039;fi&#039;,
				  &#039;french&#039;         =&gt; &#039;fr&#039;,
				  &#039;frisian&#039;        =&gt; &#039;fy&#039;,
				  &#039;galician&#039;       =&gt; &#039;gl&#039;,
				  &#039;georgian&#039;       =&gt; &#039;ka&#039;,
				  &#039;german&#039;         =&gt; &#039;de&#039;,
				  &#039;greek&#039;          =&gt; &#039;el&#039;,
				  &#039;gujarati&#039;       =&gt; &#039;gu&#039;,
				  &#039;haitian creole&#039; =&gt; &#039;ht&#039;,
				  &#039;hebrew&#039;         =&gt; &#039;iw&#039;,
				  &#039;hindi&#039;          =&gt; &#039;hi&#039;,
				  &#039;hungarian&#039;      =&gt; &#039;hu&#039;,
				  &#039;icelandic&#039;      =&gt; &#039;is&#039;,
				  &#039;indonesian&#039;     =&gt; &#039;id&#039;,
				  &#039;inuktitut&#039;      =&gt; &#039;iu&#039;,
				  &#039;irish&#039;          =&gt; &#039;ga&#039;,
				  &#039;italian&#039;        =&gt; &#039;it&#039;,
				  &#039;japanese&#039;       =&gt; &#039;ja&#039;,
				  &#039;javanese&#039;       =&gt; &#039;jw&#039;,
				  &#039;kannada&#039;        =&gt; &#039;kn&#039;,
				  &#039;kazakh&#039;         =&gt; &#039;kk&#039;,
				  &#039;khmer&#039;          =&gt; &#039;km&#039;,
				  &#039;korean&#039;         =&gt; &#039;ko&#039;,
				  &#039;kurdish&#039;        =&gt; &#039;ku&#039;,
				  &#039;kyrgyz&#039;         =&gt; &#039;ky&#039;,
				  &#039;lao&#039;            =&gt; &#039;lo&#039;,
				  &#039;latin&#039;          =&gt; &#039;la&#039;,
				  &#039;latvian&#039;        =&gt; &#039;lv&#039;,
				  &#039;lithuanian&#039;     =&gt; &#039;lt&#039;,
				  &#039;luxembourgish&#039;  =&gt; &#039;lb&#039;,
				  &#039;macedonian&#039;     =&gt; &#039;mk&#039;,
				  &#039;malay&#039;          =&gt; &#039;ms&#039;,
				  &#039;malayalam&#039;      =&gt; &#039;ml&#039;,
				  &#039;maltese&#039;        =&gt; &#039;mt&#039;,
				  &#039;maori&#039;          =&gt; &#039;mi&#039;,
				  &#039;marathi&#039;        =&gt; &#039;mr&#039;,
				  &#039;mongolian&#039;      =&gt; &#039;mn&#039;,
				  &#039;nepali&#039;         =&gt; &#039;ne&#039;,
				  &#039;norwegian&#039;      =&gt; &#039;no&#039;,
				  &#039;occitan&#039;        =&gt; &#039;oc&#039;,
				  &#039;oriya&#039;          =&gt; &#039;or&#039;,
				  &#039;pashto&#039;         =&gt; &#039;ps&#039;,
				  &#039;persian&#039;        =&gt; &#039;fa&#039;,
				  &#039;polish&#039;         =&gt; &#039;pl&#039;,
				  &#039;portuguese&#039;     =&gt; &#039;pt&#039;,
				  &#039;punjabi&#039;        =&gt; &#039;pa&#039;,
				  &#039;quechua&#039;        =&gt; &#039;qu&#039;,
				  &#039;romanian&#039;       =&gt; &#039;ro&#039;,
				  &#039;russian&#039;        =&gt; &#039;ru&#039;,
				  &#039;sanskrit&#039;       =&gt; &#039;sa&#039;,
				  &#039;scots_gaelic&#039;   =&gt; &#039;gd&#039;,
				  &#039;serbian&#039;        =&gt; &#039;sr&#039;,
				  &#039;sindhi&#039;         =&gt; &#039;sd&#039;,
				  &#039;sinhalese&#039;      =&gt; &#039;si&#039;,
				  &#039;slovak&#039;         =&gt; &#039;sk&#039;,
				  &#039;slovenian&#039;      =&gt; &#039;sl&#039;,
				  &#039;spanish&#039;        =&gt; &#039;es&#039;,
				  &#039;sundanese&#039;      =&gt; &#039;su&#039;,
				  &#039;swahili&#039;        =&gt; &#039;sw&#039;,
				  &#039;swedish&#039;        =&gt; &#039;sv&#039;,
				  &#039;syriac&#039;         =&gt; &#039;syr&#039;,
				  &#039;tajik&#039;          =&gt; &#039;tg&#039;,
				  &#039;tamil&#039;          =&gt; &#039;ta&#039;,
				  &#039;tatar&#039;          =&gt; &#039;tt&#039;,
				  &#039;telugu&#039;         =&gt; &#039;te&#039;,
				  &#039;thai&#039;           =&gt; &#039;th&#039;,
				  &#039;tibetan&#039;        =&gt; &#039;bo&#039;,
				  &#039;tonga&#039;          =&gt; &#039;to&#039;,
				  &#039;turkish&#039;        =&gt; &#039;tr&#039;,
				  &#039;ukrainian&#039;      =&gt; &#039;uk&#039;,
				  &#039;urdu&#039;           =&gt; &#039;ur&#039;,
				  &#039;uzbek&#039;          =&gt; &#039;uz&#039;,
				  &#039;uighur&#039;         =&gt; &#039;ug&#039;,
				  &#039;vietnamese&#039;     =&gt; &#039;vi&#039;,
				  &#039;welsh&#039;          =&gt; &#039;cy&#039;,
				  &#039;yiddish&#039;        =&gt; &#039;yi&#039;,
				  &#039;yoruba&#039;         =&gt; &#039;yo&#039;,
);

# get window size for country listing
open( TTY, &quot;+&lt;/dev/tty&quot; ) or $has_tty = 0;
if ($has_tty) {
	unless ( ioctl( TTY, &amp;TIOCGWINSZ, $winsize = &#039;&#039; ) ) {
		die sprintf &quot;$0: ioctl TIOCGWINSZ (%08x: $!)\n&quot;, &amp;TIOCGWINSZ;
	}
	( $screen_rows, $screen_cols, $screen_xpixels, $screen_ypixels ) = unpack( &#039;S4&#039;, $winsize );
}

getopts( &#039;f:t:o:hl&#039;, \my %opts );
if ( defined $opts{h} &amp;&amp; $opts{h} == 1 ) { usage() }
if ( defined $opts{l} &amp;&amp; $opts{l} == 1 ) { usage() }
my ( $from, $to ) = ( $opts{f}, $opts{t} );
if ( !defined $opts{f} ) { $from = &#039;&#039;; }
if ( !defined $opts{t} ) { $to   = &#039;en&#039;; }

# if text was passed on the command line
if ( defined $ARGV[0] ) {
	$original = $ARGV[0];
# text is from a file
} elsif ( defined $opts{o} ) {
	# slurp from file
	open FILE, $opts{o} or die &quot;-o argument: couldn&#039;t open file: $!&quot;;
	local $/ = undef;
	$original = &lt;FILE&gt;;
	close FILE;
# text is from STDIN
} else {
	# slurp STDIN
	local $/ = undef;
	$original = &lt;STDIN&gt;;
}

my $ua = LWP::UserAgent-&gt;new;
$ua-&gt;agent(&quot;PGDict/1.0&quot;);
my $request =
  HTTP::Request-&gt;new( GET =&gt; &quot;http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&amp;langpair=$from|$to&amp;q=$original&quot; );
my $response = $ua-&gt;request($request);

if ( $response-&gt;is_success ) {
	my $perl_res = from_json( $response-&gt;content );
	if ( $perl_res-&gt;{&#039;responseStatus&#039;} eq &#039;200&#039; ) {
		print $perl_res-&gt;{&#039;responseData&#039;}-&gt;{&#039;translatedText&#039;} . &quot;\n&quot;;
	} else {
		warn &quot;error &quot; . $perl_res-&gt;{&#039;responseDetails&#039;} . &quot;\n&quot;;
	}
} else {
	print $response-&gt;status_line . &quot;\n&quot;;
}

sub usage {
	print &quot;usage: &quot;;
	print &quot;\ttranny -f language_code -t language_code [original text]\n\n&quot;;
	print &quot;-f language_code (optional)\n\n&quot;;
	print &quot;-t language_code (optional)\n\n&quot;;
	print &quot;-o original_file (optional)\n\n&quot;;
	print &quot;-h this help\n\n&quot;;
	print &quot;-l language list\n\n&quot;;
	print &quot;Tranny uses Google Translate and requires an Internet connection to work.\n&quot;;
	print &quot;Text is translated from STDIN, from the command line or a file with -o.\n\n&quot;;
	print &quot;By default,the &#039;from&#039; language is automatically detected and translated to English (en).\n\n&quot;;
	if ( defined $opts{l} &amp;&amp; $opts{l} == 1 ) { list_languages() }
	exit;
}

sub list_languages {
	my $num_columns = ceil( $screen_cols / 23 );
	my $num_rows = ceil ( keys(%languages) /$num_columns );
	my $row = 0;
	my $col = 0;
	my @formatted_languages = ( );
	foreach my $key ( sort ( keys(%languages) ) ) {
		$row++;
		$formatted_languages[$col][$row] =  sprintf( &quot;%-14s %-6s&quot;, $key, $languages{$key} );
		if ( $row == $num_rows ){
			$row = 0;
			$col++;
		}
	}
	for ($row = 0; $row &lt;= $num_rows; $row++) {
		for ($col = 0; $col &lt;= $num_columns; $col++) {
			if ( defined $formatted_languages[$col][$row] ){
				print $formatted_languages[$col][$row];
			}
		}
		print &quot;\n&quot;;
	}
}
</pre>



share and enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F23%2Flinux-command-line-language-translator%2F&amp;partner=sociable" title="Print"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F23%2Flinux-command-line-language-translator%2F&amp;title=Linux%20command%20line%20language%20translator&amp;bodytext=I%20wanted%20a%20command%20language%20translator%20that%20can%20be%20used%20in%20bash%20shell%20scripts.%20There%20are%20a%20couple%20of%20options%20available%2C%20but%20none%20that%20were%20versatile%20enough.%20A%20little%20research%20resulted%20in%20finding%20that%20Google%20Translate%20offered%20what%20I%20wanted%20and%20that%20th" title="Digg"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F23%2Flinux-command-line-language-translator%2F" title="Sphinn"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F23%2Flinux-command-line-language-translator%2F&amp;title=Linux%20command%20line%20language%20translator&amp;notes=I%20wanted%20a%20command%20language%20translator%20that%20can%20be%20used%20in%20bash%20shell%20scripts.%20There%20are%20a%20couple%20of%20options%20available%2C%20but%20none%20that%20were%20versatile%20enough.%20A%20little%20research%20resulted%20in%20finding%20that%20Google%20Translate%20offered%20what%20I%20wanted%20and%20that%20th" title="del.icio.us"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F23%2Flinux-command-line-language-translator%2F&amp;t=Linux%20command%20line%20language%20translator" title="Facebook"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F23%2Flinux-command-line-language-translator%2F&amp;title=Linux%20command%20line%20language%20translator" title="Mixx"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F23%2Flinux-command-line-language-translator%2F&amp;title=Linux%20command%20line%20language%20translator&amp;annotation=I%20wanted%20a%20command%20language%20translator%20that%20can%20be%20used%20in%20bash%20shell%20scripts.%20There%20are%20a%20couple%20of%20options%20available%2C%20but%20none%20that%20were%20versatile%20enough.%20A%20little%20research%20resulted%20in%20finding%20that%20Google%20Translate%20offered%20what%20I%20wanted%20and%20that%20th" title="Google Bookmarks"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a  href="http://blogplay.com" title="Blogplay"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Linux%20command%20line%20language%20translator&amp;u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F23%2Flinux-command-line-language-translator%2F" title="Fark"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F23%2Flinux-command-line-language-translator%2F&amp;title=Linux%20command%20line%20language%20translator" title="Reddit"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=Linux%20command%20line%20language%20translator&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F23%2Flinux-command-line-language-translator%2F" title="Slashdot"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F23%2Flinux-command-line-language-translator%2F&amp;title=Linux%20command%20line%20language%20translator" title="StumbleUpon"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Linux%20command%20line%20language%20translator%20-%20http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F23%2Flinux-command-line-language-translator%2F" title="Twitter"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/>
<p><a href="http://feedads.g.doubleclick.net/~a/wNzZwgUa3HUT1PrrzJbmTgwM6Hs/0/da"><img src="http://feedads.g.doubleclick.net/~a/wNzZwgUa3HUT1PrrzJbmTgwM6Hs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/wNzZwgUa3HUT1PrrzJbmTgwM6Hs/1/da"><img src="http://feedads.g.doubleclick.net/~a/wNzZwgUa3HUT1PrrzJbmTgwM6Hs/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/andrewault/~4/fViCQDPhjFM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.andrewault.net/2010/06/23/linux-command-line-language-translator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.andrewault.net/2010/06/23/linux-command-line-language-translator/</feedburner:origLink></item>
		<item>
		<title>Bash for the word lover</title>
		<link>http://feedproxy.google.com/~r/andrewault/~3/Wq_Xez1LzRw/</link>
		<comments>http://www.andrewault.net/2010/06/10/bash-for-the-word-lover/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 23:54:10 +0000</pubDate>
		<dc:creator>Andrew Ault</dc:creator>
				<category><![CDATA[fun]]></category>
		<category><![CDATA[unix bash]]></category>
		<category><![CDATA[utiity]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[dictionary]]></category>
		<category><![CDATA[words]]></category>

		<guid isPermaLink="false">http://www.andrewault.net/?p=626</guid>
		<description><![CDATA[<p>It&#8217;s a WYSIWYG world. After all, we&#8217;re nearly in the future, which I define as 2019, the year Rick Deckard chases down replicants in the Blade Runner. Still no flying cars, which is disappointing. Even so, we have Steve Jobs, so the future coming, right?</p>
<p>GUI everything isn&#8217;t all that it could be. For many, many tasks, [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a WYSIWYG world. After all, we&#8217;re nearly in the future, which I define as 2019, the year Rick Deckard chases down replicants in the Blade Runner. Still no flying cars, which is disappointing. Even so, we have Steve Jobs, so the future coming, right?</p>
<p>GUI everything isn&#8217;t all that it could be. For many, many tasks, it is more expeditious to open a terminal and get a bash prompt. CLI. Character. Text. It could be green on black, or it would be a rainbow on white, but it is not different from a Televideo terminal, or a Teletype for that matter. As good as the Bourne Again Shell is, it is not graphical or fancy.</p>
<p>What it is is efficient. For a sharp mind and one given to efficiency, the terminal is power. Want to replace frick with frack in 800 HTML files?</p>
<pre class="brush: php">
find ~/web/project3 -name &#039;*.php&#039; | xargs perl -pi -e &#039;s/frick/frack/g&#039;
</pre>
<p><strong>Bam.</strong> Done.</p>
<p>This is why I have 3 terminals open right now. One is connected to a server somewhere in Texas. I just fixed some text on a site with a command much like the one above.</p>
<p>But you already knew all that. You Googled and found this page, so you are already 1337 or whatnot. How about some word power on the command line?</p>
<h3>Install some packages</h3>
<p>This will install the packages we will use on an Ubuntu or Debian system. For other distributions, you will need to use your distributions package system.</p>
<p>To install on Ubuntu or Debian, just install the needed APT packages:</p>
<pre class="brush: php">
sudo aptitude -y install wordnet wamerican-large curl wget an
</pre>
<h3>Definitions</h3>
<p>This grabs a definition for a word from dict.org. For &#8220;unusual&#8221; for example:</p>
<pre class="brush: php">
curl --stderr /dev/null dict://dict.org/d:unusual | sed &#039;/^[.,0-9].*$/d&#039;
</pre>
<p>Which returns:</p>
<p><code>Unusual \Un*u"su*al\, a.<br />
   Not usual; uncommon; rare; as, an unusual season; a person of<br />
   unusual grace or erudition. -- {Un*u"su*al*ly}, adv. --<br />
   {Un*u"su*al*ness}, n.<br />
   [1913 Webster]<br />
</code></p>
<p>As you can see you are using <strong>curl</strong> to request a definition for &#8220;unusual&#8221;, then using <strong>sed</strong> to filter the results, to exclude extra stuff you don&#8217;t want. You could just enter &#8220;curl dict://dict.org/d:unusual&#8221; for the raw deal. Good on ya.</p>
<p>You can turn this into a script:</p>
<pre class="brush: php">
#! /bin/bash
# display definition of a word
#
curl --stderr /dev/null dict://dict.org/d:$1 | sed &#039;/^[.,0-9].*$/d&#039;
</pre>
<p>Save that in a file called &#8220;def&#8221; and run &#8220;chmod +x def&#8221; to make it executable. Then &#8220;def unusual&#8221; will return the same definition. You just created your own tool. You rock.</p>
<h3>Wordnet</h3>
<p>How about more power? Princeton has a project called <a href="http://wordnet.princeton.edu/">Wordnet</a>, which organizes nouns, verbs, adjectives and adverbs into set of &#8220;cognitive synonyms&#8221; and provides tools to use this data. With Wordnet, synonyms, antonyms and other lexical relations can be found for a given word.</p>
<p>To show a definition, (still using &#8220;unusual&#8221; as an example):</p>
<pre class="brush: php">
wn unusual -over
</pre>
<p>Here&#8217;s the output:</p>
<p><code>Overview of adj unusual</p>
<p>The adj unusual has 3 senses (first 3 from tagged texts)</p>
<p>1. (24) unusual -- (not usual or common or ordinary; "a scene of unusual beauty"; "a man of unusual ability"; "cruel and unusual punishment"; "an unusual meteorite")<br />
2. (1) strange, unusual -- (being definitely out of the ordinary and unexpected; slightly odd or even a bit weird; "a strange exaltation that was indefinable"; "a strange fantastical mind"; "what a strange sense of humor she has")<br />
3. (1) unusual -- (not commonly encountered; "two-career families are no longer unusual")<br />
</code></p>
<p>This uses the &#8220;-over&#8221; option. Some other options are:</p>
<table>
<tr>
<td>-synsa</td>
<td>adjective synonyms</td>
</tr>
<tr>
<td>-synsn</td>
<td>noun synonyms</td>
</tr>
<tr>
<td>-synsr</td>
<td>adverb synonyms</td>
</tr>
<tr>
<td>-antsa</td>
<td>adjective antonymns</td>
</tr>
<tr>
<td>-antsn</td>
<td>noun antonymns</td>
</tr>
<tr>
<td>-antsr</td>
<td>adverb antonymns</td>
</tr>
</table>
<p>Wordnet is extensive and there are many more options, run &#8220;man wn&#8221; for more.</p>
<h3>Crossword help</h3>
<p>This is simply a use of <strong>grep</strong> to pattern match words in a word list file.</p>
<p>Use a regular expression to find a word. In quotes, start your pattern with a &#8220;^&#8221; character and end with a &#8220;$&#8221; character. Use a period &#8220;.&#8221; for each unknown character.</p>
<pre class="brush: php">
grep &#039;^.a...f.c.n...$&#039; /usr/share/dict/words
</pre>
<p>Magnificent!</p>
<h3>Rhyming</h3>
<p>This uses the <a href="http://rhyme.sourceforge.net/">rhyme</a> project, which provides a rhyming dictionary for the command line.</p>
<p>To get, build and install <strong>rhyme</strong> on your system:</p>
<pre class="brush: php">
sudo aptitude -y install build-essential libgdbm-dev libreadline-dev
cd ~
DIR=&quot;src&quot; &amp;&amp; [ -d &quot;$DIR&quot; ] || mkdir &quot;$DIR&quot;
cd src
wget http://softlayer.dl.sourceforge.net/project/rhyme/rhyme/0.9/rhyme-0.9.tar.gz
tar -xzf rhyme-0.9.tar.gz
cd rhyme-0.9
make
sudo make install
</pre>
<p>Holy smokes, you just built software! There is no stopping you. To find a rhyme, using &#8220;house&#8221; as an example:</p>
<pre class="brush: php">
rhyme house
</pre>
<p>House rhymes! Lots of them.</p>
<h3>Anagrams</h3>
<p>Anagrams are pretty much pure word fun. It is fun to see what an anagram of your name is.</p>
<p>Print single-word anagrams of &#8220;andrew&#8221;:</p>
<pre class="brush: php">
an -l 1 andrew
</pre>
<p>Just call me the wander warden.</p>



share and enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F10%2Fbash-for-the-word-lover%2F&amp;partner=sociable" title="Print"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F10%2Fbash-for-the-word-lover%2F&amp;title=Bash%20for%20the%20word%20lover&amp;bodytext=It%27s%20a%20WYSIWYG%20world.%20After%20all%2C%20we%27re%20nearly%20in%20the%20future%2C%20which%20I%20define%20as%202019%2C%20the%20year%20Rick%20Deckard%20chases%20down%20replicants%20in%20the%20Blade%20Runner.%20Still%20no%20flying%20cars%2C%20which%20is%20disappointing.%20Even%20so%2C%20we%20have%20Steve%20Jobs%2C%20so%20the%20future%20coming%2C%20ri" title="Digg"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F10%2Fbash-for-the-word-lover%2F" title="Sphinn"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F10%2Fbash-for-the-word-lover%2F&amp;title=Bash%20for%20the%20word%20lover&amp;notes=It%27s%20a%20WYSIWYG%20world.%20After%20all%2C%20we%27re%20nearly%20in%20the%20future%2C%20which%20I%20define%20as%202019%2C%20the%20year%20Rick%20Deckard%20chases%20down%20replicants%20in%20the%20Blade%20Runner.%20Still%20no%20flying%20cars%2C%20which%20is%20disappointing.%20Even%20so%2C%20we%20have%20Steve%20Jobs%2C%20so%20the%20future%20coming%2C%20ri" title="del.icio.us"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F10%2Fbash-for-the-word-lover%2F&amp;t=Bash%20for%20the%20word%20lover" title="Facebook"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F10%2Fbash-for-the-word-lover%2F&amp;title=Bash%20for%20the%20word%20lover" title="Mixx"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F10%2Fbash-for-the-word-lover%2F&amp;title=Bash%20for%20the%20word%20lover&amp;annotation=It%27s%20a%20WYSIWYG%20world.%20After%20all%2C%20we%27re%20nearly%20in%20the%20future%2C%20which%20I%20define%20as%202019%2C%20the%20year%20Rick%20Deckard%20chases%20down%20replicants%20in%20the%20Blade%20Runner.%20Still%20no%20flying%20cars%2C%20which%20is%20disappointing.%20Even%20so%2C%20we%20have%20Steve%20Jobs%2C%20so%20the%20future%20coming%2C%20ri" title="Google Bookmarks"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a  href="http://blogplay.com" title="Blogplay"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Bash%20for%20the%20word%20lover&amp;u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F10%2Fbash-for-the-word-lover%2F" title="Fark"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F10%2Fbash-for-the-word-lover%2F&amp;title=Bash%20for%20the%20word%20lover" title="Reddit"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=Bash%20for%20the%20word%20lover&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F10%2Fbash-for-the-word-lover%2F" title="Slashdot"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F10%2Fbash-for-the-word-lover%2F&amp;title=Bash%20for%20the%20word%20lover" title="StumbleUpon"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Bash%20for%20the%20word%20lover%20-%20http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F10%2Fbash-for-the-word-lover%2F" title="Twitter"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/>
<p><a href="http://feedads.g.doubleclick.net/~a/z_FgN-s9Wt7sLO_R85ydewnGqb8/0/da"><img src="http://feedads.g.doubleclick.net/~a/z_FgN-s9Wt7sLO_R85ydewnGqb8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/z_FgN-s9Wt7sLO_R85ydewnGqb8/1/da"><img src="http://feedads.g.doubleclick.net/~a/z_FgN-s9Wt7sLO_R85ydewnGqb8/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/andrewault/~4/Wq_Xez1LzRw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.andrewault.net/2010/06/10/bash-for-the-word-lover/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.andrewault.net/2010/06/10/bash-for-the-word-lover/</feedburner:origLink></item>
		<item>
		<title>Install Dropbox on Ubuntu Server</title>
		<link>http://feedproxy.google.com/~r/andrewault/~3/qMhywEM2wiA/</link>
		<comments>http://www.andrewault.net/2010/06/08/install-dropbox-on-ubuntu-server/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 21:31:38 +0000</pubDate>
		<dc:creator>Andrew Ault</dc:creator>
				<category><![CDATA[admin]]></category>
		<category><![CDATA[ubuntu server]]></category>
		<category><![CDATA[dropbox]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.andrewault.net/?p=602</guid>
		<description><![CDATA[<p>Dropbox is so useful! Wouldn&#8217;t it be great to have that same convenience and function for your user account on your server, just like you have on your workstation?</p>
<p>This has been tested on Ubuntu Lucid and Jaunty. This procedure will create a system with:</p>

Install a separate Dropbox client (daemon) for individual users
Each user has a separate [...]]]></description>
			<content:encoded><![CDATA[<p>Dropbox is so useful! Wouldn&#8217;t it be great to have that same convenience and function for your user account on your server, just like you have on your workstation?</p>
<p>This has been tested on Ubuntu Lucid and Jaunty. This procedure will create a system with:</p>
<ul>
<li>Install a separate Dropbox client (daemon) for individual users</li>
<li>Each user has a separate Dropbox account</li>
<li>All the daemons will be managed together with normal daemon controls</li>
</ul>
<p>This allows individuals to have their own Dropbox accounts, each with a separate process syncing their individual ~/Dropbox directory. With one command an admin can start or stop all the daemons at once.</p>
<h3>Install Prerequisites</h3>
<p>Later, we&#8217;ll need to read a sqlite3 database record, so install sqlite3.</p>
<pre class="brush: bash">
sudo aptitude -y install sqlite3
</pre>
<h3>Install Dropbox client for an individual user</h3>
<p>This step is repeated for each user that wants a Dropbox client. Start by setting up your own account, then repeat for each user. This is run with a user&#8217;s own account. The changes made all take place in their home directory.</p>
<p>First, determine whether you have 32-bit or 64-bit Ubuntu Server. You must install the correct version, either 32 or 64 bit or it will not work. The following command will tell you which is installed:</p>
<pre class="brush: bash">
uname -a | grep &#039;_64&#039; &gt;/dev/null &amp;&amp; echo &#039;A 64-bit OS is installed&#039;; uname -a | grep &#039;_64&#039; &gt;/dev/null || echo &#039;A 32-bit OS is installed&#039;
</pre>
<p>Run the correct installation, based on whether a 32-bit or 64-bit OS is installed.</p>
<p>32-bit installation:</p>
<pre class="brush: bash">
cd ~
wget -O dropbox.tar.gz http://www.dropbox.com/download/?plat=lnx.x86
tar -zxof dropbox.tar.gz
</pre>
<p><strong>or</strong></p>
<p>64-bit installation:</p>
<pre class="brush: bash">
cd ~
wget -O dropbox.tar.gz http://www.dropbox.com/download/?plat=lnx.x86_64
tar -zxof dropbox.tar.gz
</pre>
<p><strong>Link user&#8217;s Dropbox client to their Dropbox account:</strong></p>
<pre class="brush: bash">
wget http://dl.dropbox.com/u/6995/dbmakefakelib.py
python dbmakefakelib.py
</pre>
<p>The above will <strong>run for a little while without printing anything</strong>, then print “dropboxd ran for 15 seconds without quitting &#8211; success?”. <strong>When it does so, press control-c twice.</strong> Yes, it is unusual. What this does is populate a sqlite3 database with an ID from the Dropbox server. Next, we&#8217;ll extract that code and use it to link your Dropbox user account with this CLI Dropbox client instance.</p>
<p>Get the URL with:</p>
<pre class="brush: bash">
echo https://www.dropbox.com/cli_link?host_id=`echo &#039;.dump config&#039; | sqlite3 ~/.dropbox/dropbox.db | grep host_id | cut -d \&#039; -f 4 | python -c &#039;print raw_input().decode(&quot;base64&quot;)&#039; | grep &#039;^V&#039; | cut -b 2-`
</pre>
<p>Copy the URL that the above printed and paste it into a web browser. When you do so, Dropbox will register your client on the server with your Dropbox account.</p>
<p>At this point, Dropbox will not be quite working yet. The next steps will take care of that.</p>
<h3>Create Dropbox daemon control</h3>
<p>The next task is to create a system to start and stop the dropbox daemon for each user on the system that has Dropbox installed for his/her user account. The following daemon init script was lifted from: <a href="http://wiki.dropbox.com/TipsAndTricks/TextBasedLinuxInstall">http://wiki.dropbox.com/TipsAndTricks/TextBasedLinuxInstall</a>.</p>
<p>Of course, this is for the use of the system admin. This creates a normal daemon init start/stop script and installs it so the Dropbox daemons are started when the system boots. The admin can also use this to control the Dropbox daemons manually.
<pre class="brush: bash">
sudo vi /etc/init.d/dropbox
</pre>
<p>Paste in the following code. Then, modify line 3, replacing &#8220;user1 user2&#8243; with your username. For future reference, additional user&#8217;s Dropbox daemons can be controlled with this one script &#8211; add additional username separated with spaces.</p>
<pre class="brush: bash">
# dropbox service
# separate usernames in the following line with spaces.
DROPBOX_USERS=&quot;user1 user2&quot;

DAEMON=.dropbox-dist/dropbox

start() {
    echo &quot;Starting dropbox...&quot;
    for dbuser in $DROPBOX_USERS; do
        HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
        if [ -x $HOMEDIR/$DAEMON ]; then
            HOME=&quot;$HOMEDIR&quot; start-stop-daemon -b -o -c $dbuser -S -u $dbuser -x $HOMEDIR/$DAEMON
        fi
    done
}

stop() {
    echo &quot;Stopping dropbox...&quot;
    for dbuser in $DROPBOX_USERS; do
        HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
        if [ -x $HOMEDIR/$DAEMON ]; then
            start-stop-daemon -o -c $dbuser -K -u $dbuser -x $HOMEDIR/$DAEMON
        fi
    done
}

status() {
    for dbuser in $DROPBOX_USERS; do
        dbpid=`pgrep -u $dbuser dropbox`
        if [ -z $dbpid ] ; then
            echo &quot;dropboxd for USER $dbuser: not running.&quot;
        else
            echo &quot;dropboxd for USER $dbuser: running (pid $dbpid)&quot;
        fi
    done
}

case &quot;$1&quot; in
  start)
    start
    ;;

  stop)
    stop
    ;;

  restart|reload|force-reload)
    stop
    start
    ;;

  status)
    status
    ;;

  *)
    echo &quot;Usage: /etc/init.d/dropbox {start|stop|reload|force-reload|restart|status}&quot;
    exit 1

esac

exit 0
</pre>
<p>Make the init script executable and restart the daemon:</p>
<pre class="brush: bash">
sudo chmod +x /etc/init.d/dropbox
sudo /etc/init.d/dropbox restart
</pre>
<p>When you restart the daemon, it will be running correctly linked to your Dropbox account. It will create a Dropbox directory in your home directory and will start to populate it with files you have on Dropbox.</p>
<p>Have the daemon(s) run automatically at boot time:</p>
<pre class="brush: bash">
sudo update-rc.d dropbox defaults
</pre>
<p>The above correctly copies links as needed so the daemon(s) start when the server boots.</p>
<h3>Managing the Daemons</h3>
<p>A separate daemon will be run for each user that has the Dropbox client installed &#8211; with only one command. This makes it easy for individual users to have separate Dropbox accounts, each syncing to ~/Dropbox for their user account. Here are the commands to manage these daemons:</p>
<p><strong>Start</strong> Dropbox services for all users:</p>
<pre class="brush: bash">
sudo /etc/init.d/dropbox start
</pre>
<p><strong>Stop</strong> Dropbox services for all users:</p>
<pre class="brush: bash">
sudo /etc/init.d/dropbox stop
</pre>
<p><strong>Restart</strong> Dropbox services for all users:</p>
<pre class="brush: bash">
sudo /etc/init.d/dropbox restart
</pre>
<p>Get <strong>service status</strong> for each user Dropbox service:</p>
<pre class="brush: bash">
sudo /etc/init.d/dropbox status
</pre>



share and enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F08%2Finstall-dropbox-on-ubuntu-server%2F&amp;partner=sociable" title="Print"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F08%2Finstall-dropbox-on-ubuntu-server%2F&amp;title=Install%20Dropbox%20on%20Ubuntu%20Server&amp;bodytext=Dropbox%20is%20so%20useful%21%20Wouldn%27t%20it%20be%20great%20to%20have%20that%20same%20convenience%20and%20function%20for%20your%20user%20account%20on%20your%20server%2C%20just%20like%20you%20have%20on%20your%20workstation%3F%0D%0A%0D%0AThis%20has%20been%20tested%20on%20Ubuntu%20Lucid%20and%20Jaunty.%20This%20procedure%20will%20create%20a%20syste" title="Digg"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F08%2Finstall-dropbox-on-ubuntu-server%2F" title="Sphinn"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F08%2Finstall-dropbox-on-ubuntu-server%2F&amp;title=Install%20Dropbox%20on%20Ubuntu%20Server&amp;notes=Dropbox%20is%20so%20useful%21%20Wouldn%27t%20it%20be%20great%20to%20have%20that%20same%20convenience%20and%20function%20for%20your%20user%20account%20on%20your%20server%2C%20just%20like%20you%20have%20on%20your%20workstation%3F%0D%0A%0D%0AThis%20has%20been%20tested%20on%20Ubuntu%20Lucid%20and%20Jaunty.%20This%20procedure%20will%20create%20a%20syste" title="del.icio.us"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F08%2Finstall-dropbox-on-ubuntu-server%2F&amp;t=Install%20Dropbox%20on%20Ubuntu%20Server" title="Facebook"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F08%2Finstall-dropbox-on-ubuntu-server%2F&amp;title=Install%20Dropbox%20on%20Ubuntu%20Server" title="Mixx"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F08%2Finstall-dropbox-on-ubuntu-server%2F&amp;title=Install%20Dropbox%20on%20Ubuntu%20Server&amp;annotation=Dropbox%20is%20so%20useful%21%20Wouldn%27t%20it%20be%20great%20to%20have%20that%20same%20convenience%20and%20function%20for%20your%20user%20account%20on%20your%20server%2C%20just%20like%20you%20have%20on%20your%20workstation%3F%0D%0A%0D%0AThis%20has%20been%20tested%20on%20Ubuntu%20Lucid%20and%20Jaunty.%20This%20procedure%20will%20create%20a%20syste" title="Google Bookmarks"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a  href="http://blogplay.com" title="Blogplay"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Install%20Dropbox%20on%20Ubuntu%20Server&amp;u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F08%2Finstall-dropbox-on-ubuntu-server%2F" title="Fark"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F08%2Finstall-dropbox-on-ubuntu-server%2F&amp;title=Install%20Dropbox%20on%20Ubuntu%20Server" title="Reddit"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=Install%20Dropbox%20on%20Ubuntu%20Server&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F08%2Finstall-dropbox-on-ubuntu-server%2F" title="Slashdot"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F08%2Finstall-dropbox-on-ubuntu-server%2F&amp;title=Install%20Dropbox%20on%20Ubuntu%20Server" title="StumbleUpon"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Install%20Dropbox%20on%20Ubuntu%20Server%20-%20http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F08%2Finstall-dropbox-on-ubuntu-server%2F" title="Twitter"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/>
<p><a href="http://feedads.g.doubleclick.net/~a/E1SuSV66XvnMC3Fg19E_yNPzy6s/0/da"><img src="http://feedads.g.doubleclick.net/~a/E1SuSV66XvnMC3Fg19E_yNPzy6s/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/E1SuSV66XvnMC3Fg19E_yNPzy6s/1/da"><img src="http://feedads.g.doubleclick.net/~a/E1SuSV66XvnMC3Fg19E_yNPzy6s/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/andrewault/~4/qMhywEM2wiA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.andrewault.net/2010/06/08/install-dropbox-on-ubuntu-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.andrewault.net/2010/06/08/install-dropbox-on-ubuntu-server/</feedburner:origLink></item>
		<item>
		<title>Script to create a Kohana instance</title>
		<link>http://feedproxy.google.com/~r/andrewault/~3/YuLDW3UQBo0/</link>
		<comments>http://www.andrewault.net/2010/06/07/script-to-create-a-kohana-instance/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 23:07:00 +0000</pubDate>
		<dc:creator>Andrew Ault</dc:creator>
				<category><![CDATA[admin]]></category>
		<category><![CDATA[kohana]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.andrewault.net/?p=597</guid>
		<description><![CDATA[<p>This is a copy of the script I use to create an instance of a Kohana project. It works on Ubuntu server (tested with Lucid). Adapt it to your own needs, of course.</p>

#! /bin/bash

CODE=&#34;upc&#34;
OWNER=&#34;myusername&#34;
GROUP=&#34;mygroupname&#34;
KOHANA_URL=&#34;http://dev.kohanaframework.org/attachments/download/1355/kohana-v2.3.4.zip&#34;
KOHANA_ZIP=&#34;kohana-v2.3.4.zip&#34;
SITESROOT=&#34;/usr/local/var/www&#34;
URL=&#34;www.mysite.com&#34;
# database.php parameters
DBUSER=&#34;mydbuser&#34;
DBPWD=&#34;mydbpasswd&#34;
DBHOST=&#34;localhost&#34;
DBDATABASE=&#34;mydbname&#34;

#
# make sure this is run as root
#
if [[ $UID -ne 0 ]]; then
    echo &#34;Not running as [...]]]></description>
			<content:encoded><![CDATA[<p>This is a copy of the script I use to create an instance of a Kohana project. It works on Ubuntu server (tested with Lucid). Adapt it to your own needs, of course.</p>
<pre class="brush: bash">
#! /bin/bash

CODE=&quot;upc&quot;
OWNER=&quot;myusername&quot;
GROUP=&quot;mygroupname&quot;
KOHANA_URL=&quot;http://dev.kohanaframework.org/attachments/download/1355/kohana-v2.3.4.zip&quot;
KOHANA_ZIP=&quot;kohana-v2.3.4.zip&quot;
SITESROOT=&quot;/usr/local/var/www&quot;
URL=&quot;www.mysite.com&quot;
# database.php parameters
DBUSER=&quot;mydbuser&quot;
DBPWD=&quot;mydbpasswd&quot;
DBHOST=&quot;localhost&quot;
DBDATABASE=&quot;mydbname&quot;

#
# make sure this is run as root
#
if [[ $UID -ne 0 ]]; then
    echo &quot;Not running as root&quot;
    exit
fi

if [ ! -d $SITESROOT ]; then
	echo &quot;$SITESROOT directory does not exist&quot;
	exit
fi

#
# change to the siteroot directory
#
cd $SITESROOT

if [ -d $URL ]; then
	echo &quot;$SITESROOT/$URL directory already exists&quot;
	exit
fi 

mkdir $URL
chown $OWNER:$GROUP $URL
cd $URL

#
# create kohana directory
#
echo creating kohana directory
mkdir kohana
chown $OWNER:$GROUP kohana
chmod g+ws kohana
wget &quot;$KOHANA_URL&quot;
unzip &quot;$KOHANA_ZIP&quot;
rm &quot;$KOHANA_ZIP&quot;
chown -R $OWNER:$GROUP kohana
chmod -R g+w kohana
chown $OWNER:www-data kohana/application/logs
rm kohana/example.htaccess
rm kohana/install.php
rm kohana/Kohana\ License.html
rm kohana/kohana.png

#
# create public directory
#
echo creating public directory
mkdir public
chown $OWNER:$GROUP public
chmod g+ws public
mv kohana/index.php public/
sed -i &quot;s\\kohana_application =.*$\\kohana_application = &#039;../kohana/application&#039;;\\&quot; public/index.php
sed -i &quot;s\\kohana_modules =.*$\\kohana_modules = &#039;../kohana/modules&#039;;\\&quot; public/index.php
sed -i &quot;s\\kohana_system =.*$\\kohana_system = &#039;../kohana/system&#039;;\\&quot; public/index.php
echo &quot;# turn on URL rewriting
RewriteEngine On
RewriteBase /
&quot; &gt; public/.htaccess

#
# create Apache logs directory
#
echo creating logs directory
mkdir logs
chown $OWNER:www-data logs
chmod g+ws logs
touch logs/error.log
touch logs/combined.log

#
# create utilties directory
#
echo creating utilties directory
mkdir utilities
chown $OWNER:$GROUP utilities
chmod g+ws utilities

#
# modify kohana/application/config/config.php
#
echo modifying kohana/application/config/config.php
sed -i &quot;s\\&#039;/kohana/&#039;\\&#039;$URL/&#039;\\&quot; kohana/application/config/config.php

#
# create kohana/application/config/database.php
#
echo creating kohana/application/config/database.php
cp kohana/system/config/database.php kohana/application/config/database.php
chown $OWNER:$GROUP kohana/application/config/database.php
chmod g+w kohana/application/config/database.php
sed -i &quot;s\\&#039;user&#039;.*$\\&#039;user&#039;     =&gt; &#039;$DBUSER&#039;,\\&quot; kohana/application/config/database.php
sed -i &quot;s\\&#039;pass&#039;.*$\\&#039;pass&#039;     =&gt; &#039;$DBPWD&#039;,\\&quot; kohana/application/config/database.php
sed -i &quot;s\\&#039;host&#039;.*$\\&#039;host&#039;     =&gt; &#039;$DBHOST&#039;,\\&quot; kohana/application/config/database.php
sed -i &quot;s\\&#039;database&#039;.*$\\&#039;database&#039; =&gt; &#039;$DBDATABASE&#039;,\\&quot; kohana/application/config/database.php

#
# create kohana/application/config/routes.php
#
echo creating kohana/application/config/routes.php
cp kohana/system/config/routes.php kohana/application/config/routes.php
chown $OWNER:$GROUP kohana/application/config/routes.php
chmod g+w kohana/application/config/routes.php
sed -i &quot;s\\&#039;welcome&#039;\\&#039;/index&#039;\\&quot; kohana/application/config/routes.php

#
# copy kohana/application/config/profiler.php
#
echo creating kohana/application/config/profiler.php
cp kohana/system/config/profiler.php kohana/application/config/profiler.php
chown $OWNER:$GROUP kohana/application/config/profiler.php
chmod g+w kohana/application/config/profiler.php

#
# create Apache virtual site
#
echo creating Apache virtual site file in /etc/apache2/sites-available
echo &quot;&lt;VirtualHost *:80&gt;
	ServerName $URL
	DocumentRoot $SITESROOT/$URL/public
	DirectoryIndex index.php
	LogLevel warn
	ErrorLog $SITESROOT/$URL/logs/error.log
	CustomLog $SITESROOT/$URL/logs/combined.log combined
&lt;/VirtualHost&gt;
&quot; &gt; /etc/apache2/sites-available/$URL

#
# finish up
#
echo &quot;enable site with: sudo a2ensite $URL&quot;
echo &quot;restart Apache with: sudo /etc/init.d/apache2 restart&quot;
</pre>



share and enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F07%2Fscript-to-create-a-kohana-instance%2F&amp;partner=sociable" title="Print"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F07%2Fscript-to-create-a-kohana-instance%2F&amp;title=Script%20to%20create%20a%20Kohana%20instance&amp;bodytext=This%20is%20a%20copy%20of%20the%20script%20I%20use%20to%20create%20an%20instance%20of%20a%20Kohana%20project.%20It%20works%20on%20Ubuntu%20server%20%28tested%20with%20Lucid%29.%20Adapt%20it%20to%20your%20own%20needs%2C%20of%20course.%0D%0A%0D%0A%5Bsourcecode%20language%3D%22bash%22%5D%0D%0A%23%21%20%2Fbin%2Fbash%0D%0A%20%0D%0ACODE%3D%22upc%22%0D%0AOWNER%3D%22myusername%22%0D%0AGROU" title="Digg"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F07%2Fscript-to-create-a-kohana-instance%2F" title="Sphinn"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F07%2Fscript-to-create-a-kohana-instance%2F&amp;title=Script%20to%20create%20a%20Kohana%20instance&amp;notes=This%20is%20a%20copy%20of%20the%20script%20I%20use%20to%20create%20an%20instance%20of%20a%20Kohana%20project.%20It%20works%20on%20Ubuntu%20server%20%28tested%20with%20Lucid%29.%20Adapt%20it%20to%20your%20own%20needs%2C%20of%20course.%0D%0A%0D%0A%5Bsourcecode%20language%3D%22bash%22%5D%0D%0A%23%21%20%2Fbin%2Fbash%0D%0A%20%0D%0ACODE%3D%22upc%22%0D%0AOWNER%3D%22myusername%22%0D%0AGROU" title="del.icio.us"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F07%2Fscript-to-create-a-kohana-instance%2F&amp;t=Script%20to%20create%20a%20Kohana%20instance" title="Facebook"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F07%2Fscript-to-create-a-kohana-instance%2F&amp;title=Script%20to%20create%20a%20Kohana%20instance" title="Mixx"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F07%2Fscript-to-create-a-kohana-instance%2F&amp;title=Script%20to%20create%20a%20Kohana%20instance&amp;annotation=This%20is%20a%20copy%20of%20the%20script%20I%20use%20to%20create%20an%20instance%20of%20a%20Kohana%20project.%20It%20works%20on%20Ubuntu%20server%20%28tested%20with%20Lucid%29.%20Adapt%20it%20to%20your%20own%20needs%2C%20of%20course.%0D%0A%0D%0A%5Bsourcecode%20language%3D%22bash%22%5D%0D%0A%23%21%20%2Fbin%2Fbash%0D%0A%20%0D%0ACODE%3D%22upc%22%0D%0AOWNER%3D%22myusername%22%0D%0AGROU" title="Google Bookmarks"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a  href="http://blogplay.com" title="Blogplay"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Script%20to%20create%20a%20Kohana%20instance&amp;u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F07%2Fscript-to-create-a-kohana-instance%2F" title="Fark"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F07%2Fscript-to-create-a-kohana-instance%2F&amp;title=Script%20to%20create%20a%20Kohana%20instance" title="Reddit"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=Script%20to%20create%20a%20Kohana%20instance&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F07%2Fscript-to-create-a-kohana-instance%2F" title="Slashdot"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F07%2Fscript-to-create-a-kohana-instance%2F&amp;title=Script%20to%20create%20a%20Kohana%20instance" title="StumbleUpon"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Script%20to%20create%20a%20Kohana%20instance%20-%20http%3A%2F%2Fwww.andrewault.net%2F2010%2F06%2F07%2Fscript-to-create-a-kohana-instance%2F" title="Twitter"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/>
<p><a href="http://feedads.g.doubleclick.net/~a/QrDgYrRRWzWo-qj9pvSvYnLWGIc/0/da"><img src="http://feedads.g.doubleclick.net/~a/QrDgYrRRWzWo-qj9pvSvYnLWGIc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/QrDgYrRRWzWo-qj9pvSvYnLWGIc/1/da"><img src="http://feedads.g.doubleclick.net/~a/QrDgYrRRWzWo-qj9pvSvYnLWGIc/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/andrewault/~4/YuLDW3UQBo0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.andrewault.net/2010/06/07/script-to-create-a-kohana-instance/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.andrewault.net/2010/06/07/script-to-create-a-kohana-instance/</feedburner:origLink></item>
		<item>
		<title>Creating a Perl Daemon in Ubuntu</title>
		<link>http://feedproxy.google.com/~r/andrewault/~3/4HmhhDq57FY/</link>
		<comments>http://www.andrewault.net/2010/05/27/creating-a-perl-daemon-in-ubuntu/#comments</comments>
		<pubDate>Thu, 27 May 2010 19:20:58 +0000</pubDate>
		<dc:creator>Andrew Ault</dc:creator>
				<category><![CDATA[admin]]></category>
		<category><![CDATA[daemon]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.andrewault.net/?p=557</guid>
		<description><![CDATA[You can create your own daemon in Perl to do whatever is needed. [...]]]></description>
			<content:encoded><![CDATA[<p>If you have a process that need to run in the background, creating a daemon is the key. Some examples of what your can do:</p>
<ul>
<li>Wait for video files to be dropped via FTP and then process them</li>
<li>Check for a recurring problem and report it to admin</li>
<li>Monitor system load and report to the admin at a certain threshold</li>
</ul>
<p>In this post we&#8217;ll take a look at how to create a Perl daemon script and how to get it to run as a daemon whenever the system is started. For the Perl script, a template will be created and for control of the daemon process, standard Debian facilities will be used.</p>
<p>What will be covered:</p>
<ul>
<li>Create the start/stop script in /etc/init.d</li>
<li>Create the Perl daemon script in /usr/bin/</li>
<li>Create the log file in /var/log/</li>
<li>Get the daemon to start automatically when the system boots</li>
<li>How to manage your daemon</li>
</ul>
<p>The <strong>start/stop script</strong> starts and stops the daemon. It is also used by the system to start your daemon when the system starts.</p>
<p>The Perl daemon script contains your custom Perl code to run in the background. It executes your code every x number of seconds.</p>
</p>
<h4>Create the Start/stop Script</h4>
<p>Happily, Debian and therefore Ubuntu, supplies a template that uses the Debian start-stop-daemon command to start and stop daemons. It is only necessary to copy this template to a new file of the correct name and modify it for the purpose.</p>
<p>These scripts reside in the /etc/init.d/ directory. The script you create will have the exact same filename as the Perl daemon script you will create and the name cannot have a file extension &#8211; just the bare name.</p>
<p><p>Substitute your daemon&#8217;s name for &#8220;mydaemon&#8221; in the examples.</p>
<pre class="brush: bash">
sudo cp /etc/init.d/skeleton /etc/init.d/mydaemon
sudo chmod +x /etc/init.d/mydaemon
</pre>
<pre class="brush: bash">
sudo vi /etc/init.d/mydaemon
</pre>
<p>Make changes to your start/stop script. Locate the header in the script:</p>
<pre class="brush: bash">
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC=&quot;Description of the service&quot;
NAME=daemonexecutablename
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS=&quot;--options args&quot;
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
</pre>
<li>Change the content of DESC to a meaningful description of your daemon.</li>
<li>Change the content for NAME to the exact name of your daemon.</li>
<h4>Create the Perl Daemon Script</h4>
<p>Use the Perl Daemon Script Template located at the end of this post. In the following, the script template is copied to /usr/bin/where executables specific to this system are located. Actually, you would copy the template to your home directory, make the changes and then copy the daemon script to /usr/bin/.</p>
<pre class="brush: bash">
sudo cp daemon_template.pl /usr/bin/mydaemon
sudo vi /usr/bin/mydaemon
sudo chmod +x /usr/bin/mydaemon
</pre>
<p>The script template is commented with the changes that are needed. In particular, change the value of <strong>$daemonName</strong> to the exact name of your new daemon. Ten, add your custom code where <strong># do something</strong> appears.</p>
<h3>Prerequisites</h3>
<p>The script uses File::Pid and POSIX from CPAN, so you&#8217;ll need to install that module:</p>
<pre class="brush: bash">
sudo aptitude install cpan
sudo cpan POSIX
sudo cpan File::Pid
</pre>
<h4>Create the Log File</h4>
<p>We&#8217;ll create the log file so it has the correct ownership and permissions. The log fie has the daemon name appended with &#8220;.log&#8221;. It is located in the /var/log/ directory.</p>
<pre class="brush: bash">
sudo touch /var/log/mydaemon.log
sudo chmod 640 /var/log/mydaemon.log
sudo chown root:adm /var/log/mydaemon.log
</pre>
<p>The permissions and ownership change allow adm group members to read the log, per convention. Add yourself to adm group to view logs.</p>
<h4>Run your Daemon</h4>
<p>As you have created a standard start/stop script for your daemon, you can start it the standard way:</p>
<pre class="brush: bash">
sudo /etc/init.d/mydaemon start
</pre>
<h4>Stop your Daemon</h4>
<p>Similarly, your daemon is easy to stop and restart:</p>
<pre class="brush: bash">
sudo /etc/init.d/mydaemon stop
</pre>
<pre class="brush: bash">
sudo /etc/init.d/mydaemon restart
</pre>
<h4> Automatically Start your Daemon</h4>
<p>This command tells your system to start your daemon automatically when the system starts:</p>
<pre class="brush: bash">
update-rc.d mydaemon defaults 99
</pre>
<p>To keep your daemon from starting, if needed:</p>
<pre class="brush: bash">
update-rc.d -f mydaemon remove
</pre>
<h3>Managing Daemons</h3>
<h4>List running daemons</h4>
<p>Well-behaved daemons generally create a PID file in /var/run/. List that directory and your have a fair list of running daemons.</p>
<pre class="brush: bash">
sudo ls /var/run/
</pre>
<h4>Get PID for a particular daemon</h4>
<p>If you know the name of a daemon and want to see if it is running and get its PID, use pgrep.</p>
<pre class="brush: bash">
pgrep mydaemon
</pre>
<p>Also useful is the ps command, which list processes.</p>
<pre class="brush: bash">
ps aux
</pre>
<p> The aux switch limits output to processes not associated with a terminal. </p>
<h4>Show programs running as daemons</h4>
<p>This line attempts to show programs that are running as daemons.</p>
<pre class="brush: bash">
which `ps aux | cut -c 66- | cut -d\  -f 1` | sort | uniq
</pre>
<h3>The Perl Daemon Script Template</h3>
<pre class="brush: perl">
#!/usr/bin/perl -w
#
# mydaemon.pl by Andrew Ault, www.andrewault.net
#
# Free software. Use this as you wish.
#
# Throughout this template &quot;mydaemon&quot; is used where the name of your daemon should
# be, replace occurrences of &quot;mydaemon&quot; with the name of your daemon.
#
# This name will also be the exact name to give this file (WITHOUT a &quot;.pl&quot; extension).
#
# It is also the exact name to give the start-stop script that will go into the
# /etc/init.d/ directory.
#
# It is also the name of the log file in the /var/log/ directory WITH a &quot;.log&quot;
# file extension.
#
# Replace &quot;# do something&quot; with your super useful code.
#
# Use &quot;# logEntry(&quot;log something&quot;);&quot; to log whatever your need to see in the log.
#
use strict;
use warnings;
use POSIX;
use File::Pid;

# make &quot;mydaemon.log&quot; file in /var/log/ with &quot;chown root:adm mydaemon&quot;

# TODO: change &quot;mydaemon&quot; to the exact name of your daemon.
my $daemonName    = &quot;mydaemon&quot;;
#
my $dieNow        = 0;                                     # used for &quot;infinte loop&quot; construct - allows daemon mode to gracefully exit
my $sleepMainLoop = 120;                                    # number of seconds to wait between &quot;do something&quot; execution after queue is clear
my $logging       = 1;                                     # 1= logging is on
my $logFilePath   = &quot;/var/log/&quot;;                           # log file path
my $logFile       = $logFilePath . $daemonName . &quot;.log&quot;;
my $pidFilePath   = &quot;/var/run/&quot;;                           # PID file path
my $pidFile       = $pidFilePath . $daemonName . &quot;.pid&quot;;

# daemonize
use POSIX qw(setsid);
chdir &#039;/&#039;;
umask 0;
open STDIN,  &#039;/dev/null&#039;   or die &quot;Can&#039;t read /dev/null: $!&quot;;
open STDOUT, &#039;&gt;&gt;/dev/null&#039; or die &quot;Can&#039;t write to /dev/null: $!&quot;;
open STDERR, &#039;&gt;&gt;/dev/null&#039; or die &quot;Can&#039;t write to /dev/null: $!&quot;;
defined( my $pid = fork ) or die &quot;Can&#039;t fork: $!&quot;;
exit if $pid;

# dissociate this process from the controlling terminal that started it and stop being part
# of whatever process group this process was a part of.
POSIX::setsid() or die &quot;Can&#039;t start a new session.&quot;;

# callback signal handler for signals.
$SIG{INT} = $SIG{TERM} = $SIG{HUP} = \&amp;signalHandler;
$SIG{PIPE} = &#039;ignore&#039;;

# create pid file in /var/run/
my $pidfile = File::Pid-&gt;new( { file =&gt; $pidFile, } );

$pidfile-&gt;write or die &quot;Can&#039;t write PID file, /dev/null: $!&quot;;

# turn on logging
if ($logging) {
	open LOG, &quot;&gt;&gt;$logFile&quot;;
	select((select(LOG), $|=1)[0]); # make the log file &quot;hot&quot; - turn off buffering
}

# &quot;infinite&quot; loop where some useful process happens
until ($dieNow) {
	sleep($sleepMainLoop);

	# TODO: put your custom code here!
	# do something

	# logEntry(&quot;log something&quot;); # use this to log whatever you need to
}

# add a line to the log file
sub logEntry {
	my ($logText) = @_;
	my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time);
	my $dateTime = sprintf &quot;%4d-%02d-%02d %02d:%02d:%02d&quot;, $year + 1900, $mon + 1, $mday, $hour, $min, $sec;
	if ($logging) {
		print LOG &quot;$dateTime $logText\n&quot;;
	}
}

# catch signals and end the program if one is caught.
sub signalHandler {
	$dieNow = 1;    # this will cause the &quot;infinite loop&quot; to exit
}

# do this stuff when exit() is called.
END {
	if ($logging) { close LOG }
	$pidfile-&gt;remove if defined $pidfile;
}
</pre>



share and enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F27%2Fcreating-a-perl-daemon-in-ubuntu%2F&amp;partner=sociable" title="Print"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F27%2Fcreating-a-perl-daemon-in-ubuntu%2F&amp;title=Creating%20a%20Perl%20Daemon%20in%20Ubuntu&amp;bodytext=You%20can%20create%20your%20own%20daemon%20in%20Perl%20to%20do%20whatever%20is%20needed." title="Digg"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F27%2Fcreating-a-perl-daemon-in-ubuntu%2F" title="Sphinn"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F27%2Fcreating-a-perl-daemon-in-ubuntu%2F&amp;title=Creating%20a%20Perl%20Daemon%20in%20Ubuntu&amp;notes=You%20can%20create%20your%20own%20daemon%20in%20Perl%20to%20do%20whatever%20is%20needed." title="del.icio.us"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F27%2Fcreating-a-perl-daemon-in-ubuntu%2F&amp;t=Creating%20a%20Perl%20Daemon%20in%20Ubuntu" title="Facebook"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F27%2Fcreating-a-perl-daemon-in-ubuntu%2F&amp;title=Creating%20a%20Perl%20Daemon%20in%20Ubuntu" title="Mixx"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F27%2Fcreating-a-perl-daemon-in-ubuntu%2F&amp;title=Creating%20a%20Perl%20Daemon%20in%20Ubuntu&amp;annotation=You%20can%20create%20your%20own%20daemon%20in%20Perl%20to%20do%20whatever%20is%20needed." title="Google Bookmarks"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a  href="http://blogplay.com" title="Blogplay"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Creating%20a%20Perl%20Daemon%20in%20Ubuntu&amp;u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F27%2Fcreating-a-perl-daemon-in-ubuntu%2F" title="Fark"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F27%2Fcreating-a-perl-daemon-in-ubuntu%2F&amp;title=Creating%20a%20Perl%20Daemon%20in%20Ubuntu" title="Reddit"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=Creating%20a%20Perl%20Daemon%20in%20Ubuntu&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F27%2Fcreating-a-perl-daemon-in-ubuntu%2F" title="Slashdot"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F27%2Fcreating-a-perl-daemon-in-ubuntu%2F&amp;title=Creating%20a%20Perl%20Daemon%20in%20Ubuntu" title="StumbleUpon"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Creating%20a%20Perl%20Daemon%20in%20Ubuntu%20-%20http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F27%2Fcreating-a-perl-daemon-in-ubuntu%2F" title="Twitter"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/>
<p><a href="http://feedads.g.doubleclick.net/~a/HwCcuQTXRc0Z4Sjhn6JKhT7JqQo/0/da"><img src="http://feedads.g.doubleclick.net/~a/HwCcuQTXRc0Z4Sjhn6JKhT7JqQo/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/HwCcuQTXRc0Z4Sjhn6JKhT7JqQo/1/da"><img src="http://feedads.g.doubleclick.net/~a/HwCcuQTXRc0Z4Sjhn6JKhT7JqQo/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/andrewault/~4/4HmhhDq57FY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.andrewault.net/2010/05/27/creating-a-perl-daemon-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://www.andrewault.net/2010/05/27/creating-a-perl-daemon-in-ubuntu/</feedburner:origLink></item>
		<item>
		<title>Upgrade Google Chrome from Beta to Stable on Ubuntu</title>
		<link>http://feedproxy.google.com/~r/andrewault/~3/OQ6NsGeygwY/</link>
		<comments>http://www.andrewault.net/2010/05/25/upgrading-google-chrome-from-beta-to-stable-on-ubuntu/#comments</comments>
		<pubDate>Tue, 25 May 2010 19:51:13 +0000</pubDate>
		<dc:creator>Andrew Ault</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.andrewault.net/?p=553</guid>
		<description><![CDATA[<p>If you have been running Google Chrome Beta on Ubuntu, you can now upgrade to stable! Mmm, stable, just like the cool kids.</p>
<p>Open a Terminal and type in the following commands:</p>

sudo aptitude remove google-chrome-beta
sudo aptitude install google-chrome-stable

<p>Your settings will be preserved.</p>



share [...]]]></description>
			<content:encoded><![CDATA[<p>If you have been running Google Chrome Beta on Ubuntu, you can now upgrade to stable! Mmm, stable, just like the cool kids.</p>
<p>Open a Terminal and type in the following commands:</p>
<pre class="brush: php">
sudo aptitude remove google-chrome-beta
sudo aptitude install google-chrome-stable
</pre>
<p>Your settings will be preserved.</p>



share and enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fupgrading-google-chrome-from-beta-to-stable-on-ubuntu%2F&amp;partner=sociable" title="Print"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fupgrading-google-chrome-from-beta-to-stable-on-ubuntu%2F&amp;title=Upgrade%20Google%20Chrome%20from%20Beta%20to%20Stable%20on%20Ubuntu&amp;bodytext=If%20you%20have%20been%20running%20Google%20Chrome%20Beta%20on%20Ubuntu%2C%20you%20can%20now%20upgrade%20to%20stable%21%20Mmm%2C%20stable%2C%20just%20like%20the%20cool%20kids.%0D%0A%0D%0AOpen%20a%20Terminal%20and%20type%20in%20the%20following%20commands%3A%0D%0A%0D%0A%5Bsourcecode%5D%0D%0Asudo%20aptitude%20remove%20google-chrome-beta%0D%0Asudo%20aptitude" title="Digg"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fupgrading-google-chrome-from-beta-to-stable-on-ubuntu%2F" title="Sphinn"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fupgrading-google-chrome-from-beta-to-stable-on-ubuntu%2F&amp;title=Upgrade%20Google%20Chrome%20from%20Beta%20to%20Stable%20on%20Ubuntu&amp;notes=If%20you%20have%20been%20running%20Google%20Chrome%20Beta%20on%20Ubuntu%2C%20you%20can%20now%20upgrade%20to%20stable%21%20Mmm%2C%20stable%2C%20just%20like%20the%20cool%20kids.%0D%0A%0D%0AOpen%20a%20Terminal%20and%20type%20in%20the%20following%20commands%3A%0D%0A%0D%0A%5Bsourcecode%5D%0D%0Asudo%20aptitude%20remove%20google-chrome-beta%0D%0Asudo%20aptitude" title="del.icio.us"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fupgrading-google-chrome-from-beta-to-stable-on-ubuntu%2F&amp;t=Upgrade%20Google%20Chrome%20from%20Beta%20to%20Stable%20on%20Ubuntu" title="Facebook"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fupgrading-google-chrome-from-beta-to-stable-on-ubuntu%2F&amp;title=Upgrade%20Google%20Chrome%20from%20Beta%20to%20Stable%20on%20Ubuntu" title="Mixx"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fupgrading-google-chrome-from-beta-to-stable-on-ubuntu%2F&amp;title=Upgrade%20Google%20Chrome%20from%20Beta%20to%20Stable%20on%20Ubuntu&amp;annotation=If%20you%20have%20been%20running%20Google%20Chrome%20Beta%20on%20Ubuntu%2C%20you%20can%20now%20upgrade%20to%20stable%21%20Mmm%2C%20stable%2C%20just%20like%20the%20cool%20kids.%0D%0A%0D%0AOpen%20a%20Terminal%20and%20type%20in%20the%20following%20commands%3A%0D%0A%0D%0A%5Bsourcecode%5D%0D%0Asudo%20aptitude%20remove%20google-chrome-beta%0D%0Asudo%20aptitude" title="Google Bookmarks"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a  href="http://blogplay.com" title="Blogplay"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Upgrade%20Google%20Chrome%20from%20Beta%20to%20Stable%20on%20Ubuntu&amp;u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fupgrading-google-chrome-from-beta-to-stable-on-ubuntu%2F" title="Fark"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fupgrading-google-chrome-from-beta-to-stable-on-ubuntu%2F&amp;title=Upgrade%20Google%20Chrome%20from%20Beta%20to%20Stable%20on%20Ubuntu" title="Reddit"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=Upgrade%20Google%20Chrome%20from%20Beta%20to%20Stable%20on%20Ubuntu&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fupgrading-google-chrome-from-beta-to-stable-on-ubuntu%2F" title="Slashdot"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fupgrading-google-chrome-from-beta-to-stable-on-ubuntu%2F&amp;title=Upgrade%20Google%20Chrome%20from%20Beta%20to%20Stable%20on%20Ubuntu" title="StumbleUpon"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Upgrade%20Google%20Chrome%20from%20Beta%20to%20Stable%20on%20Ubuntu%20-%20http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fupgrading-google-chrome-from-beta-to-stable-on-ubuntu%2F" title="Twitter"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/>
<p><a href="http://feedads.g.doubleclick.net/~a/v9gXBjC1s66LVq3Xgqi0aVL15GU/0/da"><img src="http://feedads.g.doubleclick.net/~a/v9gXBjC1s66LVq3Xgqi0aVL15GU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/v9gXBjC1s66LVq3Xgqi0aVL15GU/1/da"><img src="http://feedads.g.doubleclick.net/~a/v9gXBjC1s66LVq3Xgqi0aVL15GU/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/andrewault/~4/OQ6NsGeygwY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.andrewault.net/2010/05/25/upgrading-google-chrome-from-beta-to-stable-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.andrewault.net/2010/05/25/upgrading-google-chrome-from-beta-to-stable-on-ubuntu/</feedburner:origLink></item>
		<item>
		<title>Passive Mode (PASV) FTP client on an Ubuntu server</title>
		<link>http://feedproxy.google.com/~r/andrewault/~3/kS6Tdximnkg/</link>
		<comments>http://www.andrewault.net/2010/05/25/passive-mode-pasv-ftp-client-on-an-ubuntu-server/#comments</comments>
		<pubDate>Tue, 25 May 2010 17:52:25 +0000</pubDate>
		<dc:creator>Andrew Ault</dc:creator>
				<category><![CDATA[ubuntu server]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.andrewault.net/?p=534</guid>
		<description><![CDATA[<p>If you need to communicate from your Ubuntu server to an FTP server that requires passive mode, there is a problem: your firewall likely blocks communication. Using an FTP client manually, you can probably connect with the server, but not list or transfer files!</p>
<p>The reasons for this are straightforward, your system is operating exactly as it [...]]]></description>
			<content:encoded><![CDATA[<p>If you need to communicate from your Ubuntu server to an FTP server that requires passive mode, there is a problem: your firewall likely blocks communication. Using an FTP client manually, you can probably connect with the server, but not list or transfer files!</p>
<p>The reasons for this are straightforward, your system is operating exactly as it is configured to. The explanation requires a little understanding of FTP and firewalls.</p>
<p>Most IP protocols use one port on the local machine and port on the server being connected to. FTP happens to use two ports instead of one. When negotiating a connection, the two computers negotiate which port to send data to. This brings us to an important difference between the two modes:</p>
<ul>
<li>In active mode FTP, the client sends the server a <strong>PORT</strong> command, which tells the server client which port to use for data. The <strong>client connects to the server</strong>.</li>
<li>In passive more, the client sends the server a <strong>PASV</strong> command that asks for a server port to use for data. The <strong>server connects with the client</strong>.</li>
</ul>
<p>The tricky bits concern this second port that is negotiated. This port is not a fixed number, it is a dynamically allocated port above 1023. The port number is encoded in a packet as two numbers that need to be multiplied together to get the port number. The firewalls involved need to be smart enough to recognize the FTP negotiation and extract this data from the data, open that specified port and keep it open during the FTP session.</p>
<p>In active mode, this tricky bit is handled by the server, but in passive mode, it is handled by the client&#8217;s firewall! Ah ha! So, you need to configure your firewall to be smart about address translation and FTP connections.</p>
<h3>Configuring the firewall</h3>
<p>You will need to activate a couple of kernel modules for iptables. These will turn on NAT (network address translation) for FTP and FTP connection tracking. As iptables/Netfilter is part of the kernel, we need to use modprobe to add these to the current session and also make changes to /etc/modules so the modules will load next time the server is rebooted.</p>
<p>First, use modprobe to use these two modules now:</p>
<pre class="brush: php">
sudo modprobe ip_nat_ftp
sudo modprobe ip_conntrack_ftp
</pre>
<p>Then, modify /etc/modules so the modules will load on next reboot:</p>
<pre class="brush: php">
sudo vi /etc/modules
</pre>
<p>Add these lines:</p>
<pre class="brush: php">
ip_nat_ftp
ip_conntrack_ftp
</pre>
<p>With these two modules, you should now be able to use passive mode from an FTP client on your Ubuntu server.</p>



share and enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fpassive-mode-pasv-ftp-client-on-an-ubuntu-server%2F&amp;partner=sociable" title="Print"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fpassive-mode-pasv-ftp-client-on-an-ubuntu-server%2F&amp;title=Passive%20Mode%20%28PASV%29%20FTP%20client%20on%20an%20Ubuntu%20server&amp;bodytext=If%20you%20need%20to%20communicate%20from%20your%20Ubuntu%20server%20to%20an%20FTP%20server%20that%20requires%20passive%20mode%2C%20there%20is%20a%20problem%3A%20your%20firewall%20likely%20blocks%20communication.%20Using%20an%20FTP%20client%20manually%2C%20you%20can%20probably%20connect%20with%20the%20server%2C%20but%20not%20list%20or%20tra" title="Digg"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fpassive-mode-pasv-ftp-client-on-an-ubuntu-server%2F" title="Sphinn"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fpassive-mode-pasv-ftp-client-on-an-ubuntu-server%2F&amp;title=Passive%20Mode%20%28PASV%29%20FTP%20client%20on%20an%20Ubuntu%20server&amp;notes=If%20you%20need%20to%20communicate%20from%20your%20Ubuntu%20server%20to%20an%20FTP%20server%20that%20requires%20passive%20mode%2C%20there%20is%20a%20problem%3A%20your%20firewall%20likely%20blocks%20communication.%20Using%20an%20FTP%20client%20manually%2C%20you%20can%20probably%20connect%20with%20the%20server%2C%20but%20not%20list%20or%20tra" title="del.icio.us"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fpassive-mode-pasv-ftp-client-on-an-ubuntu-server%2F&amp;t=Passive%20Mode%20%28PASV%29%20FTP%20client%20on%20an%20Ubuntu%20server" title="Facebook"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fpassive-mode-pasv-ftp-client-on-an-ubuntu-server%2F&amp;title=Passive%20Mode%20%28PASV%29%20FTP%20client%20on%20an%20Ubuntu%20server" title="Mixx"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fpassive-mode-pasv-ftp-client-on-an-ubuntu-server%2F&amp;title=Passive%20Mode%20%28PASV%29%20FTP%20client%20on%20an%20Ubuntu%20server&amp;annotation=If%20you%20need%20to%20communicate%20from%20your%20Ubuntu%20server%20to%20an%20FTP%20server%20that%20requires%20passive%20mode%2C%20there%20is%20a%20problem%3A%20your%20firewall%20likely%20blocks%20communication.%20Using%20an%20FTP%20client%20manually%2C%20you%20can%20probably%20connect%20with%20the%20server%2C%20but%20not%20list%20or%20tra" title="Google Bookmarks"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a  href="http://blogplay.com" title="Blogplay"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Passive%20Mode%20%28PASV%29%20FTP%20client%20on%20an%20Ubuntu%20server&amp;u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fpassive-mode-pasv-ftp-client-on-an-ubuntu-server%2F" title="Fark"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fpassive-mode-pasv-ftp-client-on-an-ubuntu-server%2F&amp;title=Passive%20Mode%20%28PASV%29%20FTP%20client%20on%20an%20Ubuntu%20server" title="Reddit"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=Passive%20Mode%20%28PASV%29%20FTP%20client%20on%20an%20Ubuntu%20server&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fpassive-mode-pasv-ftp-client-on-an-ubuntu-server%2F" title="Slashdot"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fpassive-mode-pasv-ftp-client-on-an-ubuntu-server%2F&amp;title=Passive%20Mode%20%28PASV%29%20FTP%20client%20on%20an%20Ubuntu%20server" title="StumbleUpon"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Passive%20Mode%20%28PASV%29%20FTP%20client%20on%20an%20Ubuntu%20server%20-%20http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F25%2Fpassive-mode-pasv-ftp-client-on-an-ubuntu-server%2F" title="Twitter"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/>
<p><a href="http://feedads.g.doubleclick.net/~a/4tiexM7p0C7KHvPcl7AM9N2X8yk/0/da"><img src="http://feedads.g.doubleclick.net/~a/4tiexM7p0C7KHvPcl7AM9N2X8yk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/4tiexM7p0C7KHvPcl7AM9N2X8yk/1/da"><img src="http://feedads.g.doubleclick.net/~a/4tiexM7p0C7KHvPcl7AM9N2X8yk/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/andrewault/~4/kS6Tdximnkg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.andrewault.net/2010/05/25/passive-mode-pasv-ftp-client-on-an-ubuntu-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.andrewault.net/2010/05/25/passive-mode-pasv-ftp-client-on-an-ubuntu-server/</feedburner:origLink></item>
		<item>
		<title>Securing an Ubuntu Server</title>
		<link>http://feedproxy.google.com/~r/andrewault/~3/neMFZfAHXdk/</link>
		<comments>http://www.andrewault.net/2010/05/17/securing-an-ubuntu-server/#comments</comments>
		<pubDate>Mon, 17 May 2010 21:51:41 +0000</pubDate>
		<dc:creator>Andrew Ault</dc:creator>
				<category><![CDATA[admin]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.andrewault.net/?p=444</guid>
		<description><![CDATA[<p>Security is relative. Will these steps make your server &#8220;secure&#8221;? Sort of. It will be more secure than it was before. And more secure than most servers. Your server will not be &#8220;low hanging fruit&#8221;. Security is an on-going process. It includes settings, practices and procedures. Make it your business to regularly read about security and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.andrewault.net/wp-content/uploads/2010/05/ubuntu_lock1.png"><img src="http://www.andrewault.net/wp-content/uploads/2010/05/ubuntu_lock1.png" alt="" title="ubuntu_lock" width="155" height="175" class="alignright size-full wp-image-531" /></a><strong>Security is relative.</strong> Will these steps make your server &#8220;secure&#8221;? Sort of. It will be more secure than it was before. And more secure than most servers. Your server will not be &#8220;low hanging fruit&#8221;. Security is an on-going process. It includes settings, practices and procedures. Make it your business to regularly read about security and to understand the concepts and our system.</p>
<p>I&#8217;ve tested what is presented here in Ubuntu Server 10.04 (Lucid). If you want to harden your new Ubuntu server, this is a good start.</p>
<p>Ubuntu server is well designed, regularly updated and relatively secure. The <a href='https://wiki.ubuntu.com/SecurityTeam' >Ubuntu Security Team</a> manifests an <a href='https://wiki.ubuntu.com/SecurityTeam/UpdateProcedures' >onging effort</a> to keep Ubuntu secure. Regular security updates are available and easy to implement.</p>
<ul>
<li>No open ports</li>
<li>Role-based administration</li>
<li>No X server</li>
<li>Security updates</li>
<li>Kernel and compiler hardening</li>
</ul>
<p>In this post, we are going to meet the security challenge in with multi-pronged effort that will include: system analysis, changing settings for additional hardening against attack, installing a firewall maintenance system, scanning for rootkits, and offering a regular maintenance regimen.</p>
<ul>
<li>Change settings for increased security</li>
<li>Implement UFW, the uncomplicated firewall</li>
<li>Use denyhosts to automatically blacklist attackers</li>
<li>Scan the system for vulnerabilities with Tiger</li>
<li>Detect attempted intrusions with psad</li>
<li>Install nmap and scan the system for open ports</li>
<li>Check the system for rootkits with chkrootkit</li>
<li>Monitor logs</li>
</ul>
<h3>Change settings for increased security</h3>
<p><strong>see also:</strong> <a href="https://help.ubuntu.com/community/StricterDefaults">https://help.ubuntu.com/community/StricterDefaults</a></p>
<h4>Secure shared memory</h4>
<p><strong>/dev/shm</strong> can be used in an attack against a running service, such as httpd. Modify <strong>/etc/fstab</strong> to make it more secure.</p>
<pre class="brush: php">
sudo vi /etc/fstab
</pre>
<p>Add this line:</p>
<pre class="brush: php">
tmpfs     /dev/shm     tmpfs     defaults,noexec,nosuid     0     0
</pre>
<h4>Disable root SSH login</h4>
<p>The root account is disabled by default in Ubuntu. If you installed Ubuntu on Slicehost or Linode, root is enabled. In any case, it is a good idea to disable root SSH access. Edit <strong>/etc/ssh/sshd_config</strong> and set <strong>PermitRootLogin</strong> to <strong>no</strong>.</p>
<pre class="brush: php">
sudo vi /etc/ssh/sshd_config
</pre>
<p>Change <strong>PermitRootLogin</strong> to <strong>no</strong>:</p>
<pre class="brush: php">
PermitRootLogin no
</pre>
<p>Of course, if you access your server via SSH, you should make sure you have sudo working for your user before disabling SSH root access.</p>
<h4>Only allow admin users to use su</h4>
<p>This helps prevent privilege escalation.</p>
<p>By default, Ubuntu does not have an admin group. Create an admin group:</p>
<pre class="brush: php">
sudo groupadd admin
</pre>
<p>Add yourself to the admin group:</p>
<pre class="brush: php">
sudo usermod -a -G admin andrew
</pre>
<p>Restrict access to /bin/su to admin group members:</p>
<pre class="brush: php">
sudo dpkg-statoverride --update --add root admin 4750 /bin/su
</pre>
<p>Check permissions for /bin/su with:</p>
<pre class="brush: php">
ls -lh /bin/su
</pre>
<p>&#8230;and see the following:</p>
<pre class="brush: php">
-rwsr-x--- 1 root admin 31K 2010-01-26 17:09 /bin/su
</pre>
<h4>Do not permit source routing of incoming packets</h4>
<p><strong>see also:</strong> <a href="http://www.cromwell-intl.com/security/security-stack-hardening.html">http://www.cromwell-intl.com/security/security-stack-hardening.html</a></p>
<pre class="brush: php">
sudo sysctl -w net.ipv4.conf.all.accept_source_route=0
sudo sysctl ­-w net.ipv4.conf.default.accept_source_route=0
</pre>
<h4>Don&#8217;t allow system users to access an FTP server</h4>
<p>This is only needed is ftpd is installed and running. <strong>Only if you&#8217;ve installed ftpd.</strong> However, it is Ok to do this anyway and it will remove a FAIL from the tiger report.</p>
<p>SFTP is probably better than FTP, if it is usable for your files transfer needs.</p>
<p><strong>see ftpusers manual:</strong> <a href="http://manpages.ubuntu.com/manpages/lucid/man5/ftpusers.5.html">http://manpages.ubuntu.com/manpages/lucid/man5/ftpusers.5.html</a></p>
<p>Edit /etc/ftpusers:</p>
<pre class="brush: php">
sudo vi /etc/ftpusers
</pre>
<p>Add system users to deny use of ftpd:</p>
<pre class="brush: php">
backup
bin
daemon
games
gnats
irc
libuuid
list
lp
mail
man
mysql
news
ntp
postfix
proxy
sshd
sync
sys
syslog
uucp
www-data
</pre>
<h3>UFW: basic firewall</h3>
<p><strong>previous post:</strong> <a href='http://www.andrewault.net/2010/04/15/ubuntu-ufw-uncomplicated-firewall-examples/' >Ubuntu UFW Uncomplicated Firewall Examples</a></p>
<p><strong>community documentation:</strong> <a href='https://help.ubuntu.com/community/UFW' >https://help.ubuntu.com/community/UFW</a></p>
<p><strong>server guide:</strong> <a href='https://help.ubuntu.com/8.04/serverguide/C/firewall.html' >https://help.ubuntu.com/10.04/serverguide/C/firewall.html</a></p>
<p><strong>ufw manual:</strong> <a href="http://manpages.ubuntu.com/manpages/lucid/en/man8/ufw.8.html">http://manpages.ubuntu.com/manpages/lucid/en/man8/ufw.8.html</a></p>
<p><strong>project wiki:</strong> <a href="https://wiki.ubuntu.com/UncomplicatedFirewall">https://wiki.ubuntu.com/UncomplicatedFirewall</a></p>
<p><strong>nice article:</strong> <a href="http://savvyadmin.com/ubuntus-ufw/">http://savvyadmin.com/ubuntus-ufw/</a></p>
<p>UFW (Uncomplicated Firewall) provides an easy to understand interface to control iptables (iptables conteol Netfilter, which is built into the kernel). Will just a few commands, your server can control access. Checking status is also easy.</p>
<p>UFW (uncomplicated firewall) is a simple interface used to configure iptables.</p>
<p><strong>Install and enable Uncomplicated Firewall:</strong></p>
<pre class="brush: php">
sudo aptitude install -y ufw
sudo ufw enable
</pre>
<p><strong>Display available UFW commands:</strong></p>
<pre class="brush: php">
sudo ufw show
</pre>
<p><strong>Display UFW configuration:</strong></p>
<pre class="brush: php">
sudo ufw status
</pre>
<p><strong>Allow SSH and HTTP access to the Apache server:</strong></p>
<pre class="brush: php">
sudo ufw allow ssh
sudo ufw allow http
</pre>
<p>In the above example, ports for OpenSSH and Apache were opened by service name (&#8220;ssh&#8221; and &#8220;http&#8221;). You can use a port number instead of the service name (like &#8220;80&#8243; instead of &#8220;http&#8221;).</p>
<p><strong>See services running and which names to use:</strong></p>
<p>The practice here is to open only ports that you use &#8211; ports that use a service that have a service running. To see a list of services that you have running for which you might want to open ports for:</p>
<pre class="brush: php">
sudo ufw app list
</pre>
<p>To see a list of services that UFW uses (like in the &#8220;sudo ufw allow ssh&#8221; example, above):</p>
<pre class="brush: php">
less /etc/services
</pre>
<h3>Denyhosts: avoid SSH attacks</h3>
<p><strong>project:</strong> <a href="http://denyhosts.sourceforge.net/">http://denyhosts.sourceforge.net/</a></p>
<p>Looking at /var/log/auth.log on servers that I manage shows a steady streams of attacks on SSH. I am countering these attacks in a number of ways, starting with <strong>denyhosts</strong>.</p>
<p><strong>Denyhosts</strong> periodically scans <strong>/var/log/auth.log</strong> for repeated failures to access the system via SSH. It then adds these offenders to <strong>/etc/hosts.deny</strong>. See the project page for details.</p>
<pre class="brush: php">
sudo aptitude -y install denyhosts
</pre>
<p>That does it &#8211; the rest is automatic. You can see the IP addresses added to /etc/hosts.deny with:</p>
<pre class="brush: php">
sudo less /etc/hosts.deny
</pre>
<h3> Tiger: security system scanner</h3>
<p><strong>project:</strong> <a href="http://www.nongnu.org/tiger/">http://www.nongnu.org/tiger/</a></p>
<p>Tiger creates an automated security audit by analyzing files and settings on the system and creating a report listing what has been analyzed and listing warning, alerts and failures.</p>
<p>The <strong>tiger</strong> command creates a report of potential security problems in <strong>/var/log/tiger</strong>. The use the <strong>tigexp</strong> command to look up the resulting codes generated for a detailed explanation and what to do to make the system more secure. The problems tiger considers most serious are marked with <strong>FAIL</strong>.</p>
<p>Install tiger:</p>
<pre class="brush: php">
sudo aptitude -y install tiger
</pre>
<p>Run tiger to create a report of security issues.</p>
<pre class="brush: php">
sudo tiger
</pre>
<p>Use <strong>less</strong> to view the <em>most recent</em> tiger report:</p>
<pre class="brush: php">
sudo -i
less /var/log/tiger/`ls -t1 /var/log/tiger | head -1`
exit
</pre>
<p>Use tigexp to list explanations for FAIL codes:</p>
<pre class="brush: php">
tigexp dev002f
</pre>
<p>Google is also helpful, naturally.</p>
<p>Ignore these:</p>
<pre class="brush: php">
--FAIL-- [dev002f] /dev/fuse has world permissions
--FAIL-- [logf005f] Log file /var/log/btmp permission should be 660
</pre>
<p>Changing permissions for these could cause problems.</p>
<h3>Detect attempted intrusions with psad</h3>
<p><strong>project:</strong> <a href="http://www.cipherdyne.org/psad/">http://www.cipherdyne.org/psad/</a></p>
<p>Psad is a collection of lightweight daemons that log attempted intrusions, in particular monitoring iptables.</p>
<p>Installation:</p>
<pre class="brush: php">
sudo aptitude -y install psad
</pre>
<p>The daemons will run automatically.</p>
<p>To check current status:</p>
<pre class="brush: php">
sudo psad -S
</pre>
<p>You can modify psad settings to e-mail the admin in the event of intrusion detection.</p>
<h3>Nmap: port scanning</h3>
<p><strong>project:</strong> <a href="http://nmap.org/">http://nmap.org/</a></p>
<p>This allows you to see which ports are open, verifying that UFW/iptables is working correctly.</p>
<p><strong>Installing nmap:</strong></p>
<pre class="brush: php">
sudo aptitude install -y nmap
</pre>
<p><strong>Port scanning:</strong></p>
<pre class="brush: php">
nmap -v -sT localhost
</pre>
<p><strong>SYN Scanning:</strong></p>
<pre class="brush: php">
sudo nmap -v -sS localhost
</pre>
<p><strong>scan type explanations:</strong> <a href="http://nmap.org/book/man-port-scanning-techniques.html">http://nmap.org/book/man-port-scanning-techniques.html</a></p>
<h3>Chkrootkit: check for rootkit presence</h3>
<p><strong>project:</strong> <a href="http://www.chkrootkit.org/">http://www.chkrootkit.org/</a></p>
<p>Chkrootkit scans the system for evidence that a <a href="http://en.wikipedia.org/wiki/Rootkit">rootkit</a> has been installed.</p>
<p>This is a confidence test to be used to test whether your system has been compromised. In a perfect world you would not need this&#8230;but in this world, it is good to run periodically.</p>
<p><strong>Installing chkrootkit:</strong></p>
<pre class="brush: php">
sudo aptitude install -y chkrootkit
</pre>
<p><strong>Running chkrootkit:</strong></p>
<pre class="brush: php">
sudo chkrootkit
</pre>
<h3>LogWatch</h3>
<p><strong>Ubuntu community documentation:</strong> <a href='https://help.ubuntu.com/community/Logwatch'>https://help.ubuntu.com/community/Logwatch</a></p>
<p>The most detailed and informative logs in the world are useless if no one looks at them. Logwatch winnows the deluge to a succinct report&#8230;which you will look at. Even so, familiarize yourself with your system&#8217;s logs and review them on a regular basis. A daily logwatch habit would be a good start.</p>
<p>Installation:</p>
<pre class="brush: php">
sudo aptitude -y install logwatch
</pre>
<p>Usage:</p>
<pre class="brush: php">
sudo logwatch | less
</pre>
<h3>Ongoing maintenance</h3>
<p>Your server is now more secure. Once a week, perform on-going maintenance.</p>
<p><strong>Updating software:</strong></p>
<pre class="brush: php">
sudo aptitude update
sudo aptitude safe-upgrade
</pre>
<p>The safe-upgrade action is preferred by me because it does not upgrade packages that rely on dependencies that have not been upgraded to required levels.</p>
<p><strong>see:</strong> <a href="http://wiki.debian.org/Aptitude">http://wiki.debian.org/Aptitude</a></p>
<p>Or, you could set-up automatic security updates, if you cannot do the weekly maintenance. This is not a perfect solution because an administrator is not monitoring what is being updated and testing after updates. <strong>see:</strong> <a href="https://help.ubuntu.com/10.04/serverguide/C/automatic-updates.html">https://help.ubuntu.com/10.04/serverguide/C/automatic-updates.html</a></p>
<p><strong>Check for attempted instrusions:</strong></p>
<pre class="brush: php">
sudo psad -S
</pre>
<p><strong>UPDATED: Analyze system with tiger.</strong> Because the tiger reports in /var/log/tiger/are owned by root, run these commands one at a time. (This solves a problem some people were having with permissions.)</p>
<pre class="brush: php">
sudo -i
tiger
grep FAIL /var/log/tiger/`ls -t1 /var/log/tiger | head -1`
exit
</pre>
<p>In the above, FAILs are pulled from the newest report file with <strong>grep</strong>. The <strong>ls</strong> clause in backticks gives grep the newest file in the directory. The <strong>sudo -i</strong> command allows you to run multiple commands as root, ending with <strong>exit</strong>.</p>
<p>Use <strong>tigexp</strong> to list explanations for FAIL codes:</p>
<pre class="brush: php">
tigexp dev002f
</pre>
<p><strong>Scan ports with nmap:</strong></p>
<pre class="brush: php">
sudo nmap -v -sS localhost
</pre>
<p><strong>Check for rootkits</strong></p>
<pre class="brush: php">
sudo chkrootkit
</pre>
<p><strong>Look at logs:</strong></p>
<pre class="brush: php">
sudo logwatch | less
</pre>
<p><strong>Keep up with trends</strong></p>
<p>visit: <a href="http://www.linuxsecurity.com/">http://www.linuxsecurity.com/</a></p>
<h3>Elsewhere</h3>
<p><a href="http://www.itsecurity.com/features/ubuntu-secure-install-resource/">http://www.itsecurity.com/features/ubuntu-secure-install-resource/</a></p>
<p><a href="http://www.cyberciti.biz/tips/linux-security.html">http://www.cyberciti.biz/tips/linux-security.html</a></p>



share and enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F17%2Fsecuring-an-ubuntu-server%2F&amp;partner=sociable" title="Print"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F17%2Fsecuring-an-ubuntu-server%2F&amp;title=Securing%20an%20Ubuntu%20Server&amp;bodytext=Security%20is%20relative.%20Will%20these%20steps%20make%20your%20server%20%22secure%22%3F%20Sort%20of.%20It%20will%20be%20more%20secure%20than%20it%20was%20before.%20And%20more%20secure%20than%20most%20servers.%20Your%20server%20will%20not%20be%20%22low%20hanging%20fruit%22.%20Security%20is%20an%20on-going%20process.%20It%20includes%20setting" title="Digg"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F17%2Fsecuring-an-ubuntu-server%2F" title="Sphinn"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F17%2Fsecuring-an-ubuntu-server%2F&amp;title=Securing%20an%20Ubuntu%20Server&amp;notes=Security%20is%20relative.%20Will%20these%20steps%20make%20your%20server%20%22secure%22%3F%20Sort%20of.%20It%20will%20be%20more%20secure%20than%20it%20was%20before.%20And%20more%20secure%20than%20most%20servers.%20Your%20server%20will%20not%20be%20%22low%20hanging%20fruit%22.%20Security%20is%20an%20on-going%20process.%20It%20includes%20setting" title="del.icio.us"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F17%2Fsecuring-an-ubuntu-server%2F&amp;t=Securing%20an%20Ubuntu%20Server" title="Facebook"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F17%2Fsecuring-an-ubuntu-server%2F&amp;title=Securing%20an%20Ubuntu%20Server" title="Mixx"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F17%2Fsecuring-an-ubuntu-server%2F&amp;title=Securing%20an%20Ubuntu%20Server&amp;annotation=Security%20is%20relative.%20Will%20these%20steps%20make%20your%20server%20%22secure%22%3F%20Sort%20of.%20It%20will%20be%20more%20secure%20than%20it%20was%20before.%20And%20more%20secure%20than%20most%20servers.%20Your%20server%20will%20not%20be%20%22low%20hanging%20fruit%22.%20Security%20is%20an%20on-going%20process.%20It%20includes%20setting" title="Google Bookmarks"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a  href="http://blogplay.com" title="Blogplay"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Securing%20an%20Ubuntu%20Server&amp;u=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F17%2Fsecuring-an-ubuntu-server%2F" title="Fark"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F17%2Fsecuring-an-ubuntu-server%2F&amp;title=Securing%20an%20Ubuntu%20Server" title="Reddit"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=Securing%20an%20Ubuntu%20Server&amp;url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F17%2Fsecuring-an-ubuntu-server%2F" title="Slashdot"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F17%2Fsecuring-an-ubuntu-server%2F&amp;title=Securing%20an%20Ubuntu%20Server" title="StumbleUpon"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Securing%20an%20Ubuntu%20Server%20-%20http%3A%2F%2Fwww.andrewault.net%2F2010%2F05%2F17%2Fsecuring-an-ubuntu-server%2F" title="Twitter"><img src="http://www.andrewault.net/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/>
<p><a href="http://feedads.g.doubleclick.net/~a/d2pBVtWYrQiJyo-QIPg_UWD50_U/0/da"><img src="http://feedads.g.doubleclick.net/~a/d2pBVtWYrQiJyo-QIPg_UWD50_U/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/d2pBVtWYrQiJyo-QIPg_UWD50_U/1/da"><img src="http://feedads.g.doubleclick.net/~a/d2pBVtWYrQiJyo-QIPg_UWD50_U/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/andrewault/~4/neMFZfAHXdk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.andrewault.net/2010/05/17/securing-an-ubuntu-server/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.andrewault.net/2010/05/17/securing-an-ubuntu-server/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.877 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-09-05 16:59:07 -->
