<?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>NewInstance &#187; Linux</title>
	<atom:link href="http://en.newinstance.it/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://en.newinstance.it</link>
	<description>Welcome to the official blog of Luigi R. Viggiano. Beware of imitations.</description>
	<lastBuildDate>Mon, 09 Jan 2012 20:29:03 +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>Using VMWare to run Windows in a Sandbox</title>
		<link>http://en.newinstance.it/2011/07/01/using-vmware-to-run-windows-in-a-sandbox/</link>
		<comments>http://en.newinstance.it/2011/07/01/using-vmware-to-run-windows-in-a-sandbox/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 10:12:17 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Lifehacks]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[sandbox]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[virtual machine]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/?p=1098</guid>
		<description><![CDATA[Being a Unix user (Linux/OSX) I need sometime to run some Windows utility in a Virtual Machine. But I don&#8217;t want to break the virtual machine, installing and uninstalling things, or accidentally, or by the wast hordes of viruses and malwares that infestate Windows. So, here I found how to do it: How to discard [...]]]></description>
			<content:encoded><![CDATA[<p><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic -->Being a Unix user (Linux/OSX) I need sometime to run some Windows utility in a Virtual Machine. But I don&#8217;t want to break the virtual machine, installing and uninstalling things, or accidentally, or by the wast hordes of viruses and malwares that infestate Windows. </p>
<p>So, here I found how to do it: <a href="http://communities.vmware.com/message/722101">How to discard changes in VMWare player?</a></p>
<p><b>Q:</b> Running a virtual machine, how can I ensure that the changes gets discarded after I close it?</p>
<p><b>A:</b> Shutdown the VM cleanly. Edit the vmx and add this line if the VM uses a scsi-disk</p>
<pre>
scsi0:0.mode = "independent-nonpersistent"
</pre>
<p>or this if the VM uses an IDE-disk</p>
<pre>
ide0:0.mode = "independent-nonpersistent"
</pre>
<p>Alternatively, use this two lines:</p>
<pre>
snapshot.action = "autoRevert"
snapshot.disabled = "TRUE"
</pre>
<p>Several ways lead to Rome.  Both ways should work, but don&#8217;t mix them.
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2006/07/05/free-virtualization-for-windows-with-qemu/" rel="bookmark" class="crp_title">Free Virtualization for Windows with Qemu</a></li>
<li><a href="http://en.newinstance.it/2008/03/04/ubuntu-710-on-lenovo-t61/" rel="bookmark" class="crp_title">Ubuntu 7.10 on Lenovo T61</a></li>
<li><a href="http://en.newinstance.it/2009/08/28/linux-ram-disks/" rel="bookmark" class="crp_title">Linux RAM Disks</a></li>
<li><a href="http://en.newinstance.it/2011/02/27/how-to-create-a-statically-linked-version-of-git-binaries/" rel="bookmark" class="crp_title">How to create a statically linked version of git binaries</a></li>
<li><a href="http://en.newinstance.it/2009/11/26/karmic-and-luks-usb-drive-encryption-made-almost-easy/" rel="bookmark" class="crp_title">Karmic and Luks: USB drive encryption made (almost) easy</a></li>
</ul>
</div>
<div class="shr-publisher-1098"></div>
<p><!-- Start Shareaholic LikeButtonSetBottom Automatic -->
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2011%2F07%2F01%2Fusing-vmware-to-run-windows-in-a-sandbox%2F' data-shr_title='Using+VMWare+to+run+Windows+in+a+Sandbox'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2011%2F07%2F01%2Fusing-vmware-to-run-windows-in-a-sandbox%2F' data-shr_title='Using+VMWare+to+run+Windows+in+a+Sandbox'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2011%2F07%2F01%2Fusing-vmware-to-run-windows-in-a-sandbox%2F' data-shr_title='Using+VMWare+to+run+Windows+in+a+Sandbox'></a></div>
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<p><!-- End Shareaholic LikeButtonSetBottom Automatic --></p>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2011/07/01/using-vmware-to-run-windows-in-a-sandbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH Bash Completion</title>
		<link>http://en.newinstance.it/2011/06/30/ssh-bash-completion/</link>
		<comments>http://en.newinstance.it/2011/06/30/ssh-bash-completion/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 17:18:13 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[completion]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/?p=1072</guid>
		<description><![CDATA[Today I was having a look on how the git-completition is implemented. If you have not enabled the completition for git, I think you should really read my article on how to do it. So I found this two links, that explain the basics on how to implement bash completion for simple commands: An introduction [...]]]></description>
			<content:encoded><![CDATA[<p><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic -->Today I was having a look on how the git-completition is implemented. If you have not enabled the completition for git, I think you should really read <a href="http://en.newinstance.it/2010/05/23/git-autocompletion-and-enhanced-bash-prompt/">my article</a> on how to do it.</p>
<p>So I found this two links, that explain the basics on how to implement bash completion for simple commands:</p>
<ul>
<li><a href="http://www.debian-administration.org/articles/316">An introduction to bash completion: part 1</a></li>
<li><a href="http://www.debian-administration.org/article/317/An_introduction_to_bash_completion_part_2">An introduction to bash completion: part 2</a></li>
</ul>
<p>And I implemented my completion for ssh, which takes the hostnames from the file ~/.ssh/known_hosts</p>
<pre class="brush:bash">
# Add bash completion for ssh: it tries to complete the host to which you
# want to connect from the list of the ones contained in ~/.ssh/known_hosts

__ssh_known_hosts() {
    if [[ -f ~/.ssh/known_hosts ]]; then
        cut -d " " -f1 ~/.ssh/known_hosts | cut -d "," -f1
    fi
}

_ssh() {
    local cur known_hosts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    known_hosts="$(__ssh_known_hosts)"

    if [[ ! ${cur} == -* ]] ; then
    	COMPREPLY=( $(compgen -W "${known_hosts}" -- ${cur}) )
        return 0
    fi
}

complete -o bashdefault -o default -o nospace -F _ssh ssh 2>/dev/null \
	|| complete -o default -o nospace -F _ssh ssh
</pre>
<p>To load it, save the above script into a file called &#8216;ssh-completion&#8217; then add &#8220;source ssh-completion&#8221; in your ~/.profile or ~/.bashrc. Some Linux distributions offer a directory  where you can deploy your completion scripts, for example debian should have them like /etc/bash-completion.d/foobar.bash. </p>
<p>Then go on the command line and type: </p>
<pre class="brush:bash">
$ ssh [tab]
</pre>
<p>If everything went fine, you should see a list of servers to which you recently connected.</p>
<p>I don&#8217;t go in detail to explain the above script, since there are good tutorials around for this purpose, including the links I included before.<br />
I only want to say that the &#8216;compgen&#8217; is an internal bash command, used in the above script: what it does is taking a list of words (-W ${known_hosts} option) from which to try to complete a given partial word (in the above example the ${cur} variable, which is the word at the cursor).</p>
<p>Since completion is usually implemented with bash scripts, it&#8217;s good to keep handy a <a href="http://www.gnu.org/software/bash/manual/bashref.html">bash reference manual</a>. </p>
<h3>Scared of bash scripts?</h3>
<p>I am. I continuously forget the syntax of loops and conditional expressions: I think that the bash language is quite obscure and counter-intuitive. So I guess that is also possible to implement completion as part of your program using your language of choice (Java in my case). You can implement a feature in your program that reads and analyzes the <tt>COMP_WORDS</tt> and <tt>COMP_CWORD</tt> environment variables, and generate the list of completion words, as the &#8216;compgen&#8217; bash built-in command does. And, if your language allows it, set those words into the <tt>COMPREPLY</tt> environment variable; in Java I think it&#8217;s not possible to alter environment variables, but you can just output the words on the standard output and use a brief script to set that output to the <tt>COMPREPLY</tt> variable.<br />
I&#8217;d suggest to bind this functionality to a &#8216;&#8211;completion&#8217; option that can be specified in the command line, as we usually do for the &#8211;help option. </p>
<p>See <a href="https://github.com/rtomayko/git-sh/blob/master/git-completion.bash">git-completion.bash</a> if you want an example of a complex completion script&#8230; bash can be hard. </p>
<h3>Update</h3>
<p>I just typed &#8216;complete&#8217; on my mac, and I discovered I have 408 commands binded to some completion script. Including a more advanced ssh script which implements the hostname suggestions.
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2010/05/23/git-autocompletion-and-enhanced-bash-prompt/" rel="bookmark" class="crp_title">GIT autocompletion and enhanced bash prompt</a></li>
<li><a href="http://en.newinstance.it/2010/04/06/how-to-create-launchers-in-osx/" rel="bookmark" class="crp_title">How to create launchers in OSX</a></li>
<li><a href="http://en.newinstance.it/2009/03/05/ant-macrodefs/" rel="bookmark" class="crp_title">Ant macrodefs</a></li>
<li><a href="http://en.newinstance.it/2009/02/27/execute-commands-in-modified-environment/" rel="bookmark" class="crp_title">Execute commands in modified environment</a></li>
<li><a href="http://en.newinstance.it/2011/06/01/checking-configuration-files-inside-jars/" rel="bookmark" class="crp_title">Checking configuration files inside jars</a></li>
</ul>
</div>
<div class="shr-publisher-1072"></div>
<p><!-- Start Shareaholic LikeButtonSetBottom Automatic -->
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2011%2F06%2F30%2Fssh-bash-completion%2F' data-shr_title='SSH+Bash+Completion'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2011%2F06%2F30%2Fssh-bash-completion%2F' data-shr_title='SSH+Bash+Completion'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2011%2F06%2F30%2Fssh-bash-completion%2F' data-shr_title='SSH+Bash+Completion'></a></div>
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<p><!-- End Shareaholic LikeButtonSetBottom Automatic --></p>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2011/06/30/ssh-bash-completion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Checking configuration files inside jars</title>
		<link>http://en.newinstance.it/2011/06/01/checking-configuration-files-inside-jars/</link>
		<comments>http://en.newinstance.it/2011/06/01/checking-configuration-files-inside-jars/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 11:36:36 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Opinions]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[hiding]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[making things simpler]]></category>
		<category><![CDATA[resources]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[unzip]]></category>
		<category><![CDATA[zip]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/?p=1035</guid>
		<description><![CDATA[Are you habit to have some configuration files packaged inside the jar of your application? If so, you can still have a look at those configuration files in the running environment using the unzip Unix utility. $ unzip -p /opt/myapp/lib/my-app.jar log4j.properties log4j.rootLogger=INFO,stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Threshold=INFO log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{dd-MMM hh:mm} [%-5p] %m%n The -p option uncompress and prints [...]]]></description>
			<content:encoded><![CDATA[<p><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic -->Are you habit to have some configuration files packaged inside the jar of your application? </p>
<p>If so, you can still have a look at those configuration files in the running environment using the unzip Unix utility.</p>
<pre class="brush:bash">
$ unzip -p /opt/myapp/lib/my-app.jar log4j.properties
log4j.rootLogger=INFO,stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Threshold=INFO
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{dd-MMM hh:mm} [%-5p] %m%n
</pre>
<p>The -p option uncompress and prints the file content to standard output.</p>
<p>I like to include resource files in the deployable artifact, unless I want those files to be modifiable without repackaging. Hiding most of configuration helps to keep things simpler for the end user, but still those files can be accessed for the technical support.</p>
<p>By the way, the above log4j configuration is the one I used to replace some System.out/System.err in a simple command line based application. I was thinking to remove the date part &#8216;%d{dd-MMM hh:mm}&#8217; and make it look like the output of ant/maven, but then I thought that -after all- the date is quite useful since the application in question is ran by cron redirecting the standard out into a file, so we keep that as a log of the last run, to have some clue in case of errors.</p>
<p><script type="text/javascript">var dzone_url = 'http://java.dzone.com/articles/checking-configuration-files'; var dzone_style = '2';</script><script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script>
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2010/12/01/android-sdk-2-2_r2-sources/" rel="bookmark" class="crp_title">Android sdk 2.2_r2 sources</a></li>
<li><a href="http://en.newinstance.it/2009/05/07/java-native-compilation/" rel="bookmark" class="crp_title">Java native compilation</a></li>
<li><a href="http://en.newinstance.it/2010/09/10/using-files-in-your-interfaces-is-not-a-good-idea/" rel="bookmark" class="crp_title">Using Files in your interfaces is NOT a good idea</a></li>
<li><a href="http://en.newinstance.it/2011/02/10/eclipse-save-actions/" rel="bookmark" class="crp_title">Eclipse Save Actions</a></li>
<li><a href="http://en.newinstance.it/2011/02/27/how-to-create-a-statically-linked-version-of-git-binaries/" rel="bookmark" class="crp_title">How to create a statically linked version of git binaries</a></li>
</ul>
</div>
<div class="shr-publisher-1035"></div>
<p><!-- Start Shareaholic LikeButtonSetBottom Automatic -->
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2011%2F06%2F01%2Fchecking-configuration-files-inside-jars%2F' data-shr_title='Checking+configuration+files+inside+jars'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2011%2F06%2F01%2Fchecking-configuration-files-inside-jars%2F' data-shr_title='Checking+configuration+files+inside+jars'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2011%2F06%2F01%2Fchecking-configuration-files-inside-jars%2F' data-shr_title='Checking+configuration+files+inside+jars'></a></div>
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<p><!-- End Shareaholic LikeButtonSetBottom Automatic --></p>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2011/06/01/checking-configuration-files-inside-jars/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create a statically linked version of git binaries</title>
		<link>http://en.newinstance.it/2011/02/27/how-to-create-a-statically-linked-version-of-git-binaries/</link>
		<comments>http://en.newinstance.it/2011/02/27/how-to-create-a-statically-linked-version-of-git-binaries/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 21:23:23 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[portability]]></category>
		<category><![CDATA[static]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/?p=986</guid>
		<description><![CDATA[Creating a statically linked version of a unix software saves you in all the circumstances where you can&#8217;t install the software as root, when you don&#8217;t have development tools on the target machine, when you cannot find a prepackaged version for the specific server, when the libraries available on a server are conflicting with the [...]]]></description>
			<content:encoded><![CDATA[<p><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic -->Creating a <a href="http://en.wikipedia.org/wiki/Static_linking">statically linked</a> version of a unix software saves you in all the circumstances where you can&#8217;t install the software as root, when you don&#8217;t have development tools on the target machine, when you cannot find a prepackaged version for the specific server, when the libraries available on a server are conflicting with the ones required by your software, etc.</p>
<p>Examples:</p>
<ol>
<li>The unix server that hosts this blog, provides me a restricted shell to manage mysql and public web files with minimal access privileges. On this server I periodically update WordPress and other things, and I like to keep the changes under control and backed up with git. The problem is that on this server I haven&#8217;t git binaries, and I cannot install software and libraries required.<br />
Having the files of my WordPress installation under git version control saved me a lot of time in the past when somebody hacked into the server and changed the php files to do nasty stuff. I was able to easily check what was exactly changed since last legitimate update with &#8220;git status&#8221; command, and restore things as before.</li>
<li>I own a little NAS (network attached storage) which runs a mini distribution of Linux which doesn&#8217;t have a prepackaged version of git to install, nor I cannot use any package management tool like apt rpm or yum etc. </li>
</ol>
<p>So I thought that I can compile by myself the git binaries and have them deployed on the target machine. It is possible, but there is an important note: when you build a software on a unix server, the resulting binaries are referencing the libraries installed there, so you cannot easily port the binaries between servers since they have dependencies.<br />
What you need is a &#8220;statically linked&#8221; version of the software, which fortunately it&#8217;s not so difficult to achieve. Binaries which are statically linked are usually bigger in size and will possibly require more memory to execute, but they won&#8217;t require the specific libraries to be present on the executing computer, since the libraries code is contained in the binaries themselves.</p>
<p>Here is how I built a static version of git on an ubuntu virtual machine, that can be ported to other unix servers:</p>
<pre class="brush:bash">
# let's make sure we have all we need to proceed
$ sudo apt-get install libexpat1-dev asciidoc libz-dev gettext curl

# let's create the directory to host the built artifacts
$ sudo mkdir /opt/git-1.7.4.1-static

# we are ready to download and unpack latest version of git sources
$ curl http://kernel.org/pub/software/scm/git/git-1.7.4.1.tar.bz2 | tar xvj
$ cd git-1.7.4.1/

# then compile and install the files in the target directory we created
$ ./configure --prefix=/opt/git-1.7.4.1-static CFLAGS="${CFLAGS} -static" NO_OPENSSL=1 NO_CURL=1
$ sudo make install
$ sudo make install-doc
</pre>
<p>On the above commands, the thing to notice is the <em>CFLAGS=&#8221;${CFLAGS} -static&#8221;</em> which is used to specify that the libraries must be statically linked with the binaries. </p>
<p>The last thing to do is create a tarball of /opt/git-1.7.4.1-static folder and copy that on the target machine; adding the /opt/git-1.7.4.1-static/bin directory to the PATH variable and the /opt/git-1.7.4.1-static/share/man to the MANPATH variable. </p>
<p>If possible, it&#8217;s a good idea to keep the same installation path on target machine (/opt/git-1.7.4.1-static) since this path gets hardcoded in some git scripts during the build process. But it shouldn&#8217;t give too many problems, anyway.</p>
<p><script type="text/javascript">var dzone_url = 'http://java.dzone.com/articles/how-create-statically-linked'; var dzone_style = '2';</script><script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script>
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2009/05/13/making-eclipse-javahl-working-recompiling-subversion-from-the-sources/" rel="bookmark" class="crp_title">Making Eclipse JavaHL working, recompiling Subversion from the sources</a></li>
<li><a href="http://en.newinstance.it/2009/02/27/execute-commands-in-modified-environment/" rel="bookmark" class="crp_title">Execute commands in modified environment</a></li>
<li><a href="http://en.newinstance.it/2009/04/02/more-on-tracing-network-connections/" rel="bookmark" class="crp_title">More on tracing network connections.</a></li>
<li><a href="http://en.newinstance.it/2006/07/05/free-virtualization-for-windows-with-qemu/" rel="bookmark" class="crp_title">Free Virtualization for Windows with Qemu</a></li>
<li><a href="http://en.newinstance.it/2008/06/19/setting-up-javahl-jni-support-in-eclipse-on-linux/" rel="bookmark" class="crp_title">Setting up JavaHL (JNI) support in Eclipse on Linux</a></li>
</ul>
</div>
<div class="shr-publisher-986"></div>
<p><!-- Start Shareaholic LikeButtonSetBottom Automatic -->
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2011%2F02%2F27%2Fhow-to-create-a-statically-linked-version-of-git-binaries%2F' data-shr_title='How+to+create+a+statically+linked+version+of+git+binaries'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2011%2F02%2F27%2Fhow-to-create-a-statically-linked-version-of-git-binaries%2F' data-shr_title='How+to+create+a+statically+linked+version+of+git+binaries'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2011%2F02%2F27%2Fhow-to-create-a-statically-linked-version-of-git-binaries%2F' data-shr_title='How+to+create+a+statically+linked+version+of+git+binaries'></a></div>
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<p><!-- End Shareaholic LikeButtonSetBottom Automatic --></p>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2011/02/27/how-to-create-a-statically-linked-version-of-git-binaries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GIT autocompletion and enhanced bash prompt</title>
		<link>http://en.newinstance.it/2010/05/23/git-autocompletion-and-enhanced-bash-prompt/</link>
		<comments>http://en.newinstance.it/2010/05/23/git-autocompletion-and-enhanced-bash-prompt/#comments</comments>
		<pubDate>Sun, 23 May 2010 20:47:19 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/?p=427</guid>
		<description><![CDATA[There are a couple of cool features in GIT that may not be well known by everyone, depending on which platform you are using. For example on Linux it is quite common to have the bash completion working, while in Windows msysgit comes with a cool prompt which displays the current branch and some status [...]]]></description>
			<content:encoded><![CDATA[<p><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic -->There are a couple of cool features in GIT that may not be well known by everyone, depending on which platform you are using. For example on Linux it is quite common to have the bash completion working, while in Windows msysgit comes with a cool prompt which displays the current branch and some status information on the command line, as well as with the bash completion.<br />
Git (version 1.7.0, and probably 1.7.1) on OS X comes with nothing, so here I show how to enable the command line completion and the git enhanced prompt. You can use the same tip on Linux to get the GIT enhanced prompt.</p>
<p>Here you can see how my prompt looks like:<br />
<img src="http://en.newinstance.it/wp-content/uploads/2010/05/git-prompt.png" alt="Git Prompt and Completition" title="git-prompt" width="291" height="33" class="alignnone size-full wp-image-448" /></p>
<p>"luigi@hal9000:~/bin" is my usual prompt (username@hostname:folder), the red part indicates current branch, and the asterisk means that I have some modified files to commit.<br />
In the above sample, also you see what happens when I type "git cl[tab-key]". The tab key triggers command line completion, and I can see available git commands starting with "cl"; in this case <em>clone</em> and <em>clean</em>.<br />
The completion works not only on the command names, but also on file names and git object names, for example on branch names: if you type "git checkout mas[tab-key]" you should get it expaended to "git checkout master".</p>
<p>To enable the GIT bash completion, on OSX, you need to execute the script located at <tt>/usr/local/git/contrib/completion/git-completion.bash</tt>. This script is installed together with GIT utilities on OSX. To have its features enabled when you open a terminal session you should add following lines to your .profile:</p>
<pre class="brush:bash">
# Set git autocompletion and PS1 integration
if [ -f /usr/local/git/contrib/completion/git-completion.bash ]; then
  . /usr/local/git/contrib/completion/git-completion.bash
fi
GIT_PS1_SHOWDIRTYSTATE=true

if [ -f /opt/local/etc/bash_completion ]; then
    . /opt/local/etc/bash_completion
fi

PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ '
</pre>
<p>The GIT_PS1_SHOWDIRTYSTATE variable is used to indicate that the prompt should display the asterisk or other characters to indicate that the state of the working tree is "dirty" (something is changed and it has not yet been committed).<br />
The script git-completion.bash enables bash completion and contains also some functions that can be executed when the prompt (defined in the PS1 variable) is shown. In this case the function displayed is named __git_ps1 and it displayes the current branch; the rest of the PS1 text is to display a nice prompt with colors.<br />
For Linux user (at least for Ubuntu ones), it is just necessary to define the PS1 variable in the ~/.bashrc file, as the git completion script is usually included by default when installing git.</p>
<p>Another nice trick, that is not enabled by default, is the coloring for the following git commands: branch, status and diff. Having colors enabled helps to faster and easier understand the output. To enable colors issue the following commands:</p>
<pre class="brush:bash">
$ git config --global color.branch auto
$ git config --global color.diff auto
$ git config --global color.status auto
</pre>
<p>Configuring above git properties will affect color display as in following examples:</p>
<p>Branch:<br />
<img src="http://en.newinstance.it/wp-content/uploads/2010/05/git-branch.png" alt="git branch" title="git-branch" width="331" height="51" class="alignnone size-full wp-image-462" /></p>
<p>Status:<br />
<img src="http://en.newinstance.it/wp-content/uploads/2010/05/git-status-e1274647088714.png" alt="" title="git-status" width="499" height="209" class="size-full wp-image-464" /></p>
<p>Diff:<br />
<img src="http://en.newinstance.it/wp-content/uploads/2010/05/git-diff.png" alt="git diff" title="git-diff" width="336" height="150" class="alignnone size-full wp-image-466" /></p>
<p>Hope you find those tricks as useful as I do find them.</p>
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2011/06/30/ssh-bash-completion/" rel="bookmark" class="crp_title">SSH Bash Completion</a></li>
<li><a href="http://en.newinstance.it/2006/07/02/command-line-shortcuts-on-folder-and-drives/" rel="bookmark" class="crp_title">Command line shortcuts on folder and drives.</a></li>
<li><a href="http://en.newinstance.it/2010/05/17/attaching-sources-to-androidjar-in-eclipse/" rel="bookmark" class="crp_title">Attaching sources to android.jar in Eclipse</a></li>
<li><a href="http://en.newinstance.it/2009/02/12/some-tips-for-iterm/" rel="bookmark" class="crp_title">Some tips for iTerm</a></li>
<li><a href="http://en.newinstance.it/2009/12/03/ipod-touch-with-linux/" rel="bookmark" class="crp_title">Ipod touch with Linux</a></li>
</ul>
</div>
<div class="shr-publisher-427"></div>
<p><!-- Start Shareaholic LikeButtonSetBottom Automatic -->
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2010%2F05%2F23%2Fgit-autocompletion-and-enhanced-bash-prompt%2F' data-shr_title='GIT+autocompletion+and+enhanced+bash+prompt'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2010%2F05%2F23%2Fgit-autocompletion-and-enhanced-bash-prompt%2F' data-shr_title='GIT+autocompletion+and+enhanced+bash+prompt'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2010%2F05%2F23%2Fgit-autocompletion-and-enhanced-bash-prompt%2F' data-shr_title='GIT+autocompletion+and+enhanced+bash+prompt'></a></div>
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<p><!-- End Shareaholic LikeButtonSetBottom Automatic --></p>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2010/05/23/git-autocompletion-and-enhanced-bash-prompt/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Attaching sources to android.jar in Eclipse</title>
		<link>http://en.newinstance.it/2010/05/17/attaching-sources-to-androidjar-in-eclipse/</link>
		<comments>http://en.newinstance.it/2010/05/17/attaching-sources-to-androidjar-in-eclipse/#comments</comments>
		<pubDate>Mon, 17 May 2010 14:54:25 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/2010/05/17/attaching-sources-to-androidjar-in-eclipse/</guid>
		<description><![CDATA[If you are working with the Android Development Toolkit (ADT) for Eclipse you may have noticed that the sources for android.jar are missing. The Android SDK comes without the sources, and even if you manage to download the source code for the Android library, the ADT does not allow you to attach the sources to [...]]]></description>
			<content:encoded><![CDATA[<p><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic -->If you are working with the Android Development Toolkit (ADT) for Eclipse you may have noticed that the sources for android.jar are missing.<br />
The Android SDK comes without the sources, and even if you manage to download the source code for the Android library, the ADT does not allow you to attach the sources to the library in the IDE. When debugging or navigating into the sources of android classes this may be similar to what you'll get:</p>
<p><img id="image424" src="http://en.newinstance.it/wp-content/uploads/2010/05/class-file-editor.png" alt="Class File Editor" /></p>
<p>The trick, how explained <a href="http://stuffthathappens.com/blog/2008/11/01/browsing-android-source-in-eclipse/">here</a>, is to download the sources and copy them into android-sdk/platforms/android-<em>X</em>/sources folder (where <em>X</em> is the API version).</p>
<p>For example, supposing I've installed the SDK into ~/opt/android-sdk-mac_86 on my Mac, and I am developing an application with Android 1.5 (API level 3). I should <a href="http://source.android.com/download/">download the source files</a> from Android website using <a href="http://git-scm.com/">git</a>. Then I need to checkout the sources with tag name "android-sdk-1.5_r3", collect all the source files and move them into the directory ~/opt/android-sdk-mac_86/platforms/android-3/sources.</p>
<p>Here's my source tree under android-sdk-mac_86/platforms; in red color the directory where to put the sources:</p>
<pre>
luigi@hal9000:~/opt/android-sdk-mac_86$ <b>tree -L 2  platforms</b>
platforms/
|-- android-3
|   |-- android.jar
|   |-- build.prop
|   |-- data
|   |-- framework.aidl
|   |-- images
|   |-- samples
|   |-- skins
|   |-- source.properties
|   |-- <span style="color:red">sources</span>
|   |-- templates
|   `-- tools
|-- android-4
|   `-- ...
|-- android-6
|   `-- ...
`-- android-7
    `-- ...
</pre>
<p>Creating a directory and copy some files inside it's not much complicate. But once you downloaded the sources, you'll discover that they are spread in several sub-directories. Also you need some practice with git command line utility to download the sources check available tags, switch to the proper source tree, then package all the source files into a folder or an archive.</p>
<p>I created following script, which runs on OSX (and hopefully on Linux as well).</p>
<pre class="brush: bash">
luigi@hal9000:~$ cat bin/android-src-build.sh

#!/bin/sh 

SRC_DIR=/tmp/android-api

print_syntax() {
   echo "Syntax:\n\t$(basename $0) [option]"
   echo "\nOptions:"
   echo "\t-l prints available versions"
   echo "\t-v builds jar file with sources of specified version"
   echo "\t-c cleans up the sources from the temp directory\n"
   exit 1
}

error() {
   echo "Error:" $1
   exit 1
}

download_sources() {
    if [[ ! -d $SRC_DIR ]]; then
        git clone git://git.source.android.com/platform/frameworks/base $SRC_DIR
    fi
}

if ! which git > /dev/null ; then
    error "git not installed (or not in the PATH)"
fi

if ! which jar > /dev/null ; then
    error "jar not installed (or not in the PATH)"
fi

if [[ "$1" == "-l" ]]; then
    download_sources
    cd $SRC_DIR
    git tag -l
    exit 0;
fi

if [[ "$1" == "-c" ]]; then
    rm -rf $SRC_DIR
    exit 0;
fi

if [[ "$1" == "-v"  &#038;& ! -z "$2"  ]]; then
    JAR_FILE=$(pwd)/$2-src.jar
    download_sources
    cd $SRC_DIR
    if ! git tag -l | grep $2 ; then
        echo "Version \"$2\" not found"
        exit 1;
    fi
    git checkout $2
    touch $JAR_FILE
    find . -depth 2 -name "java" -type d -exec jar uf $JAR_FILE -C {} . \;
    exit 0
fi

print_syntax
</pre>
<p>You can download it here: <a id="p423" href="http://en.newinstance.it/wp-content/uploads/2010/05/android-src-build-sh.gz">android-src-build.sh.gz</a>. (It's a bash script: download and execute it at your own risk!)</p>
<p>The script, is able to download the sources from the Android git repository, and, given the version number it packs it into a jar file, that can be lately be unpacked into the <em>sources</em> folder of the Android SDK, where indicated above.</p>
<p>When you run it without parameters it gives you following help:</p>
<pre>
luigi@hal9000:~$ <b>android-src-build.sh </b>
Syntax:
        android-src-build.sh [option]

Options:
        -l prints available versions
        -v builds jar file with sources of specified version
        -c cleans up the sources from the temp directory
</pre>
<p>The -l parameter prints the list of available versions. If the sources have not been already downloaded, the -l will also download them. So the first time, it will take some minutes before displaying the available releases: </p>
<pre>
luigi@hal9000:~$ <b>android-src-build.sh -l</b>
Initialized empty Git repository in /private/tmp/android-api/.git/
remote: Counting objects: 106183, done.
remote: Compressing objects: 100% (35592/35592), done.
remote: Total 106183 (delta 61793), reused 104978 (delta 60893)
Receiving objects: 100% (106183/106183), 128.07 MiB | 1.52 MiB/s, done.
Resolving deltas: 100% (61793/61793), done.
Checking out files: 100% (8431/8431), done.
android-1.0
android-1.5
android-1.5r2
android-1.5r3
android-1.5r4
android-1.6_r1
android-1.6_r1.1
android-1.6_r1.2
android-1.6_r1.3
android-1.6_r1.4
android-1.6_r1.5
android-1.6_r2
android-2.0.1_r1
android-2.0_r1
android-2.1_r1
android-2.1_r2
android-2.1_r2.1p
android-2.1_r2.1p2
android-2.1_r2.1s
android-sdk-1.5-pre
android-sdk-1.5_r1
android-sdk-1.5_r3
android-sdk-1.6-docs_r1
android-sdk-1.6_r1
android-sdk-1.6_r2
android-sdk-2.0.1-docs_r1
android-sdk-2.0.1_r1
android-sdk-2.0_r1
android-sdk-2.1_r1
android-sdk-tools_r2
android-sdk-tools_r3
android-sdk-tools_r4
android-sdk-tools_r5
</pre>
<p>Now, let's say that we are developing on Android 1.5, we may want to create a jar file containing all the java sources for that version with:</p>
<pre>
luigi@hal9000:~$ <b>android-src-build.sh -v android-sdk-1.5_r3</b>
android-sdk-1.5_r3
Note: moving to 'android-sdk-1.5_r3' which isn't a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
  git checkout -b <new_branch_name>
HEAD is now at b69bed1... AI 150122: Merge from donut.   Fix permissions issue for uninstall of updated system applications.   If an existing update for a system application is uninstalled, when reverting back to the existing   version in system partition, permissions have to be granted again.   BUG=1893639
luigi@hal9000:~$ <b>ls -l *.jar</b>
-rw-r--r--  1 luigi  staff  4766477 May 17 15:59 <span style="color:red">android-sdk-1.5_r3-src.jar</span>
</pre>
<p>As shown above, after issuing the command a file called android-sdk-1.5_r3-src.jar will be generated into the current directory.<br />
Now the only thing remaining is to expand this file into the folder ~/opt/android-sdk-mac_86/platforms/android-3/sources:</p>
<pre>
luigi@hal9000:~$ <b>rm -rf /Users/luigi/opt/android-sdk-mac_86/platforms/android-3/sources/</b>
luigi@hal9000:~$ <b>mkdir ~/opt/android-sdk-mac_86/platforms/android-3/sources</b>
luigi@hal9000:~$ <b>cd ~/opt/android-sdk-mac_86/platforms/android-3/sources</b>
luigi@hal9000:~/opt/android-sdk-mac_86/platforms/android-3/sources$ <b>jar xf ~/android-sdk-1.5_r3-src.jar</b>
</pre>
<p>At this point, restarting eclipse should be enough to have the ADT linked with the source files.</p>
<p>About the platforms available into the Android SDK, under the <tt>platform</tt> directory, there are following folders: android-3, android-4, android-6, and adroid-7.<br />
I am not 100% sure, but they should correspond to the source code identified respectively by following table:</p>
<pre>
android-3 = android-sdk-1.5_r3
android-4 = android-sdk-1.6_r2
android-6 = android-sdk-2.0.1_r1
android-7 = android-sdk-2.1_r1
</pre>
<p>Finally, if you want to remove the sources downloaded you can run the script with the -c (clean) option: it will remove the sources stored temporarily into the folder <tt>/tmp/android-api</tt>:</p>
<pre>
luigi@hal9000:~$ <b>android-src-build.sh -c</b>
(no output returned)
</pre>
<p>Alternatively, you may want to remove the files manually.</p>
<p>Now, after a refresh (or a restart) from Eclipse, the sources from Android classes should look much better:</p>
<p><img id="image425" src="http://en.newinstance.it/wp-content/uploads/2010/05/sources.png" alt="Sample Android Source " /></p>
<p>Check the referenced articles for further information on how to download the android sources, and how the ADT plugin for Eclipse locates the sources for the Android SDK.</p>
<p>I really think that Google should release the sources nicely packed as per the android.jar and make sure they are properly referenced by the ADT. Since then, this is my way.</p>
<p>For questions, mistakes, etc. leave a comment.</p>
<h4>References</h4>
<p>- <a href="http://stuffthathappens.com/blog/2008/11/01/browsing-android-source-in-eclipse/">Browsing Android Source in Eclipse</a><br />
- <a href="http://source.android.com/source/download.html">Android sources</a>
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2010/05/18/androidjar-sources/" rel="bookmark" class="crp_title">Android.jar sources</a></li>
<li><a href="http://en.newinstance.it/2010/12/01/android-sdk-2-2_r2-sources/" rel="bookmark" class="crp_title">Android sdk 2.2_r2 sources</a></li>
<li><a href="http://en.newinstance.it/2009/05/13/making-eclipse-javahl-working-recompiling-subversion-from-the-sources/" rel="bookmark" class="crp_title">Making Eclipse JavaHL working, recompiling Subversion from the sources</a></li>
<li><a href="http://en.newinstance.it/2005/08/03/debian-package-managing-survival-guide/" rel="bookmark" class="crp_title">Debian Package Managing Survival Guide</a></li>
<li><a href="http://en.newinstance.it/2009/05/07/java-native-compilation/" rel="bookmark" class="crp_title">Java native compilation</a></li>
</ul>
</div>
<div class="shr-publisher-421"></div>
<p><!-- Start Shareaholic LikeButtonSetBottom Automatic -->
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2010%2F05%2F17%2Fattaching-sources-to-androidjar-in-eclipse%2F' data-shr_title='Attaching+sources+to+android.jar+in+Eclipse'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2010%2F05%2F17%2Fattaching-sources-to-androidjar-in-eclipse%2F' data-shr_title='Attaching+sources+to+android.jar+in+Eclipse'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2010%2F05%2F17%2Fattaching-sources-to-androidjar-in-eclipse%2F' data-shr_title='Attaching+sources+to+android.jar+in+Eclipse'></a></div>
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<p><!-- End Shareaholic LikeButtonSetBottom Automatic --></p>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2010/05/17/attaching-sources-to-androidjar-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Sharing keyboard and mouse on multiple computers</title>
		<link>http://en.newinstance.it/2010/05/03/sharing-keyboard-and-mouse-on-multiple-computers/</link>
		<comments>http://en.newinstance.it/2010/05/03/sharing-keyboard-and-mouse-on-multiple-computers/#comments</comments>
		<pubDate>Mon, 03 May 2010 15:23:21 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Lifehacks]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/2010/05/03/sharing-keyboard-and-mouse-on-multiple-computers/</guid>
		<description><![CDATA[If you have more than one laptop/computer on your desktop, you may find yourself jumping from a keyboard to another to make use of them. In this article I explain how I configured my laptops to share keyboard and mouse using synergy. It is always a good thing to have a second monitor, for example [...]]]></description>
			<content:encoded><![CDATA[<p><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic -->If you have more than one laptop/computer on your desktop, you may find yourself jumping from a keyboard to another to make use of them. In this article I explain how I configured my laptops to share keyboard and mouse using synergy.</p>
<p>It is always a good thing to have a second monitor, for example to read documentation while doing some development, or for listening to music or watching videos while doing things that do not require full attention.<br />
I have an ancient (10 years old) Dell Inspiron 8600 laptop on which the keyboard and the touchpad are starting to lose efficiency, but still it has a great display and an unrivaled audio system. The keyboard is pretty different from the macbook I am using daily, and dealing with different keyboards may not be so enjoyable. Also being an old generation laptop, the keyboard it's not very pleasant to the touch, and sometime it loses some key press. </p>
<p>With <a href="http://synergy2.sourceforge.net/">Synergy</a>, it is possible to control remote computers with a single keyboard and mouse. So now, I can work on my MacBook running OSX Snow Leopard and control also the second laptop, the ancient Dell on my desk running Ubuntu 10.4, without switching keyboard or mouse. A second thing that comes for free with Synergy is the clipboard sharing; this means that you can cut-and-paste across the computers you are using: it is very helpful.<br />
You can find more information about synergy at the <a href="http://synergy2.sourceforge.net/">official site</a>.</p>
<p>First of all, you need to install synergy executable files on all the computers you need to control. Download it from <a href="http://sourceforge.net/projects/synergy2/files/">here</a>. Then, ensure that the computer can see each others on the network, using ip address or dns names. If they can ping each others, usually it should be enough.<br />
On ubuntu you can install synergy using apt-get, while on the mac you can download the executables packed into a tarball and unpack them in a any folder you like, in my case I used ~/opt/synergy-1.3.1.</p>
<p>I want to use my mac's keyboard and mouse to control the dell laptop. You can have a single controller computer and many controlled computers. The controller will need the synergy server, while the controlled computers will run the client.<br />
So on my macbook I created a configuration file which describes computers I want to control and what edge of the screen is the "border" from which the mouse will jump on the other computers. I placed it under ~/etc/synergy.conf :</p>
<pre>
section: screens
    dell:
    macbook:
end

section: links
    dell:
        left = macbook
    macbook:
        right = dell
end
</pre>
<p>The above configuration describe my screens configuration and the links between the laptops. Basicallly I am telling that I have two screens, the dell one and the macbook. And for the dell I have a macbook on the left, and for the macbook I have the dell on the right. There are many other options, but here I am just using the defaults. The full documentation on the configuration options can be found <a href="http://synergy2.sourceforge.net/configuration.html">here</a>.</p>
<p>Then I have to start the Synergy server on the macbook using the command:</p>
<pre>
$ synergys --config ~/etc/synergy.conf
</pre>
<p>On the dell computer then I need to run the client, who will connect to the macbook (the controller laptop) and act consequently. To do so, I can connect the client launching one of the following commands</p>
<pre>

// supposing 192.168.1.123 is the ip of my macbook
$ synergyc 192.168.1.123

// in my network I can refer the server as macbook.local or just macbook.
$ synergyc macbook.local
// or
$ synergyc macbook
</pre>
<p>After doing so, you should be able to move your mouse from one computer to the other(s) just passing through the edges of the screens, and control all the computers on your desk.</p>
<p>If something goes wrong, you can use the -f option to run the client and the server in foreground, and the -d to enable debug tracing. </p>
<p>If you still have troubles with command line tools, you may want to try <a href="http://www.volker-lanz.de/en/software/qsynergy/">QSynergy</a>, which is a graphical user interface over synergy.</p>
<p>Yet it is missing some "file sharing" feature; it would be very good if synergy was able to copy files dragging and dropping files from a desk to another, but at the moment, this is missing.  Installing OpenSSH can do what is missing: file transfers (scp) and remote ssh logins should be enough to complete synergy desktop integration.</p>
<p>Here there is a video that visually explains what you can do with Synergy:</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/UdP1Rei2muw&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/UdP1Rei2muw&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>It looks like in the video she forgot to start the client; btw it is just needed to launch the synergyc executable as I explained above.</p>
<p>And here, a guy shared his mouse and keyboard over 7 computers using synergy:</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/Id3GHAruhAk&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Id3GHAruhAk&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>Have fun.
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2008/11/10/wassup-yesterday-and-today/" rel="bookmark" class="crp_title">Wassup yesterday and today</a></li>
<li><a href="http://en.newinstance.it/2009/01/06/reinventing-the-wheel/" rel="bookmark" class="crp_title">Reinventing the wheel.</a></li>
<li><a href="http://en.newinstance.it/2005/12/23/ubuntu-on-my-laptop/" rel="bookmark" class="crp_title">Ubuntu on my laptop</a></li>
<li><a href="http://en.newinstance.it/2011/05/25/fan-control-for-macbook/" rel="bookmark" class="crp_title">Fan Control for MacBook</a></li>
<li><a href="http://en.newinstance.it/2008/11/01/the-intrepid-ibex-on-dell-inspiron-8600/" rel="bookmark" class="crp_title">The Intrepid Ibex on Dell Inspiron 8600</a></li>
</ul>
</div>
<div class="shr-publisher-419"></div>
<p><!-- Start Shareaholic LikeButtonSetBottom Automatic -->
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2010%2F05%2F03%2Fsharing-keyboard-and-mouse-on-multiple-computers%2F' data-shr_title='Sharing+keyboard+and+mouse+on+multiple+computers'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2010%2F05%2F03%2Fsharing-keyboard-and-mouse-on-multiple-computers%2F' data-shr_title='Sharing+keyboard+and+mouse+on+multiple+computers'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2010%2F05%2F03%2Fsharing-keyboard-and-mouse-on-multiple-computers%2F' data-shr_title='Sharing+keyboard+and+mouse+on+multiple+computers'></a></div>
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<p><!-- End Shareaholic LikeButtonSetBottom Automatic --></p>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2010/05/03/sharing-keyboard-and-mouse-on-multiple-computers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3G USB Stick on Ubuntu</title>
		<link>http://en.newinstance.it/2010/01/08/3g-usb-stick-on-ubuntu/</link>
		<comments>http://en.newinstance.it/2010/01/08/3g-usb-stick-on-ubuntu/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 23:22:33 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/2010/01/08/3g-usb-stick-on-ubuntu/</guid>
		<description><![CDATA[I am in London for work, and my hotel wants me to pay £ 17 per day for accessing internet. But I found an internet café which is offering Internet connection on a 3G USB stick for £ 19.99 per week ( reload.com 197 Praed Street, Paddington ). The USB stick is from Three, like [...]]]></description>
			<content:encoded><![CDATA[<p><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic -->I am in London for work, and my hotel wants me to pay £ 17 per day for accessing internet. But I found an internet café which is offering Internet connection on a 3G USB stick for £ 19.99 per week ( reload.com 197 Praed Street, Paddington ). The USB stick is from <a href="http://three.co.uk">Three</a>, like the one that can be found <a href="http://threestore.three.co.uk/dealsummary.aspx?offercode=24MB1GD029&#038;id=1397">here</a>.<br />
When you plug it in, Linux will mount a storage device which contains the drivers for OSX/Windows/Linux. The ones for Linux, of course, do not work: there are some files (zte drivers) precompiled for some version of Fedora, and other stuff which doesn't compile on Ubuntu.<br />
The good news is that you don't need any driver in Linux; just some hacking. The kernel of Ubuntu is built with support of the most common 3G drivers.</p>
<p>Below I explain how to make it work.</p>
<h4>Disable the USB storage</h4>
<p>When the USB stick is behaving as USB storage it won't work as 3G modem. The first thing to do is to disable that.</p>
<p>Locate the device assigned to the USB stick:</p>
<pre>
luigi@hal9000:~$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda3            199024992 113153688  75761392  60% /
udev                   2018164       296   2017868   1% /dev
none                   2018164       340   2017824   1% /dev/shm
none                   2018164       324   2017840   1% /var/run
none                   2018164         0   2018164   0% /var/lock
none                   2018164         0   2018164   0% /lib/init/rw
/dev/sr1                 26330     26330         0 100% /media/3Connect
</pre>
<p>The 3Connect one is the USB stick, so let's unmount it, to be able - later - to unload the usb_storage kernel module.</p>
<pre>
luigi@hal9000:~$ sudo eject /dev/sr1
[sudo] password for luigi: *****
</pre>
<p>now let's unload the usb_storage kernel module.</p>
<pre>
luigi@hal9000:~$ lsmod | grep usb_storage
usb_storage            66016  0
luigi@hal9000:~$ sudo rmmod usb_storage
luigi@hal9000:~$ lsmod | grep usb_storage
</pre>
<p>The first command (lsmod) checks that usb_storage is loaded, and see if there are other modules depending on it. There aren't, so we can remove the module (rmmod command). Last command (lsmod) is to verify that the module is successfully unloaded; if it doesn't display anything means that the usb_storage module is gone, so it's ok! </p>
<h4>Load the usbserial kernel module</h4>
<p>Now we can load the usbserial kernel module and we can associate that to the USB stick.</p>
<p>First of all, let's check how the module is loaded:</p>
<pre>
luigi@hal9000:~$ lsmod | grep usbserial
usbserial              43248  1 option
</pre>
<p>We see that there's the "option" module depending on the usbserial, so we need to first unload option then usbserial.<br />
Let's do that with rmmod command.</p>
<pre>
luigi@hal9000:~$ sudo rmmod option usbserial
luigi@hal9000:~$ lsmod | grep usbserial
</pre>
<p>The lsmod at the end is just to ensure that usbserial is successfully unloaded. This time it should not display anything.</p>
<p>Now we need to know the manufacturer id and the product id of the usb device. Let's do that with lsusb command:</p>
<pre>
luigi@hal9000:~$ lsusb
Bus 004 Device 003: ID 05ac:8213 Apple, Inc.
Bus 004 Device 002: ID 0a5c:4500 Broadcom Corp.
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 05ac:8507 Apple, Inc.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 003: ID 05ac:0237 Apple, Inc.
Bus 003 Device 002: ID 05ac:8242 Apple, Inc.
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 006: ID 19d2:0031 ONDA Communication S.p.A.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
</pre>
<p>Our device is the 19d2:0031 ONDA Communication S.p.A. I found that after some tries, pluggin and unplugging the USB stick and checking the differences printed by lsmod. Notice that if the usb_storage module is active the product id will be different, while the manufacturer id will be the same. The output of lsmod is not very informative and helping to understand the nature of the usb device, unfortunately. </p>
<p>Now we can load the usbserial device specifying the vendor id and product id of the USB stick.</p>
<pre>
luigi@hal9000:~$ sudo modprobe usbserial vendor=0x19d2 product=0x0031
</pre>
<p>If there are no error displayed, and the command ends silently, then it means that the module is loaded successfully.</p>
<h4>Configuring the 3G connection</h4>
<p>Clicking on the NetworkManager we should now be able to see the New Mobile BroadBand (GSM) Connection:<br />
<img id="image405" src="http://en.newinstance.it/wp-content/uploads/2010/01/new-mobile-broadband.png" alt="new-mobile-broadband.png" /> </p>
<p>Click on it to configure. It will result in a Wizard dialog that will ask you information to "Set up a Mobile Broadband Connection". In my case I filled following information:<br />
Country: I selected "Britain (UK)" ... I took some time to find it: I was looking for "UK" or "United Kingdom" or "England" or some other name...<br />
Select your provider form a list: 3<br />
Select your plan: Internet<br />
Confirm.</p>
<p>After that, the connection is ready and you should be able to browse the internet. Clicking on the NetworkManager tray icon you'll see that you are now connected through it:<br />
<img id="image406" src="http://en.newinstance.it/wp-content/uploads/2010/01/3-internet.png" alt="3-internet.png" /></p>
<h4>Improving the connection reliability</h4>
<p>The connection is quite bad through the 3 network. Sometime you keep being connected but internet stops working. I thought to DNS problem so I set up OpenDNS following <a href="https://store.opendns.com/setup/operatingsystem/ubuntu">these instructions</a>, and now it seems more reliable and usable, but still sometime the connection stops working, and you need to unplug the stick and restart from with the procedure described above.<br />
I don't know why... if somebody knows, please leave a comment.</p>
<p>I'd like to buy a 3G USB Stick or 3G modem; if somebody have some hints on a good supported device, and stable, (easier to set up), please leave a comment.
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2009/08/28/linux-ram-disks/" rel="bookmark" class="crp_title">Linux RAM Disks</a></li>
<li><a href="http://en.newinstance.it/2005/12/23/ubuntu-on-my-laptop/" rel="bookmark" class="crp_title">Ubuntu on my laptop</a></li>
<li><a href="http://en.newinstance.it/2009/05/13/making-eclipse-javahl-working-recompiling-subversion-from-the-sources/" rel="bookmark" class="crp_title">Making Eclipse JavaHL working, recompiling Subversion from the sources</a></li>
<li><a href="http://en.newinstance.it/2009/08/31/skype-21047-beta-released-and-amd64-packages-available/" rel="bookmark" class="crp_title">Skype 2.1.0.47 beta released, and  amd64 packages available!</a></li>
<li><a href="http://en.newinstance.it/2005/12/07/aboutabout/" rel="bookmark" class="crp_title">About:About</a></li>
</ul>
</div>
<div class="shr-publisher-404"></div>
<p><!-- Start Shareaholic LikeButtonSetBottom Automatic -->
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2010%2F01%2F08%2F3g-usb-stick-on-ubuntu%2F' data-shr_title='3G+USB+Stick+on+Ubuntu'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2010%2F01%2F08%2F3g-usb-stick-on-ubuntu%2F' data-shr_title='3G+USB+Stick+on+Ubuntu'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2010%2F01%2F08%2F3g-usb-stick-on-ubuntu%2F' data-shr_title='3G+USB+Stick+on+Ubuntu'></a></div>
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<p><!-- End Shareaholic LikeButtonSetBottom Automatic --></p>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2010/01/08/3g-usb-stick-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ipod touch with Linux</title>
		<link>http://en.newinstance.it/2009/12/03/ipod-touch-with-linux/</link>
		<comments>http://en.newinstance.it/2009/12/03/ipod-touch-with-linux/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 12:11:58 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[iPod]]></category>
		<category><![CDATA[OSX]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/2009/12/03/ipod-touch-with-linux/</guid>
		<description><![CDATA[Yesterday night I tried to connect the iPod to Linux. I tried some programs but none was working decently; but the good news is that you don't really need any special program "made for iPod" to do this. For the guys who do not know about iTunes and iPod/iPhone foolishnesses, the problem is that when [...]]]></description>
			<content:encoded><![CDATA[<p><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic -->Yesterday night I tried to connect the iPod to Linux. I tried some programs but none was working decently; but the good news is that you don't really need any special program "made for iPod" to do this. </p>
<p>For the guys who do not know about iTunes and iPod/iPhone foolishnesses, the problem is that when connecting trough USB they are not exposing the filesystem as usb disk. The second problem is how iTunes memorizes files: they get renamed in 4 char lenght filenames under a 3 char lenght folder... so you have files like: </p>
<pre>
iTunes_Control/Music/F26/UBFF.mp3
iTunes_Control/Music/F26/UEBM.mp3
iTunes_Control/Music/F26/UIPQ.mp3
iTunes_Control/Music/F26/UWCJ.mp3
iTunes_Control/Music/F26/WGOH.m4a
</pre>
<p>As result of this, if you have songs belonging to different authors and coming from different albums, but you was keeping in the same folder to listen together... you can't specify to iTunes to play a folder as a playlist, because folder and filenames gets chaotically "reorganized" when imported in iTunes. iTunes, then uses id3 tags to expose views to the user, grouping by author or album title, etc.</p>
<p>To connect to iPod filesystem with Linux, you need to <a href="http://en.wikipedia.org/wiki/Jailbreak_%28iPhone_OS%29">jailbreak</a> the iPhone or the iPod touch, and have OpenSSH running on it. It is not very difficult, but, afaik it's the only way to access remotely to the iPod filesystem, through network (wifi).</p>
<p>Once done that, you need to mount the filesystem using ssh protocol; this can be done with sshfs, which is the ssh protocol support for <a href="http://fuse.sourceforge.net/">FUSE</a> (Filesystem in USEr space) which allows you to mount several type of local or remote filesystem without needing root privileges.</p>
<pre>
$ sudo apt-get install sshfs
</pre>
<p>Then I created a folder under my ~/Music folder where to mount my iPod media</p>
<pre>
$ mkdir ~/Music/iPod
</pre>
<p>At last I made a bash script to mount and unmount the iPod media to the folder I just created. This is the content:</p>
<pre class="brush: bash">
#! /bin/bash

case "$1" in
mount)
        echo -n foobar | sshfs root@Luigi-R-Viggianos-iPod.local:/private/var/mobile/Media/ ~/Music/iPod -o password_stdin
	;;

umount)
        fusermount -u -z ~/Music/iPod
	;;

*)
	echo "Usage: `basename $0` {mount|umount}"
	exit 1
	;;
esac
</pre>
<p>In the above script "foobar" is the password to use to ssh-connect as root on my ipod. Unfortunately I did not succeed in using public key authentication, even modifying the sshd configuration on the ipod, I do not know why... So I had to specify the password in the script.<br />
The Luigi-R-Viggianos-iPod.local is the hostname used by my iPod. Alternatively you can use the ip address, but when you change network you will need to update the script; the hostname usually gets recognized in different WIFIs and mapped to corresponding ip address.</p>
<p>To get the ip address of the iPod connected to WIFI, there are some programs downloadable on the apple store, one is called, with much of fantasy, "IP Address". To know the hostname of the ipod, just connect to it through ssh, and you will see that displayed on the bash prompt line, in my case: "Luigi-R-Viggianos-iPod:~ root#", unfortunately apples likes to have weird unix system on their devices so you don't have basic commands like 'hostname' or files like /etc/hostname to check... did I already said that I hate OSX...? </p>
<p>At this point what I do is just running the script:</p>
<pre>
$ ipod mount
or
$ ipod umount
</pre>
<p>to mount or unmount the iPod to ~/Music/iPod folder. The iPod needs to be attached to a power source, the laptop trough usb or to a docking station, otherwise it will disable the WIFI connection when it goes on stand by; but the file access is fully wireless.</p>
<p>To play files, you need to launch Amarok or Rhytmbox and import the folder ~/Music/iPod. I use Rhytmbox and it indexes the folder. When the folder is mounted I can see the music on my iPod, and when it is not, the music just disappears.</p>
<p>If you want to export an album of MP3 files from the iPod, you just need to select files from Rhytmbox and drag and drop into Nautilus (filesystem browser). But you will have the weird names for the MP3 files set by iTunes. To batch rename the files you can install and use id3ren, which lets you to customize (-template option) how the filename should be renamed (using album title, song title, author, etc):</p>
<pre>
$ sudo apt-get install id3ren
$ id3ren -template='%a - %t - %s.mp3' *
</pre>
<p>If you like to backup the music on your iPod just use rsync or cp. But I don't know how to import new songs in the weird filesystem-format used by iTunes... For this, possibly the easiest solution is to use iTunes on Windows or OSX using VMWare, until Apple does not decide to release <a href="http://www.petitiononline.com/itmslin/petition.html">iTunes on Linux</a>. </p>
<p>Have fun.
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2009/08/28/linux-ram-disks/" rel="bookmark" class="crp_title">Linux RAM Disks</a></li>
<li><a href="http://en.newinstance.it/2007/08/09/multiple-ip-on-a-single-network-interface/" rel="bookmark" class="crp_title">Multiple IP on a single network interface</a></li>
<li><a href="http://en.newinstance.it/2010/01/08/3g-usb-stick-on-ubuntu/" rel="bookmark" class="crp_title">3G USB Stick on Ubuntu</a></li>
<li><a href="http://en.newinstance.it/2009/11/26/karmic-and-luks-usb-drive-encryption-made-almost-easy/" rel="bookmark" class="crp_title">Karmic and Luks: USB drive encryption made (almost) easy</a></li>
<li><a href="http://en.newinstance.it/2009/09/03/macbook-international-keyboard-and-linux/" rel="bookmark" class="crp_title">MacBook International Keyboard and Linux</a></li>
</ul>
</div>
<div class="shr-publisher-400"></div>
<p><!-- Start Shareaholic LikeButtonSetBottom Automatic -->
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2009%2F12%2F03%2Fipod-touch-with-linux%2F' data-shr_title='Ipod+touch+with+Linux'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2009%2F12%2F03%2Fipod-touch-with-linux%2F' data-shr_title='Ipod+touch+with+Linux'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2009%2F12%2F03%2Fipod-touch-with-linux%2F' data-shr_title='Ipod+touch+with+Linux'></a></div>
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<p><!-- End Shareaholic LikeButtonSetBottom Automatic --></p>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2009/12/03/ipod-touch-with-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Karmic and Luks: USB drive encryption made (almost) easy</title>
		<link>http://en.newinstance.it/2009/11/26/karmic-and-luks-usb-drive-encryption-made-almost-easy/</link>
		<comments>http://en.newinstance.it/2009/11/26/karmic-and-luks-usb-drive-encryption-made-almost-easy/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 16:34:48 +0000</pubDate>
		<dc:creator>Luigi</dc:creator>
				<category><![CDATA[Lifehacks]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Encription]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Karmic]]></category>
		<category><![CDATA[Lucks]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[USB]]></category>

		<guid isPermaLink="false">http://en.newinstance.it/2009/11/26/karmic-and-luks-usb-drive-encryption-made-almost-easy/</guid>
		<description><![CDATA[I discovered today that in Karmic there is an option to format encrypted usb disks. But first of all you need to install the support for this feature; from the terminal: $ sudo apt-get install cryptsetup When you plug in your USB disk, and mount it, you'll see an icon on your desktop. Right-clicking on [...]]]></description>
			<content:encoded><![CDATA[<p><!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic -->I discovered today that in Karmic there is an option to format encrypted usb disks.<br />
But first of all you need to install the support for this feature; from the terminal:</p>
<pre>
$ sudo apt-get install cryptsetup
</pre>
<p>When you plug in your USB disk, and mount it, you'll see an icon on your desktop. Right-clicking on it and selecting "Format" will let you to specify an encrypted filesystem type:</p>
<p><img id="image396" src="http://en.newinstance.it/wp-content/uploads/2009/11/Screenshot-1.png" alt="Format USB drive" /></p>
<p><img id="image394" src="http://en.newinstance.it/wp-content/uploads/2009/11/Screenshot-Format%20SanDisk%20Cruzer%20Pattern%20%288-0%20GB%29.png" alt="Screenshot-Format SanDisk Cruzer Pattern (8.0 GB)" /></p>
<p>Clicking to "Format" button will ask you to type the password for the encrypted volume: </p>
<p><img id="image395" src="http://en.newinstance.it/wp-content/uploads/2009/11/Screenshot-Enter%20Passphrase.png" alt="Screenshot-Enter Passphrase" /></p>
<p>At this point the format will proceed and, after, the USB drive will be mounted with an open lock icon:<br />
<img id="image397" src="http://en.newinstance.it/wp-content/uploads/2009/11/mounted-encrypted.png" alt="encrypted volume mounted " /></p>
<p>If you want to change the password it should be possible from the "Disk Utility" (System>Administration>Disk Utility, or type "palimpsest" at the command line), but <a href="https://bugs.launchpad.net/ubuntu/+source/gnome-disk-utility/+bug/484904">it seems to be buggy</a>, as it always gives me "Incorrect Passphrase. Try again".</p>
<p>Command line tools always helps in those cases.</p>
<p>First step, add the new password for the volume:</p>
<pre>
$ sudo cryptsetup luksAddKey /dev/sdb
[sudo] password for luigi: (my system admin password)
Enter any LUKS passphrase: (any password registered to this volume)
key slot 0 unlocked.
Enter new passphrase for key slot: (the new password)
Verify passphrase: (the new password again)
Command successful.
</pre>
<p>Second step, dump all the key password for the volume: </p>
<pre>
$ sudo cryptsetup luksDump /dev/sdb
LUKS header information for /dev/sdb

Version:       	1
Cipher name:   	aes
Cipher mode:   	cbc-essiv:sha256
Hash spec:     	sha1
Payload offset:	1032
MK bits:       	128
MK digest:     	c8 97 18 80 0c 0a 86 ed 8f 3c 85 03 e1 de de 2d 68 ed 70 a0
MK salt:       	16 ae 5b 05 2c 2b 02 d5 af 0d 71 d7 08 ba 51 fd
               	9f 98 cd 11 52 e8 14 44 71 4f 84 53 99 02 97 c7
MK iterations: 	10
UUID:          	c4ada688-3cae-4053-a1c6-781614ad683f

Key Slot 0: ENABLED
	Iterations:         	447466
	Salt:               	63 30 36 1f 87 83 f6 73 75 e9 a2 b2 dc f1 30 4c
	                      	09 67 1d e7 82 71 35 6c c4 df ce 10 0e 3b 42 2f
	Key material offset:	8
	AF stripes:            	4000
Key Slot 1: ENABLED
	Iterations:         	451004
	Salt:               	55 c4 d0 4f e9 24 d8 c0 2a cb b2 7f 09 a1 80 98
	                      	4f 4d 1a 5e 6f 1c d5 ad c2 30 a3 02 15 9d 1e bd
	Key material offset:	136
	AF stripes:            	4000
Key Slot 2: DISABLED
Key Slot 3: DISABLED
Key Slot 4: DISABLED
Key Slot 5: DISABLED
Key Slot 6: DISABLED
Key Slot 7: DISABLED
</pre>
<p>Third step: remove the old password:</p>
<pre>
$ sudo cryptsetup luksKillSlot /dev/sdb 0
Enter any remaining LUKS passphrase:
key slot 1 verified.
Command successful.
</pre>
<p>Unmount the volume and try the new password. It should work.</p>
<p>Of course it would be better to have the "change password" feature in the context menu of the mounted volume, or at least having the feature working in the "Disk Utility" program. But, you know, it's Linux, and you need to hack it sometimes :) </p>
<p>It seems also that LUKS is supported on Windows, see <a href="http://www.freeotfe.org/">here</a>.</p>
<p>Another good, portable, free, and more complete solution to encrypted filesystems is the great <a href="http://www.truecrypt.org/">TrueCrypt</a>.</p>
<p>For the experts, a useful command-line HOWTO on using LUKS: <a href="http://ubuntuforums.org/showthread.php?t=404346">http://ubuntuforums.org/showthread.php?t=404346</a>.
<div id="crp_related">
<h4>Related Posts:</h4>
<ul>
<li><a href="http://en.newinstance.it/2008/07/17/secure-storage-in-ganymede-is-forced-paranoia/" rel="bookmark" class="crp_title">&#8220;Secure Storage&#8221; in Ganymede is forced paranoia</a></li>
<li><a href="http://en.newinstance.it/2009/08/28/linux-ram-disks/" rel="bookmark" class="crp_title">Linux RAM Disks</a></li>
<li><a href="http://en.newinstance.it/2008/06/27/the-passwords-hell/" rel="bookmark" class="crp_title">The passwords hell</a></li>
<li><a href="http://en.newinstance.it/2009/11/25/suspendresume-in-karmic-2/" rel="bookmark" class="crp_title">Suspend/Resume in Karmic /2</a></li>
<li><a href="http://en.newinstance.it/2005/07/28/bug-parade/" rel="bookmark" class="crp_title">Bug Parade</a></li>
</ul>
</div>
<div class="shr-publisher-393"></div>
<p><!-- Start Shareaholic LikeButtonSetBottom Automatic -->
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2009%2F11%2F26%2Fkarmic-and-luks-usb-drive-encryption-made-almost-easy%2F' data-shr_title='Karmic+and+Luks%3A+USB+drive+encryption+made+%28almost%29+easy'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2009%2F11%2F26%2Fkarmic-and-luks-usb-drive-encryption-made-almost-easy%2F' data-shr_title='Karmic+and+Luks%3A+USB+drive+encryption+made+%28almost%29+easy'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fen.newinstance.it%2F2009%2F11%2F26%2Fkarmic-and-luks-usb-drive-encryption-made-almost-easy%2F' data-shr_title='Karmic+and+Luks%3A+USB+drive+encryption+made+%28almost%29+easy'></a></div>
<div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>
<p><!-- End Shareaholic LikeButtonSetBottom Automatic --></p>
]]></content:encoded>
			<wfw:commentRss>http://en.newinstance.it/2009/11/26/karmic-and-luks-usb-drive-encryption-made-almost-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

