<?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>Lâmôlabs</title>
	<atom:link href="http://www.lamolabs.org/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lamolabs.org/blog</link>
	<description>Lame Oh Labs .... Linux &#38; Tech! Is there anything else?</description>
	<lastBuildDate>Thu, 23 May 2013 22:00:33 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>How does a process deal with user credentials?</title>
		<link>http://www.lamolabs.org/blog/10715/how-does-a-process-deal-with-user-credentials/</link>
		<comments>http://www.lamolabs.org/blog/10715/how-does-a-process-deal-with-user-credentials/#comments</comments>
		<pubDate>Wed, 22 May 2013 00:17:51 +0000</pubDate>
		<dc:creator>slmingol</dc:creator>
				<category><![CDATA[tutorials]]></category>
		<category><![CDATA[credentials]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.lamolabs.org/blog/?p=10715</guid>
		<description><![CDATA[Background

<p>A question came up on the Stack Exchange site Unix &#38; Linux in which I wrote up a pretty good answer, that describes some of the mechanics of how a process deals with its user credentials, so I&#8217;m adding my writeup to the blog.</p>

<p>It really comes down to what makes up a process in Unix. [...]<div class="wherego_related"> </div>]]></description>
				<content:encoded><![CDATA[<h3>Background</h3>

<p>A <a href="http://unix.stackexchange.com/questions/76634/what-is-a-process-gid-and-what-purpose-does-it-serve/76649#76649">question</a> came up on the <a href="http://unix.stackexchange.com">Stack Exchange site Unix &amp; Linux</a> in which I wrote up a pretty good answer, that describes some of the mechanics of how a process deals with its user credentials, so I&#8217;m adding my writeup to the blog.</p>

<p>It really comes down to what makes up a process in Unix. A process can come into existence in one of 2 ways. Either via the <code>fork()</code> function or through one of the <code>exec()</code> functions in C. </p>

<h5 class="line"><code>fork()</code></h5>

<p><code>fork()</code> basically just makes a copy of the current process, but assigns it a new process ID (PID). It&#8217;s a child of the original process. You can see this relationship in the output of @ps@:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p107156"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p10715code6"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ps</span> axjf
 PPID   PID  PGID   SID TTY      TPGID STAT   UID   TIME COMMAND
    1  5255  1964  1964 ?           <span style="color: #660033;">-1</span> Sl     500   0:39 gnome-terminal
 5255  5259  1964  1964 ?           <span style="color: #660033;">-1</span> S      500   0:00  \_ gnome-pty-helper
 5255 18422 18422 18422 pts<span style="color: #000000; font-weight: bold;">/</span>1    18422 Ss+    500   0:01  \_ <span style="color: #c20cb9; font-weight: bold;">bash</span>
 5255 30473 30473 30473 pts<span style="color: #000000; font-weight: bold;">/</span>4    30473 Ss+    500   0:00  \_ <span style="color: #c20cb9; font-weight: bold;">bash</span>
30473   782   782 30473 pts<span style="color: #000000; font-weight: bold;">/</span>4    30473 Sl     500   1:14  <span style="color: #000000; font-weight: bold;">|</span>   \_ evince s.pdf</pre></td></tr></table></div>




<p>Here you can see that <code>gnome-terminal</code> is the parent process (PID = 5255) and that <code>bash</code> is it&#8217;s child (PID = 18422, <span class="caps">PPID </span>= 5255). </p>

<p>When a process forks from its parent, it &#8220;inherits&#8221; certain things, such as copies of all the file descriptors that the parent currently has for open files and the parent&#8217;s user and group IDs. </p>

<p><b style="color:red">NOTE1:</b> <em style="color:gray">PPID = Parent Process <span class="caps">ID.</span></em><br />
<b style="color:red">NOTE2:</b> <em style="color:gray">The last 2 are what identify what file and group permissions this process will have when accessing the file system.</em></p>

<p>So if a process just inherits its user and group ID from its parent, then why isn&#8217;t everything just owned by root or a single user? This is where <code>exec()</code> comes in.</p>

<h5 class="line"><code>exec()</code> Part #1</h5>

<p><span id="more-10715"></span></p>

<p>The <code>exec()</code> family of functions, specifically <code>execve()</code>, &#8220;replace&#8221; a current process image with a new process image. The terminology &#8220;process image&#8221; is really just a file, i.e. an executable on disk. So this is how a bash script can execute a program such as <code>/usr/bin/time</code>. </p>

<p>So what about the user ID and group ID? Well to understand that let&#8217;s first discuss the concept of &#8220;Persona&#8221;.</p>

<h5 class="line">Persona</h5>

<p>At any time, each process has an effective user <span class="caps">ID, </span>an effective group <span class="caps">ID, </span>and a set of supplementary group IDs. These IDs determine the privileges of the process. They are collectively called the [persona of the process]<sup class="footnote"><a href="#fn1">1</a></sup>, because they determine &#8220;who it is&#8221; for purposes of access control.</p>

<h5 class="line"><code>exec()</code> Part #2</h5>

<p>So in addition to being able to swap out the &#8220;process image&#8221;, <code>exec()</code> can also change the user &amp; group IDs from the original &#8220;real&#8221; ones to &#8220;effective&#8221; ones.</p>

<h5 class="line">An example</h5>

<p>For this demonstration I&#8217;m going to show you what happens when we start out in a shell as our default <span class="caps">UID</span>/GID, and then spawn a child shell using one of my supplementary <span class="caps">GID</span>s, making it the child shell&#8217;s effective <span class="caps">GID.</span></p>

<p>To perform this I&#8217;m going to make use of the unix command <code>newgrp</code>. <code>newgrp</code> allows you to spawn a new shell passing it the supplementary group that I&#8217;d like to make my effective <span class="caps">GID.</span></p>

<p>For starters:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p107157"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p10715code7"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">id</span> <span style="color: #660033;">-a</span>
<span style="color: #007800;">uid</span>=500<span style="color: #7a0874; font-weight: bold;">&#40;</span>saml<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">gid</span>=501<span style="color: #7a0874; font-weight: bold;">&#40;</span>saml<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">groups</span>=<span style="color: #000000;">501</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>saml<span style="color: #7a0874; font-weight: bold;">&#41;</span>,<span style="color: #000000;">502</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>vboxusers<span style="color: #7a0874; font-weight: bold;">&#41;</span>,<span style="color: #000000;">503</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>jupiter<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></td></tr></table></div>




<p>We can see that this shell is currently configured with my default <span class="caps">UID</span>/GID of <code>saml</code> &amp; <code>saml</code>. Touching some files shows that this is the case as well:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p107158"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p10715code8"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">touch</span> afile1
$ <span style="color: #c20cb9; font-weight: bold;">touch</span> afile2
$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span>
total 0
<span style="color: #660033;">-rw-rw-r--</span> 1 saml saml 0 May 21 23:47 afile1
<span style="color: #660033;">-rw-rw-r--</span> <span style="color: #000000;">1</span> saml saml <span style="color: #000000;">0</span> May <span style="color: #000000;">21</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">47</span> afile2</pre></td></tr></table></div>




<p>Now we make our supplementary group <code>jupiter</code> the effective <span class="caps">GID</span>:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p107159"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p10715code9"><pre class="bash" style="font-family:monospace;">$ newgrp jupiter
$ <span style="color: #c20cb9; font-weight: bold;">id</span> <span style="color: #660033;">-a</span>
<span style="color: #007800;">uid</span>=500<span style="color: #7a0874; font-weight: bold;">&#40;</span>saml<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">gid</span>=503<span style="color: #7a0874; font-weight: bold;">&#40;</span>jupiter<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">groups</span>=<span style="color: #000000;">501</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>saml<span style="color: #7a0874; font-weight: bold;">&#41;</span>,<span style="color: #000000;">502</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>vboxusers<span style="color: #7a0874; font-weight: bold;">&#41;</span>,<span style="color: #000000;">503</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>jupiter<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></td></tr></table></div>




<p>Now if we touch some files:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1071510"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p10715code10"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">touch</span> afile3
$ <span style="color: #c20cb9; font-weight: bold;">touch</span> afile4
$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span>
total 0
<span style="color: #660033;">-rw-rw-r--</span> 1 saml saml    0 May 21 23:47 afile1
<span style="color: #660033;">-rw-rw-r--</span> 1 saml saml    0 May 21 23:47 afile2
<span style="color: #660033;">-rw-r--r--</span> 1 saml jupiter 0 May 21 23:49 afile3
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> saml jupiter <span style="color: #000000;">0</span> May <span style="color: #000000;">21</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">49</span> afile4</pre></td></tr></table></div>




<p>We see that the shell&#8217;s effective <span class="caps">GID </span>is <code>jupiter</code>, so any interactions with the disk result in files being created with <code>jupiter</code> rather than my normal default group of <code>saml</code>.</p>

<h5 class="line">References</h5>


<ul>
<li><a href="http://linux.die.net/man/2/fork">fork() man page</a></li>
<li><a href="http://linux.die.net/man/3/exec">exec() man page</a></li>
<li><a href="http://linux.die.net/man/2/execve">execve() man page</a></li>
<li><a href="http://linux.die.net/man/7/credentials">credentials man page</a></li>
<li><a href="http://linux.die.net/man/1/newgrp">newgrp man page</a></li>
<li><a href="http://www.delorie.com/gnu/docs/glibc/libc.html">The <span class="caps">GNU</span> C Library</a></li>
<li><a href="http://www.delorie.com/gnu/docs/glibc/libc_567.html">The <span class="caps">GNU</span> C Library &#8211; 26.4 Creating a Process</a></li>
<li><a href="http://www.delorie.com/gnu/docs/glibc/libc_568.html">The <span class="caps">GNU</span> C Library &#8211; 26.5 Executing a File</a></li>
<li><a href="http://unix.stackexchange.com/questions/18198/gid-current-primary-supplementary-effective-and-real-group-ids"><span class="caps">GID, </span>current, primary, supplementary, effective and real group IDs?</a></li>
</ul>

<div class="wherego_related"> </div>]]></content:encoded>
			<wfw:commentRss>http://www.lamolabs.org/blog/10715/how-does-a-process-deal-with-user-credentials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How is my password stored in Linux?</title>
		<link>http://www.lamolabs.org/blog/10670/how-is-my-password-stored-in-linux/</link>
		<comments>http://www.lamolabs.org/blog/10670/how-is-my-password-stored-in-linux/#comments</comments>
		<pubDate>Sun, 19 May 2013 00:50:39 +0000</pubDate>
		<dc:creator>slmingol</dc:creator>
				<category><![CDATA[tutorials]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[passwords]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SHA-512]]></category>
		<category><![CDATA[shadow]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.lamolabs.org/blog/?p=10670</guid>
		<description><![CDATA[Background

<p>People that use Linux on a daily basis probably are completely oblivious to the actual mechanisms being used to store their passwords safely and securely on a given Linux system. Oh they might guess that their password is stored in the /etc/passwd file (they&#8217;d be wrong by the way) but most probably never even gave [...]<div class="wherego_related"> </div>]]></description>
				<content:encoded><![CDATA[<h3>Background</h3>

<p>People that use Linux on a daily basis probably are completely oblivious to the actual mechanisms being used to store their passwords safely and securely on a given Linux system. Oh they might guess that their password is stored in the <code>/etc/passwd</code> file (they&#8217;d be wrong by the way) but most probably never even gave it a passing thought. So I thought I&#8217;d take the opportunity to shed some light on how Linux systems &#8220;stash&#8221; your precious password away.</p>

<h3>Solution</h3>

<p>So if your password isn&#8217;t actually stored in the <code>/etc/passwd</code> file then where does it get stored?</p>

<p>Answer: the <code>/etc/shadow</code> file. </p>

<p>This file is where all the keys to each user&#8217;s account are kept for safe keeping. Obviously only the root user can peer inside this file so all the commands we&#8217;ll be dealing with in this post, it should be assumed that you&#8217;ll need to either be root, or use <code>sudo</code> to run.</p>

<h5 class="line"><code>/etc/shadow</code></h5>

<p>A typical <code>/etc/shadow</code> entry:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1067017"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p10670code17"><pre class="text" style="font-family:monospace;">root:$6$bbmDJwcZHy5bgEDz$kFO.W/T7nUqcszZWl5RglxoDDAcDxevWpHVfN3v3f.Cx2ZeMcn5PX23VvnnkgtNWZf8hYtqsL0pPkZqyj50NY/:14362:0:33333:7:::</pre></td></tr></table></div>




<p><strong style="color:red">NOTE1:</strong> <em style="color:gray">Don&#8217;t get too excited, the above isn&#8217;t really my entry, I made this one up.</em><br />
<strong style="color:red">NOTE2:</strong> <em style="color:gray">Each field is separated by a colon (:) &amp; we&#8217;re only concerned with the first two columns!</em></p>

<h5 class="line">dissecting the hash</h5>

<p>The key pieces to notice in that line of what looks like gibberish is the following:</p>


<ul>
<li>The first column, <code>root</code> is the user whom this entry belongs to from the <code>/etc/passwd</code> file.</li>
<li>The second column, <code>$6$.....</code> is essentially the user&#8217;s hashed password.</li>
</ul>



<p>Taking the second column apart further you should start to notice that&#8217;s it&#8217;s not complete gibberish after all. </p>

<p>For example:</p>


<ul>
<li>the first couple of characters, <code>$6$</code>, is a mark that tells the system what type of hashing was used to hash the password. </li>
<li>The text between the next set of dollar signs, <code>$bbmDJwcZHy5bgEDz$</code>, is the actual salt that was used to hash your password. </li>
<li>Everything else after, is your <b>password</b> + <b>salt</b> hashed using whatever hash function was specified at the beginning, <b>$6$</b>, in our example here.</li>
</ul>



<p>Specifically if you look at the man page for the crypt command, <a href="http://man7.org/linux/man-pages/man3/crypt.3.html"><code>man 3 crypt</code></a> there is a section that discusses what the <code>$6$</code> notation means:</p>

<blockquote><p>So $5$salt$encrypted is an <span class="caps">SHA</span>-256 encoded password and $6$salt$encrypted is an <span class="caps">SHA</span>-512 encoded one.</p></blockquote>

<p><strong style="color:red">NOTE:</strong> So in our case the <b>password</b> + <b>salt</b> is being hashed using the <a href="https://en.wikipedia.org/wiki/SHA-2"><span class="caps">SHA</span>-512</a> scheme.</p>

<h5 class="line">design details</h5>

<p><span id="more-10670"></span></p>

<p>For reference purposes here&#8217;s the rest of that excerpt from the crypt man page:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1067018"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code" id="p10670code18"><pre class="text" style="font-family:monospace;">If salt is a character string starting with the characters &quot;$id$&quot; followed by a
string terminated by &quot;$&quot;:
&nbsp;
       $id$salt$encrypted
&nbsp;
then instead of using the DES machine, id identifies the encryption method used
and this then determines how the rest of the password string is interpreted.
The following values of id are supported:
&nbsp;
       ID  | Method
       ─────────────────────────────────────────────────────────
       1   | MD5
       2a  | Blowfish (not in mainline glibc; added in some
           | Linux distributions)
       5   | SHA-256 (since glibc 2.7)
       6   | SHA-512 (since glibc 2.7)
&nbsp;
So $5$salt$encrypted is an SHA-256 encoded password and $6$salt$encrypted is an
SHA-512 encoded one.
&nbsp;
&quot;salt&quot; stands for the up to 16 characters following &quot;$id$&quot; in the salt. The
encrypted part of the password string is  the actual computed password. The
size of this string is fixed:
&nbsp;
MD5     | 22 characters
SHA-256 | 43 characters
SHA-512 | 86 characters
&nbsp;
The characters in &quot;salt&quot; and &quot;encrypted&quot; are drawn from the set [a–zA–Z0–9./].
In the MD5 and SHA implementations the entire key is significant (instead of
only the first 8 bytes in DES).</pre></td></tr></table></div>




<h5 class="line">Now what?</h5>

<p>So by now you&#8217;re probably saying to yourself. <span class="caps">OK, </span>big deal, my password is hashed with some salt and stored in <code>/etc/shadow</code>. What else?</p>

<h5 class="line">generating the hash manually using <code>mkpasswd</code></h5>

<p>For starters you can generate the <code>$6$...</code> string yourself manually using the <code>mkpasswd</code> command:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1067019"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p10670code19"><pre class="bash" style="font-family:monospace;">$ mkpasswd <span style="color: #660033;">-m</span> sha-512 password saltsalt
$<span style="color: #000000;">6</span><span style="color: #007800;">$saltsalt</span><span style="color: #007800;">$qFmFH</span>.bQmmtXzyBY0s9v7Oicd2z4XSIecDzlB5KiA2<span style="color: #000000; font-weight: bold;">/</span>jctKu9YterLp8wwnSq.qc.eoxqOmSuNp2xS0ktL3nh<span style="color: #000000; font-weight: bold;">/</span></pre></td></tr></table></div>




<p>In the above command we&#8217;re specifying that we want to use the <span class="caps">SHA</span>-512 hash, our password is the string <b>password</b> and our salt string is <b>saltsalt</b>. As before we can see in our resulting string the following components:</p>


<ul>
<li>$6$ &#8211; which hash function was used</li>
<li>saltsalt &#8211; the string &#8220;saltsalt&#8221; was used</li>
<li>qFmFH.bQmmtXzyBY0s9v7Oicd2z4XSIecDzlB5KiA2/jctKu9YterLp8wwnSq.qc.eoxqOmSuNp2xS0ktL3nh/ &#8211; <b>password</b> + <b>salt</b> hashed using <span class="caps">SHA</span>-512</li>
</ul>



<h5 class="line">generating the hash manually using Python</h5>

<p>I came across the following nice Python one-liner that effectively does the same thing as the <code>mkpasswd</code> command discussed above.</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1067020"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p10670code20"><pre class="python" style="font-family:monospace;">$ python -c <span style="color: #483d8b;">&quot;import crypt, getpass, pwd; <span style="color: #000099; font-weight: bold;">\</span>
             print crypt.crypt('password', '<span style="color: #000099; font-weight: bold;">\$</span>6<span style="color: #000099; font-weight: bold;">\$</span>saltsalt<span style="color: #000099; font-weight: bold;">\$</span>')&quot;</span>
$<span style="color: #ff4500;">6</span>$saltsalt$qFmFH.<span style="color: black;">bQmmtXzyBY0s9v7Oicd2z4XSIecDzlB5KiA2</span>/jctKu9YterLp8wwnSq.<span style="color: black;">qc</span>.<span style="color: black;">eoxqOmSuNp2xS0ktL3nh</span>/</pre></td></tr></table></div>




<h5 class="line">generating the hash manually using Perl</h5>


<div class="wp_codebox"><table width="100%" ><tr id="p1067021"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p10670code21"><pre class="perl" style="font-family:monospace;">$ perl <span style="color: #339933;">-</span>e <span style="color: #ff0000;">'print crypt(&quot;password&quot;,&quot;\$6\$saltsalt\$&quot;) . &quot;\n&quot;'</span>
<span style="color: #0000ff;">$6</span><span style="color: #0000ff;">$saltsalt</span><span style="color: #0000ff;">$qFmFH</span><span style="color: #339933;">.</span>bQmmtXzyBY0s9v7Oicd2z4XSIecDzlB5KiA2<span style="color: #339933;">/</span>jctKu9YterLp8wwnSq<span style="color: #339933;">.</span>qc<span style="color: #339933;">.</span>eoxqOmSuNp2xS0ktL3nh<span style="color: #339933;">/</span></pre></td></tr></table></div>




<h5 class="line"><code>authconfig</code></h5>

<p>Before I wrap up I thought I&#8217;d mention one final tool <code>authconfig</code> that&#8217;s included on Red Hat distros such as Fedora, CentOS, and <span class="caps">RHEL.</span> This tool allows you to change what hash algorithm is being used on a particular system. The command to change a system to use <span class="caps">SHA</span>-512 would be as follows:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1067022"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p10670code22"><pre class="bash" style="font-family:monospace;">authconfig –passalgo sha512 –update</pre></td></tr></table></div>




<p>See the man page for <code>authconfig</code> for more details.</p>

<h5 class="line">conclusions</h5>

<p>And with that you are now a little more in the know as to how Linux systems take your password and store them in the <code>/etc/shadow</code> file.</p>

<h3>References</h3>

<h5>links</h5>


<ul>
<li><a href="http://man7.org/linux/man-pages/man3/crypt.3.html">crypt man page</a></li>
<li><a href="http://ubuntuforums.org/showthread.php?t=1169551">Thread: generate hashed password for /etc/shadow &#8211; ubuntuforums.org</a></li>
<li><a href="http://openwall.info/wiki/john/Generating-test-hashes">How to produce test hashes for various formats</a></li>
<li><a href="http://aricgardner.com/commandlinefu/etc-shadow-fu/">Shadow Fu</a></li>
<li><a href="http://stackoverflow.com/questions/5171487/using-ruby-to-generate-sha512-crypt-style-hashes-formatted-for-etc-shadow">Using ruby to generate <span class="caps">SHA512 </span>crypt-style hashes formatted for /etc/shadow?</a></li>
<li><a href="http://sandilands.info/sgordon/calculate-sha-hash-of-linux-password-in-shadow-file">Calculate <span class="caps">SHA</span> Hash of Linux Password in Shadow File</a></li>
</ul>

<div class="wherego_related"> </div>]]></content:encoded>
			<wfw:commentRss>http://www.lamolabs.org/blog/10670/how-is-my-password-stored-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to rsync certain files, exclude the rest, all while ignoring .svn directories?</title>
		<link>http://www.lamolabs.org/blog/10648/how-to-rsync-certain-files-exclude-the-rest-all-while-ignoring-svn-directories/</link>
		<comments>http://www.lamolabs.org/blog/10648/how-to-rsync-certain-files-exclude-the-rest-all-while-ignoring-svn-directories/#comments</comments>
		<pubDate>Fri, 17 May 2013 22:16:12 +0000</pubDate>
		<dc:creator>slmingol</dc:creator>
				<category><![CDATA[tutorials]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.lamolabs.org/blog/?p=10648</guid>
		<description><![CDATA[<p>I came across this question on the Stack Exchange site Unix &#38; Linux. The question interested me so I answered it but thought I&#8217;d cross post it on my blog as well, given I took a pretty significant amount of time to put together a test case and write-up of how the solution ultimately worked.</p>

Problem

<p>I&#8217;m [...]<div class="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.lamolabs.org/blog/74/formatting-text-using-textile/"     class="wherego_title">Formatting text using Textile</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/" rel="nofollow">Where did they go from here?</a></li></ul></div>]]></description>
				<content:encoded><![CDATA[<p>I came across this question on the Stack Exchange site Unix &amp; Linux. The question interested me so I answered it but thought I&#8217;d cross post it on my blog as well, given I took a pretty significant amount of time to put together a test case and write-up of how the solution ultimately worked.</p>

<h3>Problem</h3>

<blockquote><p>I&#8217;m using rsync to copy some files from a share to another.</p>

<p>Recursively, I need to:</p>

<p>- delete files at the destination that are deleted in the origin<br />
- Only sync php and js files<br />
- exclude de rest of file types<br />
- Don&#8217;t delete .svn/ directory in the destination</p>

<p>If I use this:</p>

<p><code>rsync -zavC --delete --include='*.php' --include='*.js' --exclude=&quot;*&quot; /media/datacod/Test/ /home/lucas/Desktop/rsync/</code></p>

<p>Then <code>rsync</code> is not recursive because exclude=&#8221;*&#8221; excludes all files but also folders</p>

<p>If I add <code>--include=&quot;*/&quot;</code> then the <code>.svn/</code> directory gets deleted (it also gets included)</p>

<p>How can I solve this mind blasting dilemma?</p></blockquote>

<h3>Solution</h3>

<p>The solution I ultimately came up with made use of a little known feature, at least to me, called filters. Filters allow you to play games with the includes/excludes by protecting portions based on regular expressions. Read on, I&#8217;ll discuss them further down.</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1064830"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p10648code30"><pre class="bash" style="font-family:monospace;">rsync <span style="color: #660033;">-avzC</span> <span style="color: #660033;">--filter</span>=<span style="color: #ff0000;">'-rs_*/.svn*'</span> <span style="color: #660033;">--include</span>=<span style="color: #ff0000;">&quot;*/&quot;</span> <span style="color: #660033;">--include</span>=<span style="color: #ff0000;">'*.js'</span> <span style="color: #660033;">--include</span>=<span style="color: #ff0000;">'*.php'</span> \
     <span style="color: #660033;">--exclude</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #660033;">--delete</span> dir1<span style="color: #000000; font-weight: bold;">/</span> dir2<span style="color: #000000; font-weight: bold;">/</span></pre></td></tr></table></div>




<h3>test data</h3>

<p>To help determine if my solution was going to work or not I created some sample data so that I could test it out. For starters I wrote a script that would generate the data. Here&#8217;s that script, <code>setup_svn_sample.bash</code>:</p>

<p><span id="more-10648"></span></p>


<div class="wp_codebox"><table width="100%" ><tr id="p1064831"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p10648code31"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># setup .svn dirs</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #c20cb9; font-weight: bold;">dir</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>1,2<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">dir</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span>,<span style="color: #000000;">2</span>,<span style="color: #000000;">3</span>,<span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>.svn
&nbsp;
<span style="color: #666666; font-style: italic;"># fake data under .svn</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> dir1<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">dir</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>1,2,3,4<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>.svn<span style="color: #000000; font-weight: bold;">/</span>origdir
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> dir2<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">dir</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span>,<span style="color: #000000;">2</span>,<span style="color: #000000;">3</span>,<span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>.svn<span style="color: #000000; font-weight: bold;">/</span>keepdir
&nbsp;
<span style="color: #666666; font-style: italic;"># files to not sync</span>
<span style="color: #c20cb9; font-weight: bold;">touch</span> dir1<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">dir</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>1,2,3,4<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span>,<span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># files to sync</span>
<span style="color: #c20cb9; font-weight: bold;">touch</span> dir1<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">dir</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>1,2,3,4<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>file1.js
<span style="color: #c20cb9; font-weight: bold;">touch</span> dir1<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">dir</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span>,<span style="color: #000000;">2</span>,<span style="color: #000000;">3</span>,<span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>file1.php</pre></td></tr></table></div>




<p>Running the above script produces the following directories (<code>dir1</code> &amp; <code>dir2</code>):</p>

<p><b>source dir</b></p>


<div class="wp_codebox"><table width="100%" ><tr id="p1064832"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code" id="p10648code32"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">tree</span> <span style="color: #660033;">-a</span> dir1
dir1
<span style="color: #000000; font-weight: bold;">|</span>-- dir1
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file1
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file1.js
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file1.php
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file2
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">`</span>-- .svn
<span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">`</span>-- origdir
<span style="color: #000000; font-weight: bold;">|</span>-- dir2
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file1
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file1.js
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file1.php
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file2
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">`</span>-- .svn
<span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">`</span>-- origdir
<span style="color: #000000; font-weight: bold;">|</span>-- dir3
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file1
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file1.js
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file1.php
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file2
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">`</span>-- .svn
<span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">`</span>-- origdir
<span style="color: #000000; font-weight: bold;">`</span>-- dir4
    <span style="color: #000000; font-weight: bold;">|</span>-- file1
    <span style="color: #000000; font-weight: bold;">|</span>-- file1.js
    <span style="color: #000000; font-weight: bold;">|</span>-- file1.php
    <span style="color: #000000; font-weight: bold;">|</span>-- file2
    <span style="color: #000000; font-weight: bold;">`</span>-- .svn
        <span style="color: #000000; font-weight: bold;">`</span>-- origdir</pre></td></tr></table></div>




<p><b>destination dir</b></p>


<div class="wp_codebox"><table width="100%" ><tr id="p1064833"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p10648code33"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">tree</span> <span style="color: #660033;">-a</span> dir2
dir2
<span style="color: #000000; font-weight: bold;">|</span>-- dir1
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">`</span>-- .svn
<span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">`</span>-- keepdir
<span style="color: #000000; font-weight: bold;">|</span>-- dir2
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">`</span>-- .svn
<span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">`</span>-- keepdir
<span style="color: #000000; font-weight: bold;">|</span>-- dir3
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">`</span>-- .svn
<span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">`</span>-- keepdir
<span style="color: #000000; font-weight: bold;">`</span>-- dir4
    <span style="color: #000000; font-weight: bold;">`</span>-- .svn
        <span style="color: #000000; font-weight: bold;">`</span>-- keepdir</pre></td></tr></table></div>




<p>Running the above <code>rsync</code> command which includes the <code>--filter</code> below we can see that it&#8217;s only syncing the files that match the <code>--include</code> patterns:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1064834"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p10648code34"><pre class="bash" style="font-family:monospace;">rsync <span style="color: #660033;">-avzC</span> <span style="color: #660033;">--filter</span>=<span style="color: #ff0000;">'-rs_*/.svn*'</span> <span style="color: #660033;">--include</span>=<span style="color: #ff0000;">&quot;*/&quot;</span> <span style="color: #660033;">--include</span>=<span style="color: #ff0000;">'*.js'</span> <span style="color: #660033;">--include</span>=<span style="color: #ff0000;">'*.php'</span> \
     <span style="color: #660033;">--exclude</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #660033;">--delete</span> dir1<span style="color: #000000; font-weight: bold;">/</span> dir2<span style="color: #000000; font-weight: bold;">/</span>
sending incremental <span style="color: #c20cb9; font-weight: bold;">file</span> list
dir1<span style="color: #000000; font-weight: bold;">/</span>file1.js
dir1<span style="color: #000000; font-weight: bold;">/</span>file1.php
dir2<span style="color: #000000; font-weight: bold;">/</span>file1.js
dir2<span style="color: #000000; font-weight: bold;">/</span>file1.php
dir3<span style="color: #000000; font-weight: bold;">/</span>file1.js
dir3<span style="color: #000000; font-weight: bold;">/</span>file1.php
dir4<span style="color: #000000; font-weight: bold;">/</span>file1.js
dir4<span style="color: #000000; font-weight: bold;">/</span>file1.php
&nbsp;
sent 480 bytes  received 168 bytes  1296.00 bytes<span style="color: #000000; font-weight: bold;">/</span>sec
total <span style="color: #c20cb9; font-weight: bold;">size</span> is <span style="color: #000000;">0</span>  speedup is <span style="color: #000000;">0.00</span></pre></td></tr></table></div>




<p>Resulting <code>dir2</code> afterwards:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1064835"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="p10648code35"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">tree</span> <span style="color: #660033;">-a</span> dir2
dir2
<span style="color: #000000; font-weight: bold;">|</span>-- dir1
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file1.js
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file1.php
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">`</span>-- .svn
<span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">`</span>-- keepdir
<span style="color: #000000; font-weight: bold;">|</span>-- dir2
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file1.js
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file1.php
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">`</span>-- .svn
<span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">`</span>-- keepdir
<span style="color: #000000; font-weight: bold;">|</span>-- dir3
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file1.js
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">|</span>-- file1.php
<span style="color: #000000; font-weight: bold;">|</span>   <span style="color: #000000; font-weight: bold;">`</span>-- .svn
<span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">`</span>-- keepdir
<span style="color: #000000; font-weight: bold;">`</span>-- dir4
    <span style="color: #000000; font-weight: bold;">|</span>-- file1.js
    <span style="color: #000000; font-weight: bold;">|</span>-- file1.php
    <span style="color: #000000; font-weight: bold;">`</span>-- .svn
        <span style="color: #000000; font-weight: bold;">`</span>-- keepdir</pre></td></tr></table></div>




<h3>Why does it work?</h3>

<p>The key piece to this script is to make use of the filters capability of <code>rsync</code>. Filters allow you to remove files from the matched set at various points in the command. So in our case we&#8217;re filtering any files that match the pattern <code>*/.svn*</code>. The modifiers <code>-rs_</code> tell the filter that we want to filter on both the source side as well as the target side.</p>

<p><em>excerpt from the <span class="caps">FILTER NOTES </span>section of rsync&#8217;s man page</em></p>

<blockquote><p>- An <b>s</b> is used to indicate that the rule applies to the sending side. When a rule affects the sending side, it prevents files from  being <br />
transferred. The default is for a rule to affect both sides unless <code>--delete-excluded</code> was specified, in which case default rules become sender-side only.  See also the hide (H) and show (S) rules, which are an alternate way to specify sending-side includes/excludes.</p>

<p>- An <b>r</b>  is used to indicate that the rule applies to the receiving side. When a rule affects the receiving side, it prevents files from being deleted. See the s modifier for more info. See also the protect (P) and risk &#174; rules, which are an alternate way to specify receiver-side includes/excludes.</p></blockquote>

<p>See <a href="http://linux.die.net/man/1/rsync">man rsync</a> for more details.</p>

<h3>Tips for figuring this out (hint using <code>--dry-run</code>)</h3>

<p>While describing how to do this I thought I&#8217;d mention the <code>--dry-run</code> switch to <code>rsync</code>. It&#8217; extremely useful in seeing what will happen without having the <code>rsync</code> actually take place. </p>

<p><b>For Example</b></p>

<p>Using the following command will do a test run and show us the decision logic behind <code>rsync</code>:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1064836"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
</pre></td><td class="code" id="p10648code36"><pre class="bash" style="font-family:monospace;">rsync <span style="color: #660033;">--dry-run</span> <span style="color: #660033;">-avvzC</span> <span style="color: #660033;">--filter</span>=<span style="color: #ff0000;">'-rs_*/.svn*'</span> <span style="color: #660033;">--include</span>=<span style="color: #ff0000;">&quot;*/&quot;</span> \
     <span style="color: #660033;">--include</span>=<span style="color: #ff0000;">'*.js'</span> <span style="color: #660033;">--include</span>=<span style="color: #ff0000;">'*.php'</span> <span style="color: #660033;">--exclude</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #660033;">--delete</span> dir1<span style="color: #000000; font-weight: bold;">/</span> dir2<span style="color: #000000; font-weight: bold;">/</span>
sending incremental <span style="color: #c20cb9; font-weight: bold;">file</span> list
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> showing directory dir3 because of pattern <span style="color: #000000; font-weight: bold;">*/</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> showing directory dir2 because of pattern <span style="color: #000000; font-weight: bold;">*/</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> showing directory dir4 because of pattern <span style="color: #000000; font-weight: bold;">*/</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> showing directory dir1 because of pattern <span style="color: #000000; font-weight: bold;">*/</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> hiding <span style="color: #c20cb9; font-weight: bold;">file</span> dir1<span style="color: #000000; font-weight: bold;">/</span>file1 because of pattern <span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> showing <span style="color: #c20cb9; font-weight: bold;">file</span> dir1<span style="color: #000000; font-weight: bold;">/</span>file1.js because of pattern <span style="color: #000000; font-weight: bold;">*</span>.js
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> hiding <span style="color: #c20cb9; font-weight: bold;">file</span> dir1<span style="color: #000000; font-weight: bold;">/</span>file2 because of pattern <span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> showing <span style="color: #c20cb9; font-weight: bold;">file</span> dir1<span style="color: #000000; font-weight: bold;">/</span>file1.php because of pattern <span style="color: #000000; font-weight: bold;">*</span>.php
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> hiding directory dir1<span style="color: #000000; font-weight: bold;">/</span>.svn because of pattern <span style="color: #000000; font-weight: bold;">*/</span>.svn<span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> hiding <span style="color: #c20cb9; font-weight: bold;">file</span> dir2<span style="color: #000000; font-weight: bold;">/</span>file1 because of pattern <span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> showing <span style="color: #c20cb9; font-weight: bold;">file</span> dir2<span style="color: #000000; font-weight: bold;">/</span>file1.js because of pattern <span style="color: #000000; font-weight: bold;">*</span>.js
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> hiding <span style="color: #c20cb9; font-weight: bold;">file</span> dir2<span style="color: #000000; font-weight: bold;">/</span>file2 because of pattern <span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> showing <span style="color: #c20cb9; font-weight: bold;">file</span> dir2<span style="color: #000000; font-weight: bold;">/</span>file1.php because of pattern <span style="color: #000000; font-weight: bold;">*</span>.php
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> hiding directory dir2<span style="color: #000000; font-weight: bold;">/</span>.svn because of pattern <span style="color: #000000; font-weight: bold;">*/</span>.svn<span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> hiding <span style="color: #c20cb9; font-weight: bold;">file</span> dir3<span style="color: #000000; font-weight: bold;">/</span>file1 because of pattern <span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> showing <span style="color: #c20cb9; font-weight: bold;">file</span> dir3<span style="color: #000000; font-weight: bold;">/</span>file1.js because of pattern <span style="color: #000000; font-weight: bold;">*</span>.js
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> hiding <span style="color: #c20cb9; font-weight: bold;">file</span> dir3<span style="color: #000000; font-weight: bold;">/</span>file2 because of pattern <span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> showing <span style="color: #c20cb9; font-weight: bold;">file</span> dir3<span style="color: #000000; font-weight: bold;">/</span>file1.php because of pattern <span style="color: #000000; font-weight: bold;">*</span>.php
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> hiding directory dir3<span style="color: #000000; font-weight: bold;">/</span>.svn because of pattern <span style="color: #000000; font-weight: bold;">*/</span>.svn<span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> hiding <span style="color: #c20cb9; font-weight: bold;">file</span> dir4<span style="color: #000000; font-weight: bold;">/</span>file1 because of pattern <span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> showing <span style="color: #c20cb9; font-weight: bold;">file</span> dir4<span style="color: #000000; font-weight: bold;">/</span>file1.js because of pattern <span style="color: #000000; font-weight: bold;">*</span>.js
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> hiding <span style="color: #c20cb9; font-weight: bold;">file</span> dir4<span style="color: #000000; font-weight: bold;">/</span>file2 because of pattern <span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> showing <span style="color: #c20cb9; font-weight: bold;">file</span> dir4<span style="color: #000000; font-weight: bold;">/</span>file1.php because of pattern <span style="color: #000000; font-weight: bold;">*</span>.php
<span style="color: #7a0874; font-weight: bold;">&#91;</span>sender<span style="color: #7a0874; font-weight: bold;">&#93;</span> hiding directory dir4<span style="color: #000000; font-weight: bold;">/</span>.svn because of pattern <span style="color: #000000; font-weight: bold;">*/</span>.svn<span style="color: #000000; font-weight: bold;">*</span>
delta-transmission disabled <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #7a0874; font-weight: bold;">local</span> transfer or <span style="color: #660033;">--whole-file</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>generator<span style="color: #7a0874; font-weight: bold;">&#93;</span> risking directory dir3 because of pattern <span style="color: #000000; font-weight: bold;">*/</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>generator<span style="color: #7a0874; font-weight: bold;">&#93;</span> risking directory dir2 because of pattern <span style="color: #000000; font-weight: bold;">*/</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>generator<span style="color: #7a0874; font-weight: bold;">&#93;</span> risking directory dir4 because of pattern <span style="color: #000000; font-weight: bold;">*/</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>generator<span style="color: #7a0874; font-weight: bold;">&#93;</span> risking directory dir1 because of pattern <span style="color: #000000; font-weight: bold;">*/</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>generator<span style="color: #7a0874; font-weight: bold;">&#93;</span> protecting directory dir1<span style="color: #000000; font-weight: bold;">/</span>.svn because of pattern <span style="color: #000000; font-weight: bold;">*/</span>.svn<span style="color: #000000; font-weight: bold;">*</span>
dir1<span style="color: #000000; font-weight: bold;">/</span>file1.js
dir1<span style="color: #000000; font-weight: bold;">/</span>file1.php
<span style="color: #7a0874; font-weight: bold;">&#91;</span>generator<span style="color: #7a0874; font-weight: bold;">&#93;</span> protecting directory dir2<span style="color: #000000; font-weight: bold;">/</span>.svn because of pattern <span style="color: #000000; font-weight: bold;">*/</span>.svn<span style="color: #000000; font-weight: bold;">*</span>
dir2<span style="color: #000000; font-weight: bold;">/</span>file1.js
dir2<span style="color: #000000; font-weight: bold;">/</span>file1.php
<span style="color: #7a0874; font-weight: bold;">&#91;</span>generator<span style="color: #7a0874; font-weight: bold;">&#93;</span> protecting directory dir3<span style="color: #000000; font-weight: bold;">/</span>.svn because of pattern <span style="color: #000000; font-weight: bold;">*/</span>.svn<span style="color: #000000; font-weight: bold;">*</span>
dir3<span style="color: #000000; font-weight: bold;">/</span>file1.js
dir3<span style="color: #000000; font-weight: bold;">/</span>file1.php
<span style="color: #7a0874; font-weight: bold;">&#91;</span>generator<span style="color: #7a0874; font-weight: bold;">&#93;</span> protecting directory dir4<span style="color: #000000; font-weight: bold;">/</span>.svn because of pattern <span style="color: #000000; font-weight: bold;">*/</span>.svn<span style="color: #000000; font-weight: bold;">*</span>
dir4<span style="color: #000000; font-weight: bold;">/</span>file1.js
dir4<span style="color: #000000; font-weight: bold;">/</span>file1.php
total: <span style="color: #007800;">matches</span>=0  <span style="color: #007800;">hash_hits</span>=0  <span style="color: #007800;">false_alarms</span>=0 <span style="color: #007800;">data</span>=0
&nbsp;
sent 231 bytes  received 55 bytes  572.00 bytes<span style="color: #000000; font-weight: bold;">/</span>sec
total <span style="color: #c20cb9; font-weight: bold;">size</span> is <span style="color: #000000;">0</span>  speedup is <span style="color: #000000;">0.00</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>DRY RUN<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></td></tr></table></div>




<p>In the above output you can see that the <code>./svn</code> directories are being protected by our filter rule. Valuable insight for debugging the <code>rsync</code>.</p>


<h3>References</h3>

<p>- <a href="http://unix.stackexchange.com/questions/5451/delete-extraneous-files-from-dest-dir-via-rsync">Delete extraneous files from dest dir via rsync?</a><br />
- <a href="http://www.lamolabs.org/blog/wp-content/uploads/2013/05/svn-test.tar.gz">Above scripts in a tarball</a></p><div class="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.lamolabs.org/blog/74/formatting-text-using-textile/"     class="wherego_title">Formatting text using Textile</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/" rel="nofollow">Where did they go from here?</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.lamolabs.org/blog/10648/how-to-rsync-certain-files-exclude-the-rest-all-while-ignoring-svn-directories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[one-liner]: Dealing with UEFI</title>
		<link>http://www.lamolabs.org/blog/10633/one-liner-dealing-with-uefi/</link>
		<comments>http://www.lamolabs.org/blog/10633/one-liner-dealing-with-uefi/#comments</comments>
		<pubDate>Tue, 14 May 2013 21:31:25 +0000</pubDate>
		<dc:creator>slmingol</dc:creator>
				<category><![CDATA[tips & tricks]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[rhel]]></category>
		<category><![CDATA[UEFI]]></category>

		<guid isPermaLink="false">http://www.lamolabs.org/blog/?p=10633</guid>
		<description><![CDATA[Background

<p>UEFI looks to be a major pain in the @$$, but like it or hate it everyone in the Linux community will need to learn to navigate it.  Here&#8217;s a list of useful UEFI resources that I&#8217;ve come across as I&#8217;ve started to get smarter about how to deal with this beast.</p>

Solution

<p>Wikipedia</p>



Unified Extensible Firmware [...]<div class="wherego_related"> </div>]]></description>
				<content:encoded><![CDATA[<h3>Background</h3>

<p><span class="caps">UEFI </span>looks to be a major pain in the @$$, but like it or hate it everyone in the Linux community will need to learn to navigate it.  Here&#8217;s a list of useful <span class="caps">UEFI </span>resources that I&#8217;ve come across as I&#8217;ve started to get smarter about how to deal with this beast.</p>

<h3>Solution</h3>

<p><b>Wikipedia</b></p>


<ul>
<li><a href="http://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface">Unified Extensible Firmware Interface</a></li>
</ul>



<p><b>Ubuntu Docs</b></p>


<ul>
<li><a href="https://help.ubuntu.com/community/UEFI"><span class="caps">UEFI</span></a></li>
<li><a href="https://help.ubuntu.com/community/UEFIBooting"><span class="caps">UEFIB</span>ooting &#8211; Booting Linux natively on a <span class="caps">UEFI </span>system (without <span class="caps">BIOS CSM</span>) using <span class="caps">GRUB2</span></a></li>
</ul>



<p><b>AskUbuntu</b></p>


<ul>
<li><a href="http://askubuntu.com/questions/236787/install-ubuntu-next-to-windows-8-uefi-dual-boot" title="UEFI dual boot">Install Ubuntu next to Windows 8</a></li>
<li><a href="http://askubuntu.com/questions/221835/installing-ubuntu-on-a-pre-installed-uefi-supported-windows-8-system">Installing Ubuntu on a Pre-Installed <span class="caps">UEFI</span> Supported Windows 8 system</a></li>
</ul>



<p><b>Rodsbooks.com</b></p>


<ul>
<li><a href="http://www.rodsbooks.com/efi-bootloaders/index.html">Managing <span class="caps">EFI</span> Boot Loaders for Linux</a></li>
<li><a href="http://www.rodsbooks.com/efi-bootloaders/grub2.html">Managing <span class="caps">EFI</span> Boot Loaders for Linux: Using <span class="caps">GRUB</span> 2</a></li>
<li><a href="http://www.rodsbooks.com/efi-bootloaders/secureboot.html">Managing <span class="caps">EFI</span> Boot Loaders for Linux: Dealing with Secure Boot</a></li>
</ul>



<p><b>Misc.</b></p>


<ul>
<li><a href="http://linuxriola.wordpress.com/2011/05/08/running-rhel-on-efi-bios-based-system/">Running <span class="caps">RHEL</span> 6 on <span class="caps">EFI BIOS</span>-based system</a></li>
</ul>



<p><strong><span class="caps">NOTE</span>:</strong> For further details regarding my <strong>one-liner</strong> blog posts, check out my <a href="http://www.lamolabs.org/blog/2147/intro-blogs-one-liner-code-block-style-guides/">one-liner style guide primer</a>.</p><div class="wherego_related"> </div>]]></content:encoded>
			<wfw:commentRss>http://www.lamolabs.org/blog/10633/one-liner-dealing-with-uefi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[one-liner]: Debugging Bash Scripts</title>
		<link>http://www.lamolabs.org/blog/10603/one-liner-debugging-bash-scripts/</link>
		<comments>http://www.lamolabs.org/blog/10603/one-liner-debugging-bash-scripts/#comments</comments>
		<pubDate>Fri, 10 May 2013 22:39:34 +0000</pubDate>
		<dc:creator>slmingol</dc:creator>
				<category><![CDATA[tips & tricks]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.lamolabs.org/blog/?p=10603</guid>
		<description><![CDATA[Background

<p>From time to time it&#8217;s useful if you can turn up the debugging messages that come from Bash, when working out either interactive or shell script problems. Here are 2 methods that can help in getting down to the details.</p>

Solution

<p>There are essentially 2 methods.</p>

Method #1: -x method

<p>When writing a shell script you&#8217;ll sometimes want to [...]<div class="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.lamolabs.org/blog/2147/intro-blogs-one-liner-code-block-style-guides/"     class="wherego_title">Intro to my Blog&#8217;s [one-liner] Code Block Style Guides</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/" rel="nofollow">Where did they go from here?</a></li></ul></div>]]></description>
				<content:encoded><![CDATA[<h3>Background</h3>

<p>From time to time it&#8217;s useful if you can turn up the debugging messages that come from Bash, when working out either interactive or shell script problems. Here are 2 methods that can help in getting down to the details.</p>

<h3>Solution</h3>

<p>There are essentially 2 methods.</p>

<h5>Method #1: -x method</h5>

<p>When writing a shell script you&#8217;ll sometimes want to turn on line by line debugging. There&#8217;s basically 2 ways to to this.</p>

<p>Before we get started, suppose we have this sample script, <code>myscript.bash</code>:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1060343"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p10603code43"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;hi&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;bye&quot;</span></pre></td></tr></table></div>




<p>First you can run your script like so:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1060344"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p10603code44"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-x</span> myscript.bash
+ <span style="color: #7a0874; font-weight: bold;">echo</span> hi
hi
+ <span style="color: #7a0874; font-weight: bold;">echo</span> bye
bye</pre></td></tr></table></div>




<p>As an alternative you can add the following line, <code>set -x</code> to the top of our shell script to enable debugging as well:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1060345"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p10603code45"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-x</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;hi&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;bye&quot;</span></pre></td></tr></table></div>





<div class="wp_codebox"><table width="100%" ><tr id="p1060346"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p10603code46"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> .<span style="color: #000000; font-weight: bold;">/</span>myscript.bash
+ <span style="color: #7a0874; font-weight: bold;">echo</span> hi
hi
+ <span style="color: #7a0874; font-weight: bold;">echo</span> bye
bye</pre></td></tr></table></div>




<h5>Method #2: env <span class="caps">SHELLOPTS</span>=xtrace &#8230;</h5>

<p>This approach sets the env. variable <code>SHELLOPTS=xtrace</code> which has the same effect as using <code>bash -x</code>.</p>

<p>For example:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1060347"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p10603code47"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #007800;">SHELLOPTS</span>=xtrace .<span style="color: #000000; font-weight: bold;">/</span>myscript.bash 
+ <span style="color: #7a0874; font-weight: bold;">echo</span> hi
hi
+ <span style="color: #7a0874; font-weight: bold;">echo</span> bye
bye</pre></td></tr></table></div>




<p>You can also use this technique to debug your bash environment (think <code>.bashrc</code> and <code>.bash_profile</code>) like so:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1060348"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p10603code48"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #007800;">SHELLOPTS</span>=xtrace <span style="color: #c20cb9; font-weight: bold;">bash</span>
...
...
+++++ <span style="color: #007800;">line</span>=<span style="color: #ff0000;">'complete -f -X
'</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">'!*.@(zip|[ejw]ar|exe|pk3|wsz|zargo|xpi|sxw|o[tx]t|od[fgpst]|epub|apk)'</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">'
unzip zipinfo'</span>
+++++ <span style="color: #007800;">line</span>=<span style="color: #ff0000;">' unzip zipinfo'</span>
+++++ <span style="color: #007800;">list</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">${list[@]}</span>&quot;</span> <span style="color: #007800;">$line</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
+++++ <span style="color: #c20cb9; font-weight: bold;">read</span> line
+++++ <span style="color: #ff0000;">'['</span> <span style="color: #ff0000;">'complete -f -X '</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">'*.Z'</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">' compress znew'</span> <span style="color: #ff0000;">'!='</span> <span style="color: #ff0000;">'complete -f
-X '</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">'*.Z'</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">' compress znew'</span> <span style="color: #ff0000;">']'</span>
+++++ <span style="color: #007800;">line</span>=<span style="color: #ff0000;">'complete -f -X '</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">'*.Z'</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">' compress znew'</span>
+++++ <span style="color: #007800;">line</span>=<span style="color: #ff0000;">'complete -f -X '</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">'*.Z'</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">' compress znew'</span>
+++++ <span style="color: #007800;">line</span>=<span style="color: #ff0000;">' compress znew'</span>
+++++ <span style="color: #007800;">list</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">${list[@]}</span>&quot;</span> <span style="color: #007800;">$line</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
+++++ <span style="color: #c20cb9; font-weight: bold;">read</span> line
+++++ <span style="color: #ff0000;">'['</span> <span style="color: #ff0000;">' zcmp, zdiff, z*grep, zless, zmore intentionally not here,
see Debian: #455510'</span> <span style="color: #ff0000;">'!='</span> <span style="color: #ff0000;">'# zcmp, zdiff, z*grep, zless, zmore
intentionally not here, see Debian: #455510'</span> <span style="color: #ff0000;">']'</span>
...
...</pre></td></tr></table></div>




<p>Here you can see every command getting executed from the system and user&#8217;s <code>.bashrc</code> and <code>.bash_profile</code> as <code>bash</code> starts up.</p>

<p><strong><span class="caps">NOTE</span>:</strong> For further details regarding my <strong>one-liner</strong> blog posts, check out my <a href="http://www.lamolabs.org/blog/2147/intro-blogs-one-liner-code-block-style-guides/">one-liner style guide primer</a>.</p><div class="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.lamolabs.org/blog/2147/intro-blogs-one-liner-code-block-style-guides/"     class="wherego_title">Intro to my Blog&#8217;s [one-liner] Code Block Style Guides</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/" rel="nofollow">Where did they go from here?</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.lamolabs.org/blog/10603/one-liner-debugging-bash-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[one-liner]: Why is Conky reporting a lower CPU frequency, when my CPU frequency is actually much higher?</title>
		<link>http://www.lamolabs.org/blog/10481/one-liner-why-is-conky-reporting-a-lower-cpu-frequency-when-my-cpu-frequency-is-actually-much-higher/</link>
		<comments>http://www.lamolabs.org/blog/10481/one-liner-why-is-conky-reporting-a-lower-cpu-frequency-when-my-cpu-frequency-is-actually-much-higher/#comments</comments>
		<pubDate>Sun, 21 Apr 2013 11:41:20 +0000</pubDate>
		<dc:creator>slmingol</dc:creator>
				<category><![CDATA[tips & tricks]]></category>
		<category><![CDATA[conky]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.lamolabs.org/blog/?p=10481</guid>
		<description><![CDATA[Background

<p>If you&#8217;ve every dealt with Conky you may have gotten a little confused when you&#8217;re trying to get it to display your CPU frequency like so:</p>


1
${freq_g cpu0} Ghz




<p>&#8230; and Conky is reporting your CPU frequency as 1.12GHz when in fact it&#8217;s actually much higher than that, say 2.67GHz. Most likely this is being caused by [...]<div class="wherego_related"> </div>]]></description>
				<content:encoded><![CDATA[<h3>Background</h3>

<p>If you&#8217;ve every dealt with <a href="http://conky.sourceforge.net/">Conky</a> you may have gotten a little confused when you&#8217;re trying to get it to display your <span class="caps">CPU </span>frequency like so:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1048153"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p10481code53"><pre class="rc" style="font-family:monospace;">${freq_g cpu0} Ghz</pre></td></tr></table></div>




<p>&#8230; and <a href="http://conky.sourceforge.net/">Conky</a> is reporting your <span class="caps">CPU </span>frequency as 1.12GHz when in fact it&#8217;s actually much higher than that, say 2.67GHz. Most likely this is being caused by the <span class="caps">CPU </span>governing features that are present in most modern hardware. Here&#8217;s a behind the scenes 5 second tour of seeing what&#8217;s going on within your Linux Kernel.</p>

<h3>Solution</h3>

<p>First, from the <a href="http://conky.sourceforge.net/docs.html">conky man page</a>.</p>

<h5>cpu (cpuN)</h5>

<blockquote><p><span class="caps">CPU </span>usage in percents. For <span class="caps">SMP </span>machines, the <span class="caps">CPU </span>number can<br />
be provided as an argument. ${cpu cpu0} is the total usage, and ${cpu<br />
cpuX} (X &gt;= 1) are individual <span class="caps">CPU</span>s.</p></blockquote>

<h5>freq_g (n)</h5>

<blockquote><p>Returns <span class="caps">CPU </span>#n&#8217;s frequency in GHz. <span class="caps">CPU</span>s are counted from 1. <br />
If omitted, the parameter defaults to 1.</p></blockquote>

<p>You most likely have something like <a href="http://en.wikipedia.org/wiki/SpeedStep">SpeedStep</a> enabled which is acting like a governor on a car, regulating the speed of the cores inside your <span class="caps">CPU.</span> You can confirm that this is going on by looking at the output of this command:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1048154"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p10481code54"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">less</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>cpuinfo
processor       : <span style="color: #000000;">0</span>
vendor_id       : GenuineIntel
cpu family      : <span style="color: #000000;">6</span>
model           : <span style="color: #000000;">37</span>
model name      : Intel<span style="color: #7a0874; font-weight: bold;">&#40;</span>R<span style="color: #7a0874; font-weight: bold;">&#41;</span> Core<span style="color: #7a0874; font-weight: bold;">&#40;</span>TM<span style="color: #7a0874; font-weight: bold;">&#41;</span> i5 CPU       M <span style="color: #000000;">560</span>  <span style="color: #000000; font-weight: bold;">@</span> 2.67GHz
stepping        : <span style="color: #000000;">5</span>
cpu MHz         : <span style="color: #000000;">1199.000</span>
...</pre></td></tr></table></div>




<p>The 2 numbers that matter are the 2.67GHz, that the GHz that my <span class="caps">CPU </span>is rated to operate at followed by the number 1199.00, this is what my <span class="caps">CPU </span>is allowed to run at by the governor setup on my Linux laptop.</p>

<p>You can see what governor is currently configured like so:</p>

<p><span id="more-10481"></span></p>


<div class="wp_codebox"><table width="100%" ><tr id="p1048155"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="p10481code55"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># available governors</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>system<span style="color: #000000; font-weight: bold;">/</span>cpu<span style="color: #000000; font-weight: bold;">/</span>cpu0<span style="color: #000000; font-weight: bold;">/</span>cpufreq<span style="color: #000000; font-weight: bold;">/</span>scaling_available_governors 
powersave ondemand userspace performance 
<span style="color: #666666; font-style: italic;"># which one am I using?</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>system<span style="color: #000000; font-weight: bold;">/</span>cpu<span style="color: #000000; font-weight: bold;">/</span>cpu0<span style="color: #000000; font-weight: bold;">/</span>cpufreq<span style="color: #000000; font-weight: bold;">/</span>scaling_governor 
powersave
&nbsp;
<span style="color: #666666; font-style: italic;"># what's my current frequency scaling?</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>system<span style="color: #000000; font-weight: bold;">/</span>cpu<span style="color: #000000; font-weight: bold;">/</span>cpu0<span style="color: #000000; font-weight: bold;">/</span>cpufreq<span style="color: #000000; font-weight: bold;">/</span>scaling_cur_freq 
<span style="color: #000000;">1199000</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># what maximum is available?</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>system<span style="color: #000000; font-weight: bold;">/</span>cpu<span style="color: #000000; font-weight: bold;">/</span>cpu0<span style="color: #000000; font-weight: bold;">/</span>cpufreq<span style="color: #000000; font-weight: bold;">/</span>scaling_max_freq 
<span style="color: #000000;">2667000</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># what's the minimum?</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>system<span style="color: #000000; font-weight: bold;">/</span>cpu<span style="color: #000000; font-weight: bold;">/</span>cpu0<span style="color: #000000; font-weight: bold;">/</span>cpufreq<span style="color: #000000; font-weight: bold;">/</span>scaling_min_freq 
<span style="color: #000000;">1199000</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># what scaling frequencies can my CPU support?</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>system<span style="color: #000000; font-weight: bold;">/</span>cpu<span style="color: #000000; font-weight: bold;">/</span>cpu0<span style="color: #000000; font-weight: bold;">/</span>cpufreq<span style="color: #000000; font-weight: bold;">/</span>scaling_available_frequencies 
<span style="color: #000000;">2667000</span> <span style="color: #000000;">2666000</span> <span style="color: #000000;">2533000</span> <span style="color: #000000;">2399000</span> <span style="color: #000000;">2266000</span> <span style="color: #000000;">2133000</span> <span style="color: #000000;">1999000</span> <span style="color: #000000;">1866000</span> <span style="color: #000000;">1733000</span> <span style="color: #000000;">1599000</span> <span style="color: #000000;">1466000</span> <span style="color: #000000;">1333000</span> <span style="color: #000000;">1199000</span></pre></td></tr></table></div>




<p>You can override your governor by doing the following, using one of the governor&#8217;s listed above:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1048156"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p10481code56"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;echo performance &gt; /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor&quot;</span></pre></td></tr></table></div>








<h3>References</h3>

<h5>links</h5>


<ul>
<li><a href="http://conky.sourceforge.net/">Conky</a></li>
<li><a href="http://conky.sourceforge.net/docs.html">Conky man page</a></li>
<li><a href="http://en.wikipedia.org/wiki/SpeedStep">SpeedStep &#8211; wikipedia</a></li>
<li><a href="http://www.pantz.org/software/cpufreq/usingcpufreqonlinux.html">Using <span class="caps">CPU</span> Frequency (CPUFreq) on Linux Reference</a></li>
</ul>



<p><strong><span class="caps">NOTE</span>:</strong> For further details regarding my <strong>one-liner</strong> blog posts, check out my <a href="http://www.lamolabs.org/blog/2147/intro-blogs-one-liner-code-block-style-guides/">one-liner style guide primer</a>.</p><div class="wherego_related"> </div>]]></content:encoded>
			<wfw:commentRss>http://www.lamolabs.org/blog/10481/one-liner-why-is-conky-reporting-a-lower-cpu-frequency-when-my-cpu-frequency-is-actually-much-higher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[one-liner]: How do you capture the status of a command ($?) in Bash, when run through a pipe?</title>
		<link>http://www.lamolabs.org/blog/10480/one-liner-how-do-you-capture-the-status-of-a-command-in-bash-when-run-through-a-pipe/</link>
		<comments>http://www.lamolabs.org/blog/10480/one-liner-how-do-you-capture-the-status-of-a-command-in-bash-when-run-through-a-pipe/#comments</comments>
		<pubDate>Sun, 21 Apr 2013 10:20:58 +0000</pubDate>
		<dc:creator>slmingol</dc:creator>
				<category><![CDATA[tips & tricks]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.lamolabs.org/blog/?p=10480</guid>
		<description><![CDATA[Background

<p>While answering questions on the stackexchage website Unix &#38; Linux I saw the following question which was about something I&#8217;d encountered, but until today never knew how to accomplish, so I&#8217;m posting it here for my own reference in the future.</p>

<p>The question?</p>

<p>How do you get the exit status ( $? ) from the command haconf [...]<div class="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.lamolabs.org/blog/10319/one-liner-overview-of-bash-io-redirection/"     class="wherego_title">[one-liner]: Overview of Bash I/O Redirection</a></li><li><a href="http://www.lamolabs.org/blog/10391/one-liner-free-online-programming-courses/"     class="wherego_title">[one-liner]: Free Online Programming Courses</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/" rel="nofollow">Where did they go from here?</a></li></ul></div>]]></description>
				<content:encoded><![CDATA[<h3>Background</h3>

<p>While answering questions on the stackexchage website <a href="http://unix.stackexchange.com">Unix &amp; Linux</a> I saw the following question which was about something I&#8217;d encountered, but until today never knew how to accomplish, so I&#8217;m posting it here for my own reference in the future.</p>

<p><b>The question?</b></p>

<p>How do you get the exit status ( $? ) from the command haconf -makerw in place of grep? i.e. what need to add in to my syntax in order to understand if haconf -makerw succeeded?</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1048061"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p10480code61"><pre class="bash" style="font-family:monospace;">    haconf <span style="color: #660033;">-makerw</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-iq</span> <span style="color: #ff0000;">&quot;Cluster already writable&quot;</span>
        <span style="color: #666666; font-style: italic;"># echo $? ( will print the exe status from haconf -makerw  )</span></pre></td></tr></table></div>




<h3>Solution</h3>

<p>There are 3 ways of doing this. However your current setup should work. The reason here being that the grep won&#8217;t match anything if the command fails, so grep will return with status 1 (unless the program always shows that text no matter what).</p>

<h5>Pipefail</h5>

<p>The first way is to set the pipefail option. This is the simplest and what it does is basically set the exit status $? to the exit code of the last program to exit non-zero (or zero if all exited successfully).</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1048062"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p10480code62"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># false | true; echo $?</span>
<span style="color: #000000;">0</span>
<span style="color: #666666; font-style: italic;"># set -o pipefail</span>
<span style="color: #666666; font-style: italic;"># false | true; echo $?</span>
<span style="color: #000000;">1</span></pre></td></tr></table></div>




<h5>$PIPESTATUS</h5>

<p>Bash also has a variable called $PIPESTATUS which contains the exit status of all the programs in the last command.</p>

<p><span id="more-10480"></span></p>


<div class="wp_codebox"><table width="100%" ><tr id="p1048063"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p10480code63"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># true | true; echo &quot;${PIPESTATUS[@]}&quot;</span>
<span style="color: #000000;">0</span> <span style="color: #000000;">0</span>
<span style="color: #666666; font-style: italic;"># false | true; echo &quot;${PIPESTATUS[@]}&quot;</span>
<span style="color: #000000;">1</span> <span style="color: #000000;">0</span>
<span style="color: #666666; font-style: italic;"># false | true; echo &quot;${PIPESTATUS[0]}&quot;</span>
<span style="color: #000000;">1</span>
<span style="color: #666666; font-style: italic;"># true | false; echo &quot;${PIPESTATUS[@]}&quot;</span>
<span style="color: #000000;">0</span> <span style="color: #000000;">1</span></pre></td></tr></table></div>




<p><b><span class="caps">NOTE</span>:</b> You can use the 3rd command example to get the specific value in the pipeline that you need.</p>

<p>This solution might not be available though. I think $PIPESTATUS might have been added in a fairly recent version of bash, and your OS may not have it.</p>

<h5>Separate executions</h5>

<p>This is the most unwieldy of the solutions. Run each command separately and capture the status.</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1048064"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p10480code64"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># OUTPUT=&quot;$(haconf -makerw)&quot;</span>
<span style="color: #666666; font-style: italic;"># STATUS_HACONF=&quot;$?&quot;</span>
<span style="color: #666666; font-style: italic;"># printf '%s' &quot;$OUTPUT&quot; | grep -iq &quot;Cluster already writable&quot;</span></pre></td></tr></table></div>




<h3>References</h3>

<h5>links</h5>


<ul>
<li><a href="http://unix.stackexchange.com/questions/73170/how-to-get-exit-status-from-the-command-before-the-last">how to get exit status from the command before the last &#8211; <span class="caps">U&amp;L</span></a></li>
<li><a href="http://unix.stackexchange.com/a/73180/7453">Answer to <span class="caps">U&amp;L</span> Question</a></li>
<li><a href="http://stackoverflow.com/questions/1221833/bash-tee-output-and-capture-exit-status">bash: tee output <span class="caps">AND </span>capture exit status &#8211; stackoverflow</a></li>
</ul>



<p><strong><span class="caps">NOTE</span>:</strong> For further details regarding my <strong>one-liner</strong> blog posts, check out my <a href="http://www.lamolabs.org/blog/2147/intro-blogs-one-liner-code-block-style-guides/">one-liner style guide primer</a>.</p><div class="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.lamolabs.org/blog/10319/one-liner-overview-of-bash-io-redirection/"     class="wherego_title">[one-liner]: Overview of Bash I/O Redirection</a></li><li><a href="http://www.lamolabs.org/blog/10391/one-liner-free-online-programming-courses/"     class="wherego_title">[one-liner]: Free Online Programming Courses</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/" rel="nofollow">Where did they go from here?</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.lamolabs.org/blog/10480/one-liner-how-do-you-capture-the-status-of-a-command-in-bash-when-run-through-a-pipe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[one-liner]: Checking out a HDD&#8217;s Health using the Command Line Tool udisk</title>
		<link>http://www.lamolabs.org/blog/10445/one-liner-checking-out-a-hdds-health-using-the-command-line-tool-udisk/</link>
		<comments>http://www.lamolabs.org/blog/10445/one-liner-checking-out-a-hdds-health-using-the-command-line-tool-udisk/#comments</comments>
		<pubDate>Mon, 15 Apr 2013 21:50:14 +0000</pubDate>
		<dc:creator>slmingol</dc:creator>
				<category><![CDATA[tips & tricks]]></category>
		<category><![CDATA[HDD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.lamolabs.org/blog/?p=10445</guid>
		<description><![CDATA[Background

<p>Here&#8217;s a quick tip for checking out the overall health of your computer&#8217;s hard drive. It makes use of a little known tool called udisks which provides access to information about storage devices from the D-Bus interface.</p>

Solution

<p>Before we jump into udisks here are some resources that might prove useful when dealing with the design/architecture of [...]<div class="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.lamolabs.org/blog/2147/intro-blogs-one-liner-code-block-style-guides/"     class="wherego_title">Intro to my Blog&#8217;s [one-liner] Code Block Style Guides</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/" rel="nofollow">Where did they go from here?</a></li></ul></div>]]></description>
				<content:encoded><![CDATA[<h3>Background</h3>

<p>Here&#8217;s a quick tip for checking out the overall health of your computer&#8217;s hard drive. It makes use of a little known tool called <b>udisks</b> which provides access to information about storage devices from the D-Bus interface.</p>

<h3>Solution</h3>

<p>Before we jump into <b>udisks</b> here are some resources that might prove useful when dealing with the design/architecture of <b>udisks</b>.</p>


<ul>
<li><a href="http://www.freedesktop.org/wiki/Software/udisks">udisks&#8217; main website</a></li>
<li><a href="http://udisks.freedesktop.org/docs/latest/">udisks&#8217; reference manual</a></li>
</ul>



<p>To see which drives are currently under <b>udisks</b> watchful eye, you can use the following command:</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1044568"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p10445code68"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> udisks <span style="color: #660033;">--enumerate</span>
<span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>UDisks<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>dm_2d0
<span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>UDisks<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>dm_2d1
<span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>UDisks<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>dm_2d2
<span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>UDisks<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>sda1
<span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>UDisks<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>sda2
<span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>UDisks<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>sda3
<span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>UDisks<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>sda4
<span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>UDisks<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>sda5
<span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>UDisks<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>sda6
<span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>UDisks<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>sr0
<span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>UDisks<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>sda</pre></td></tr></table></div>




<p>This output shows that I have several partitions that are currently bing monitored, the last bit in the path tells you which device, i.e.  sda1, sda2, sda3, etc. These are partitions /dev/sda1, /dev/sda2, etc.</p>

<p>Now on to the actual health output. This next command will show you the overall health of device /dev/sda, i.e. my primary <span class="caps">HDD </span>on my laptop:</p>

<p><span id="more-10445"></span></p>


<div class="wp_codebox"><table width="100%" ><tr id="p1044569"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
</pre></td><td class="code" id="p10445code69"><pre class="bash" style="font-family:monospace;">udisks <span style="color: #660033;">--show-info</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda
Showing information <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>UDisks<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>sda
  native-path:                 <span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>pci0000:00<span style="color: #000000; font-weight: bold;">/</span>0000:00:1f.2<span style="color: #000000; font-weight: bold;">/</span>host0<span style="color: #000000; font-weight: bold;">/</span>target0:0:0<span style="color: #000000; font-weight: bold;">/</span>0:0:0:0<span style="color: #000000; font-weight: bold;">/</span>block<span style="color: #000000; font-weight: bold;">/</span>sda
  device:                      8:0
  device-file:                 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda
    presentation:              <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda
    by-id:                     <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>disk<span style="color: #000000; font-weight: bold;">/</span>by-id<span style="color: #000000; font-weight: bold;">/</span>ata-ST9500420AS_5VJ9H3BY
    by-id:                     <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>disk<span style="color: #000000; font-weight: bold;">/</span>by-id<span style="color: #000000; font-weight: bold;">/</span>scsi-SATA_ST9500420AS_5VJ9H3BY
    by-id:                     <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>disk<span style="color: #000000; font-weight: bold;">/</span>by-id<span style="color: #000000; font-weight: bold;">/</span>wwn-0x5000c5002ed97512
    by-path:                   <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>disk<span style="color: #000000; font-weight: bold;">/</span>by-path<span style="color: #000000; font-weight: bold;">/</span>pci-0000:00:1f.2-scsi-0:0:0:0
  detected at:                 Mon 15 Apr 2013 01:00:39 PM EDT
  system internal:             1
  removable:                   0
  has media:                   1 <span style="color: #7a0874; font-weight: bold;">&#40;</span>detected at Mon 15 Apr 2013 01:00:39 PM EDT<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    detects change:            0
    detection by polling:      0
    detection inhibitable:     0
    detection inhibited:       0
  is <span style="color: #c20cb9; font-weight: bold;">read</span> only:                0
  is mounted:                  0
  <span style="color: #c20cb9; font-weight: bold;">mount</span> paths:             
  mounted by uid:              0
  presentation hide:           0
  presentation nopolicy:       0
  presentation name:           
  presentation icon:           
  <span style="color: #c20cb9; font-weight: bold;">size</span>:                        500107862016
  block <span style="color: #c20cb9; font-weight: bold;">size</span>:                  512
  job underway:                no
  usage:                       
  <span style="color: #7a0874; font-weight: bold;">type</span>:                        
  version:                     
  uuid:                        
  label:                       
  partition table:
    scheme:                    mbr
    count:                     6
  drive:
    vendor:                    ATA
    model:                     ST9500420AS
    revision:                  0003LV1M
    serial:                    5VJ9H3BY
    WWN:                       5000c5002ed97512
    detachable:                0
    can spindown:              1
    rotational media:          Yes, at 7200 RPM
    write-cache:               enabled
    ejectable:                 0
    adapter:                   <span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>UDisks<span style="color: #000000; font-weight: bold;">/</span>adapters<span style="color: #000000; font-weight: bold;">/</span>0000_3a00_3a1f_2e2
    ports:
      <span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>UDisks<span style="color: #000000; font-weight: bold;">/</span>adapters<span style="color: #000000; font-weight: bold;">/</span>0000_3a00_3a1f_2e2<span style="color: #000000; font-weight: bold;">/</span>host0
    similar devices:
    media:                     
      compat:                 
    interface:                 ata
    <span style="color: #000000; font-weight: bold;">if</span> speed:                  <span style="color: #7a0874; font-weight: bold;">&#40;</span>unknown<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    ATA SMART:                 Updated at Mon 15 Apr 2013 09:26:39 PM EDT
      overall assessment:      Good
===============================================================================
 Attribute       Current<span style="color: #000000; font-weight: bold;">|</span>Worst<span style="color: #000000; font-weight: bold;">|</span>Threshold  Status   Value       Type     Updates
===============================================================================
 raw-read-error-rate         <span style="color: #000000;">104</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">99</span><span style="color: #000000; font-weight: bold;">|</span> 34   good    6520505     Pre-fail Online 
 spin-up-time                <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">99</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    0           Pre-fail Online 
 start-stop-count             <span style="color: #000000;">98</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">98</span><span style="color: #000000; font-weight: bold;">|</span> 20   good    2785        Old-age  Online 
 reallocated-sector-count    <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span> 36   good    0 sectors   Pre-fail Online 
 seek-error-rate              <span style="color: #000000;">72</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">60</span><span style="color: #000000; font-weight: bold;">|</span> 30   good    25872919731 Pre-fail Online 
 power-on-hours               <span style="color: #000000;">89</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">89</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    424.5 days  Old-age  Online 
 spin-retry-count            <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span> 97   good    0           Pre-fail Online 
 power-cycle-count            <span style="color: #000000;">98</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">98</span><span style="color: #000000; font-weight: bold;">|</span> 20   good    2753        Old-age  Online 
 attribute-184               <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span> 99   good    0           Old-age  Online 
 reported-uncorrect          <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    0 sectors   Old-age  Online 
 attribute-188               <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">96</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    0           Old-age  Online 
 high-fly-writes             <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    0           Old-age  Online 
 airflow-temperature-celsius  <span style="color: #000000;">58</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">42</span><span style="color: #000000; font-weight: bold;">|</span> 45 FAIL_PAST 42C <span style="color: #000000; font-weight: bold;">/</span> 108F  Old-age  Online 
 g-sense-error-rate          <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    124         Old-age  Online 
 power-off-retract-count     <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    15          Old-age  Online 
 load-cycle-count              <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    248327      Old-age  Online 
 temperature-celsius-2        <span style="color: #000000;">42</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">58</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    42C <span style="color: #000000; font-weight: bold;">/</span> 108F  Old-age  Online 
 hardware-ecc-recovered       <span style="color: #000000;">44</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">38</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    6520505     Old-age  Online 
 reallocated-event-count      <span style="color: #000000;">89</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">89</span><span style="color: #000000; font-weight: bold;">|</span> 30   good    79886391715520 Pre-fail Online 
 current-pending-sector      <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    0 sectors   Old-age  Online 
 offline-uncorrectable       <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    0 sectors   Old-age  Offline
 udma-crc-error-count        <span style="color: #000000;">200</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">200</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    0           Old-age  Online 
 attribute-254               <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000;">0</span>    n<span style="color: #000000; font-weight: bold;">/</span>a    <span style="color: #000000;">0</span>           Old-age  Online</pre></td></tr></table></div>




<p>One thing to note, my <span class="caps">HDD </span>is essentially overheating at 58 degrees celcius while threshold for that value is suppose to be 45 degrees celcius. Might need to think about replacing it some time soon 8-).</p>

<p>Here&#8217;s another way to get just the health information using the <b>&#8211;dump</b> switch instead.</p>


<div class="wp_codebox"><table width="100%" ><tr id="p1044570"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code" id="p10445code70"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> udisks <span style="color: #660033;">--dump</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-A</span> 24 Updates
&nbsp;
 Attribute       Current<span style="color: #000000; font-weight: bold;">|</span>Worst<span style="color: #000000; font-weight: bold;">|</span>Threshold  Status   Value       Type     Updates
===============================================================================
 raw-read-error-rate         <span style="color: #000000;">103</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">99</span><span style="color: #000000; font-weight: bold;">|</span> 34   good    6214810     Pre-fail Online 
 spin-up-time                <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">99</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    0           Pre-fail Online 
 start-stop-count             <span style="color: #000000;">98</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">98</span><span style="color: #000000; font-weight: bold;">|</span> 20   good    2785        Old-age  Online 
 reallocated-sector-count    <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span> 36   good    0 sectors   Pre-fail Online 
 seek-error-rate              <span style="color: #000000;">72</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">60</span><span style="color: #000000; font-weight: bold;">|</span> 30   good    25872903767 Pre-fail Online 
 power-on-hours               <span style="color: #000000;">89</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">89</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    424.4 days  Old-age  Online 
 spin-retry-count            <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span> 97   good    0           Pre-fail Online 
 power-cycle-count            <span style="color: #000000;">98</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">98</span><span style="color: #000000; font-weight: bold;">|</span> 20   good    2753        Old-age  Online 
 attribute-184               <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span> 99   good    0           Old-age  Online 
 reported-uncorrect          <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    0 sectors   Old-age  Online 
 attribute-188               <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">96</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    0           Old-age  Online 
 high-fly-writes             <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    0           Old-age  Online 
 airflow-temperature-celsius  <span style="color: #000000;">58</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">42</span><span style="color: #000000; font-weight: bold;">|</span> 45 FAIL_PAST 42C <span style="color: #000000; font-weight: bold;">/</span> 108F  Old-age  Online 
 g-sense-error-rate          <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    124         Old-age  Online 
 power-off-retract-count     <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    15          Old-age  Online 
 load-cycle-count              <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    248327      Old-age  Online 
 temperature-celsius-2        <span style="color: #000000;">42</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">58</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    42C <span style="color: #000000; font-weight: bold;">/</span> 108F  Old-age  Online 
 hardware-ecc-recovered       <span style="color: #000000;">44</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">38</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    6214810     Old-age  Online 
 reallocated-event-count      <span style="color: #000000;">89</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">89</span><span style="color: #000000; font-weight: bold;">|</span> 30   good    181604102186687 Pre-fail Online 
 current-pending-sector      <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    0 sectors   Old-age  Online 
 offline-uncorrectable       <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    0 sectors   Old-age  Offline
 udma-crc-error-count        <span style="color: #000000;">200</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">200</span><span style="color: #000000; font-weight: bold;">|</span>  0    n<span style="color: #000000; font-weight: bold;">/</span>a    0           Old-age  Online 
 attribute-254               <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000;">0</span>    n<span style="color: #000000; font-weight: bold;">/</span>a    <span style="color: #000000;">0</span>           Old-age  Online</pre></td></tr></table></div>





<h3>References</h3>

<h5>links</h5>


<ul>
<li><a href="http://www.scribd.com/doc/63425975/Introduction-to-Udisks">Introduction to Udisks &#8211; Finnbarr P. Murphy</a></li>
<li><a href="http://www.freedesktop.org/wiki/Software/udisks">udisks&#8217; main website</a></li>
<li><a href="http://udisks.freedesktop.org/docs/latest/">udisks&#8217; reference manual</a></li>
</ul>



<h5>local copies</h5>


<ul>
<li><a href="http://www.lamolabs.org/blog/wp-content/uploads/2013/04/63425975-Introduction-to-Udisks.pdf">Introduction to Udisks &#8211; Finnbarr P. Murphy</a></li>
</ul>




<p><strong><span class="caps">NOTE</span>:</strong> For further details regarding my <strong>one-liner</strong> blog posts, check out my <a href="http://www.lamolabs.org/blog/2147/intro-blogs-one-liner-code-block-style-guides/">one-liner style guide primer</a>.</p><div class="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.lamolabs.org/blog/2147/intro-blogs-one-liner-code-block-style-guides/"     class="wherego_title">Intro to my Blog&#8217;s [one-liner] Code Block Style Guides</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/" rel="nofollow">Where did they go from here?</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.lamolabs.org/blog/10445/one-liner-checking-out-a-hdds-health-using-the-command-line-tool-udisk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[one-liner]: Free Online Programming Courses</title>
		<link>http://www.lamolabs.org/blog/10391/one-liner-free-online-programming-courses/</link>
		<comments>http://www.lamolabs.org/blog/10391/one-liner-free-online-programming-courses/#comments</comments>
		<pubDate>Wed, 10 Apr 2013 01:12:29 +0000</pubDate>
		<dc:creator>slmingol</dc:creator>
				<category><![CDATA[tips & tricks]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.lamolabs.org/blog/?p=10391</guid>
		<description><![CDATA[Background

<p>This post is intended to capture various online resources for taking classes and/or getting training in anything. They&#8217;re predominately programming language and software engineering courses but their are other tracks that focus on history and chemistry, for example.</p>

Solution

<p>This is by no means meant to be an exhaustive list, it&#8217;s a clearinghouse of the different resources [...]<div class="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.lamolabs.org/blog/226/how-to-setup-a-mail-server-on-centos-5/"     class="wherego_title">How to Setup a Mail Server on CentOS 5</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/" rel="nofollow">Where did they go from here?</a></li></ul></div>]]></description>
				<content:encoded><![CDATA[<h3>Background</h3>

<p>This post is intended to capture various online resources for taking classes and/or getting training in <strong>anything</strong>. They&#8217;re predominately programming language and software engineering courses but their are other tracks that focus on history and chemistry, for example.</p>

<h3>Solution</h3>

<p>This is by no means meant to be an exhaustive list, it&#8217;s a clearinghouse of the different resources as I come across them.</p>

<p><b style="text-decoration:underline">General Sites</b></p>


<ul>
<li><a href="http://ocw.mit.edu/index.htm"><span class="caps">MIT</span> Open Course Ware</a></li>
<li><a href="http://www.openculture.com/freeonlinecourses">700 Free Online Courses from Top Universities</a></li>
<li><a href="http://www.bdpa-detroit.org/portal/index.php?option=com_content&amp;view=article&amp;id=57%3Amoocs-top-10-sites-for-free-education-with-elite-universities&amp;catid=29%3Aeducation&amp;Itemid=20"><span class="caps">MOOC</span>s: Top 10 Sites for Free Education With Elite Universities</a></li>
<li><a href="http://www.coursera.org/">Coursera</a></li>
</ul>



<p><b style="text-decoration:underline">General Programming Courses</b></p>


<ul>
<li><a href="http://www.codecademy.com/#!/exercises/0">Codecademy</a></li>
<li><a href="http://see.stanford.edu/see/courses.aspx">Stanford Engineering Everywhere courses</a></li>
<li><a href="http://www.extension.harvard.edu/open-learning-initiative/intensive-introduction-computer-science">Harvard Extension School &#8211; Intensive Introduction to Computer Science</a></li>
</ul>



<p><b style="text-decoration:underline">HTML/Javascript/Web/etc.</b></p>


<ul>
<li><a href="http://cs75.tv/2010/fall/">Computer Science E-75: Building Dynamic Websites</a></li>
<li><a href="http://cs76.tv/2011/spring/">Computer Science E-76: Building Mobile Applications</a></li>
<li><a href="http://www.codeavengers.com/">Code Avengers</a></li>
<li><a href="http://openclassroom.stanford.edu/MainFolder/HomePage.php">Openclassroom</a></li>
</ul>



<p><b style="text-decoration:underline">Ruby</b></p>


<ul>
<li><a href="http://www.rubyquiz.com/">Ruby Quiz</a></li>
<li><a href="http://ruby4kids.com/ruby4kids/">Ruby4Kids</a></li>
<li><a href="http://rubykoans.com/">Learn Ruby with the Neo Ruby Koans</a></li>
</ul>



















<p><strong><span class="caps">NOTE</span>:</strong> For further details regarding my <strong>one-liner</strong> blog posts, check out my <a href="http://www.lamolabs.org/blog/2147/intro-blogs-one-liner-code-block-style-guides/">one-liner style guide primer</a>.</p><div class="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.lamolabs.org/blog/226/how-to-setup-a-mail-server-on-centos-5/"     class="wherego_title">How to Setup a Mail Server on CentOS 5</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/" rel="nofollow">Where did they go from here?</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.lamolabs.org/blog/10391/one-liner-free-online-programming-courses/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[one-liner]: Overview of Bash I/O Redirection</title>
		<link>http://www.lamolabs.org/blog/10319/one-liner-overview-of-bash-io-redirection/</link>
		<comments>http://www.lamolabs.org/blog/10319/one-liner-overview-of-bash-io-redirection/#comments</comments>
		<pubDate>Wed, 03 Apr 2013 01:10:44 +0000</pubDate>
		<dc:creator>slmingol</dc:creator>
				<category><![CDATA[tips & tricks]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.lamolabs.org/blog/?p=10319</guid>
		<description><![CDATA[Background

<p>I recently came across this question on the Stackexchange site Unix &#38; Linux. This question was interesting in the sense that it covered much of the I/O redirection facilities that are available in the Bash Shell, so for posterity sake I&#8217;m adding my answer to this question here on my blog.</p>

Solution



a number 1 = standard [...]<div class="wherego_related"> </div>]]></description>
				<content:encoded><![CDATA[<h3>Background</h3>

<p>I recently came across <a href="http://unix.stackexchange.com/questions/70963/difference-between-2-2-dev-null-dev-null-and-dev-null-21">this question</a> on the <a href="http://unix.stackexchange.com/">Stackexchange site Unix &amp; Linux</a>. This question was interesting in the sense that it covered much of the I/O redirection facilities that are available in the Bash Shell, so for posterity sake I&#8217;m adding my answer to this question here on my blog.</p>

<h3>Solution</h3>


<ul>
<li>a <b>number 1</b> = standard out (i.e. <b><span class="caps">STDOUT</span></b>)</li>
<li>a <b>number 2</b> = standard error (i.e. <b><span class="caps">STDERR</span></b>)</li>
<li>if a number isn&#8217;t explicitly given, then <b>number 1</b> is assumed by the shell (bash)</li>
</ul>



<p>First let&#8217;s tackle the function of these. For reference see the <a href="http://www.tldp.org/LDP/abs/html/io-redirection.html">Advanced Bash-Scripting Guide</a>.</p>

<h5 style="text-decoration:underline">Functions</h5>

<table class="noborders" cellspacing="0"><tr><td>
<ul>
<li><code>2&gt;&amp;-</code></li>
</ul>

</td><td>- The general form of this one is <code>M&gt;&amp;-</code>, where <b>&#8220;M&#8221;</b> is a file descriptor number. This will close output for whichever file descriptor is referenced, i.e. <b>&#8220;M&#8221;</b>.</td></tr><tr><td>
<ul>
<li><code>2&gt;/dev/null</code></li>
</ul>

</td><td>- The general form of this one is <code>M&gt;/dev/null</code>, where <b>&#8220;M&#8221;</b> is a file descriptor number. This will redirect the file descriptor, <b>&#8220;M&#8221;</b>, to <code>/dev/null</code>.</td></tr><tr><td>
<ul>
<li><code>2&gt;&amp;1</code></li>
</ul>

</td><td>- The general form of this one is <code>M&gt;&amp;N</code>, where <b>&#8220;M&#8221;</b> &amp; <b>&#8220;N&#8221;</b> are file descriptor numbers. It combines the output of file descriptors <b>&#8220;M&#8221;</b> and <b>&#8220;N&#8221;</b> into a single stream.</td></tr><tr><td>
<ul>
<li><code>&amp;#124;&amp;</code></li>
</ul>

</td><td>- This is just an abbreviation for <code>2&gt;&amp;1</code>. It was added in Bash 4.</td></tr><tr><td>
<ul>
<li><code>&amp;&gt;/dev/null</code></li>
</ul>

</td><td>- This is just an abbreviation for <code>2&gt;&amp;1 &gt;/dev/null</code>. It too was added in Bash 4. It redirects file descriptor 2 <b>(STDERR)</b> and descriptor 1 <b>(STDOUT)</b> to <code>/dev/null</code>.</td></tr><tr><td>
<ul>
<li><code>&gt;/dev/null</code></li>
</ul>

</td><td>- This is just an abbreviation for <code>1&gt;/dev/null</code>. It redirects file descriptor 1 <b>(STDOUT)</b> to  <code>/dev/null</code>.</td></tr></table>

<h5 style="text-decoration:underline">Portability to non-bash, <code>tcsh</code>, <code>mksh</code>, etc.</h5>

<p>I&#8217;ve not dealt much with other shells outside of <code>csh</code> and <code>tcsh</code>. My experience with those 2 compared to bash&#8217;s redirection operators, is that <code>bash</code> is superior in that regard. See the <a href="http://linux.die.net/man/1/tcsh">tcsh man page</a> for more details.</p>

<p>Of the commands asked about in the <a href="http://unix.stackexchange.com/questions/70963/difference-between-2-2-dev-null-dev-null-and-dev-null-21">Unix &amp; Linux question</a>, none are directly supported by <code>csh</code> or <code>tcsh</code>. You&#8217;d have to use different syntaxes to construct similar functions.</p>

<h3>References</h3>


<ul>
<li><a href="http://www.tldp.org/LDP/abs/html/io-redirection.html">Advanced Bash-Scripting Guide</a></li>
<li><a href="http://linux.die.net/man/1/tcsh">tcsh man page</a></li>
<li><a href="http://unix.stackexchange.com/questions/70963/difference-between-2-2-dev-null-dev-null-and-dev-null-21">stackexchange unix &amp; linux question regarding shell redirections</a></li>
</ul>



<p><strong><span class="caps">NOTE</span>:</strong> For further details regarding my <strong>one-liner</strong> blog posts, check out my <a href="http://www.lamolabs.org/blog/2147/intro-blogs-one-liner-code-block-style-guides/">one-liner style guide primer</a>.</p><div class="wherego_related"> </div>]]></content:encoded>
			<wfw:commentRss>http://www.lamolabs.org/blog/10319/one-liner-overview-of-bash-io-redirection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
