<?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>The Road to Elysium &#187; Linux</title>
	<atom:link href="http://jorge.fbarr.net/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://jorge.fbarr.net</link>
	<description>The life of a geek, father and husband</description>
	<lastBuildDate>Wed, 16 Nov 2011 14:43:15 +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>Wallpaper concatenation with ImageMagick</title>
		<link>http://jorge.fbarr.net/2011/04/03/wallpaper-concatenation-with-imagemagick/</link>
		<comments>http://jorge.fbarr.net/2011/04/03/wallpaper-concatenation-with-imagemagick/#comments</comments>
		<pubDate>Sun, 03 Apr 2011 19:03:46 +0000</pubDate>
		<dc:creator>jorge</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[concatenate]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[side by side]]></category>
		<category><![CDATA[wallpaper]]></category>
		<category><![CDATA[xmonad]]></category>

		<guid isPermaLink="false">http://jorge.fbarr.net/?p=1194</guid>
		<description><![CDATA[At both home and work, I have a dual monitor setup. Having recently discovered the windowmanager xmonad, I&#8217;ve found a setup that enables me to use Xinerama, and at the same time have the functionality that a separate X screen-setup would provide me. But with Xinerama comes the Twin View-setting that the Nvidia drivers provide, [...]]]></description>
			<content:encoded><![CDATA[<p>At both home and work, I have a dual monitor setup. Having recently discovered the windowmanager <a href="http://www.xmonad.org">xmonad</a>, I&#8217;ve found a setup that enables me to use Xinerama, and at the same time have the functionality that a separate X screen-setup would provide me. But with Xinerama comes the Twin View-setting that the Nvidia drivers provide, which &#8220;merges&#8221; both monitors, and gives me one large virtual desktop. Finding wallpaper for it can be a bit tricky, especially the ones that are designed for one specific resolution. But this is where <b>ImageMagick</b> comes into play. What I want is two images, with different resolutions, side by side. You could of course use something else, like <b>GIMP</b>, but you&#8217;d have to align things manually, and why risk it when a simple command can do the trick?</p>
<p>First install <b>ImageMagick</b>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #c20cb9; font-weight: bold;">install</span> ImageMagick</pre></div></div>

<p>..then do the magic:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">montage wallpaper_1920x1080.jpg wallpaper_1680x1050.jpg <span style="color: #660033;">-tile</span> 2x1 <span style="color: #660033;">-geometry</span> <span style="color: #ff0000;">&quot;1920x1080+0+0&quot;</span> <span style="color: #660033;">-mode</span> concatenate final_wallpaper.jpg</pre></div></div>

<p>By setting <b>geometry</b> to <b>&#8220;1920&#215;1080+0+0&#8243;</b>, we set the preferred size of one of the tiles to be that, thus resizing images that are too large.</p>
<p>The results? Well, for me, this was it:</p>
<p><a href="http://jorge.fbarr.net/wp-content/uploads/2011/04/xmonad_wallpaper.jpg"><img src="http://jorge.fbarr.net/wp-content/uploads/2011/04/xmonad_wallpaper-300x90.jpg" alt="" title="xmonad_wallpaper" width="300" height="90" class="aligncenter size-medium wp-image-1199" /></a></p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://jorge.fbarr.net/2011/04/03/wallpaper-concatenation-with-imagemagick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making your BASH history more efficient</title>
		<link>http://jorge.fbarr.net/2011/03/24/making-your-bash-history-more-efficient/</link>
		<comments>http://jorge.fbarr.net/2011/03/24/making-your-bash-history-more-efficient/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 11:36:37 +0000</pubDate>
		<dc:creator>jorge</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[erasedups]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[global]]></category>
		<category><![CDATA[histcontrol]]></category>
		<category><![CDATA[histignore]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[histtimeformat]]></category>
		<category><![CDATA[ignoreboth]]></category>
		<category><![CDATA[ignoredups]]></category>
		<category><![CDATA[ignorespace]]></category>
		<category><![CDATA[profile]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://jorge.fbarr.net/?p=1179</guid>
		<description><![CDATA[There are several ways to improve how you troubleshoot a system. One of the things I consider to be important is the BASH history. Here you can see what commands were executed. Though as default you can&#8217;t see when, or ignore certain things, like duplicate commands. Here&#8217;s a little guide to show you how. Table [...]]]></description>
			<content:encoded><![CDATA[<p>There are several ways to improve how you troubleshoot a system. One of the things I consider to be important is the BASH history. Here you can see what commands were executed. Though as default you can&#8217;t see when, or ignore certain things, like duplicate commands. Here&#8217;s a little guide to show you how.</p>
<div id='toc' class='post-1179'><div id='toc_title'>Table of contents</div>
<ul><li><a href="#HISTTIMEFORMAT">HISTTIMEFORMAT</a></li>
<li><a href="#HISTCONTROL">HISTCONTROL</a>
<ul><li><a href="#ignoredups">ignoredups</a></li>
<li><a href="#erasedups">erasedups</a></li>
<li><a href="#ignorespace">ignorespace</a></li>
<li><a href="#ignoredups-and-ignorespace">ignoredups and ignorespace</a></li></ul></li>
<li><a href="#HISTIGNORE">HISTIGNORE</a></li>
<li><a href="#HISTSIZE">HISTSIZE</a></li>
</ul>
</div>
<p><b>Notice</b>: To make these features a permanent solution, open up your <b>/etc/profile</b>, and add the lines to the bottom of the file. Save and close it. The next time you log in the functions should be working as you specified them!</p>
<h3 id='HISTTIMEFORMAT'>HISTTIMEFORMAT</h3>
<p>A simple yet effective little trick is to change the format of the output the command <b>history</b> spits out. In my case it comes to good use when troubleshooting a system, wanting to find out if errors in the system log match up with commands executed at that time. To enable the feature in your current terminal, run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTTIMEFORMAT</span>=<span style="color: #ff0000;">&quot;%h %d %H:%M:%S&gt; &quot;</span></pre></div></div>

<p>So the output from <b>history</b> that was looking like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>jorge<span style="color: #000000; font-weight: bold;">@</span>ashitaka ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #7a0874; font-weight: bold;">history</span>
 <span style="color: #000000;">1</span>  <span style="color: #c20cb9; font-weight: bold;">ls</span>
 <span style="color: #000000;">2</span>  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Hello&quot;</span>
 <span style="color: #000000;">3</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span>
...</pre></div></div>

<p>Now looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>jorge<span style="color: #000000; font-weight: bold;">@</span>ashitaka ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #7a0874; font-weight: bold;">history</span>
 <span style="color: #000000;">1</span>  Mar <span style="color: #000000;">24</span> <span style="color: #000000;">12</span>:<span style="color: #000000;">53</span>:<span style="color: #000000;">35</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">ls</span>
 <span style="color: #000000;">2</span>  Mar <span style="color: #000000;">24</span> <span style="color: #000000;">12</span>:<span style="color: #000000;">53</span>:<span style="color: #000000;">36</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Hello&quot;</span>
 <span style="color: #000000;">3</span>  Mar <span style="color: #000000;">24</span> <span style="color: #000000;">12</span>:<span style="color: #000000;">53</span>:<span style="color: #000000;">37</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">pwd</span>
...</pre></div></div>

<h3 id='HISTCONTROL'>HISTCONTROL</h3>
<p>The variable <b>HISTCONTROL</b> can do a few things, like ignoring duplicates if they are in a row and erasing duplicates. The difference here is that by ignoring duplicates, it will remove duplicates only if they are in a row, while erasing duplicates, it will remove previous commands from the history file. Let&#8217;s give an example:</p>
<h4 id='ignoredups'>ignoredups</h4>
<p>First run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTCONTROL</span>=ignoredups</pre></div></div>

<p>The output that looked like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>jorge<span style="color: #000000; font-weight: bold;">@</span>ashitaka ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #7a0874; font-weight: bold;">history</span>
 <span style="color: #000000;">1</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span>
 <span style="color: #000000;">2</span>  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Hello&quot;</span>
 <span style="color: #000000;">3</span>  <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span>
 <span style="color: #000000;">4</span>  <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-h</span>
 <span style="color: #000000;">5</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span>
 <span style="color: #000000;">6</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span>
...</pre></div></div>

<p>Will now look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>jorge<span style="color: #000000; font-weight: bold;">@</span>ashitaka ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #7a0874; font-weight: bold;">history</span>
 <span style="color: #000000;">1</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span>
 <span style="color: #000000;">2</span>  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Hello&quot;</span>
 <span style="color: #000000;">3</span>  <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span>
 <span style="color: #000000;">4</span>  <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-h</span>
 <span style="color: #000000;">5</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span>
...</pre></div></div>

<h4 id='erasedups'>erasedups</h4>
<p><b>erasedups</b> means that if you executed the same command previously, that entry will be erased, substituted by the newly run command. Generally not recommended though. If you still wish to do so, it can be done by running the following line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTCONTROL</span>=erasedups</pre></div></div>

<p>So a <b>history</b> that looked like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>jorge<span style="color: #000000; font-weight: bold;">@</span>ashitaka ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #7a0874; font-weight: bold;">history</span>
 <span style="color: #000000;">1</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span>
 <span style="color: #000000;">2</span>  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Hello&quot;</span>
 <span style="color: #000000;">3</span>  <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span>
 <span style="color: #000000;">4</span>  <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-h</span>
 <span style="color: #000000;">5</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span>
...</pre></div></div>

<p>After the export, will now look like this when we run the command <b>pwd</b> again:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>jorge<span style="color: #000000; font-weight: bold;">@</span>ashitaka ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #7a0874; font-weight: bold;">history</span>
 <span style="color: #000000;">1</span>  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Hello&quot;</span>
 <span style="color: #000000;">2</span>  <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span>
 <span style="color: #000000;">3</span>  <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-h</span>
 <span style="color: #000000;">4</span>  <span style="color: #7a0874; font-weight: bold;">pwd</span>
...</pre></div></div>

<h4 id='ignorespace'>ignorespace</h4>
<p>If you want full control over which commands will be stored by history and which will not be stored, set <b>HISTCONTROL</b> to ignorespace:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTCONTROL</span>=ignorespace</pre></div></div>

<p>So out of these commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-la</span>
 <span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-h</span>
<span style="color: #c20cb9; font-weight: bold;">ps</span></pre></div></div>

<p>Only these will show:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>jorge<span style="color: #000000; font-weight: bold;">@</span>ashitaka ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #7a0874; font-weight: bold;">history</span>
 <span style="color: #000000;">1</span>  <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-la</span>
 <span style="color: #000000;">2</span>  <span style="color: #c20cb9; font-weight: bold;">ps</span>
...</pre></div></div>

<h4 id='ignoredups-and-ignorespace'>ignoredups and ignorespace</h4>
<p>To use both of these features, simply use:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTCONTROL</span>=ignoreboth</pre></div></div>

<h3 id='HISTIGNORE'>HISTIGNORE</h3>
<p>The variable <b>HISTIGNORE</b> will help you tell <b>history</b> which commands to ignore, meaning that they shouldn&#8217;t be picked up by the BASH history. For instance, let&#8217;s say that I want the commands <b>df</b> and <b>free</b> to be ignored, including optional flags:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTIGNORE</span>=<span style="color: #ff0000;">&quot;df*:free*&quot;</span></pre></div></div>

<h3 id='HISTSIZE'>HISTSIZE</h3>
<p>Setting how many lines of history to store is always a nice feature:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTSIZE</span>=<span style="color: #000000;">10000</span></pre></div></div>

<p>Thanks to <b>pkhamre</b> for suggesting to include <b>HISTCONTROL</b> and <b>HISTIGNORE</b>. ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://jorge.fbarr.net/2011/03/24/making-your-bash-history-more-efficient/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introduction to screen</title>
		<link>http://jorge.fbarr.net/2011/02/09/introduction-to-screen/</link>
		<comments>http://jorge.fbarr.net/2011/02/09/introduction-to-screen/#comments</comments>
		<pubDate>Wed, 09 Feb 2011 13:49:32 +0000</pubDate>
		<dc:creator>jorge</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[split]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[window]]></category>

		<guid isPermaLink="false">http://jorge.fbarr.net/?p=1162</guid>
		<description><![CDATA[screen is to many people an unknown program and tool, but for those who do know it, consider it to be an essential one. This is because of the functionality of the program, that can end up saving you a lot of work and time. You can run any number of console-based applications &#8211; editors, [...]]]></description>
			<content:encoded><![CDATA[<p><b>screen</b> is to many people an unknown program and tool, but for those who do know it, consider it to be an essential one. This is because of the functionality of the program, that can end up saving you a lot of work and time. You can run any number of console-based applications &#8211; editors, mail clients, browsers, in just a single terminal. Sometimes it&#8217;s useful to have a terminal for each console-based application you&#8217;re running, but sometimes not, obviously.</p>
<p>For my part, the main reason for me using <b>screen</b> is the ability to decouple the terminal emulator from the running programs. In other words, I can detach and reattach things as I please. To put it in simple terms; it&#8217;s a tool for session management. Let&#8217;s go ahead with an example.</p>
<p>You are logged into your remote server via SSH, working on some configuration file, when suddenly you lose connection to it. Almost done, having spent hours, you grab your laptop in anger and smack the closest unfortunate person next to you. Not only have you lost valuable work, but soon enough people with shields, guns and helmets will come after you. Imagine, with <b>screen</b>, it could have been avoided! Had you been editing the configuration file within a <b>screen</b>, and should you have lost connection, the editing would still be in an active <b>screen</b> session, allowing you to detach and reattach the <b>screen</b> to your terminal once you logged back in.</p>
<p>Let&#8217;s have a closer look at what we can do with <b>screen</b>.</p>
<div id='toc' class='post-1162'><div id='toc_title'>Table of contents</div>
<ul><li><a href="#Starting-screen">Starting screen</a></li>
<li><a href="#Using-screen">Using screen</a></li>
<li><a href="#Sharing-a-screen">Sharing a screen</a></li>
<li><a href="#Multiple-applications-in-one-session">Multiple applications in one session</a></li>
<li><a href="#Navigating-within-the-screens">Navigating within the screens</a></li>
<li><a href="#Clearing-destroyed-sessions">Clearing destroyed sessions</a></li>
<li><a href="#Splitting-windows">Splitting windows</a></li>
</ul>
</div>
<h3 id='Starting-screen'>Starting screen</h3>
<p>Fire up a terminal and just type:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">screen</span></pre></div></div>

<p>If installed, you probably won&#8217;t get a message about having entered a <b>screen</b> session, but I&#8217;m sure you have. Everything functions just like a normal shell, except for a few special characters. <b>screen</b> uses the command <b>Ctrl-A</b> as a signal to <b>screen</b> instead of the shell.</p>
<p>To see the help page for <b>screen</b>, press <b>Ctrl-A</b>, then press <b>?</b>. In other words:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">^A ?</pre></div></div>

<p>As you can see here, <b>Ctrl</b> is represented by the <b>^</b>, <b>A</b> is <b>a</b>, and well, you get the rest.</p>
<p>To start a program directly into <b>screen</b>, just type <b>screen
<program></b>. Let&#8217;s use <b>top</b> as an example.</p>
<h3 id='Using-screen'>Using screen</h3>
<p>Fire it up:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">screen</span> top</pre></div></div>

<p><b>top</b> is started in the usual way, just inside a <b>screen</b> session. To detach the session and let it run in the background, use <b>Ctrl-a d</b>:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Ctrl-a d (^a d)</pre></div></div>

<p>Once your session is detached you can list the available <b>screen</b> sessions by using:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-ls</span></pre></div></div>

<p>The output you&#8217;ll see will be something along the lines of:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>jorge<span style="color: #000000; font-weight: bold;">@</span><span style="color: #c20cb9; font-weight: bold;">cat</span> ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-ls</span>
There is a <span style="color: #c20cb9; font-weight: bold;">screen</span> on:
    <span style="color: #000000;">26606</span>.pts-<span style="color: #000000;">39</span>.cat    <span style="color: #7a0874; font-weight: bold;">&#40;</span>Detached<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000;">1</span> Socket <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>screen<span style="color: #000000; font-weight: bold;">/</span>S-jorge.</pre></div></div>

<p>To reattach the <b>screen</b> session to your current terminal, you can use <b>screen -dr <session ID></b>. In this case it would be:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-dr</span> <span style="color: #000000;">26606</span></pre></div></div>

<p>This brings up an interesting question though. How can you differentiate what multiple <b>screen</b> sessions are holding, if you can only read the process number? Easy &#8211; you give each <b>screen</b> session a name. For most people, a name is easier to remember than a number. So, we start a new <b>screen</b>, in which we&#8217;re going to open an IRC client called <b>irssi</b>. Let&#8217;s use <b>-S</b>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-S</span> irc irssi</pre></div></div>

<p>Entering <b>irssi</b>, we detach the session with <b>Ctrl-a d</b>, and do a <b>screen -ls</b> to see what we&#8217;ve got now:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>jorge<span style="color: #000000; font-weight: bold;">@</span><span style="color: #c20cb9; font-weight: bold;">cat</span> ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-ls</span>
There are screens on:
    <span style="color: #000000;">26606</span>.pts-<span style="color: #000000;">39</span>.cat    <span style="color: #7a0874; font-weight: bold;">&#40;</span>Detached<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #000000;">26702</span>.irc    <span style="color: #7a0874; font-weight: bold;">&#40;</span>Detached<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000;">2</span> Sockets <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>screen<span style="color: #000000; font-weight: bold;">/</span>S-jorge.</pre></div></div>

<p>There you clearly see the name <b>irc</b> that we entered earlier, and the session holding <b>top</b>, which we started up even before being able to specify a name. Pretty handy, huh? This is particularly hand if you&#8217;re only going to have one application in the <b>screen</b> session. If more, it would probably be better to have a more descriptive session name of some sort.</p>
<h3 id='Sharing-a-screen'>Sharing a screen</h3>
<p>If someone else, or you, has created a <b>screen</b>, and would like to share with someone else what you&#8217;re doing, then <b>screen -x</b> does the trick. Simply use:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-x</span> irc</pre></div></div>

<p>..if <b>irc</b> is the name of the session, or the process ID. Once done, you should have enabled multi display mode. And if you find out that the <b>screen</b> you have taken part of doesn&#8217;t match up to the size of your own terminal, simply use:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Ctrl-a F (^a F)</pre></div></div>

<p>..to force it to match up to the dimensions.</p>
<h3 id='Multiple-applications-in-one-session'>Multiple applications in one session</h3>
<p>Now I&#8217;ve introduced you to the basics of using <b>screen</b>. Let&#8217;s proceed onto using <b>screen</b> with multiple applications. Detach and resume the <b>screen</b> session called <b>irc</b> with:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-dr</span> irc</pre></div></div>

<p>Once resumed, press <b>Ctrl-a Ctrl-c</b> (^a ^c) to create a new <b>screen</b> session from within your current one. This will start up a new shell. Let&#8217;s start a new application &#8211; <b>nano</b>. Simply type:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">nano</span></pre></div></div>

<p>And the application will start. Let&#8217;s give this internal <b>screen</b> session a name. Press <b>Ctrl-a Shift-a</b> (^a A). Notice that <b>a</b> is different from <b>A</b> (capital A). </p>
<p>You will be asked:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Set window's title to:</pre></div></div>

<p>Type <b>editor</b> and press enter.</p>
<h3 id='Navigating-within-the-screens'>Navigating within the screens</h3>
<p>You can switch between the various applications by pressing <b>Ctrl-a 0-9</b>, so:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Ctrl-a 0</pre></div></div>

<p>will go to the first application, <b>irssi</b> in this case. Other ways of navigating is by using</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Ctrl-c Ctrl-n (next window)</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Ctrl-c Ctrl-p (previous window)</pre></div></div>

<p>To list up all of the shells available on the <b>screen</b>, type:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Ctrl-a &quot; (^a &quot;)</pre></div></div>

<p>You&#8217;ll get a list that looks something like:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Num Name                                                                   Flags
&nbsp;
  0 irssi                                                                      $
  1 nano                                                                       $</pre></div></div>

<p>Use your Up/Down arrows and press enter to select a shell to go to.</p>
<h3 id='Clearing-destroyed-sessions'>Clearing destroyed sessions</h3>
<p>If you have a <b>screen</b> session up, and the machine it is on goes down, then the <b>screen</b> session is probably destroyed. You can see the available screens by typing <b>screen -ls</b>. To get rid of destroyed screens, type:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-wipe</span></pre></div></div>

<h3 id='Splitting-windows'>Splitting windows</h3>
<p>Another interesting thing many people have asked about is how you can split a window in a <b>screen</b> session. A useful feature if you say would like to have two documents open, or you have to do some work while having a conversation on IRC. To split the window, type:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Ctrl-a Shift-s (^a S)</pre></div></div>

<p>You will see that your <b>screen</b> is now split, and you have a new area on the bottom. To move to this area, type:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Ctrl-a TAB (^a TAB)</pre></div></div>

<p>Now that you&#8217;re in the new area, there&#8217;s not much to do but to create another shell, so do it with:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Ctrl-a Ctrl-c (^a ^c)</pre></div></div>

<p>From here you can start another application in the regular way, and give the internal shell a name of its own.</p>
<p>If you want to close the application in the bottom area, do it as normal, then to kill the area, press:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Ctrl-a Shift-x (^a X)</pre></div></div>

<p>If you want to kill every area EXCEPT then one you&#8217;re currently in, you can use:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Ctrl-a Shift-q (^a Q)</pre></div></div>

<p>And that&#8217;s pretty much it when it comes to <b>screen</b>. For more information, check out the command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">man</span> <span style="color: #c20cb9; font-weight: bold;">screen</span></pre></div></div>

<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://jorge.fbarr.net/2011/02/09/introduction-to-screen/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Rapidshare Linux Script Revisited</title>
		<link>http://jorge.fbarr.net/2010/09/16/rapidshare-linux-script-revisited/</link>
		<comments>http://jorge.fbarr.net/2010/09/16/rapidshare-linux-script-revisited/#comments</comments>
		<pubDate>Thu, 16 Sep 2010 10:53:40 +0000</pubDate>
		<dc:creator>jorge</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[aria2]]></category>
		<category><![CDATA[aria2c]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cookie]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[premium]]></category>
		<category><![CDATA[rapidshare]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[wget]]></category>

		<guid isPermaLink="false">http://jorge.fbarr.net/?p=1115</guid>
		<description><![CDATA[Update: I just added a new variable in the script, DAYS, which specifies how many days the cookie you create is valid for. Update 2011-09-13: Seems Rapidshare have been tampering with their API, which made the cookie-generating script useless. I basically changed the getaccountdetails_v1 with getaccountdetails, and the script is working fine now. I&#8217;ve fixed [...]]]></description>
			<content:encoded><![CDATA[<p><b>Update</b>: I just added a new variable in the script, <b>DAYS</b>, which specifies how many days the cookie you create is valid for.<br />
<b>Update 2011-09-13</b>: Seems Rapidshare have been tampering with their API, which made the cookie-generating script useless. I basically changed the <b>getaccountdetails_v1</b> with <b>getaccountdetails</b>, and the script is working fine now. I&#8217;ve fixed the script below to reflect this.</p>
<p>The code to get the Rapidshare-cookie in my previous post about this subject, <a href="http://jorge.fbarr.net/2010/03/26/rapidshare-linux-script/">Rapidshare Linux Script</a>, unfortunately doesn&#8217;t work anymore. It seems that Rapidshare has moved from using  <a href="https://ssl.rapidshare.com/premzone.html">https://ssl.rapidshare.com/premzone.html</a> to <a href="https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi">https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi</a>, so things just don&#8217;t work as they used to. This is for people with a premium account.</p>
<p>However, there&#8217;s a solution. First off, log in to your Rapidshare-account, go to <b>Settings</b> and make sure to check the box named <b>Direct downloads, requested files are saved without redirection via RapidShare</b>.</p>
<p>To grab the cookie you need, place the piece of code below in a file, save it, do a <b>chmod +x</b> on it. Just remember to replace <b>MyUserName</b> and <b>MyPassword</b> with your username and password before you run the script:</p>
<p><b>Note</b>: The script requires <b>curl</b> to be installed.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Script to get your Rapidshare-cookie, nom nom</span>
<span style="color: #666666; font-style: italic;"># Jorge Enrique Barrera</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Variables you can change</span>
<span style="color: #007800;">USERNAME</span>=<span style="color: #ff0000;">&quot;MyUserName&quot;</span> <span style="color: #666666; font-style: italic;"># Username to your Rapidshare premium-account</span>
<span style="color: #007800;">PASSWORD</span>=<span style="color: #ff0000;">&quot;MyPassword&quot;</span> <span style="color: #666666; font-style: italic;"># Password</span>
<span style="color: #007800;">COOKIEJAR</span>=<span style="color: #ff0000;">&quot;/home/jorge/.cookies&quot;</span> <span style="color: #666666; font-style: italic;"># Where the cookies are to be placed</span>
<span style="color: #007800;">DAYS</span>=<span style="color: #ff0000;">&quot;30&quot;</span> <span style="color: #666666; font-style: italic;"># The number of days the cookie is valid for</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">## Do not change anything below here ##</span>
&nbsp;
<span style="color: #007800;">DATA</span>=<span style="color: #ff0000;">&quot;sub=getaccountdetails&amp;withcookie=1&amp;type=prem&amp;login=<span style="color: #007800;">$USERNAME</span>&amp;password=<span style="color: #007800;">$PASSWORD</span>&quot;</span>
<span style="color: #007800;">COOKIE_STRING</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>curl <span style="color: #660033;">-s</span> <span style="color: #660033;">--data</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DATA</span>&quot;</span> <span style="color: #ff0000;">&quot;https://api.rapidshare.com/cgi-bin/rsapi.cgi&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> cookie <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-c</span> <span style="color: #000000;">8</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">COOKIE</span>=<span style="color: #ff0000;">&quot;.rapidshare.com TRUE / FALSE <span style="color: #007800;">$(($(date +%s)</span>+24*60*60*<span style="color: #007800;">$DAYS</span>)) enc <span style="color: #007800;">$COOKIE_STRING</span>&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$COOKIEJAR</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Creating the directory <span style="color: #007800;">$COOKIEJAR</span>.&quot;</span>
        <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$COOKIEJAR</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Done.&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$COOKIE</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #ff0000;">' '</span> <span style="color: #ff0000;">'\t'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$COOKIEJAR</span><span style="color: #000000; font-weight: bold;">/</span>rapidshare</pre></div></div>

<p>Now that the cookie is present, you can proceed by downloading the files you want. Which way you do that, is up to you.</p>
<p>Either way I will paste two scripts, one with <b>wget</b> and the other one with <b>aria2</b>, and you can then make your pick. Just place the URL of the files you want to download in <b>/home/jorge/Downloads/.url</b>, one in each line:</p>
<p><i><b>wget</b></i></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">LIST</span>=<span style="color: #ff0000;">&quot;/home/jorge/Downloads/.url&quot;</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Downloads
<span style="color: #000000; font-weight: bold;">for</span> url <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$LIST</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">--load-cookies</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>jorge<span style="color: #000000; font-weight: bold;">/</span>.cookies<span style="color: #000000; font-weight: bold;">/</span>rapidshare <span style="color: #007800;">$url</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>Save this file as <b>wrsd.sh</b> and make it executable by doing a:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x wrsd.sh</pre></div></div>

<p><i><b>aria2</i></b></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Downloads
aria2c <span style="color: #660033;">-j</span> <span style="color: #000000;">5</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">--load-cookies</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>jorge<span style="color: #000000; font-weight: bold;">/</span>.cookies<span style="color: #000000; font-weight: bold;">/</span>rapidshare <span style="color: #660033;">-i</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>jorge<span style="color: #000000; font-weight: bold;">/</span>Downloads<span style="color: #000000; font-weight: bold;">/</span>.url</pre></div></div>

<p>Enjoy. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://jorge.fbarr.net/2010/09/16/rapidshare-linux-script-revisited/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Spotify for Linux rpm</title>
		<link>http://jorge.fbarr.net/2010/09/08/spotify-for-linux-rpm/</link>
		<comments>http://jorge.fbarr.net/2010/09/08/spotify-for-linux-rpm/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 09:00:32 +0000</pubDate>
		<dc:creator>jorge</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[deb]]></category>
		<category><![CDATA[preview]]></category>
		<category><![CDATA[rpm]]></category>
		<category><![CDATA[spotify]]></category>

		<guid isPermaLink="false">http://jorge.fbarr.net/?p=1075</guid>
		<description><![CDATA[I&#8217;ve taken the liberty of converting the &#8220;Spotify for Linux&#8221;-files located at http://www.spotify.com/no/download/previews/ from .deb to .rpm. For now it can only be used if you have a Premium account. To install it on Fedora 13, do the following: su - rpm --nodeps -Uvh http://jorge.fbarr.net/files/spotify-client-gnome-support.noarch.rpm http://jorge.fbarr.net/files/spotify-client-qt.i386.rpm And that&#8217;s it. Now you can run Spotify as [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve taken the liberty of converting the &#8220;Spotify for Linux&#8221;-files located at <a href="http://www.spotify.com/no/download/previews/">http://www.spotify.com/no/download/previews/</a> from <b>.deb</b> to <b>.rpm</b>. For now it can only be used if you have a Premium account.</p>
<p>To install it on Fedora 13, do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">su</span> -
rpm <span style="color: #660033;">--nodeps</span> <span style="color: #660033;">-Uvh</span> http:<span style="color: #000000; font-weight: bold;">//</span>jorge.fbarr.net<span style="color: #000000; font-weight: bold;">/</span>files<span style="color: #000000; font-weight: bold;">/</span>spotify-client-gnome-support.noarch.rpm http:<span style="color: #000000; font-weight: bold;">//</span>jorge.fbarr.net<span style="color: #000000; font-weight: bold;">/</span>files<span style="color: #000000; font-weight: bold;">/</span>spotify-client-qt.i386.rpm</pre></div></div>

<p>And that&#8217;s it. Now you can run Spotify as a Linux-application instead of through Wine. :)</p>
<p><a href="http://jorge.fbarr.net/wp-content/uploads/2010/09/spotify_for_linux.png"><img src="http://jorge.fbarr.net/wp-content/uploads/2010/09/spotify_for_linux-300x168.png" alt="" title="spotify_for_linux" width="300" height="168" class="aligncenter size-medium wp-image-1085" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://jorge.fbarr.net/2010/09/08/spotify-for-linux-rpm/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

