<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Chris JeanChris Jean &#187; Linux</title>
	<atom:link href="http://chrisjean.com/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://chrisjean.com</link>
	<description>Linux, WordPress, programming, anime, and other stuff</description>
	<lastBuildDate>Mon, 16 Jan 2012 15:22:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Updating Multiple Git Repositories Easily Using Bash for Loop</title>
		<link>http://chrisjean.com/2009/09/15/updating-multiple-git-repositories-easily-using-bash-for-loop/</link>
		<comments>http://chrisjean.com/2009/09/15/updating-multiple-git-repositories-easily-using-bash-for-loop/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 16:42:14 +0000</pubDate>
		<dc:creator>Chris Jean</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips 'n Tricks]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[Mastering The Command Line]]></category>

		<guid isPermaLink="false">http://gaarai.com/?p=1508</guid>
		<description><![CDATA[All of the WordPress themes that I work on for iThemes are managed as Git repositories. Recently, we moved past the 100 repositories mark. That&#8217;s a lot of repositories to manage, and unfortunately, too many of those repositories contain duplicated information. Later on, I might delve into how we use Git to manage our theme [...]]]></description>
			<content:encoded><![CDATA[<!-- filtered -->
<p>All of the <a href="http://wordpress.org/" target="_blank">WordPress</a> themes that I work on for <a href="http://ithemes.com/" target="_blank">iThemes</a> are managed as Git repositories. Recently, we moved past the 100 repositories mark. That&#8217;s a lot of repositories to manage, and unfortunately, too many of those repositories contain duplicated information.</p>
<p>Later on, I might delve into how we use Git to manage our theme repos. For today, however, I&#8217;d like to focus on how I quickly and easily pushed up changes to more than a dozen repos in a single, albeit long, Bash command.</p>
<p>I had finished making updates to 16 <a href="http://ithemes.com/purchase/flexx-theme-wordpress-blog-themes/" target="_blank">Flexx</a> repos, and I needed to push all of those changes up. Since I had multiple working repos in that folder, I was lucky that each of these repos began with the text &#8220;Flexx&#8221;. Also, since they are all part of the same series and need to keep the same version number, that simplified the tagging as all could be tagged as 2.5.0.</p>
<p>Given this information, I simply ran the following command from the directory that contained all the repository directories:</p>
<div class="code">for i in `ls|grep Flexx`; do echo &#8220;&#8212; Pushing $i&#8221;; cd $i; git commit -am &#8217;2.5.0&#8242; &amp;&amp; git push &amp;&amp; git tag 2.5.0 &amp;&amp; git push &#8211;tags; cd ..; echo &#8220;&#8212; Finished $i&#8221;; done</div>
<p>There&#8217;s a lot going on here, so I&#8217;ll break it up and explain what I&#8217;m doing.</p>
<p><span id="more-1508"></span></p>
<div class="code">for i in `ls|grep Flexx`</div>
<p>This is basically a compound command. Bash&#8217;s <code>for</code> command is being used to step through the results of <code>ls|grep Flexx</code>. Each result will be stored to the variable <code>i</code> which can be referred to with <code>$i</code>.</p>
<p>In other words, I&#8217;m going to loop through each directory that contains the text &#8220;Flexx&#8221; (technically, it isn&#8217;t limited to just directories, but I don&#8217;t have any files containing &#8220;Flexx&#8221;, so I&#8217;m safe). For each iteration of the loop, the variable <code>$i</code> will contain the name of the folder I&#8217;m interested in.</p>
<div class="code">do echo &#8220;&#8212; Pushing $i&#8221;</div>
<p>The most important bit here is <code>do</code>. <code>do</code> simply begins the functional part of the loop and could be followed by any command that I wanted to start the loop with.</p>
<p>The <code>echo</code> command isn&#8217;t technically necessary. I simply have it there so that I can better determine what output belongs to which repository.</p>
<div class="code">cd $i</div>
<p>This is a very important command. It changes the directory to the repository I wish to run commands on.</p>
<div class="code">git commit -am &#8217;2.5.0&#8242; &amp;&amp; git push &amp;&amp; git tag 2.5.0 &amp;&amp; git push &#8211;tags</div>
<p>This is the command that actually does what I want to do in each repo directory. This adds all the modified files, commits them with a message of &#8220;2.5.0&#8243;, pushes the changes to the remote repository, creates a new tag of 2.5.0, and pushes up the new tag.</p>
<p>I have all of these commands chained together with <code>&amp;&amp;</code> so that if one command fails, the other ones won&#8217;t run. This prevents tagging in the event that the repository couldn&#8217;t be committed or pushed.</p>
<div class="code">cd ..</div>
<p>It&#8217;s a small command but necessary. This switches back to the main directory that holds all the repos, thus returning us back to a state that the next loop iteration can work with.</p>
<div class="code">echo &#8220;&#8212; Finished $i&#8221;</div>
<p>As with the other <code>echo</code> command, this simply allows me to keep track of what is going on more easily.</p>
<div class="code">done</div>
<p>The <code>done</code> command finishes out the loop iteration.</p>
<p>I hope that by sharing this you can gain a bit of insight into how I work with repositories while also learning more about how you can do things with Bash.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrisjean.com/2009/09/15/updating-multiple-git-repositories-easily-using-bash-for-loop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change Default Application When Opening Files in Ubuntu</title>
		<link>http://chrisjean.com/2009/04/21/change-default-application-when-opening-files-in-ubuntu/</link>
		<comments>http://chrisjean.com/2009/04/21/change-default-application-when-opening-files-in-ubuntu/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 05:00:29 +0000</pubDate>
		<dc:creator>Chris Jean</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips 'n Tricks]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://gaarai.com/?p=1399</guid>
		<description><![CDATA[Now that I know how to do this, it seems so easy and straight-forward. To change the default application files of a specific type are opened with, do the following: Right-click a file that you wish to change the default application for and select Properties. Click the &#8220;Open With&#8221; tab. Select the desired application&#8217;s radio [...]]]></description>
			<content:encoded><![CDATA[<!-- filtered -->
<p>Now that I know how to do this, it seems so easy and straight-forward. To change the default application files of a specific type are opened with, do the following:</p>
<ol>
<li>Right-click a file that you wish to change the default application for and select Properties.</li>
<li>Click the &#8220;Open With&#8221; tab.</li>
<li>Select the desired application&#8217;s radio button.
<ul>
<li>Additional applications can be added if the one you want is not listed. Use the Add button to find the desired application.</li>
<li>You can also remove applications from the list by highlighting the application and clicking the Remove button.</li>
<li>Adding applications to or removing applications from this list changes which applications are available in the &#8220;Open With&#8221; option when you right-click a file.</li>
</ul>
</li>
<li>Click the Close button.</li>
</ol>
<p>Again, it seems so easy and straight-forward now. Go figure. <img src='http://chrisjean.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://chrisjean.com/2009/04/21/change-default-application-when-opening-files-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Gaarai is Back and the Jackalope is Jaunty</title>
		<link>http://chrisjean.com/2009/04/18/gaarai-is-back-and-the-jackalope-is-jaunty/</link>
		<comments>http://chrisjean.com/2009/04/18/gaarai-is-back-and-the-jackalope-is-jaunty/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 05:00:31 +0000</pubDate>
		<dc:creator>Chris Jean</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Random Ramblings]]></category>
		<category><![CDATA[Jaunty Jackalope]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://gaarai.com/?p=1404</guid>
		<description><![CDATA[It&#8217;s been a month since my last post. For all my regular readers, I&#8217;m very sorry for the absense. There&#8217;s a lot of intersting stuff going on right now. Fortunately, with so much going on, I shouldn&#8217;t have a lack of topics to talk about. To get the old post ball rolling again, how could [...]]]></description>
			<content:encoded><![CDATA[<!-- filtered -->
<p>It&#8217;s been a month since my last post. For all my regular readers, I&#8217;m very sorry for the absense.</p>
<p>There&#8217;s a lot of intersting stuff going on right now. Fortunately, with so much going on, I shouldn&#8217;t have a lack of topics to talk about.</p>
<p>To get the old post ball rolling again, how could I not start back up with Ubuntu 9.04?</p>
<p><span id="more-1404"></span></p>
<p>Ubuntu 9.04, Jaunty Jackalope, is scheduled to be released on April 23rd. Even though it has been a mere six months since Intrepid Ibex went to release, the Jackalope promises some good stuff:</p>
<ul>
<li><strong>GNOME 2.26</strong> -  This latest release of GNOME includes a number of features, such as: better multi-monitor support (I look forward to testing this out), a new tool to handle burning disks (Brasero), a plugin promising easier file sharing (even on Bluetooth connections), UPnP media playback support in the GNOME Media Player, new volume control that supports per-application volume control when using PulseAudio (I love this feature in Vista and am excited to get it in Ubuntu). This is just a few of the features that picqued my interest. For more details, see GNOME 2.26&#8242;s <a href="http://library.gnome.org/misc/release-notes/2.26/" target="_blank">release notes</a>.</li>
<li><strong>X.Org Server 1.6</strong> &#8211; This new version of the X server promises great improvements to the free drivers available for a large variety of cards, primarily for Intel and AMD graphics. The AMD deal is very exciting. It&#8217;s a big topic though, so I&#8217;m going to talk about it in more detail later.</li>
<li><strong>Linux Kernel 2.6.28</strong> &#8211; As with most kernel releases, a lot of things have changed. Some of the changes that I found interesting (and that I could understand the value of) are: stable implementation of the Ext4 file system and improved memory management for GPU memory via GEM (the foundation for improving Linux graphics in the future). For a full list of features, check out the breakdown at <a href="http://kernelnewbies.org/Linux_2_6_28" target="_blank">Kernel Newbies</a>.</li>
<li><a href="http://eucalyptus.cs.ucsb.edu/" target="_blank"><strong>Eucalyptus</strong></a> &#8211; Adds cloud computing capabilities to Ubuntu&#8217;s server offering. I&#8217;m excited to try this out.</li>
<li>Check out the <a href="http://www.ubuntu.com/getubuntu/releasenotes/904overview" target="_blank">release notes overview</a> for more information about the new features.</li>
</ul>
<p>As with most new software, there are some caveats to be alert of. I recommend reading the <a href="http://www.ubuntu.com/getubuntu/releasenotes/904" target="_blank">release notes</a> if you are upgrading. Pay specific attention to the removal of Ctrl+Alt+Backspace support by default and the change to update notifications.</p>
<p>I hope that you are looking forward to the release as much as I am. When the Jackalope goes golden and I have a chance to test it out, I&#8217;ll definitely post about my experiences here.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrisjean.com/2009/04/18/gaarai-is-back-and-the-jackalope-is-jaunty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing When Daily Cron Jobs Run in Ubuntu</title>
		<link>http://chrisjean.com/2009/03/18/changing-when-daily-cron-jobs-run-in-ubuntu/</link>
		<comments>http://chrisjean.com/2009/03/18/changing-when-daily-cron-jobs-run-in-ubuntu/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 20:35:52 +0000</pubDate>
		<dc:creator>Chris Jean</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips 'n Tricks]]></category>
		<category><![CDATA[Cron]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://gaarai.com/?p=1381</guid>
		<description><![CDATA[Linux has many great tools built in that help maintain the system without user intervention. One such tool is Cron. On my Ubuntu 8.10 system, there are many things that are set to run each day: locate database updates, misc cleanup utilities, automatic package updates, log rotations, etc. All of these are managed by the [...]]]></description>
			<content:encoded><![CDATA[<!-- filtered -->
<p>Linux has many great tools built in that help maintain the system without user intervention. One such tool is <a href="http://en.wikipedia.org/wiki/Cron" target="_blank">Cron</a>.</p>
<p>On my Ubuntu 8.10 system, there are many things that are set to run each day: locate database updates, misc cleanup utilities, automatic package updates, log rotations, etc. All of these are managed by the Cron system.</p>
<p>For a while, I needed to manually run the updatedb command to update the locate database, and I never thought about why. The problem is that my daily, weekly, and monthly Cron jobs never run. The reason for this is that these Cron jobs are scheduled to run very early in the morning, when my system is off. Thus, these job schedules never run.</p>
<p>The solution for this is easy. I simply need to change the times these run at to times when my system is on.</p>
<p><span id="more-1381"></span></p>
<p>Some of you may be unfamiliar with Cron and how to set up jobs for Cron to execute, so let&#8217;s look at my /etc/crontab file quickly to see what the problem is.</p>
<div class="code"># /etc/crontab: system-wide crontab<br />
# Unlike any other crontab you don&#8217;t have to run the `crontab&#8217;<br />
# command to install the new version when you edit this file<br />
# and files in /etc/cron.d. These files also have username fields,<br />
# that none of the other crontabs do.SHELL=/bin/sh<br />
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin</p>
<p># m   h  dom mon dow user  command<br />
17  *  *   *   *   root  cd / &amp;&amp; run-parts &#8211;report /etc/cron.hourly<br />
25  6  *   *   *   root  test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts &#8211;report /etc/cron.daily )<br />
47  6  *   *   7   root  test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts &#8211;report /etc/cron.weekly )<br />
52  6  1   *   *   root  test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts &#8211;report /etc/cron.monthly )</p></div>
<p>The four lines at the bottom are the parts of interest. This looks like a jumbled mess, but it&#8217;s easy to understand once you break it down section piece by piece. Each part is as follows:</p>
<ul>
<li>Minute the command is to be run at</li>
<li>Hour the command is to be run at</li>
<li>Day of the month the command is to be run at</li>
<li>Month the command is to be run at</li>
<li>Day of the week the command is to be run at</li>
<li>User to run the command as</li>
<li>The actual command to run</li>
</ul>
<p>Given this information and the fact that an asterisk (*) means all, the last line means: at 6:52am on the first day of each month, have the root user run &#8220;test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts &#8211;report /etc/cron.monthly )&#8221;.</p>
<p>So, the four lines at the bottom of my /etc/crontab file have my system run all the commands in /etc/cron.hourly every hour of every day at 17 minutes past the hour, all the commands in /etc/cron.daily every day at 6:25am, all the commands in /etc/cron.weekly on the 7th day of each week at 6:47am, and all the commands in /etc/cron.monthly on the first day of each month at 6:52am, respectively.</p>
<p>Since the specific Ubuntu machine that I am talking about is my office machine and I&#8217;m rarely in the office before 7am, these Cron jobs don&#8217;t get a chance to run like they normally should. It should be noted that they run at the specific times they do so that users who start to access the machines at regular school or office times will have a system that very recently ran these commands, providing fresh logs, a recently updated locate database, etc without bogging the system down as they begin to access it.</p>
<p>I want to change the time to something later but not so late that I don&#8217;t get to benefit from the commands until late in the day. The best time that meets these requirements for my use is changing 6am to 8am for each of the last three commands.</p>
<p>The following is my modified /etc/crontab file:</p>
<div class="code"># /etc/crontab: system-wide crontab<br />
# Unlike any other crontab you don&#8217;t have to run the `crontab&#8217;<br />
# command to install the new version when you edit this file<br />
# and files in /etc/cron.d. These files also have username fields,<br />
# that none of the other crontabs do.SHELL=/bin/sh<br />
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin</p>
<p># m   h  dom mon dow user  command<br />
17  *  *   *   *   root  cd / &amp;&amp; run-parts &#8211;report /etc/cron.hourly<br />
25  8  *   *   *   root  test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts &#8211;report /etc/cron.daily )<br />
47  8  *   *   7   root  test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts &#8211;report /etc/cron.weekly )<br />
52  8  1   *   *   root  test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts &#8211;report /etc/cron.monthly )</p></div>
<p>Notice thatall I had to do is change the last three lines&#8217; second number from a 6 to an 8. All I have to do now is save the file, close it, and wait until tomorrow for the commands to be run starting at 8:25am.</p>
<p>If you want to modify your /etc/crontab file, keep in mind that you will need root access to do this.</p>
<p>You can open the file in <a href="http://chrisjean.com/2009/02/27/using-vi-vim-as-a-command-line-editor/" target="_blank">Vi</a> using:</p>
<div class="code">sudo vi /etc/crontab</div>
<p>If you are more familiar with graphical rather than command line editors, you can open up the file for editing in Gedit with the following command:</p>
<div class="code">gksu gedit /etc/crontab</div>
<p>Now you can enjoy making use of Cron even if you don&#8217;t have your Ubuntu machine on 24/7.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrisjean.com/2009/03/18/changing-when-daily-cron-jobs-run-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>World of Goo</title>
		<link>http://chrisjean.com/2009/03/13/world-of-goo/</link>
		<comments>http://chrisjean.com/2009/03/13/world-of-goo/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 05:00:31 +0000</pubDate>
		<dc:creator>Chris Jean</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Random Ramblings]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[World of Goo]]></category>

		<guid isPermaLink="false">http://gaarai.com/?p=1363</guid>
		<description><![CDATA[There&#8217;s a very good chance that you have already heard of the game World of Goo. If not, check out this video to get a taste. This game has a number of great things going for it: It&#8217;s a heck of a lot of fun to play. The world if very unique and has a [...]]]></description>
			<content:encoded><![CDATA[<!-- filtered -->
<p>There&#8217;s a very good chance that you have already heard of the game <a href="http://www.2dboy.com/games.php" target="_blank">World of Goo</a>. If not, check out this video to get a taste.</p>
<p><object width="561" height="453" data="http://www.dailymotion.com/swf/x72eqm" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://www.dailymotion.com/swf/x72eqm" /><param name="allowfullscreen" value="true" /></object></p>
<p>This game has a number of great things going for it:</p>
<ol>
<li>It&#8217;s a heck of a lot of fun to play.</li>
<li>The world if very unique and has a fun feel to it.</li>
<li>The music really sets the mood for the different areas.</li>
<li>It supports Windows, Mac, and Linux.</li>
<li>It&#8217;s DRM free.</li>
</ol>
<p>These days, I find great favor in things that 1) have Linux support and 2) are DRM free. Since World of Goo looked like a ton of fun and had both of those, the $20 price tag was nothing. Frankly, the price is very small when you consider the many hours of fun that you can have with all the goo balls.</p>
<p>I ran World of Goo both on one of my Windows Vista machines and on my Ubuntu machine at home. It worked very well on both platforms. Even the Linux version was very smooth even though I&#8217;m running Compiz.</p>
<p>FYI: If you want to run this on Linux, you can get the software as a DEB or RPM package or as a tar.gz archive with all the application files. I recommend usingone of the package files. Since the packages are built for 32-bit, you will need to use <a href="http://2dboy.com/forum/index.php/topic,1432.0.html" target="_blank">these instructions</a> if you have a 64-bit distro.</p>
<p>I highly recommend World of Goo, but you don&#8217;t have to have blind trust in my opinion. You can <a href="http://www.2dboy.com/games.php" target="_blank">download the demo</a> and try it out for yourself.</p>
<p>You might be interested in their post about the <a href="http://2dboy.com/2009/02/12/world-of-goo-linux-version-is-ready/" target="_blank">release of the Linux version</a>. The day of the Linux release, sales were 40% higher than their previous highest-selling day. &#8220;There is a market for Linux games after all <img src='http://chrisjean.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ,&#8221; said one of the developers after updating the post.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrisjean.com/2009/03/13/world-of-goo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Good Video on the History of the Open Source Movement</title>
		<link>http://chrisjean.com/2009/03/12/a-good-video-on-the-history-of-the-open-source-movement/</link>
		<comments>http://chrisjean.com/2009/03/12/a-good-video-on-the-history-of-the-open-source-movement/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 05:00:27 +0000</pubDate>
		<dc:creator>Chris Jean</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Random Ramblings]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[FSF]]></category>
		<category><![CDATA[GNU]]></category>
		<category><![CDATA[GPL]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[Linus Torvalds]]></category>
		<category><![CDATA[Richard Stallman]]></category>

		<guid isPermaLink="false">http://gaarai.com/?p=1346</guid>
		<description><![CDATA[I recently watched the entirety of the Revolution OS documentary. While it definitely is not a video that can be enjoyed by most people, nor even most computer users, it is a very intersting watch for a number of reasons. Visiting the documentary&#8217;s site, you quickly gain a sense of what this documentary is aimed [...]]]></description>
			<content:encoded><![CDATA[<!-- filtered -->
<p>I recently watched the entirety of the <a href="http://video.google.com/videoplay?docid=7707585592627775409" target="_blank">Revolution OS</a> documentary. While it definitely is not a video that can be enjoyed by most people, nor even most computer users, it is a very intersting watch for a number of reasons.</p>
<p>Visiting the <a href="http://www.revolution-os.com/index.html" target="_blank">documentary&#8217;s site</a>, you quickly gain a sense of what this documentary is aimed to be: &#8220;&#8230; the inside story of the hackers who rebelled against the proprietary software model and Microsoft to create GNU/Linux and the Open Source movement.&#8221; However, that&#8217;s not what this video is about.</p>
<p>When I first started watching the documentary, I thought I would get this intimate insight into how people made calculated movements against the growing monopoly of Microsoft&#8217;s operating systems. In fact, this isn&#8217;t anything near what actually happened.</p>
<p><span id="more-1346"></span></p>
<p>Microsoft and its actions were not the focus of anyone involved in getting the ball rolling on the <a href="http://en.wikipedia.org/wiki/Open_source_movement" target="_blank">open source movement</a>. <a href="http://en.wikipedia.org/wiki/Richard_Stallman" target="_blank">Richard Stallman</a> was motivated to create the <a href="http://en.wikipedia.org/wiki/Free_Software_Foundation" target="_blank">Free Software Foundation</a> and started building <a href="http://en.wikipedia.org/wiki/GNU" target="_blank">GNU</a> not because of Microsoft, but because of the actions of administrators that wanted to control access to computer systems, by hardware vendors that didn&#8217;t release the source for their drivers, and by a myriad of other things. If Bill Gates and his company, Micro-Soft (as it was called at the time), was any consideration, it was merely another straw on the camel&#8217;s back.</p>
<p>There are many other surprises like this in the documentary, and it is why I highly recommend those that are interested watch it and pay attention. You will gain a good beginning understanding of the foundation and history of <a href="http://en.wikipedia.org/wiki/GNU" target="_blank">GNU</a>, <a href="http://en.wikipedia.org/wiki/GNU_General_Public_License" target="_blank">GPL</a>, <a href="http://en.wikipedia.org/wiki/Free_Software_Foundation" target="_blank">FSF</a>, Linus Torvalds and the <a href="http://en.wikipedia.org/wiki/Linux_kernel" target="_blank">Linux kernel</a>, how the Linux kernel created the opportunity for today&#8217;s <a href="http://en.wikipedia.org/wiki/Linux_distribution" target="_blank">Linux distros</a>, how the open source movement began, how the open source business model works, and much more.</p>
<p>The documentary may not be perfect. The creators may not have understood what they actually produced. And the material is actually quite dated by now. Just the same, it&#8217;s a very good watch, and I recommend that you check it out.</p>
<p><object width="549" height="426" data="http://video.google.com/googleplayer.swf?docid=7707585592627775409&amp;hl=en&amp;fs=true" type="application/x-shockwave-flash"><param name="id" value="VideoPlayback" /><param name="src" value="http://video.google.com/googleplayer.swf?docid=7707585592627775409&amp;hl=en&amp;fs=true" /><param name="allowfullscreen" value="true" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://chrisjean.com/2009/03/12/a-good-video-on-the-history-of-the-open-source-movement/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Updating Daylight Saving Time on Linux</title>
		<link>http://chrisjean.com/2009/03/10/updating-daylight-saving-time-on-linux/</link>
		<comments>http://chrisjean.com/2009/03/10/updating-daylight-saving-time-on-linux/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 05:00:52 +0000</pubDate>
		<dc:creator>Chris Jean</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips 'n Tricks]]></category>
		<category><![CDATA[Daylight Saving Time]]></category>
		<category><![CDATA[zoneinfo]]></category>

		<guid isPermaLink="false">http://gaarai.com/?p=1328</guid>
		<description><![CDATA[A few days ago, I blogged about changing the timezone on a Linux server. In the post, I mentioned how the zoneinfo files needed to be updated in 2007 due to congress expanding the number of days that Daylight Saving Time covers. However, I did not go in depth about how to update the zoneinfo [...]]]></description>
			<content:encoded><![CDATA[<!-- filtered -->
<p>A few days ago, I blogged about <a href="http://chrisjean.com/2009/03/03/change-timezone-in-centos/" target="_blank">changing the timezone on a Linux server</a>. In the post, I mentioned how the zoneinfo files needed to be updated in 2007 due to congress expanding the number of days that <a href="http://en.wikipedia.org/wiki/Daylight_saving_time" target="_blank">Daylight Saving Time</a> covers. However, I did not go in depth about how to update the zoneinfo files.</p>
<p>Since then, I&#8217;ve received many search queries from people looking for information about why their server did not properly update when the Daylight Saving Time change hit. For instance, I got queries of &#8220;is daylight savings default in centos&#8221;, &#8220;daylight savings time didn&#8217;t change centos&#8221;, &#8220;dst timezone change centos&#8221;, and many more. It&#8217;s clear that there are server administrators out there that are very confused about the Daylight Saving Time situation on their server.</p>
<p>Today, I hope to remedy that problem and give server administrators the information they need to update these zoneinfo files. I typically focus in on specific platforms, but today, I&#8217;ll try to cover as many distros as I can as well as provide a universal solution.</p>
<p><span id="more-1328"></span></p>
<h3>DST Update, Linux, and Your Server</h3>
<p>The United States Congress signed the Daylight Saving Time change into law in 2005. In this new law, Daylight Saving Time starts on the second Sunday in March and ends on the first Sunday in November. The change took effect in the US in 2007 and will be the standard until the US Congress modifies it again.</p>
<p>In 2006, new zoneinfo files for Linux were released that had the new calculations necessary to account for this change in US timezone information. Most systems should have been updated automatically, but if your system doesn&#8217;t do automatic updates, the update system is malfunctioning, or the updated information wasn&#8217;t made available for your system, you&#8217;re left with a server that has its time out of sync for many days out of the year.</p>
<h3>Checking for Old DST Calculations</h3>
<p>A good way to find out if your zoneinfo files are updated with the new calculations is to use the time zone dumper, zdump. For example, I&#8217;ll ask my local machine running Ubuntu when the pertinent DST time changes are in 2009:</p>
<div class="code">user:~$ <strong>zdump -v America/Chicago|grep 2009</strong><br />
Sun Mar  8 07:59:59 2009 UTC = Sun Mar  8 01:59:59 2009 CST<br />
Sun Mar  8 08:00:00 2009 UTC = Sun Mar  8 03:00:00 2009 CDT<br />
Sun Nov  1 06:59:59 2009 UTC = Sun Nov  1 01:59:59 2009 CDT<br />
Sun Nov  1 07:00:00 2009 UTC = Sun Nov  1 01:00:00 2009 CST</div>
<p><em>Note: I removed some of the output to make it fit.</em></p>
<p>It really doesn&#8217;t matter which timezone is used since all the US timezones will report the same changes. I simply used Central since it&#8217;s my timezone.</p>
<p>Notice how it shows that the CST to CDT switchover point is at 2am on March 8 and how the CDT to CST switchover point is at 2am on November. This is what we want to see as it indicates that my system is using the new DST calculations and not the old ones.</p>
<p>So, if your system does not respond with similar output and you are checking a US timezone that includes DST calculations, you need to update your zoneinfo files.</p>
<p>As an odd aside, it&#8217;s interesting to note that March 8th is the earliest possible second Sunday in March and November 1st is the earliest possible first Sunday in November. We get to see this interesting arrangement again in 2015, 2020, and 2026 (more years follow of course, but I won&#8217;t bore you with them). This has no importance to the topic; I simply like patterns.</p>
<h3>Updating zoneinfo Files the Easy Way</h3>
<p>Fortunately, upading your zoneinfo files should not be difficult if you are using a fairly modern distro that has a package manager. The tzdata package is available on all the distro repositories that I tested and is the package we want to install/update to fix up the zoneinfo files.</p>
<p><em>Note: In order to update zoneinfo files, you must have root access. If you do not have root access, contact your hosting provider or your sysadmin and provide them with a link to this topic with a request to update the files.</em></p>
<p>For each package management system, the same steps will be followed. First, install the tzdata package. If the package manager indicates that the tzdata package is already installed, update the package. If both of these methods fail, skip down to the next section to update the files manually.</p>
<p><em>Note: You need root access to run the following commands, either access a root shell or prefix the command with &#8216;sudo &#8216; in order to run the commands successfully.</em></p>
<h4>yum</h4>
<p><a href="http://fedoraproject.org/wiki/Tools/yum" target="_blank">yum</a> is the standard package manager used by most RPM-based distros, such as: CentOS, Fedora, and Red Hat Enterprise Linux (RHEL).</p>
<p>Install: <code><strong>yum install tzdata</strong></code></p>
<p>Update: <code><strong>yum update tzdata</strong></code></p>
<h4>APT</h4>
<p><a href="http://en.wikipedia.org/wiki/Advanced_Packaging_Tool" target="_blank">APT</a> is used by Debian and its derivitives, such as Ubuntu, Linux Mint, MEPIS, Damn Small Linux, and many others.</p>
<p>Install: <code><strong>apt-get install tzdata</strong></code></p>
<p>Update: <code><strong>apt-get update tzdata</strong></code></p>
<h3>Updating zoneinfo Files Manually</h3>
<p>If you were unable to install/update the tzdata package, were unable to find a tzdata package, or don&#8217;t have a functional package manager, you can still update your zoneinfo files. It will take a bit more work however.</p>
<p>The following commands will retrieve the new data, prepare it, and install it to the /usr/share/zoneinfo directory.</p>
<div class="code">user:~$ <strong>wget ftp://elsie.nci.nih.gov/pub/tzdata2009b.tar.gz</strong><br />
user:~$ <strong>tar -xvzf tzdata2009b.tar.gz</strong><br />
user:~$ <strong>zic -d zoneinfo northamerica</strong><br />
user:~$ <strong>cd zoneinfo</strong></div>
<p>We now need to access a root shell. If you can use sudo, you can also just add &#8220;sudo &#8221; to the beginning of the following command in order to temporarily gain root privileges.</p>
<div class="code">root:zoneinfo# <strong>cp -r * /usr/share/zoneinfo/</strong></div>
<p>If you are on an old system, you may get the following error:</p>
<div class="code">cp: cannot create regular file `/usr/share/zoneinfo/&#8217;: Is a directory</div>
<p>This means that your zoneinfo files are probably located at /usr/lib/zoneinfo. If this is the case, run the following command:</p>
<div class="code">root:zoneinfo# <strong>cp -r * /usr/lib/zoneinfo/</strong></div>
<p>Now it&#8217;s time to test the changes.</p>
<h3>Testing Changes</h3>
<p>Like before, confirm that the proper dates and times are found in your zoneinfo files for the 2009 DST changes:</p>
<div class="code">user:~$ <strong>zdump -v America/Chicago|grep 2009</strong><br />
Sun Mar  8 07:59:59 2009 UTC = Sun Mar  8 01:59:59 2009 CST<br />
Sun Mar  8 08:00:00 2009 UTC = Sun Mar  8 03:00:00 2009 CDT<br />
Sun Nov  1 06:59:59 2009 UTC = Sun Nov  1 01:59:59 2009 CDT<br />
Sun Nov  1 07:00:00 2009 UTC = Sun Nov  1 01:00:00 2009 CST</div>
<p><em>Note: I removed some of the output to make it fit.</em></p>
<p>If you don&#8217;t receive the appropriate output, please leave me a comment with the distro you are running and what steps you have tried.</p>
<p>Now we just need to check that the system has the correct time. Simply run &#8220;date&#8221; from the command line and verify that the correct date and time are reported. If the time is still incorrect, you need to update your /etc/localtime file. You can find instructions on how to do that <a href="http://chrisjean.com/2009/03/03/change-timezone-in-centos/" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrisjean.com/2009/03/10/updating-daylight-saving-time-on-linux/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Command Line History in Ubuntu Terminal</title>
		<link>http://chrisjean.com/2009/03/09/command-line-history-in-ubuntu-terminal/</link>
		<comments>http://chrisjean.com/2009/03/09/command-line-history-in-ubuntu-terminal/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 06:00:30 +0000</pubDate>
		<dc:creator>Chris Jean</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips 'n Tricks]]></category>
		<category><![CDATA[BASH]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[Mastering The Command Line]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://gaarai.com/?p=1304</guid>
		<description><![CDATA[I&#8217;ve had a lot of fun recently posting about how to do stuff on the command line in Linux. My focus is specifically for Ubuntu users, but the information and techniques can be used for any Linux distro. Since I&#8217;m probably going to end up with a lot of content under this topic, I&#8217;ve decided [...]]]></description>
			<content:encoded><![CDATA[<!-- filtered -->
<p>I&#8217;ve had a lot of fun recently posting about how to do stuff on the command line in Linux. My focus is specifically for Ubuntu users, but the information and techniques can be used for any Linux distro.</p>
<p>Since I&#8217;m probably going to end up with a lot of content under this topic, I&#8217;ve decided to create a dedicated tag: <a href="http://chrisjean.com/tag/mastering-the-command-line/">Mastering the Command Line</a>. I&#8217;ve gone through my older posts on this topic and tagged them as well. So, make sure to check out <a href="http://chrisjean.com/tag/mastering-the-command-line/" target="_blank">Mastering the Command Line</a> if you want to know how to become a command line power user.</p>
<p>Back to today&#8217;s topic. You&#8217;re starting to learn how to use the command line, but it&#8217;s annoying to always have to type in similar commands over and over. If only there were a way to pull up commands that you&#8217;ve already run to run again as is or to quickly modify. Today, I&#8217;m going to teach you how to do exactly this.</p>
<p><span id="more-1304"></span></p>
<h3>Introduction to BASH Command Line History</h3>
<p><a href="http://www.gnu.org/software/bash/" target="_blank">BASH</a> (Bourne Again SHell) is the default command line shell that is used in Ubuntu, and most other distros for that matter. The instructions that I give here are specific to BASH and may or may not work in other shells. Since most people don&#8217;t modify which shell they access through Terminal, I only point this out to inform those who have changed their shell that their experiences may differ depending on the shell used.</p>
<p>When you close a Terminal session, BASH writes all the commands you&#8217;ve run for that session to your ~/.bash_history file. When you load a new session, this file is read and those commands along with the new commands you execute for that session become your new command history.</p>
<p>It&#8217;s important to keep in mind that commands executed for a session are only written when you exit. If you have two sessions running concurrently, they cannot cross-reference the newly-executed commands run in the other session. Furthermore, if you force a Terminal session to quit, the command history will not be updated.</p>
<h3>Simple Command History Navigation</h3>
<p>The easy way to get started with your command history is to simply navigate with the up and down arrow keys. Using the up key, you can scroll through previous commands one command at a time. To scroll back down the list, you can use the down arrow key.</p>
<p>Once you&#8217;ve found the desired command, you can treat it as if you&#8217;ve typed that command in the command line. You can simply press Enter to execute the command again, or you can modify the command as needed before executing it.</p>
<p>This method is very good for quickly running commands that you have to execute repeatedly without many other commands between.</p>
<h3>Listing and Searching Command History</h3>
<p>BASH provides the history command that when executed with no options will list the entire command history. Each command will be preceeded with a number that represents that command&#8217;s command number. I&#8217;ll tell you how to use these numbers below.</p>
<p>You can also have the history command produce just the last certain number of commands by supplying a number. For example, if you want to see the previous ten commands, you can run the following:</p>
<div class="code">user:~$ <strong>history 10</strong><br />
510  which bash<br />
511  echo $$<br />
512  ps aux|grep 32115<br />
513  which sh<br />
514  history<br />
515  man history<br />
516  history|grep echo<br />
517  vi ~/.bash_history<br />
518  tail -10 ~/.bash_history<br />
519  history 10</div>
<p>Notice that the last command is the same as the command you ran to produce it. So, &#8220;history 1&#8243; will just show you &#8220;[command number] history 1&#8243;.</p>
<h4>Searching History</h4>
<p>If you remember that you ran a really cool command and can&#8217;t quite remember how you did it, combining history with <a href="http://chrisjean.com/2009/01/21/grep-why-i-love-linux/" target="_blank">grep</a> provides an easy way to find that command with just a piece of the command.</p>
<p>For example, let&#8217;s say that I ran a command that listed all the files that end in &#8220;.php&#8221; inside the ~/wordpress folder it then filters for just matches that contain the text &#8220;link&#8221; and then reverses the output. I was quite proud of that command, but I can&#8217;t remember how I did it. So, I search through my history.</p>
<p>Since I don&#8217;t think that I have the word &#8220;link&#8221; in many of my commands, I pick it as the target to search for and run the following:</p>
<div class="code">user:~$ <strong>history|grep link</strong><br />
412  find ~/wordpress -type f | grep \.php$ | grep link | sort -r</div>
<p>That&#8217;s what I was looking for. Now I can bask in the glory of my ingenious command and use it as the inspiration for other inspired words of command line magic.</p>
<h4>Running Previous Commands Again</h4>
<p>Searching through the history is great and all, but I&#8217;d rather not have to copy and paste found commands. I&#8217;d like to just run them immediately. BASH to the rescue again.</p>
<p>If you&#8217;d like to run the previous command again quickly, you can simply run &#8220;!!&#8221;. The first exclamation point tells BASH that you are running a previous commands. The second exclamation point tells BASH that it&#8217;s the last command that you&#8217;d like to run again. It&#8217;s a double exclamation point simply to make it quick and easy to type in.</p>
<p>I&#8217;ve already shown you how to look through your history and find a specific command in your history complete with the command number. Now is the time to make use of that number. If I wanted to execute command number 510 (which bash) again using the history, I can simply run the following:</p>
<div class="code">user:~$ <strong>!510</strong><br />
which bash<br />
/bin/bash</div>
<p>Notice how running the command again first lists the actual command and then the output.</p>
<p>BASH substitutes the !number command with the actual command from the history. This allows you to supply additional parameters to the command. The following is a silly example, but it gets the point across.</p>
<div class="code">user:~$ <strong>!510 dash</strong><br />
which bash dash<br />
/bin/bash<br />
/bin/dash</div>
<p>Notice how the command now has the additional parameter added to the original command. As expected, the full command is listed followed by the command output.</p>
<p>You can also do the standard manipulations such as piping the output, &#8220;!412 | grep wp-admin&#8221;, or redirecting the output, &#8220;!510 &gt; shell_locations.txt&#8221;.</p>
<h4>Searching and Running Previous Commands</h4>
<p>The &#8220;!&#8221; functionality of BASH also allows you to search through the history and execute the first match.</p>
<p>The basic form of this simply searches for matches at the beginning of the command. &#8220;!find&#8221; executes the most recent command that begins with &#8220;find&#8221;.</p>
<p>You can also search the entire command for a match. &#8220;!?link?&#8221; executes the most recent command that contains &#8220;link&#8221;.</p>
<h3>Advanced History with Regular Expressions</h3>
<p>As with many tools in the Linux world, you can attain great power by combining the tool with <a href="http://www.regular-expressions.info/" target="_blank">regular expressions</a>. The history in BASH allows you to run previous commands with a search and replace in Regex fashion.</p>
<p>Let&#8217;s take my searching through the ~/wordpress example, command number 412, and run it again with some modifications. This time, instead of searching ~/wordpress, I&#8217;d like to search through /home/site/public_hmtl/wordpress. I&#8217;d do that with the following:</p>
<div class="code">user:~$ <strong>!412:s|~/wordpress|/home/site/public_html/wordpress|</strong><br />
find /home/site/public_html/wordpress -type f | grep \.php$ | grep link | sort -r<br />
/home/site/public_html/wordpress/wp-links-opml.php<br />
/home/site/public_html/wordpress/wp-includes/link-template.php<br />
/home/site/public_html/wordpress/wp-admin/update-links.php<br />
/home/site/public_html/wordpress/wp-admin/options-permalink.php<br />
/home/site/public_html/wordpress/wp-admin/link.php<br />
/home/site/public_html/wordpress/wp-admin/link-parse-opml.php<br />
/home/site/public_html/wordpress/wp-admin/link-manager.php<br />
/home/site/public_html/wordpress/wp-admin/link-category.php<br />
/home/site/public_html/wordpress/wp-admin/link-add.php<br />
/home/site/public_html/wordpress/wp-admin/edit-link-form.php<br />
/home/site/public_html/wordpress/wp-admin/edit-link-category-form.php<br />
/home/site/public_html/wordpress/wp-admin/edit-link-categories.php</div>
<p>Note that the search and replace is done by adding &#8220;:s|find|replace|&#8221; to the end of the history command. I used the pipes, &#8220;|&#8221;, to deliminate the find and replace portions to make it easier to add the forward slashes, &#8220;/&#8221;, to the terms. You can also use &#8220;:s/find/replace/&#8221;.</p>
<h3>Closing Thoughts</h3>
<p>I hope that you enjoy my Mastering the Command Line series. If you have any command line-specific requests, please leave a comment, and I will see about creating a tutorial on that topic.</p>
<p>Remember, those who forget history, are doomed to repeat it by manual entry.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrisjean.com/2009/03/09/command-line-history-in-ubuntu-terminal/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Convert DOS-Formatted Files to Unix-Format in Ubuntu and CentOS</title>
		<link>http://chrisjean.com/2009/03/08/convert-dos-formatted-files-to-unix-format-in-ubuntu-and-centos/</link>
		<comments>http://chrisjean.com/2009/03/08/convert-dos-formatted-files-to-unix-format-in-ubuntu-and-centos/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 06:00:37 +0000</pubDate>
		<dc:creator>Chris Jean</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips 'n Tricks]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[DOS]]></category>
		<category><![CDATA[dos2unix]]></category>
		<category><![CDATA[Mastering The Command Line]]></category>
		<category><![CDATA[newline]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[unix2dos]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://gaarai.com/?p=1297</guid>
		<description><![CDATA[Have you ever seen a bunch of ^M characters in a text file? This odd character at the end of a line can also be represented as a Ctrl+M or &#60;CTRL&#62;M. You don&#8217;t know what it is, and you want it to go away. Today, I&#8217;ll help you understand what that odd ^M character is, [...]]]></description>
			<content:encoded><![CDATA[<!-- filtered -->
<p>Have you ever seen a bunch of ^M characters in a text file? This odd character at the end of a line can also be represented as a Ctrl+M or &lt;CTRL&gt;M. You don&#8217;t know what it is, and you want it to go away.</p>
<p>Today, I&#8217;ll help you understand what that odd ^M character is, why it is in some of your documents, and how to get rid of them.</p>
<p><span id="more-1297"></span></p>
<h3>All About the Newline</h3>
<p>In text documents, lines are separated by what is called a <a href="http://en.wikipedia.org/wiki/Newline" target="_blank">newlin</a>e (also known as a line break or end of line). Different operating systems have different character codes that represent this newline.</p>
<p>For example:</p>
<ul>
<li>DOS-based systems, including Windows, as well as a number of other, older non-Unix OSes use a carriage return (CR) character followed by a line feed (LF) character.</li>
<li>Commodore and the old Apple OSes before OS X used a CR character. Since OS X+ is based partly on BSD, which is in turn based on Unix, the new Apple OSes use the Unix newline method described below.</li>
<li>Unix and its derivatives (Linux, BSD, and others) all use the single LF character to represent a newline.</li>
</ul>
<p>So what does all of this mean to you? It means that text documents that come from a Windows system won&#8217;t always play nice in Linux. The converse is true however. If you create a text file in Linux, many programs will fail to recognize the single LF as a newline and will render the document without any line breaks.</p>
<h3>dos2unix and unix2dos to the Rescue</h3>
<p>Fortunately, there are a couple of very easy to use programs that make dealing with this file format mess much easier. They are dos2unix and unix2dos.</p>
<p>These programs basically do exactly what their name implies: dos2unix takes a file and converts all DOS-style newlines to Unix-style newlines. unix2dos takes a file and converts all Unix-style newlines to DOS-stlye newlines.</p>
<p>I put Ubuntu and CentOS in the title because I&#8217;m going to give instructions for installing these programs on each of these distros. Why just these two? They are the two that I work with most often and are representative of the lion&#8217;s share of what people are using these days. If you need help with a different distro, please let me know in a comment.</p>
<h3>Installing dos2unix and unix2dos in Ubuntu</h3>
<p>There aren&#8217;t any dos2unix or unix2dos packages that can be found in Synaptic; howver, there is a packages that will install them for you. Simply open up Synaptic and install the tofrodos package. If you are like me and prefer to do this from the command line, you can run the following command:</p>
<div class="code">sudo apt-get install tofrodos</div>
<p>That&#8217;s all there is to it. Not only will dos2unix and unix2dos install, but alias programs fromdos and todos will be installed as well. These additional programs work in the same manner, so it&#8217;s purely a matter of preference which ones you use.</p>
<h3>Installing dos2unix and unix2dos in CentOS</h3>
<p>I really thought that I had to install these in CentOS, but amazingly, the programs are already installed by default. I tested this in a Virtual Machine fresh install, and the programs were there on the first boot.</p>
<p>So, CentOS users, you&#8217;re already good to go.</p>
<h3>Using dos2unix</h3>
<p>Fortunately, using these programs couldn&#8217;t be easier.</p>
<p>Let&#8217;s say that you are in a Terminal (Applications &gt; Accessories &gt; Terminal) viewing text files. Maybe you just downloaded a new WordPress plugin and you are reading the readme.txt file. It doesn&#8217;t really matter. However, there is a problem. The readme.txt file has a bunch of ^M characters at the end of each line, and it&#8217;s really distracting.</p>
<p>Simply exit out of the editor you are currently in, since the file will be modified, and run the following command:</p>
<div class="code">dos2unix readme.txt</div>
<p>If there are multiple files, you can specify each one with a space separating each. For example:</p>
<div class="code">dos2unix readme.txt install.txt *.php</div>
<p>The program doesn&#8217;t produce any output. Simply reopen your text file and look at all the beautiful non-existant ^M&#8217;s.</p>
<h3>Using unix2dos</h3>
<p>The unix2dos program has the exact same syntax as dos2unix. However, I thought it might be helpful to describe a situation in which you might need to use it.</p>
<p>You&#8217;re working on a project. You&#8217;ve just sent out your batch of files, and another member on the project complains that you are being a jerk and remove all the newlines in your text files. This other member is most likely using a Windows application that doesn&#8217;t understand the Unix newline format. Rather than getting into a format war, it&#8217;s typically better and quicker to simply convert your text files to a DOS/Windows format.</p>
<p>If you have a folder full of files that all need to be converted, simply run:</p>
<div class="code">unix2dos *</div>
<p>Now you can send these new files to your project group and hopefully avoid any more unproductive drama.</p>
<h3>File Formats in Vi</h3>
<p>If you happen to use Vi, you can change Vi back and forth between DOS and Unix modes for newlines with a simple command. &#8220;:set ff=dos&#8221; sets the editor to use DOS newline encoding and will save the file in a DOS-encoded format. &#8220;:set ff=unix&#8221; sets the editor use Unix newlines and will save the file in a Unix format.</p>
<p>Note that changing the format to dos from unix will always work as expected. This is because any file that contains just LF characters for new lines will be converted to CRLF while lines that already end in CRLF will be left as is.</p>
<p>If your Vi config defaults to a unix format and you open a DOS file, you will see the ^M characters. You can either use the dos2unix conversion utility first or change Vi first to the dos format and then to unix.</p>
<p>If you&#8217;d like Vi to default to DOS or Unix formating each time you start a new Vi session, you can add the setting to your ~/.vimrc file. In that file, either add &#8220;set ff=dos&#8221; or &#8220;set ff=unix&#8221; depending on your needs. Note the lack of the colon, :, in the .vimrc entries.</p>
<p>For more information on the ff or fileformat setting in Vi, check out the <a href="http://www.vim.org/htmldoc/options.html#%27fileformat%27" target="_blank">official documentation</a>.</p>
<h3>Closing Thoughts</h3>
<p>Maybe one day we won&#8217;t have to worry about these types of things. For now however, it&#8217;s good to know the tools that make these problems easily manageable.</p>
<p>BTW, <a href="http://en.wikipedia.org/wiki/Daylight_saving_time" target="_blank">Happy Daylight Savings Day</a> everyone. I hope you enjoyed the loss of an hour of sleep. <img src='http://chrisjean.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://chrisjean.com/2009/03/08/convert-dos-formatted-files-to-unix-format-in-ubuntu-and-centos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Food For Thought</title>
		<link>http://chrisjean.com/2009/03/07/food-for-thought/</link>
		<comments>http://chrisjean.com/2009/03/07/food-for-thought/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 06:00:29 +0000</pubDate>
		<dc:creator>Chris Jean</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Random Ramblings]]></category>
		<category><![CDATA[Tips 'n Tricks]]></category>
		<category><![CDATA[Armed and Dangerous]]></category>
		<category><![CDATA[Conky]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Swift Weasel]]></category>

		<guid isPermaLink="false">http://gaarai.com/?p=1294</guid>
		<description><![CDATA[I&#8217;m more or less taking the night off. I&#8217;ll leave you some good reading material that should cover just about any reader that comes here. Make Linux: Harder &#8211; Better &#8211; Faster This page is a great compilation of links on how to improve security, speed, functionality, or appearance of your Linux system. Firefox Minefield [...]]]></description>
			<content:encoded><![CDATA[<!-- filtered -->
<p>I&#8217;m more or less taking the night off. I&#8217;ll leave you some good reading material that should cover just about any reader that comes here.</p>
<ul>
<li><a href="http://www.linuxhaxor.net/2008/09/30/make-linux-harder-better-faster/" target="_blank">Make Linux: Harder &#8211; Better &#8211; Faster</a><br />
This page is a great compilation of links on how to improve security, speed, functionality, or appearance of your Linux system.</li>
<li><a href="http://www.mozilla.org/projects/minefield/" target="_blank">Firefox Minefield</a><br />
Very interesting version of Firefox that is in development. Apparently, it is <a href="http://www.linuxhaxor.net/2008/09/28/firefox-minefield-faster-than-chrome/" target="_blank">capable of massive speed</a> and gives Chrome a run for its money.</li>
<li><a href="http://conky.sourceforge.net/" target="_blank">Conky</a><br />
A highly-customizable graphical system monitor for your Linux desktop.</li>
<li><a href="http://esr.ibiblio.org/" target="_blank">Armed and Dangerous</a><br />
A blog I just happened upon today that has many great reads. The topics are varied, but there should be a little something for everyone. I was hooked with the <a href="http://esr.ibiblio.org/?p=734" target="_blank">My comment to the FCC on DRM</a> post, as I share many of the feelings that the author does on the subject.</li>
<li><a href="http://swiftweasel.tuxfamily.org/about.php" target="_blank">Swift Weasel</a><br />
This project builds Firefox from source to provide optimized builds for the Linux platform. It&#8217;s still in the early stages but has potential.</li>
</ul>
<p>I hope that my <a href="http://chrisjean.com/2009/03/06/multitasking-from-the-linux-command-line-plus-process-prioritization/" target="_blank">big post yesterday</a> makes up for my weak one today. <img src='http://chrisjean.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://chrisjean.com/2009/03/07/food-for-thought/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

