<?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>Upthrust &#187; Linux</title>
	<atom:link href="http://blog.mpathirage.com/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mpathirage.com</link>
	<description>This is the weblog of Milinda Pathirage</description>
	<lastBuildDate>Mon, 29 Aug 2011 02:00:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Merging PDF Files In Linux Using PyPDF</title>
		<link>http://blog.mpathirage.com/2010/01/16/merging-pdf-files-in-linux-using-pypdf/</link>
		<comments>http://blog.mpathirage.com/2010/01/16/merging-pdf-files-in-linux-using-pypdf/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 16:26:58 +0000</pubDate>
		<dc:creator>Milinda Lakmal</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[pyPdf]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.mpathirage.com/?p=263</guid>
		<description><![CDATA[PyPDF is a handy and valuable Python library for merging and splitting PDF files in Linux. It&#8217;s pure Python library built as a PDF toolkit. It is capable of: extracting document information (title, author, &#8230;), splitting documents page by page, merging documents page by page, cropping pages, merging multiple pages into a single page, encrypting [...]]]></description>
			<content:encoded><![CDATA[<p><strong><a rel="nofollow" href="http://pybrary.net/pyPdf/" target="_blank">PyPDF</a></strong> is a handy and valuable Python library for merging and splitting PDF files in Linux. It&#8217;s pure Python library built as a PDF toolkit. It is capable of:</p>
<ul>
<li>extracting document information (title, author, &#8230;),</li>
<li>splitting documents page by page,</li>
<li>merging documents page by page,</li>
<li>cropping pages,</li>
<li>merging multiple pages into a single page,</li>
<li>encrypting and decrypting PDF files.</li>
</ul>
<p>PyPDF is a great Python library use by many Python applications which handles PDF files directly. <strong>PDF-Shuffler </strong> is a one of the tools written based on PyPDF which you can use to merge PDF files easily in Linux. In Ubuntu you can install it using following command.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> pdfshuffler</div></div>
<p>Here is a sample code that merge PDF files together using PyPDF library. In this code I have used PdfFileWriter and PdfFileReader classes from PyPDF module to read and append PDF files together. This sample doesn&#8217;t contain completed error handling logic for file handling.</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:350px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;"># Copyright (C) 2010 Milinda Pathirage</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span><br />
<span style="color: #808080; font-style: italic;"># you may not use this file except in compliance with the License.</span><br />
<span style="color: #808080; font-style: italic;"># You may obtain a copy of the License at</span><br />
<span style="color: #808080; font-style: italic;">#</span><br />
<span style="color: #808080; font-style: italic;"># &nbsp; &nbsp;http://www.apache.org/licenses/LICENSE-2.0</span><br />
<span style="color: #808080; font-style: italic;">#</span><br />
<span style="color: #808080; font-style: italic;"># Unless required by applicable law or agreed to in writing, software</span><br />
<span style="color: #808080; font-style: italic;"># distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span><br />
<span style="color: #808080; font-style: italic;"># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span><br />
<span style="color: #808080; font-style: italic;"># See the License for the specific language governing permissions and</span><br />
<span style="color: #808080; font-style: italic;"># limitations under the License.</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span><br />
<span style="color: #ff7700;font-weight:bold;">from</span> pyPdf <span style="color: #ff7700;font-weight:bold;">import</span> PdfFileWriter<span style="color: #66cc66;">,</span> PdfFileReader<br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> mergePDFFiles<span style="color: black;">&#40;</span>outputFile<span style="color: #66cc66;">,</span> filesToBeMerged<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; output <span style="color: #66cc66;">=</span> PdfFileWriter<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span><span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>filesToBeMerged<span style="color: black;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Empty Input File List'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span><span style="color: #66cc66;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> inFile <span style="color: #ff7700;font-weight:bold;">in</span> filesToBeMerged:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Adding file'</span> + inFile + <span style="color: #483d8b;">' to the out put'</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Read the input PDF file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">input</span> <span style="color: #66cc66;">=</span> PdfFileReader<span style="color: black;">&#40;</span><span style="color: #008000;">file</span><span style="color: black;">&#40;</span>inFile<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;rb&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Add every page in input PDF file to output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> page <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">input</span>.<span style="color: black;">pages</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output.<span style="color: black;">addPage</span><span style="color: black;">&#40;</span>page<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Writing the final out put to file system'</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Out put stream for output file &nbsp; &nbsp; &nbsp; &nbsp;</span><br />
&nbsp; &nbsp; outputStream <span style="color: #66cc66;">=</span> <span style="color: #008000;">file</span><span style="color: black;">&#40;</span>outputFile<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;wb&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; output.<span style="color: black;">write</span><span style="color: black;">&#40;</span>outputStream<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; outputStream.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <br />
<br />
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'__main__'</span>:<br />
&nbsp; &nbsp; i <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; outputFile <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">''</span><br />
&nbsp; &nbsp; inputFiles <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> arg <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; i <span style="color: #66cc66;">=</span> i + <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Getting out file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> arg <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'-o'</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputFile <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Output File: '</span> + outputFile<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Extracting Input files</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> arg <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'-i'</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outfileOptionPos <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span>.<span style="color: black;">index</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'-o'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> i <span style="color: #66cc66;">&lt;</span> outfileOptionPos:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputFiles <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span>i: outfileOptionPos<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; filesStr <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;,&quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>inputFiles<span style="color: black;">&#41;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;,&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Input Files: '</span> + filesStr<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>: &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputFiles <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span>i:<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; filesStr <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;,&quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>inputFiles<span style="color: black;">&#41;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;,&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Input Files: '</span> + filesStr<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Merging PDF files</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Merging PDF Files......'</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; mergePDFFiles<span style="color: black;">&#40;</span>outputFile<span style="color: #66cc66;">,</span> inputFiles<span style="color: black;">&#41;</span></div></div>
<p>You can get more understanding about usages of PyPDF if you explore more about open source projects which uses PyPDF. Here are some of the projects which use PyPDF.</p>
<ul>
<li><a href="http://code.google.com/p/flaxcode/" target="_blank">Falx: Fast, feature-rich, flexible enterprise search </a></li>
<li><a href="http://pybrary.net/" target="_blank">Pybrary</a></li>
<li><a href="http://code.google.com/p/xhtml2pdf-base/" target="_blank">xhtml2pdf-base</a></li>
<li><a href="http://code.google.com/p/nglib/" arget="_blank">nglib</a></li>
</ul>
<p>Related Resources:</p>
<ul>
<li><a rel="nofollow" href="http://code.activestate.com/recipes/511465/" target="_blank"> Pure Python PDF to text converter</a></li>
<li><a rel="nofollow" href="http://sourceforge.net/projects/pypdfgui/" target="_blank">PyPDF GUI</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.mpathirage.com/2010/01/16/merging-pdf-files-in-linux-using-pypdf/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Linux Utilities You Should Know About</title>
		<link>http://blog.mpathirage.com/2009/12/24/linux-utilities-you-should-know-about/</link>
		<comments>http://blog.mpathirage.com/2009/12/24/linux-utilities-you-should-know-about/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 03:59:12 +0000</pubDate>
		<dc:creator>Milinda Lakmal</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[pv]]></category>

		<guid isPermaLink="false">http://blog.mpathirage.com/?p=223</guid>
		<description><![CDATA[Utility applications in Linux which are(most of them) originally created for Unix and ported to Linux can be used to make every Linux users life easier. It doesn&#8217;t matter whether you are a beginner or a hard core Linux geek, if you know the tools it&#8217;ll save you lot of time. In this post I am going [...]]]></description>
			<content:encoded><![CDATA[<p>Utility applications in Linux which are(most of them) originally created for Unix and ported to Linux can be used to make every Linux users life easier. It doesn&#8217;t matter whether you are a beginner or a hard core Linux geek, if you know the tools it&#8217;ll save you lot of time.</p>
<p>In this post I am going to give you introduction to several utilities available on Linux that originated from Unix based on the recent posts by <a rel="nofollow" href="http://www.catonmat.net/" target="_blank">Peteris Krumins</a>. I am planning to update this post time to time once he add new articles about more tools.</p>
<p><strong><span style="text-decoration: underline;">Pipe Viewer</span></strong></p>
<p>Pipe viewer (Written by <a rel="nofollow" href="http://www.ivarch.com/">Andrew Wood</a>) or <a rel="nofollow" href="http://www.ivarch.com/programs/pv.shtml" target="_blank">pv</a> in short can be used inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion.</p>
<p>Default Ubuntu installation doesn&#8217;t come with this tool. You need to install it using <em>&#8216;sudo apt-get install pv&#8217;</em> command.</p>
<p>To get start with pv, lets use this to monitor the progress of compressing large file containing giga bytes of information in to a small file. The normal way to do this using gzip is like following.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #660033;">-c</span> x.avi <span style="color: #000000; font-weight: bold;">&amp;</span>gt; x.avi.gz</div></div>
<p>But this command won&#8217;t tell you how much time it takes to compress this file or monitor the progress of compression.</p>
<p>By using pv you can precisely time how long it will take. Take a look at doing the same through pv:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">pv x.avi <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; x.avi.gz<br />
<br />
69MB <span style="color: #000000;">0</span>:00:04 <span style="color: #7a0874; font-weight: bold;">&#91;</span>  15MB<span style="color: #000000; font-weight: bold;">/</span>s<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>==================<span style="color: #000000; font-weight: bold;">&amp;</span>gt;    &nbsp;    <span style="color: #7a0874; font-weight: bold;">&#93;</span>   <span style="color: #000000;">74</span><span style="color: #000000; font-weight: bold;">%</span>  ETA <span style="color: #000000;">0</span>:00:01</div></div>
<p>Pipe viewer acts as “cat” here, except it also adds a progress bar. We can see that gzip processed 69MB of data in 4 seconds. It has processed 74% of all data and it will take 1 more seconds to finish.</p>
<p>There are several advance usage patterns of pv command and I am not going to cover those.Please refer the <a rel="nofollow" href="http://www.catonmat.net/blog/unix-utilities-pipe-viewer/" target="_blank">article</a> from Peteris to explore more about pv command.</p>
<p><strong><span style="text-decoration: underline;">lsof(list open files)</span></strong></p>
<p><a rel="nofollow" href="http://catonmat.net" target="_blank">Peteris</a> called this tools as the <em>Swiss Army Knife of Unix Debugging</em>. <strong><a rel="nofollow" href="http://www.netadmintools.com/html/lsof.man.html" target="_blank">lsof</a></strong> is a utility command that you can used to list information about files opened by  Unix/Linux processes. In Unix/Linux every things is a file: pipes are files, IP sockets are files, unix sockets are files, directories are files, devices are files, inodes are files&#8230; So you know the advantage of this kind of tools where every thing is a file.</p>
<p><strong>Using lsof</strong></p>
<p>Here are some common uage scenarios of lsof comand extracted from <a rel="nofollow" href="http://www.catonmat.net/blog/unix-utilities-lsof/" target="_blank">catonmat.net</a> blog. You must have root permission to get the information about all the open files using lsof. Unless otherwise you&#8217;ll only get information set of files which you have permission to access them.</p>
<p><span style="text-decoration: underline;">List all open files </span></p>
<p>Running lsof without any arguments lists all open files by all processes.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;"># </span>lsof</div></div>
<p><span style="text-decoration: underline;">Find who&#8217;s using a file</span></p>
<p>With an argument of a path to a file, lsof lists all the processes, which are using the file in some way.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;"># </span>lsof <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">file</span></div></div>
<p>You may also specify several files, which lists all the processes, which are using all the files:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;"># </span>lsof <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>file1 <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>file2</div></div>
<p><span style="text-decoration: underline;">Find all open files in a directory recursively</span></p>
<p>With the </p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">+D</div></div>
<p>argument lsof finds all files in the specified directory and all the subdirectories.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;"># </span>lsof +D <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib</div></div>
<p>There more use cases of lsof command like getting open files by process, open files by users, list all network connections, list all TCP connections, list network activity by user and etc. Please refer <a rel="nofollow" href="http://www.catonmat.net/blog/unix-utilities-lsof/" target="_blank">blog post</a> from Peteris for those usage scenarios. You can find some examples of lsof from <a rel="nofollow" href="http://danielmiessler.com/study/lsof/" target="_blank">this link</a> also.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mpathirage.com/2009/12/24/linux-utilities-you-should-know-about/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

