<?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>MyLinuxBook</title>
	<atom:link href="http://mylinuxbook.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mylinuxbook.com</link>
	<description>Linux, OpenSource and more...</description>
	<lastBuildDate>Mon, 20 May 2013 15:51:20 +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>Linux Vim Editor Tips and Tricks &#8211; Save Time Through Macros and Bookmarks</title>
		<link>http://mylinuxbook.com/vim-editor-tips-tricks/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=vim-editor-tips-tricks</link>
		<comments>http://mylinuxbook.com/vim-editor-tips-tricks/#comments</comments>
		<pubDate>Mon, 20 May 2013 15:51:20 +0000</pubDate>
		<dc:creator>Rupali</dc:creator>
				<category><![CDATA[Linux Vim editor]]></category>
		<category><![CDATA[Linux text editor]]></category>
		<category><![CDATA[Linux vim bookmarks]]></category>
		<category><![CDATA[Linux vim editor]]></category>
		<category><![CDATA[Linux vim macros]]></category>
		<category><![CDATA[vim bookmarks]]></category>
		<category><![CDATA[vim editor]]></category>
		<category><![CDATA[vim macros]]></category>
		<category><![CDATA[vim tips and tricks]]></category>

		<guid isPermaLink="false">http://mylinuxbook.com/?p=2153</guid>
		<description><![CDATA[<p>Vim is one of the popular text editors of Linux. Because of its capabilities, there is a large fan base of this command line based text editor. In this article, we will discuss some impressive features of vim editor that can help you save a lot of time while working on vim. Introduction to VIM [...]</p><p>The post <a href="http://mylinuxbook.com/vim-editor-tips-tricks/">Linux Vim Editor Tips and Tricks &#8211; Save Time Through Macros and Bookmarks</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Vim_(text_editor)">Vim</a> is one of the popular text editors of Linux. Because of its capabilities, there is a large fan base of this command line based text editor. In this article, we will discuss some impressive features of vim editor <strong></strong>that can help you save a lot of time while working on vim.<br />
<span id="more-2153"></span></p>
<h2><span style="text-decoration: underline;">Introduction to VIM Editor macros</span></h2>
<p>Have you ever come across a situation where you have to type redundantly into files? For example, type a text repeatedly with changes related to numbers only (that increase sequentially). Definitely, it would be a highly mundane and unattractive task if we have to do it manually. So, there is an easy and interesting way out with the help of <strong>vim macros</strong>.</p>
<h3>Recording</h3>
<p>The concept is basically recording our single individual operation and repeat it as many times as we can, therefore automating the redundant ones. Here is how we do the recording in vim:</p>
<ul>
<li>Start the recording by pressing key ‘q’ followed by a character name register, the recording to be saved to, let us say ‘x’.</li>
<li>Do the individual operation which has to be done within the loop.</li>
<li>Stop the recording by again pressing ‘q’</li>
<li>Run the recording ‘i’ number of times by typing in the format</li>
</ul>
<pre>                               i@x</pre>
<p>where,</p>
<p>i =&gt; A number representing how many times to run the recording</p>
<p>x =&gt; Run the recording identified by this register</p>
<p>Coming back to our example, let us get our hands on to it.</p>
<p><em>We have a requirement to list down all addresses in a particular area, where all addresses are same except the house numbers which are sequentially increasing</em>.</p>
<p>So, create a new file using Vim editor using following command</p>
<pre>$vim addr</pre>
<p>Now, follow these steps :</p>
<ul>
<li>Enter the insert mode(press <strong>i</strong>) and type the first address of the area,</li>
</ul>
<pre>                 house no. 300 santa clara, ca</pre>
<ul>
<li>Come out of the insert mode (press escape key), and then start the recording. Press <strong>q</strong> following by <strong>a</strong>.</li>
<li>Next, copy the current line and paste it to next line by pressing <strong>yy</strong> and then <strong>p</strong>.</li>
<li>Navigate the cursor to the number on second line and press <strong>ctrl + a</strong> (ie hold <strong>ctrl</strong> and press <strong>a</strong>)to increment the number.</li>
<li>Stop the recording by pressing <strong>q</strong>.</li>
<li>Run the newly created recording 12 times by typing <strong>12@a</strong>.</li>
</ul>
<p>It is amazing to see how we see 12 lines of text addresses with sequential house numbers.</p>
<pre>house no. <span style="color: #339966;"><strong>300</strong></span> santa clara, ca

house no. <span style="color: #339966;"><strong>301</strong></span> santa clara, ca

house no. <span style="color: #339966;"><strong>302</strong></span> santa clara, ca

house no. <span style="color: #339966;"><strong>303</strong></span> santa clara, ca

house no. <span style="color: #339966;"><strong>304</strong></span> santa clara, ca

house no. <span style="color: #339966;"><strong>305</strong></span> santa clara, ca

house no. <span style="color: #339966;"><strong>306</strong></span> santa clara, ca

house no. <span style="color: #339966;"><strong>307</strong></span> santa clara, ca

house no. <span style="color: #339966;"><strong>308</strong></span> santa clara, ca

house no. <span style="color: #339966;"><strong>309</strong></span> santa clara, ca

house no. <span style="color: #339966;"><strong>310</strong></span> santa clara, ca

house no. <span style="color: #339966;"><strong>311</strong></span> santa clara, ca

house no. <span style="color: #339966;"><strong>312</strong></span> santa clara, ca

house no. <span style="color: #339966;"><strong>313</strong></span> santa clara, ca</pre>
<p>Similarly, we can do various similar tasks like typing redundant lines of text through the same way.</p>
<p>Further moving on to a next level, let’s say we have 1000 files and we want to convert the third line of every file with a text</p>
<p><strong>I love macros</strong></p>
<p>then on line number 5 type</p>
<p><strong>Its awesome</strong></p>
<p>Here are the steps to do this using our smart chap Vim “macro”.</p>
<ul>
<li>Open all files at once by <strong>vim *</strong> if all files are in the same directory OR <strong>vim &lt;path of each file&gt;</strong>.</li>
<li>Press <strong>q</strong> and then <strong>x</strong> to start recording the macro in letter x.</li>
<li>Go to line number 3. (ie Type <strong>:3</strong> and press enter).</li>
<li>To replace the text on this line press <strong>c + $</strong>. This is for changing everything from current cursor position till end of line.</li>
<li>Now type <em>I love macros</em> and press escape to switch off the insert mode.</li>
<li>To go to 5th line press the down arrow key twice. Remember you were at line number 3 at that time.</li>
<li>Now again press <strong>c + $</strong>, type <em>Its awesome</em> and press escape to switch off insert mode.</li>
<li>Now save these changes in current file and go to next file by typing <strong>:wn</strong> and press enter.</li>
<li>These are the steps you want to perform so now save the macro by pressing “q”.</li>
<li>If 1000 files were opened initially type <strong>999 @x</strong></li>
</ul>
<p>This is superb, isn’t it? The usage of macros and creativity to use them are unlimited and extends with your imagination. You can automate your mundane tasks, make your life easier and proud to be lazy by automating operations.</p>
<h3>Macros in buffer</h3>
<p>We have set a macro, and if we want to see what it contains, type</p>
<pre>:enew</pre>
<p>This will create a new file.</p>
<p>Now type :</p>
<pre> "ap</pre>
<p>Here <strong>a</strong> is the register in which our macro is stored. This will print the macro. Note that here the macro can also be edited.</p>
<p>This is what I get in my case</p>
<pre>yyp^A</pre>
<p>As expected, we see key combinations</p>
<p>yy &#8211; yanked</p>
<p>p &#8211; paste</p>
<p>^A &#8211; increment the number</p>
<p>The screen looks like :</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/vim.jpg"><img class="alignleft size-full wp-image-2154" alt="vim" src="http://mylinuxbook.com/wp-content/uploads/2013/05/vim.jpg" width="627" height="376" /></a></p>
<p>You can edit it, say delete <strong>^A</strong> and save it to the buffer using following key combination</p>
<pre>^”ay$</pre>
<p>Re-open our ‘addr’ file and now again run the macro in register <strong>a</strong> using following</p>
<pre>3@a</pre>
<p>Notice the difference. The house number is no more incrementing.</p>
<pre>house no. <strong><span style="color: #339966;">300</span></strong> santa clara, ca

house no. <strong><span style="color: #339966;">301</span></strong> santa clara, ca

house no. <strong><span style="color: #339966;">302</span></strong> santa clara, ca

house no. <strong><span style="color: #339966;">303</span></strong> santa clara, ca

house no. <strong><span style="color: #339966;">304</span></strong> santa clara, ca

house no. <strong><span style="color: #339966;">305</span></strong> santa clara, ca

house no. <strong><span style="color: #339966;">306</span></strong> santa clara, ca

house no. <strong><span style="color: #339966;">307</span></strong> santa clara, ca

house no. <strong><span style="color: #339966;">308</span></strong> santa clara, ca

house no. <strong><span style="color: #339966;">309</span></strong> santa clara, ca

house no. <strong><span style="color: #339966;">310</span></strong> santa clara, ca

house no. <strong><span style="color: #339966;">311</span></strong> santa clara, ca

house no. <strong><span style="color: #339966;">312</span></strong> santa clara, ca

house no. <span style="color: #ff0000;"><strong>313</strong></span> santa clara, ca

house no. <span style="color: #ff0000;"><strong>313</strong></span> santa clara, ca

house no. <span style="color: #ff0000;"><strong>313</strong></span> santa clara, ca

house no. <span style="color: #ff0000;"><strong>313</strong></span> santa clara, ca</pre>
<p>The post <a href="http://mylinuxbook.com/vim-editor-tips-tricks/">Linux Vim Editor Tips and Tricks &#8211; Save Time Through Macros and Bookmarks</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mylinuxbook.com/vim-editor-tips-tricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Is Everywhere &#8211; 12 Awesome Devices Powered By Linux</title>
		<link>http://mylinuxbook.com/awesome-devices-powered-by-linux/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=awesome-devices-powered-by-linux</link>
		<comments>http://mylinuxbook.com/awesome-devices-powered-by-linux/#comments</comments>
		<pubDate>Thu, 16 May 2013 15:49:25 +0000</pubDate>
		<dc:creator>Himanshu</dc:creator>
				<category><![CDATA[Market News]]></category>
		<category><![CDATA[devices running on Linux]]></category>
		<category><![CDATA[Linux gadgets]]></category>
		<category><![CDATA[Linux powered devices]]></category>

		<guid isPermaLink="false">http://mylinuxbook.com/?p=2075</guid>
		<description><![CDATA[<p>Besides well known devices like Google&#8217;s Android, Amazon&#8217;s Kindle etc, Linux is powering some of the most amazing devices around the globe and in the sky. Have a look at these 12 awesome devices that are powered by Linux. &#160; 1. Linux Powered Rifle Developed by an Austin based start-up (TrackingPoint), it is a Linux [...]</p><p>The post <a href="http://mylinuxbook.com/awesome-devices-powered-by-linux/">Linux Is Everywhere &#8211; 12 Awesome Devices Powered By Linux</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Besides well known devices like Google&#8217;s Android, Amazon&#8217;s Kindle etc, Linux is powering some of the most amazing devices around the globe and in the sky.</p>
<p>Have a look at these 12 awesome devices that are powered by Linux.<br />
<span id="more-2075"></span></p>
<p>&nbsp;</p>
<h2>1. Linux Powered Rifle</h2>
<p>Developed by an Austin based start-up (<a href="http://tracking-point.com/">TrackingPoint</a>), it is a Linux powered Rifle that boasts of auto-aim feature. This rifle is worth about $17000. Read more about it <a href="http://arstechnica.com/gadgets/2013/01/17000-linux-powered-rifle-brings-auto-aim-to-the-real-world/">here</a>.</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/LPD8.jpg"><img class="size-full wp-image-2096 alignnone" alt="LPD8" src="http://mylinuxbook.com/wp-content/uploads/2013/05/LPD8.jpg" width="640" height="389" /></a></p>
<p>&nbsp;</p>
<p style="text-align: center;">Image Courtesy <a href="http://arstechnica.com/gadgets/2013/01/17000-linux-powered-rifle-brings-auto-aim-to-the-real-world/">ArsTechnica</a></p>
<h2>2. Linux Powered MotorBike</h2>
<p>Priced at around $41000, TTX02 from Maziven is not like any other Motor Bike. This beast comes along with Linux OS, USB based system bus, WiFi connectivity and a web server.  Read more about it <a href="http://www.engadget.com/2009/11/05/mavizens-electric-bike-hits-130-mph-ships-with-linux-and-wifi/">here</a>.</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/LPD11.3.jpg"><img class="size-full wp-image-2107 aligncenter" alt="LPD11.3" src="http://mylinuxbook.com/wp-content/uploads/2013/05/LPD11.3.jpg" width="400" height="300" /></a></p>
<p style="text-align: center;">Image Courtesy <a href="http://www.engadget.com/2009/11/05/mavizens-electric-bike-hits-130-mph-ships-with-linux-and-wifi/">Engadget</a></p>
<h2>3. Large Hadron Collider</h2>
<p>Considered as one of the greatest engineering milestones of mankind, LHC is world&#8217;s largest and highest-energy particle accelerator. It was build by European Organization for Nuclear research to prove theories of particle physics, high energy physics and particularly to test the existence of Higgs Boson. Read more about it <a href="http://en.wikipedia.org/wiki/Large_Hadron_Collider">here</a>.</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/LPD10.4.jpg"><img class="size-full wp-image-2100 aligncenter" alt="LPD10.4" src="http://mylinuxbook.com/wp-content/uploads/2013/05/LPD10.4.jpg" width="616" height="425" /></a></p>
<p style="text-align: center;">Image Courtesy <a href="http://apod.nasa.gov/apod/ap080225.html">NASA</a></p>
<p>&nbsp;</p>
<h2>4. Linux Powered Smart Fridge</h2>
<p>With Linux at it&#8217;s display heart, make way for Smart Refrigerators. Now, get to know complete inventory of your fridge, get warned if any item is nearing it&#8217;s expiry, see the stock that is nearing it&#8217;s limit and even get recipe suggestions &#8212; all of this and more, right at the face of your fridge. Read more about it <a href="http://www.smartappliancenews.org/2013/03/21/2013-year-of-the-smart-appliance-2/">here</a>.</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/LPD10.5.jpg"><img class="size-full wp-image-2101 aligncenter" alt="LPD10.5" src="http://mylinuxbook.com/wp-content/uploads/2013/05/LPD10.5.jpg" width="616" height="425" /></a></p>
<p style="text-align: center;">Image Courtesy <a href="http://www.smartappliancenews.org/2013/03/21/2013-year-of-the-smart-appliance-2/">SmartApplianceNews</a></p>
<p>The post <a href="http://mylinuxbook.com/awesome-devices-powered-by-linux/">Linux Is Everywhere &#8211; 12 Awesome Devices Powered By Linux</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mylinuxbook.com/awesome-devices-powered-by-linux/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Linux Command Line Alternatives &#8211; Leave The Mouse To Rest!</title>
		<link>http://mylinuxbook.com/linux-command-line-vs-gui/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linux-command-line-vs-gui</link>
		<comments>http://mylinuxbook.com/linux-command-line-vs-gui/#comments</comments>
		<pubDate>Mon, 13 May 2013 13:51:06 +0000</pubDate>
		<dc:creator>Rupali</dc:creator>
				<category><![CDATA[CommandLineTips]]></category>
		<category><![CDATA[Linux administration]]></category>
		<category><![CDATA[access gmail from Linux command line]]></category>
		<category><![CDATA[CLI vs GUI]]></category>
		<category><![CDATA[Linux CLI vs GUI]]></category>
		<category><![CDATA[Linux command line web browser]]></category>
		<category><![CDATA[Linux convert utility]]></category>
		<category><![CDATA[Linux image editing utility]]></category>
		<category><![CDATA[Linux imagemagik utility]]></category>
		<category><![CDATA[Linux keyboard shortcuts]]></category>
		<category><![CDATA[Linux lynx command]]></category>
		<category><![CDATA[Lynx]]></category>

		<guid isPermaLink="false">http://mylinuxbook.com/?p=2012</guid>
		<description><![CDATA[<p>My family bought our first personal computer in the Windows dominated era. So, of course, Windows was the first operating system we started using. Not just that, we even used to enjoy it unless we started learning Linux and its various flavours. Why is it so? Well, I found it better than Windows in most [...]</p><p>The post <a href="http://mylinuxbook.com/linux-command-line-vs-gui/">Linux Command Line Alternatives &#8211; Leave The Mouse To Rest!</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>My family bought our first personal computer in the Windows dominated era. So, of course, Windows was the first operating system we started using. Not just that, we even used to enjoy it unless we started learning Linux and its various flavours. Why is it so? Well, I found it better than Windows in most of the cases. (<em>Here is an <a href="http://mylinuxbook.com/linux-newbie-10-reasons-why-i-wont-miss-windows/"> article</a> which discusses some reasons that make Linux a better operating system for users</em>). But one thing remained insatiable was what makes typing the commands on Linux command line a better experience than clicking impressive GUIs?</p>
<p>&nbsp;</p>
<h2><span style="text-decoration: underline;">Linux Command Line vs GUI<br />
</span></h2>
<p>As the saying goes, “<em>we learn it best when we do it ourselves</em>”, therefore after switching to Linux I personally felt the efficiency and quickness of tasks getting done through command line verses through graphical user interface (CLI vs GUI). And the major reason being, even a mouse click generates an action which will trigger the execution of the same executable as we do through the command directly. Hence, running the same task through GUI involves an extra overhead of calculating the mouse pointer coordinates, raising a click action etc. In case, there are input options required, it adds on to the overhead. All this handling of the overhead takes some time at the cost of impressive visuals and to avoid typing.</p>
<p>Well, to talk about deep driven merits of using command line as compared to GUI, here is a synopsis of abstract points:<br />
<span id="more-2012"></span></p>
<p><b>Agile and Time-saving</b></p>
<p>Since through command line we are just triggering the executable which makes it faster than any GUI operation which involves parsing actions, inputs and displaying outputs. As a simple comparison exercise, install <a href="http://www.videolan.org">VLC player</a> using its <a href="http://www.videolan.org/vlc/">installer</a>, which is GUI download/installation, and through the command line by running the following command.</p>
<pre style="overflow: auto; width: 600px;">$sudo apt-get update

$sudo apt-get install vlc</pre>
<p>Feel the difference in the amount of time one needs for the installation in both the cases.</p>
<p><b>Mouse Disability</b></p>
<p>A Linux command line user will rarely need a mouse device. From my own experience, just using keyboard is much convenient and as we develop the skill, its way more faster than using mouse. Believe it or not, but just using keyboard and typing every damn command sharpens our memory too.</p>
<p><b>Better Understanding</b></p>
<p>Running commands offer a better understanding of how system works than any GUI alternative. Moreover, as we use commands, we implicitly memorize many and we give ourselves an opportunity to learn more.</p>
<p><b>Scripts</b></p>
<p>Many of the redundant group tasks can be easily scripted and performed using those scripts. For example, if we have a huge set of files that needs to be renamed and then moved to another destination. With the GUI, it might be a tedious one for each one of the file, but with scripts its just about one logic in the script and running the script.</p>
<p><b>Typing</b></p>
<p>Do you think typing is a hassle with command line, especially with the long directory paths? There are some interesting conducive ways to avoid that. We shall learn more in the later sections.</p>
<p><b>Powerful</b></p>
<p>Commands are any way more powerful in terms of options from any GUI alternative. To conclude, the efficiency and several micro-seconds of time saved in each command, really makes tremendous and precious value addition in the life of Linux users.</p>
<p>Remember for every small task we want out of the operating system, there exist a command or a key combination. <em><strong>Here in further sections we shall learn about certain Linux command line utilities which are not popular but are still a good alternative to GUI for some common tasks.</strong></em></p>
<p><b>Assumption</b> All the commands discussed have been tested with bash shell on Ubuntu 12.04.</p>
<h2><span style="text-decoration: underline;">Shutdown and reboot the system</span></h2>
<p>When we click on the “shutdown..” action menu or button, it actually calls a command internally.</p>
<p>Linux gives us a simple command with the simplest name to remember</p>
<pre style="overflow: auto; width: 600px;">$shutdown [TIME]</pre>
<p><a href="http://linux.die.net/man/8/shutdown">Here</a> is its man page. The user needs root privileges to run this command.</p>
<p>Now we will discuss what all it has to offer.</p>
<p><strong>1.</strong> We can even schedule a shutdown using one of its argument specifying time. The time can be specified in a phrase like ‘now’ or in minutes, minutes or hh:mm where ‘hh’ specifies the hours and ‘mm’ specifies the minutes in the time.</p>
<p>Therefore after/at specified time, the shutdown is initiated.</p>
<p>As an example, try</p>
<pre style="overflow: auto; width: 600px;">$shutdown now</pre>
<p>2. One can even restart the system through</p>
<pre style="overflow: auto; width: 600px;">$shutdown -r 3</pre>
<p>It informs and alerts us about the reboot as</p>
<pre style="overflow: auto; width: 600px;">Broadcast message from rupali@home-OptiPlex-745

    (/dev/pts/0) at 10:16 ...

The system is going down for reboot in 3 minutes!

Broadcast message from rupali@home-OptiPlex-745

    (/dev/pts/0) at 10:17 ...

The system is going down for reboot in 2 minutes!

Broadcast message from rupali@home-OptiPlex-745

    (/dev/pts/0) at 10:18 ...

The system is going down for reboot in 1 minute!

Broadcast message from rupali@home-OptiPlex-745

    (/dev/pts/0) at 10:18 …

The system is going to reboot now!</pre>
<p>There is another way to reboot the system, and that is through the ‘reboot’ command.</p>
<p>Here is how it looks like when we run the command</p>
<pre style="overflow: auto; width: 600px;">Broadcast message from rupali@home-OptiPlex-745

    (/dev/pts/0) at 10:18 …

The system is going to reboot now!</pre>
<p>&nbsp;</p>
<h2><span style="text-decoration: underline;">Web Browsing</span></h2>
<p>Not one, but there are many text-based command line web browsers available for Linux. Such kind of command line web browsers may not be as fancy as our usual browsers. As a user, we all know fancy stuff comes with a compromise on efficiency. However, such simplistic command line browsers are pretty suitable for normal browsing and study.</p>
<p>One of such web browser is Lynx. The first and foremost step is to install it</p>
<pre style="overflow: auto; width: 600px;">$sudo apt-get install lynx-cur</pre>
<p>After the installation is complete, launch the web browser by</p>
<pre style="overflow: auto; width: 600px;">$lynx</pre>
<p>And we get the following screen</p>
<p style="text-align: center;"><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll1.jpg"><img class="aligncenter size-medium wp-image-2013" alt="ll1" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll1-300x142.jpg" width="300" height="142" /></a>(Click to Enlarge)</p>
<p>We need to know following basic help information to starting using the ‘lynx’ text based browser</p>
<pre style="overflow: auto; width: 600px;">Commands: Use arrow keys to move, '?' for help, 'q' to quit, '&lt;-' to go back.

 Arrow keys: Up and Down to move.  Right to follow a link; Left to go back.

H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list</pre>
<p>To enter a URL, press ‘g’. Type the website URL one wishes to open. Lets type and enter <em>mylinuxbook.com</em><br />
Check out the following snapshot with our input URL</p>
<p style="text-align: left;"><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll2.jpg"><img class="aligncenter size-medium wp-image-2014" alt="ll2" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll2-300x139.jpg" width="300" height="139" /></a></p>
<p style="text-align: center;">(Click to Enlarge)</p>
<p>We get the website opened in our browser which looks like:</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll3.jpg"><img class="aligncenter size-medium wp-image-2015" alt="ll3" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll3-300x139.jpg" width="300" height="139" /></a></p>
<p style="text-align: center;">(Click to Enlarge)</p>
<p>Navigate through the website by using up and down arrows. As we move up/down, the selected link gets highlighted. And we click a particular link by pressing ‘enter’.</p>
<p>For me, I select the ‘commands’ link from the menu available</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll4.jpg"><img class="aligncenter size-full wp-image-2016" alt="ll4" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll4.jpg" width="352" height="403" /></a></p>
<p>After selecting ‘commands’ menu item, I press ‘enter’, which leads me to the relevant web-page.</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll5.jpg"><img class="aligncenter size-medium wp-image-2017" alt="ll5" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll5-300x145.jpg" width="300" height="145" /></a></p>
<p style="text-align: center;">(Click to Enlarge)</p>
<p>Note that, the top header menu remains the same for all the web pages of this website.</p>
<p>To go back, use left arrow key. Any time, we need to open a different URL, press ‘g’ and enter the URL. Lynx comes with a <a href="http://linux.die.net/man/1/lynx">man page </a> for its usage information.</p>
<p>However, we shall not go much in the details of the usage of web browsers as every text based web browser would have its own different ways to use.</p>
<p>A few known browsers are:</p>
<ul>
<li><a href="http://www.google.com/url?q=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FLinks_%2528web_browser%2529&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNGD41bsxDkae87l98-3QcSrRGIc8Q">Links</a></li>
<li><a href="http://www.google.com/url?q=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FW3m&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNHDAUxWwEx_4q4oDOAM1nhMT9OfSQ">w3m</a></li>
<li><a href="http://www.google.com/url?q=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FElinks&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNHQaEOeDxHd_R0zZjY_W2-KarWVdw">ELinks</a></li>
</ul>
<p>I don’t recommend any specific browser, feel free to explore the available ones and set your preference.</p>
<p>&nbsp;</p>
<h2><span style="text-decoration: underline;">Email Client</span></h2>
<p>In this connected world, are we too addicted email clients? In our CLI Linux world, we can’t afford <b>not</b> to have a command line based email clients on Linux. Command line email client tools are powerful in terms of performance, and very easy to configure and use. However, to be candid, for someone who needs an interaction-impressive email client, command line based email client tools are not for them.</p>
<p>First of all, let us go ahead installing ‘mutt’ on our linux system, which can be done by following command</p>
<pre style="overflow: auto; width: 600px;">sudo apt-get install mutt</pre>
<p>While we run this command, on my ubuntu 12.04 system, it asks</p>
<pre style="overflow: auto; width: 600px;">Need to get 2,682 kB of archives.

After this operation, 7,523 kB of additional disk space will be used.

Do you want to continue [Y/n]?</pre>
<p>Type ‘y’ and press enter to the above prompt. And then it asks for certain basic configurations with a text based in-terminal screen. Following is a snapshot</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll6.jpg"><img class="aligncenter size-medium wp-image-2018" alt="ll6" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll6-300x179.jpg" width="300" height="179" /></a></p>
<p style="text-align: center;">(Click to Enlarge)</p>
<p>Since it is purely text based, mouse won’t work here. To select ‘OK’, press right arrow and then press ‘enter’. Further we get following screen, where we need to select a general type of mail configuration</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll7.jpg"><img class="aligncenter size-medium wp-image-2019" alt="ll7" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll7-300x179.jpg" width="300" height="179" /></a></p>
<p style="text-align: center;">(Click to Enlarge)</p>
<p>Since, in this article we aim to configure our ‘www.gmail.com’ account email to this email client, hence we need to select “Internet Site”. <a href="http://www.postfix.org/BASIC_CONFIGURATION_README.html"> Here </a> is a link to know more about postfix configurations.</p>
<p>Similarly select ‘OK’ by right arrow and pressing enter.</p>
<p>Next it asks us the system mail name. The information on the screen also explains</p>
<pre style="overflow: auto; width: 600px;">│ Thus, if a mail address on the local host is foo@example.org, the         │  

│ correct value for this option would be example.org.</pre>
<p>Therefore, in case I, type ‘gmail.com’. After typing, select ‘OK’ and press enter, which completes the ‘mutt’ installation and basic configuration.</p>
<p>However, we are still one step away from using the mutt email client. What is that one step? It is the client configuration and customization. Creating the directories for caching headers and bodies along with certificates</p>
<pre style="overflow: auto; width: 600px;">$ mkdir -p ~/.mutt/cache/headers

$ mkdir ~/.mutt/cache/bodies

$ touch ~/.mutt/certificates</pre>
<p>Thereafter, creating a ‘.muttrc’ file in the home directory having the following customised settings</p>
<p><b>Notes (Before you proceed further)<br />
</b></p>
<ul>
<li>We are connecting it to the Gmail mail, which is an IMAP mail server</li>
</ul>
<ul>
<li>Replace all ‘rupali.s@gmail.com’ with your email account</li>
</ul>
<ul>
<li>One can also configure it with our password, but I won’t recommend the password to be mentioned in any clear form in any file on our system. Hence, leaving it to be prompted for whenever required.</li>
</ul>
<pre style="overflow: auto; width: 600px;"># The gmail account details. Please change it to suit you.

set imap_user = "rupali.s@gmail.com"

set smtp_url = "smtp://rupali.s@smtp.gmail.com:587/"

set from = "rupali.s@gmail.com"

set realname = "Rupali"

# Set your favourite editor here

set editor = "vi"

# Certain configurations

set folder = "imaps://imap.gmail.com:993"

set spoolfile = "+INBOX"

set imap_check_subscribed

set hostname = gmail.com

set mail_check = 120

set timeout = 300

set imap_keepalive = 300

set postponed = "+[GMail]/Drafts"

set record = "+[GMail]/Sent Mail"

set header_cache=~/.mutt/cache/headers

set message_cachedir=~/.mutt/cache/bodies

set certificate_file=~/.mutt/certificates

set move = no

set include

set sort = 'threads'

set sort_aux = 'reverse-last-date-received'

set auto_tag = yes

ignore "Authentication-Results:"

ignore "DomainKey-Signature:"

ignore "DKIM-Signature:"

hdr_order Date From To Cc

alternative_order text/plain text/html *

auto_view text/html

bind editor  complete-query

bind editor ^T complete

bind editor  noop

# Gmail-style keyboard shortcuts

macro index,pager y "unset trash\n " "Gmail archive message"

macro index,pager d "set trash=\"imaps://imap.googlemail.com/[GMail]/Bin\"\n " "Gmail delete message"

macro index,pager gi "=INBOX" "Go to inbox"

macro index,pager ga "=[Gmail]/All Mail" "Go to all mail"

macro index,pager gs "=[Gmail]/Starred" "Go to starred messages"

macro index,pager gd "=[Gmail]/Drafts" "Go to drafts"</pre>
<p>Now we are all set to use the email client ‘mutt’. Run it by running following command</p>
<pre style="overflow: auto; width: 600px;">$mutt</pre>
<p>A blank screen turns up, which prompts for the password at its bottom-most list</p>
<pre style="overflow: auto; width: 600px;">Password for rupali.s@gmail.com@imap.gmail.com:</pre>
<p>Enter your password and it will start loading your mails for you to access. Here is how it showcases your mails.</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll8.jpg"><img class="aligncenter size-full wp-image-2020" alt="ll8" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll8.jpg" width="531" height="97" /></a></p>
<p>Check out the top highlighted line which is a basic help segment always available, intimating basic key options. Here are the commonly used ones</p>
<pre style="overflow: auto; width: 600px;">Up/Down Arrow:    Navigate the messages

Enter:            Select the message

q:             To Quit the tool or return to the message list view

d:            Delete a message

u:            To Undelete a mail

s:            To Save a mail  

m:            Initiate composing a mail

r:            To Reply

g:            A group reply

?:            Need a Help</pre>
<p>While composing a mail/reply, your favourite editor shall be opened as mentioned in the ‘.muttrc’ by us.</p>
<p>Well, mutt client agent has a lot more options and customisations as we start using it. This article shall not delve into all those usage information details which can be referred <a href="http://www.mutt.org/#doc">here</a>.</p>
<p>However, there are other such command line email clients also available, such as</p>
<p><a href="http://en.wikipedia.org/wiki/Pine_(email_client)">Pine </a></p>
<p><a href="http://en.wikipedia.org/wiki/Alpine_(email_client)">Alpine </a></p>
<p><a href="http://en.wikipedia.org/wiki/Mailx"> mailx</a></p>
<p>&nbsp;</p>
<h2><span style="text-decoration: underline;">Imagemagick</span></h2>
<p>Editing images is no longer a professional’s effort in this era of social networking websites, most of us are living in. Of course, GUI has enhanced certain editing features as for example, say cropping. No doubt about that. <em><strong>However, think of cropping like hundreds of images to the same size. I am pretty sure, it wouldn’t be a pleasant experience with GUI applications any more</strong></em>. Besides, still most of the other image editing features are efficiently done through command line, without depending on any GUI application functionalities. Moreover, if the image editing is to be done on a number of images, command line tools is the most convenient rescue.</p>
<p>Linux gives us one such superb image format converter and editor which is <em>imagemagick.</em></p>
<p>It is installed with the package ‘imagemagick’</p>
<pre style="overflow: auto; width: 600px;">$sudo apt-get install imagemagick</pre>
<p>Imagemaick is like a suite of command line utilities for image operations. Here is a list of all the utilities which come within, descriptions taken from the man page.</p>
<p><strong>Note</strong>: <em>As an example image for all the illustrated example usage, we have taken following image called ‘orig.png’</em></p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll9.jpg"><img class="aligncenter size-full wp-image-2021" alt="ll9" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll9.jpg" width="198" height="264" /></a></p>
<h3>display</h3>
<p>displays an image or image sequence on any X server.</p>
<p>So, lets ask it to display the image, which can be done by</p>
<pre style="overflow: auto; width: 600px;">$display orig.png</pre>
<p>And here is what we get, A dialog window with the image displayed.</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll10.jpg"><img class="aligncenter size-full wp-image-2022" alt="ll10" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll10.jpg" width="254" height="396" /></a></p>
<h3>convert</h3>
<p>convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. The umbrella of benefits also includes the scenario where a thumbnail picture can be dexterously created in an autoscript of any application by just resizing any picture. Now we know, how might facebook has the thumbnail ready as soon as we upload our profile picture.</p>
<pre style="overflow: auto; width: 600px;">convert -resize 30x30 orig.png resized.png</pre>
<p>The resulting thumbnail is:</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll11.jpg"><img class="aligncenter size-full wp-image-2023" alt="ll11" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll11.jpg" width="29" height="34" /></a></p>
<p>To check out an example of the image effects it can do, try</p>
<pre style="overflow: auto; width: 600px;">convert -monochrome orig.png m.png</pre>
<p>Here it edits the image to convert into a black and white monochrome effect, and save it to a separate ourput file m.png. Here is how the output file looks like</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll12.jpg"><img class="aligncenter size-full wp-image-2024" alt="ll12" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll12.jpg" width="246" height="360" /></a></p>
<p>‘convert’ is also capable of converting from one image file format to another. Here is how that works specifying the compression level of the converted format JPEG.</p>
<pre style="overflow: auto; width: 600px;">$ convert -quality orig.png converted.jpg</pre>
<p>Using ‘convet’ tool, the linux users have the capability to do image effects, resize and even rotate the image. Checkout this interesting set of effects of our image.</p>
<pre style="overflow: auto; width: 600px;">$ convert orig.png -rotate 180 -emboss 1 -quality 90  new.jpg</pre>
<p>Our output image is, the penguin looks beautiful to me</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll13.jpg"><img class="aligncenter size-full wp-image-2025" alt="ll13" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll13.jpg" width="257" height="358" /></a></p>
<p>More effects and options of ‘convert’ can be referred to from its <a href="http://linux.die.net/man/1/convert">man page</a>.</p>
<h3>identify</h3>
<p>describes the format and characteristics of one or more image files.</p>
<p>Trying it out on our original image,</p>
<pre style="overflow: auto; width: 600px;">$ identify orig.png</pre>
<p>What I get is,</p>
<pre style="overflow: auto; width: 600px;">orig.png PNG 198x264 198x264+0+0 8-bit DirectClass 62.5KB 0.000u 0:00.000</pre>
<p>If one doesn’t understand, what the output means, verbose output is obtained by</p>
<pre style="overflow: auto; width: 600px;">$ identify -verbose orig.png</pre>
<p>A detailed output looks like,</p>
<pre style="overflow: auto; width: 600px;">Image: orig.png

 Format: PNG (Portable Network Graphics)

 Class: DirectClass

 Geometry: 198x264+0+0

 Resolution: 72x72

 Print size: 2.75x3.66667

 Units: Undefined

 Type: TrueColorMatte

 Endianess: Undefined

 Colorspace: RGB

 Depth: 8-bit

 Channel depth:

   red: 8-bit

   green: 8-bit

   blue: 8-bit

   alpha: 1-bit

 Channel statistics:

   Red:

     min: 0 (0)

     max: 255 (1)

     mean: 141.496 (0.554886)

     standard deviation: 61.8626 (0.242598)

     kurtosis: 0.0347628

     skewness: -0.547966

   Green:

     min: 0 (0)

     max: 255 (1)

     mean: 147.828 (0.579719)

     standard deviation: 60.3165 (0.236535)

     kurtosis: 0.504549

     skewness: -0.947011

   Blue:

     min: 0 (0)

     max: 255 (1)

     mean: 140.783 (0.552089)

     standard deviation: 66.8083 (0.261993)

     kurtosis: -0.311562

     skewness: -0.855471

   Alpha:

     min: 255 (1)

     max: 255 (1)

     mean: 255 (1)

     standard deviation: 0 (0)

     kurtosis: 0

     skewness: 0

 Image statistics:

   Overall:

     min: 0 (0)

     max: 255 (1)

     mean: 107.527 (0.421673)

     standard deviation: 82.7262 (0.324416)

     kurtosis: -1.45325

     skewness: -0.185137

 Rendering intent: Undefined

 Interlace: None

 Background color: white

 Border color: rgba(223,223,223,1)

 Matte color: grey74

 Transparent color: none

 Compose: Over

 Page geometry: 198x264+0+0

 Dispose: Undefined

 Iterations: 0

 Compression: Zip

 Orientation: Undefined

 Properties:

   date:create: 2013-05-10T22:14:27-07:00

   date:modify: 2013-05-10T22:14:27-07:00

   signature: 4fa517adcf20cdc524027ac621ba437e38635f21443781678830f3e75d890f15

 Artifacts:

   verbose: true

 Tainted: False

 Filesize: 62.5KB

 Number pixels: 52.3K

 Pixels per second: 5.227M

 User time: 0.010u

 Elapsed time: 0:01.009

 Version: ImageMagick 6.6.2-6 2011-03-16 Q16 http://www.imagemagick.org</pre>
<h3>mogrify</h3>
<p>resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. Mogrify overwrites the original image file, whereas, convert writes to a different image file.</p>
<p>To see how it works differently as compared to ‘convert’, do the following :</p>
<p>First of all, because we are expecting the original image to be overwritten, lets create a copy of our original one, as we need to use the original one for other imagemagick tools too.</p>
<pre style="overflow: auto; width: 600px;">$cp orig.png oimg.png

$mogrify -monochrome oimg.png

$display oimg.png</pre>
<p>As a result of ‘display’ command, we get</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll14.jpg"><img class="aligncenter size-full wp-image-2026" alt="ll14" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll14.jpg" width="255" height="379" /></a></p>
<p>Most of the <a href="http://linux.about.com/od/commands/l/blcmdl1_mogrify.htm">mogrify options</a> are similar to the ‘convert’ ones.</p>
<h3>composite</h3>
<p>overlaps one image over another.</p>
<p>This is going to be really amazing. It takes a lot of mouse click efforts to overlap two images in any image editor, here it just takes the following command</p>
<pre style="overflow: auto; width: 600px;">$composite thumbnail.png new.jpg overlapped.png</pre>
<p>The output image ‘overlapped.png’ is</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll15.jpg"><img class="aligncenter size-full wp-image-2027" alt="ll15" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll15.jpg" width="310" height="391" /></a></p>
<h3>montage</h3>
<p>Create a composite image by combining several separate images. The images are tiled on the composite image optionall adorned with a border, frame, image name, and more.</p>
<p>With ‘montage’, it creates a collage kind of collection of images in a geometrical way. The generic syntax to use ‘montage’ is</p>
<pre style="overflow: auto; width: 600px;">      montage input-file [options] output-file</pre>
<p>Note, the input file in above can be a set of files separated by spaces</p>
<p>For example, we shall be creating a composite image with all the effects and editing on our original image. Initially lets create several images with different effects using following simple ‘convert’ command</p>
<pre style="overflow: auto; width: 600px;">$ convert -implode 1 orig.png implode.png

$ convert -monochrome orig.png mono.png

$ convert -charcoal 3 orig.png charc.png

$ convert -emboss 6 orig.png emboss.png

$ convert -resize 60x60 orig.png resized.png</pre>
<p>With each of the above five commands, we get five differently edited images, and including the original, we have total six images in total to create a composite image.</p>
<p>Now, we use the ‘montage’ tool to create a collage as follows:</p>
<pre style="overflow: auto; width: 600px;">$montage *.png montage.png</pre>
<p>The figure below is how our output image looks like</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll16.jpg"><img class="aligncenter size-full wp-image-2028" alt="ll16" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll16.jpg" width="385" height="282" /></a></p>
<p>Note, the way the images have been composited to create the final output image. It offers various options, including to change the geometry of the images, more details of which can be referred through its <a href="http://linux.die.net/man/1/montage">man page</a>.</p>
<pre style="overflow: auto; width: 600px;"></pre>
<h3>compare</h3>
<p>Mathematically and visually annotate the difference between an image and its reconstruction.. This is a very useful tool, especially for image processing professionals who need to monitor every pixel variation. As an example, let us compare two different formats of same image.</p>
<pre style="overflow: auto; width: 600px;">$compare orig.png converted.jpg diff.png</pre>
<p>The way it illustrates a comparison visually is in the form of a diff image,</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll17.jpg"><img class="aligncenter size-full wp-image-2029" alt="ll17" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll17.jpg" width="247" height="355" /></a></p>
<p>Mathematically, it compares two images as</p>
<pre style="overflow: auto; width: 600px;">$compare -metric AE  orig.png converted.jpg diff.png</pre>
<p>We use the option -metric which needs a metric type. In this example, we use ‘AE’ which corresponds to Absolute Error. More information regarding metric and metric types is <a href="http://www.imagemagick.org/script/command-line-options.php#metric">here</a></p>
<p>For the metric type = AE, we get difference output as,</p>
<pre style="overflow: auto; width: 600px;">6707</pre>
<h3>animate</h3>
<p>Animates an image sequence on any X server.</p>
<p>I am pretty sure you would love this tool. Remember the earlier days, where animations were created by drawing several and several drawings depicting a change in the overall movement. Similarly, this tool works on the same concept of principle. As a simplest example, lets create certain images of varying sizes in a separate directory.</p>
<pre style="overflow: auto; width: 600px;">$mkdir animation

$cp orig.png animation/0.png

$cd animation

$convert -resize 10x10 0.png 1.png

$convert -resize 20x20 0.png 2.png

$convert -resize 30x30 0.png 3.png

$convert -resize 40x40 0.png 4.png

$convert -resize 50x50 0.png 5.png

$convert -resize 60x60 0.png 6.png

$convert -resize 70x70 0.png 7.png

$convert -resize 80x80 0.png 8.png

$convert -resize 90x90 0.png 9.png

$convert -resize 100x100 0.png 91.png

$convert -resize 110x110 0.png 92.png

$convert -resize 120x120 0.png 93.png</pre>
<p>Now, run the animation as</p>
<pre style="overflow: auto; width: 600px;">$animate *.png</pre>
<p>Use your creativity cells to create such animations and we would love to hear about them.</p>
<h2><span style="text-decoration: underline;">Command Line Terminal Shortcuts</span></h2>
<p>In the initial section above, we discussed that for using command line for all kinds of tasks will result in a lot of typing. I never denied that a lot of typing can be cumbersome, especially when it comes to long file names, at times re-typing commands, etc. Although, we cannot completely avoid typing but Linux does come with a way to minimize certain difficulties. In this section we shall be discussing a few fantastic key combination short cuts which can be used while working on Linux terminal.</p>
<h3><b>CTRL + r</b></h3>
<p>This is an exciting short cut to search through the list of commands we’ve run in a terminal. We can even edit the already run command and then run it with the modification. As in, suppose we once copied a file ‘f1’ from a directory path to another destination path. Now we would like to copy file ‘f2’ from the same source path to the same directory path.</p>
<p>We can re-use are earlier used command as</p>
<p>1. Press key combination ‘Ctrl + r’</p>
<p>We get following just below command prompt</p>
<pre style="overflow: auto; width: 600px;">$

<strong>(reverse-i-search)`':</strong></pre>
<p>2. Type cp.</p>
<p>Basically, type the initial matching characters of the relevant command. More the relevant characters we type, quicker we’ll encounter the matching needed command from the already run commands.</p>
<p>3. Keep pressing ‘Ctrl + r’ until it displays our needed ‘cp’ command from the list of earlier used commands.</p>
<pre style="overflow: auto; width: 600px;">$

<strong>(reverse-i-search)`cp': cp /home/rupali/programs/cstatic/f1 /home/rupali/out/dest/</strong></pre>
<p>4. Once it shows our relevant command, press right arrow key (or left arrow key) to come out.</p>
<p>5. Make modification to change the filename from ‘f1’ to ‘f2’ and then run the new modified command.</p>
<pre style="overflow: auto; width: 600px;">cp /home/rupali/programs/cstatic/f2 /home/rupali/out/dest/</pre>
<p>Therefore, it helped us to avoid re-writing the complete ‘cp’ command. It is an immensely useful key combination in Linux.</p>
<h3>Up Arrow</h3>
<p>To check and run the recently run commands in a terminal. As an example, we are debugging an application and every time we make a change in the source, we have to run our ‘make’ command. We don’t need to type ‘make target’ again and again as it is the one of the most recent command in the command history. Just use up arrow to browse through recently run commands and run it from there.</p>
<p>The same can also be done using key combination<b> ‘CTRL + p’.</b></p>
<p>To see how that works, run command ‘ls’ on your command prompt. After the command output, press up arrow key. You’ll find ‘ls’ command, which is the recent command which we just ran.</p>
<h3>CTRL + a and CTRL + e</h3>
<p>At times, we are typing our command and then notice we need to add ‘sudo’ in front of the command. We can use the key combination ‘Ctrl + a’ to reach the beginning of the command. The same can be achieved by ‘home’ key.</p>
<p>Similarly, we can use the key combination ‘Ctrl + e’ to reach the end of the command. Again, the same can also be done by ‘end’ key.</p>
<h3><b> Tab key</b></h3>
<p>Tab key is the most used among the Linux users. When we are typing a file/directory path, ‘tab’ key assists in auto-complete as we move along with the path.</p>
<p>The way how it works is, type the initial characters identifying the directory name in the path of the filename, and press ‘tab’ key. It will be auto-completed in case the initial few typed characters uniquely identify it. Otherwise, it will suggest the possible names.</p>
<p>For example, try</p>
<pre style="overflow: auto; width: 600px;">$gedit /h</pre>
<p>and then press tab key. It will be be auto-completed to</p>
<pre style="overflow: auto; width: 600px;">$ls/home</pre>
<p>In this way, we can easily type and auto-complete a long path as well conveniently.</p>
<h3><b> CTRL + l</b></h3>
<p>One can clear the terminal using ‘ctrl + l’ key combination. It has the same effect as the <a href="http://linux.die.net/man/1/clear">clear</a> command. So, no need to type ‘clear’ command again and again.</p>
<h3><b>CTRL + u</b></h3>
<p>Clears all the text to the left of the current cursor on the command prompt.<br />
For example,</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll18.jpg"><img class="aligncenter size-full wp-image-2030" alt="ll18" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll18.jpg" width="303" height="21" /></a></p>
<p>On pressing Ctrl + u, we get<br />
<a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll19.jpg"><img class="aligncenter size-full wp-image-2031" alt="ll19" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll19.jpg" width="259" height="22" /></a></p>
<h3><b>CTRL + k</b></h3>
<p>Similar to the above discussed key combination, ‘ctrl + k’ removes all the text to the right of the current cursor on the command prompt<br />
<a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll20.jpg"><img class="aligncenter size-full wp-image-2032" alt="ll20" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll20.jpg" width="306" height="25" /></a></p>
<p>On pressing ‘ctrl + k’, we get<br />
<a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll21.jpg"><img class="aligncenter size-full wp-image-2033" alt="ll21" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll21.jpg" width="342" height="24" /></a></p>
<h3><b>ALT + d</b></h3>
<p>This key combination clears the word from the command prompt. Though the cursor should be at the beginning of the word before pressing ‘alt +d’.<br />
As in,<br />
<a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll22.jpg"><img class="aligncenter size-full wp-image-2034" alt="ll22" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll22.jpg" width="214" height="23" /></a></p>
<p>On pressing ‘Alt + d’, we get<br />
<a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll23.jpg"><img class="aligncenter size-full wp-image-2035" alt="ll23" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll23.jpg" width="194" height="20" /></a></p>
<p>Note, this involves ‘Alt’ key and not the ‘Ctrl’.</p>
<h3><b>Other keyboard shortcuts</b></h3>
<p>The other keyboard shortcuts like opening a terminal, searching in the filesystem, etc can depend upon the distribution of the linux used. However, they are even changeable from the system preferences.</p>
<p>As in, in case of ubuntu, we the keyboard shortcuts can be found under</p>
<p>System &gt; Preferences &gt;Keyboard Shortcuts<br />
Following is the snapshot depicting the same.</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/ll24.jpg"><img class="aligncenter size-full wp-image-2036" alt="ll24" src="http://mylinuxbook.com/wp-content/uploads/2013/05/ll24.jpg" width="629" height="354" /></a></p>
<p>Well, from the above key shortcuts, we see Linux really values our typing and helps us in all ways in saving our effort of typing something which has been typed once.</p>
<p>NOTE &#8211; To learn some amazing Linux command line tricks, read our article on <a href="http://mylinuxbook.com/20-interesting-and-extremely-helpful-linux-command-line-tricks/"><em>20 interesting and extremely helpful Linux command line tricks</em></a></p>
<h2><span style="text-decoration: underline;">Conclusion</span></h2>
<p>This article is an effort to widen the scope of using more and more Linux command line which is much faster and effective along with aiding self learning. Believe me, there are plethora of command line Linux utilities and tricks available for each and everything that can be done on an operating system. So, it is an endless topic. Would love to hear about more command line Linux powerful tools.</p>
<p>The post <a href="http://mylinuxbook.com/linux-command-line-vs-gui/">Linux Command Line Alternatives &#8211; Leave The Mouse To Rest!</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mylinuxbook.com/linux-command-line-vs-gui/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Is Baidu Eye A Real Competition To Linux Powered Google Glass?</title>
		<link>http://mylinuxbook.com/is-baidu-eye-a-real-threat-to-linux-powered-google-glass/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=is-baidu-eye-a-real-threat-to-linux-powered-google-glass</link>
		<comments>http://mylinuxbook.com/is-baidu-eye-a-real-threat-to-linux-powered-google-glass/#comments</comments>
		<pubDate>Mon, 06 May 2013 15:43:40 +0000</pubDate>
		<dc:creator>Piunika</dc:creator>
				<category><![CDATA[Market News]]></category>

		<guid isPermaLink="false">http://mylinuxbook.com/?p=1994</guid>
		<description><![CDATA[<p>“If you can get some inspiration from your competitor then there is nothing wrong in it”. Seems like Biadu (NASDAQ:BIDU), Chinese internet search engine company, strongly believes in this. The company has reportedly come up with a wearable glass technology, named &#8216;baidu eye&#8217;, that seems to be very similar to Google&#8217;s &#8216;glass&#8217; that was introduced [...]</p><p>The post <a href="http://mylinuxbook.com/is-baidu-eye-a-real-threat-to-linux-powered-google-glass/">Is Baidu Eye A Real Competition To Linux Powered Google Glass?</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/05/googleGlass.jpg"><img class="alignleft size-full wp-image-1995" alt="googleGlass" src="http://mylinuxbook.com/wp-content/uploads/2013/05/googleGlass.jpg" width="350" height="226" /></a>“If you can get some inspiration from your competitor then there is nothing wrong in it”. Seems like Biadu (NASDAQ:BIDU), Chinese internet search engine company, strongly believes in this. The company has reportedly come up with a wearable glass technology, named &#8216;baidu eye&#8217;, that seems to be very similar to Google&#8217;s &#8216;glass&#8217; that was introduced last year (2012). For reasons best known to Baidu, they claim it to be different and innovative than Google&#8217;s technology.</p>
<p>The <a href="http://english.sina.com/business/2013/0402/577586.html">news</a> broke out around April fools day and took technology enthusiasts by surprise. While some of them appreciated the arrival of Google glass competitor, others slammed it as yet another attempt by a Chinese company to copy technology developed by an American company.<br />
<span id="more-1994"></span></p>
<p>Due to the timing, there was a whole lot of confusion related to authenticity of the news. Some of the news outlets like <a href="http://techcrunch.com/2013/04/03/baidu-reportedly-developing-baidu-eye-its-version-of-google-glass/">Techcrunch</a> made a full circle by first confirming that &#8216;eye&#8217; definitely exists and is under rapid development but then an update to the same article said that though it seems like one of the best April fool&#8217;s joke but still has a &#8216;kernel of truth&#8217;.</p>
<p>Initial reports related to &#8216;eye&#8217; also made several huge claims including that the company is working with Qualcomm to develop a technology that can extend the battery life of this wearable technology product to more than 12 hours. But, seems like this &#8216;Qualcomm story&#8217; , that was making rounds on internet, prompted Baidu to make an official public statement to clear the confusion around &#8216;eye&#8217;.</p>
<p>According to <a href="http://www.engadget.com/2013/04/03/baidu-eye-google-glass/">Engadget</a>, here is what Baidu&#8217;s director of international communications, Kaiser Kuo, said about &#8216;eye&#8217; :</p>
<blockquote><p>&#8220;We really are developing something similar in its basic functionality to what was described in the Sina Tech report and other sources in the Chinese press; the reports were correct in their essentials though they got some of the details wrong (and those inaccuracies may have its origins in an April Fool&#8217;s prank gone awry!). The project&#8217;s internal name is Baidu Eye. Not sure whether that&#8217;s going to be its final name. We&#8217;re doing some internal testing on it now on a small scale, and evaluating where this goes from here. That&#8217;s why we didn&#8217;t make any public official announcement on this.&#8221;</p></blockquote>
<p>Mr Kuo also confirmed that the &#8216;Qualcomm story&#8217; is not true to the best of his knowledge.</p>
<h2><span style="text-decoration: underline;">Baidu Eye &#8211; Features</span></h2>
<p>&#8216;Tit for tat&#8217; or &#8216;eye for an eye&#8217; ? Whatever you call it but one thing is for sure that &#8216;eye&#8217; is not fundamentally different from &#8216;glass&#8217; as Mr Kuo also confirmed that just like &#8216;glass&#8217;, &#8216;eye&#8217; is also an &#8216;ocular wearable interface&#8217;.</p>
<p>As reported, It boasts of features like :</p>
<p>• Voice search<br />
• Image search<br />
• Facial recognition<br />
• Bone conduction<br />
• etc</p>
<p>Besides, &#8216;eye&#8217; can also be used as standard pair of eyeglasses.</p>
<h2><span style="text-decoration: underline;">Business</span></h2>
<p>As of now, Baidu, the company, doesn&#8217;t seem to have an aggressive plan to launch &#8216;eye&#8217; in the market. The company claims that &#8216;eye&#8217; is an internal project which may or may not hit the market but doing research on any technology related to internet search falls in line with company&#8217;s vision.</p>
<p>Linux powered Google glass (download kernel code <a href="https://code.google.com/p/google-glass-kernel-source/">here</a>) is scheduled to arrive in market <a href="http://news.cnet.com/8301-1023_3-57580775-93/google-glass-for-everybody-a-year-ish-away/">later this year</a> with an initial price tag of $1500. This price could act as a deterrent for consumers in growing Asian economies like India and China which have huge consumer and enterprise base. If &#8216;eye&#8217; can strike the right chord with a balanced combination of &#8216;timely release&#8217; + &#8216;affordable price&#8217; + &#8216;decent quality&#8217; then it can prove to be a good competitor for Google glass at least in Asia region.</p>
<p>Besides end consumers, products like &#8216;eye&#8217; or &#8216;glass&#8217; can even help small enterprises to improve productivity as one can do things on the go which otherwise would require a hand-held device like a tablet, Laptop or a mobile phone.</p>
<p>If a device like &#8216;glass&#8217; or &#8216;eye&#8217; comes with an affordable price tag then we can imagine a technology revolution similar to the one brought by Mobile phones. Sectors like education, defence, health can gain a lot from these kind of devices but there could be areas like cinemas, casinos etc where this technology can be misused.</p>
<p>So, yes, like any other breakthrough in technology, the wearable technology is also facing concerns. But, how deep these concerns can dent the business, this is yet to be seen.</p>
<p>Meanwhile, you can read <a href="http://www.techrepublic.com/blog/google-in-the-enterprise/what-businesses-can-expect-to-see-with-google-glass/2019">this</a> great article on what businesses can expect from Wearable technology.</p>
<h2><span style="text-decoration: underline;">Future of wearable technology</span></h2>
<p>Wearable technology is the latest trend in which accessories or clothing incorporates computer as well as other advanced electronic technologies. Apart from Baidu and Google, many other companies are experimenting on this technology for example Apple is researching on a wristwatch device that would be able to show messages and e-mails that users receive on their iPhone. Similarly, Samsumg and LG are also exploring possibilities of a similar kind of smart watch devices.</p>
<h2><span style="text-decoration: underline;">Conclusion</span></h2>
<p>Samuel Johnson &#8211; The Rambler said that Almost all absurdity of conduct arises from the imitation of those whom we cannot resemble. Let us wait to see what kind of imitation will Baidu Eye produce.</p>
<p>The post <a href="http://mylinuxbook.com/is-baidu-eye-a-real-threat-to-linux-powered-google-glass/">Is Baidu Eye A Real Competition To Linux Powered Google Glass?</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mylinuxbook.com/is-baidu-eye-a-real-threat-to-linux-powered-google-glass/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>20 interesting and extremely helpful Linux command line tricks</title>
		<link>http://mylinuxbook.com/20-interesting-and-extremely-helpful-linux-command-line-tricks/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=20-interesting-and-extremely-helpful-linux-command-line-tricks</link>
		<comments>http://mylinuxbook.com/20-interesting-and-extremely-helpful-linux-command-line-tricks/#comments</comments>
		<pubDate>Mon, 29 Apr 2013 14:22:26 +0000</pubDate>
		<dc:creator>Himanshu</dc:creator>
				<category><![CDATA[CommandLineTips]]></category>
		<category><![CDATA[Linux administration]]></category>

		<guid isPermaLink="false">http://mylinuxbook.com/?p=1850</guid>
		<description><![CDATA[<p>As you start spending more and more time working on Linux command line, you tend to learn some cool tricks that make your life easy and save you lot of time. I have been working on Linux command line for many years now and I have learned a lot of Linux command line tricks. Here [...]</p><p>The post <a href="http://mylinuxbook.com/20-interesting-and-extremely-helpful-linux-command-line-tricks/">20 interesting and extremely helpful Linux command line tricks</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>As you start spending more and more time working on Linux command line, you tend to learn some cool tricks that make your life easy and save you lot of time. I have been working on Linux command line for many years now and I have learned a lot of Linux command line tricks. Here in this article, I will discuss some Linux command line tricks that I find worth using in my day to day command line activities.</p>
<p><strong>NOTE</strong> &#8211; <em>All the examples in this article are tested on bash shell.</em><br />
<span id="more-1850"></span></p>
<p>&nbsp;</p>
<h2><span style="text-decoration: underline;">Linux command line tricks</span></h2>
<p>&nbsp;</p>
<h3>1. How to switch between directories efficiently?</h3>
<p>Working on Linux command line means switching between lot of directories. You are in a directory &#8216;A&#8217;, then you move to directory &#8216;B&#8217;. Now you want to come back to directory &#8216;A&#8217;. Typing the complete directory path for &#8216;A&#8217; can be cumbersome sometimes. For this you can use &#8216;cd -&#8217; short cut.</p>
<p>Here is an example :</p>
<pre style="overflow: auto; width: 600px;">$ pwd
/home/himanshu</pre>
<pre style="overflow: auto; width: 600px;">$ cd /usr/local/bin/</pre>
<pre>$ cd -
/home/himanshu</pre>
<p>So we see that it&#8217;s easy to switch between two directories using cd- .</p>
<p>But, &#8216;cd -&#8217; resolves only a partial problem. It can only switch you back to last directory only. What if you switch between multiple directories and then want to come back to the first or some other desired directory? I mean, suppose you are in a directory &#8216;A&#8217;, then you switch to directories &#8216;B&#8217; -&gt; &#8216;C&#8217; -&gt; &#8216;D&#8217; -&gt; &#8216;E&#8217; and then you want to again go back to directory &#8216;A&#8217;.</p>
<p>Well, for this, you can use the combination of &#8216;pushd&#8217; and &#8216;popd&#8217;.</p>
<p>Here is an example :</p>
<pre style="overflow: auto; width: 600px;">$ pwd
/home/himanshu</pre>
<pre style="overflow: auto; width: 600px;"><strong>$ pushd /home/himanshu</strong>
~ ~</pre>
<pre style="overflow: auto; width: 600px;">$ cd /usr
$ cd /tmp
$ cd /proc</pre>
<pre style="overflow: auto; width: 600px;"><strong>$ popd</strong>
~</pre>
<pre style="overflow: auto; width: 600px;">$ pwd
/home/himanshu</pre>
<p>As you can see, first you pass the desired directory (to which you want to come back eventually) as argument to &#8216;pushd&#8217; and then through &#8216;popd&#8217; you can actually trigger a directory switch to that directory from anywhere on the command prompt.</p>
<h3>2. How to make efficient use of Linux command line history using !! and ! ?</h3>
<p>Double exclamation ie &#8216;!!&#8217; represents the last run command on the shell. Here is an example :</p>
<pre style="overflow: auto; width: 600px;">$ uname -a
Linux himanshu-Inspiron-1525 3.2.0-36-generic-pae #57-Ubuntu SMP Tue Jan 8 22:01:06 UTC 2013 i686 i686 i386 GNU/Linux</pre>
<pre style="overflow: auto; width: 600px;">$ !!
uname -a
Linux himanshu-Inspiron-1525 3.2.0-36-generic-pae #57-Ubuntu SMP Tue Jan 8 22:01:06 UTC 2013 i686 i686 i386 GNU/Linux</pre>
<p>So what best can we do with !! ?</p>
<p>Well, firstly, you can extend the command easily. Here is an example :</p>
<pre style="overflow: auto; width: 600px;"><strong>$ !! | grep Linux</strong>
uname -a | grep Linux
<strong>Linux</strong> himanshu-Inspiron-1525 3.2.0-36-generic-pae #57-Ubuntu SMP Tue Jan 8 22:01:06 UTC 2013 i686 i686 i386 GNU/<strong>Linux</strong></pre>
<p>Also, it so happens many times that you run a command and you get an error that the command requires root privileges. Then you press the &#8216;up arrow&#8217; key + home key + write &#8216;sudo&#8217; . Well all this can be avoided using !!.</p>
<p>Here is an example :</p>
<pre style="overflow: auto; width: 600px;">$ touch new_binary
touch: cannot touch `new_binary': Permission denied</pre>
<pre style="overflow: auto; width: 600px;"><strong>$ sudo !!</strong>
sudo touch new_binary
[sudo] password for himanshu:</pre>
<pre style="overflow: auto; width: 600px;">$ ls new_binary 
new_binary</pre>
<p>Sometimes you would like to append a command to existing shell script or would like to create a new shell script, then you can use &#8216;!!&#8217; to the task easily. Here is an example :</p>
<pre style="overflow: auto; width: 600px;">$ <strong>ls -lart /home/himanshu/practice/*.py</strong></pre>
<pre style="overflow: auto; width: 600px;">-rw-rw-r-- 1 himanshu himanshu 50 Mar  1 00:23 /home/himanshu/practice/firstPYProgram.py</pre>
<pre style="overflow: auto; width: 600px;">$ <strong>echo !! &gt; script.sh</strong> 
echo ls -lart /home/himanshu/practice/*.py &gt; script.sh</pre>
<pre style="overflow: auto; width: 600px;">$ cat script.sh 
<strong>ls -lart /home/himanshu/practice/firstPYProgram.py</strong></pre>
<p>So we see that this way !! proves to be easy and time saving.</p>
<p><span style="text-decoration: underline;"><em>Now, lets come to single exclamation ie &#8216;!&#8217;</em></span> . Unlike double exclamation ie &#8216;!!&#8217;, through single exclamation &#8216;!&#8217;, we can access any previously run command that exists in command line history. Here are some examples :</p>
<p><span style="text-decoration: underline;"><strong>Use serial number from output of <em>history</em> command to run a particular command</strong></span></p>
<pre style="overflow: auto; width: 600px;">$ history
...
...
...
<strong>2039  uname -a | grep Linux</strong>
 2040  dmesg
 2041  clear
 2042  cd bin
 2043  clear
 2044  pwd
 2045  touch new_binary
 2046  sudo touch new_binary
 2047  ls new_binary 
 2048  history</pre>
<pre style="overflow: auto; width: 600px;"><strong>$ !2039</strong>
<strong>uname -a | grep Linux</strong>
Linux himanshu-Inspiron-1525 3.2.0-36-generic-pae #57-Ubuntu SMP Tue Jan 8 22:01:06 UTC 2013 i686 i686 i386 GNU/Linux</pre>
<p>So we see that command number 2039 was run through single exclamation &#8216;!&#8217; without having to type or copy paste the command again.</p>
<p><span style="text-decoration: underline;"><strong>You can use negative integer values with &#8216;!&#8217; to run second last command, third last command, fourth last command&#8230;and so on.</strong></span></p>
<p>Here is an example :</p>
<pre style="overflow: auto; width: 600px;"> $history
...
...
...
 2049  ! 2039
<strong> 2050  uname -a | grep Linux</strong>
 2051  history</pre>
<pre style="overflow: auto; width: 600px;"><strong>$ !-2</strong>
<strong>uname -a | grep Linux</strong>
Linux himanshu-Inspiron-1525 3.2.0-36-generic-pae #57-Ubuntu SMP Tue Jan 8 22:01:06 UTC 2013 i686 i686 i386 GNU/Linux</pre>
<p><span style="text-decoration: underline;"><strong>Run a new command with argument of previous command</strong></span></p>
<p>Here is an example :</p>
<pre style="overflow: auto; width: 600px;">$ ls <strong>/home/himanshu/practice/*.py</strong>
/home/himanshu/practice/firstPYProgram.py

$ ls -lart <strong>!$</strong>
ls -lart <strong>/home/himanshu/practice/*.py</strong>
-rw-rw-r-- 1 himanshu himanshu 50 Mar  1 00:23 /home/himanshu/practice/firstPYProgram.py</pre>
<p>So we see that &#8216;!$&#8217; can be used to fetch argument from previous command and use it with the current command.</p>
<p><span style="text-decoration: underline;"><strong>In case of two arguments, use carrot &#8216;!^&#8217; to access first argument</strong></span></p>
<p>Here is an example :</p>
<pre style="overflow: auto; width: 600px;">$ ls <strong>/home/himanshu/practice/*.py</strong> /home/himanshu/practice/*.txt
/home/himanshu/practice/file.txt           /home/himanshu/practice/output.txt  /home/himanshu/practice/sort.txt
/home/himanshu/practice/firstPYProgram.py  /home/himanshu/practice/sort1.txt   /home/himanshu/practice/test.txt
/home/himanshu/practice/input.txt          /home/himanshu/practice/sort2.txt</pre>
<pre style="overflow: auto; width: 600px;">$ ls -lart <strong>!^</strong>
ls -lart <strong>/home/himanshu/practice/*.py</strong>
-rw-rw-r-- 1 himanshu himanshu 50 Mar  1 00:23 /home/himanshu/practice/firstPYProgram.py</pre>
<p>So we see that through &#8216;!^&#8217; we can access the first argument of the previous run command.</p>
<p><span style="text-decoration: underline;"><strong>To access the any other argument (of previous run command) in current command, &#8216;</strong><em>![prev command name]:[argument number]</em><strong>&#8216; can be used.</strong></span></p>
<p>Here is an example :</p>
<pre style="overflow: auto; width: 600px;">$ ls <strong>!ls:2</strong>
ls /home/himanshu/practice/*.txt
/home/himanshu/practice/file.txt    /home/himanshu/practice/sort1.txt  /home/himanshu/practice/test.txt
/home/himanshu/practice/input.txt   /home/himanshu/practice/sort2.txt
/home/himanshu/practice/output.txt  /home/himanshu/practice/sort.txt</pre>
<p>So this way, the second argument (of the previous command) was accessed.</p>
<p><span style="text-decoration: underline;"><strong>To access all the arguments of a previously run command, use &#8216;!*&#8217;</strong></span></p>
<p>Here is an example :</p>
<pre style="overflow: auto; width: 600px;">$ ls -lart <strong>!*</strong>
ls -lart /home/himanshu/practice/*.py /home/himanshu/practice/*.txt
-r--r--r-- 1 himanshu himanshu 50 Oct 24  2012 /home/himanshu/practice/output.txt
-r--r--r-- 1 himanshu himanshu  7 Nov 10 13:46 /home/himanshu/practice/input.txt
-r--r--r-- 1 himanshu himanshu  8 Dec  7 20:38 /home/himanshu/practice/sort1.txt
-r--r--r-- 1 himanshu himanshu  8 Dec  7 20:39 /home/himanshu/practice/sort2.txt
-r--r--r-- 1 himanshu himanshu 14 Dec 14 20:45 /home/himanshu/practice/file.txt
-r--r--r-- 1 himanshu himanshu 41 Jan 23 20:42 /home/himanshu/practice/sort.txt
-rw-rw-r-- 1 himanshu himanshu 50 Mar  1 00:23 /home/himanshu/practice/firstPYProgram.py
-rw-rw-r-- 1 himanshu himanshu  0 Mar 10 15:31 /home/himanshu/practice/test.txt</pre>
<p><span style="text-decoration: underline;"><strong>Use &#8216;</strong>![keyword]<strong>&#8216; to run the last command starting with [keyword]</strong></span></p>
<p>Here is an example :</p>
<pre style="overflow: auto; width: 600px;"><strong>$ !ls</strong>
<strong>ls -lart /home/himanshu/practice/*.py</strong>
-rw-rw-r-- 1 himanshu himanshu 50 Mar  1 00:23 /home/himanshu/practice/firstPYProgram.py</pre>
<p>So we see that the last <em>ls</em> command was executed. This way you can just write the first keyword of the command (which is command name usually) and you do not need to write the complete command. Single exclamation &#8216;!&#8217; will do it for you.</p>
<h3>3. Use comma &#8216;,&#8217; operator wherever it makes life easy</h3>
<p>As already said, the comma operator can make life easy for you on Linux command line. Here are some examples :</p>
<p><span style="text-decoration: underline;"><strong>Convert to lower case</strong></span></p>
<p>Comma operator can be used to convert the whole string or only the first letter to lower case.</p>
<p>Here is an example :</p>
<pre style="overflow: auto; width: 600px;">$ words="Example of comma OPERATOR"</pre>
<pre style="overflow: auto; width: 600px;">$ echo ${words,}
example of comma OPERATOR</pre>
<pre style="overflow: auto; width: 600px;">${words,,}
example of comma operator</pre>
<p>So we see that through a single comma only the first letter was converted to lower case while through double comma, complete string was converted to lower case.</p>
<p><span style="text-decoration: underline;"><strong>Use comma with file names</strong></span></p>
<p>Comma operator can be used with file names. A couple of examples are shown below.</p>
<pre style="overflow: auto; width: 600px;">$ touch new_file{1,2,3}
himanshu@himanshu-Inspiron-1525:~/practice$ ls new_file*
new_file1  new_file2  new_file3</pre>
<p>So we see that comma operator helped in creating three files easily.</p>
<p>Similarly, for one of the very popular work people do on command line is to rename files by adding .old or .new temporarily. You can save the time by doing something like :</p>
<pre style="overflow: auto; width: 600px;"><code>mv my_filename.{old,new}</code></pre>
<p>This will rename my_filename.old to myfilename.new.</p>
<h3>4. How to delete files with leading or trailing spaces?</h3>
<p>You might find yourself struggling with deleting files with leading or trailing spaces through &#8216;rm&#8217; command on Linux command line.</p>
<p>For example :</p>
<pre style="overflow: auto; width: 600px;">$ rm tempFile
rm: cannot remove `tempFile': No such file or directory</pre>
<p>So we see that rm command says that this file does not exist. But you are pretty confident that file with such name exists. Then the only thing could be that this file name would be having leading or trailing spaces.</p>
<p>You can use double quotes to avoid this problem :</p>
<pre style="overflow: auto; width: 600px;">$ rm "tempFile "</pre>
<p>The above command worked in my case.</p>
<p>Note that if you do not want to use double quotes then &#8216;\ &#8216; can be used. Here is an example :</p>
<pre style="overflow: auto; width: 600px;">$ rm tempFile\</pre>
<p>Remember to add a space after back slash.</p>
<h3>5. How to delete files with names beginning with hyphen (-) ?</h3>
<p>Sometimes you may find yourself stuck with a situation like this :</p>
<p>You have to delete a file named <strong>-1mpFile.out</strong></p>
<pre style="overflow: auto; width: 600px;">$ ls
-1mpFile.out                          CPPfile.o             libCfile.so      mylinuxbook_new  prog          split</pre>
<p>But, when you try using rm command, following error is produced :</p>
<pre style="overflow: auto; width: 600px;">$ rm -1mpFile.out
rm: invalid option -- '1'
Try `rm ./-1mpFile.out' to remove the file `-1mpFile.out'.
Try `rm --help' for more information.</pre>
<p>Even if you use double quotes, you get the following error :</p>
<pre style="overflow: auto; width: 600px;">$ rm "-1mpFile.out"
rm: invalid option -- '1'
Try `rm ./-1mpFile.out' to remove the file `-1mpFile.out'.
Try `rm --help' for more information.</pre>
<p>So, rm command considers the hyphen &#8216;-&#8217; as an indicator that some command line option will follow and so it treats &#8217;1mpFile.out&#8217; as an option. Hence the error.</p>
<p>Now, to tell &#8216;rm&#8217; that the word beginning with hyphen is file name, you need to pass double hyphen (&#8211;) first. Here is an example :</p>
<pre style="overflow: auto; width: 600px;">$ rm -- -1mpFile.out</pre>
<p>So this should remove the file successfully.</p>
<p>Since this problem is generic ie you will observe this problem even while creating this file using &#8216;touch&#8217; command etc. Double hyphen can be used with other commands too for the same purpose.</p>
<p>Here is another example of double hyphen but this time with touch and ls commands :</p>
<pre style="overflow: auto; width: 600px;">$ touch -1mpFile.out
touch: invalid option -- '1'
Try `touch --help' for more information.</pre>
<pre style="overflow: auto; width: 600px;">$ touch -- -1mpFile.out</pre>
<p>$ ls &#8212; -1mpFile.out -1mpFile.out</p>
<p>So we can safely use double hyphen (&#8211;) in a generic sense with different Linux commands.</p>
<h3>6. How to delete all files in a directory except some (with particular extensions) ?</h3>
<p>Suppose you have a directory with lot of files and you want to delete all the files except some of them (with particular file extensions). This can be done in following way :</p>
<p>Here is a directory containing lot of files :</p>
<pre style="overflow: auto; width: 600px;">$ ls
<strong>a.out</strong>         Cfile.c  file.c             macro.c     my_printf.c   <strong>orig_file.orig</strong>  stacksmash.c
bfrovrflw.c   cmd.c    firstPYProgram.py  main.c      new_printf.c  <strong>orig_file.rej</strong>   test_strace.c
bufrovrflw.c  env.c    helloworld.c       my_fopen.c  new.txt       prog.c          virtual_func.c</pre>
<p>Now, you want to delete all the files except .c and .py files.</p>
<p>Here is what you can do :</p>
<pre style="overflow: auto; width: 600px;">$ rm !(*.c|*.py)

$ ls
bfrovrflw.c   Cfile.c  env.c   firstPYProgram.py  macro.c  my_fopen.c   new_printf.c  stacksmash.c   virtual_func.c
bufrovrflw.c  cmd.c    file.c  helloworld.c       main.c   my_printf.c  prog.c        test_strace.c</pre>
<p>So you can see that files with all other extensions got deleted.</p>
<h3>7. How to create customized backup using touch and find commands?</h3>
<p>Touch command in association with find command can be used to create customized backups.</p>
<p>Suppose you want to create a backup of files that you created or changed in a directory between 9am and 5pm. For this, the very first step is to create two files temp1 and temp2 with timestamps as 9am and 5pm respectively.</p>
<pre>$ <strong>touch -d "9am" temp1</strong>
$ <strong>touch -d "5pm" temp2</strong></pre>
<p>These commands will create two files temp1 and temp2 with access and modification timestamps as 9am and 5pm respectively.</p>
<p>Let&#8217;s cross check these by using stat command:</p>
<pre>$ stat temp1
 File: `temp1'
 Size: 0 Blocks: 0 IO Block: 4096 regular empty file
 Device: 806h/2054d Inode: 528534 Links: 1
 Access: (0664/-rw-rw-r--) Uid: ( 1000/himanshu) Gid: ( 1000/himanshu)
 <strong>Access: 2013-04-28 09:00:00.000000000 +0530</strong>
 <strong>Modify: 2013-04-28 09:00:00.000000000 +0530</strong>
 Change: 2013-04-28 19:06:05.982909491 +0530
 Birth: -</pre>
<pre>$ stat temp2
 File: `temp2'
 Size: 0 Blocks: 0 IO Block: 4096 regular empty file
 Device: 806h/2054d Inode: 529476 Links: 1
 Access: (0664/-rw-rw-r--) Uid: ( 1000/himanshu) Gid: ( 1000/himanshu)
 <strong>Access: 2013-04-28 17:00:00.000000000 +0530</strong>
 <strong>Modify: 2013-04-28 17:00:00.000000000 +0530</strong>
 Change: 2013-04-28 19:06:12.090939793 +0530
 Birth: -</pre>
<p>So we see that timestamps was as expected. Now move to the directory where you want to create the backup of files. Here are the contents of the directory in my case :</p>
<pre style="overflow: auto; width: 600px;">$ ls
bfrovrflw.c   Cfile.c  env.c   firstPYProgram.py  macro.c  my_fopen.c   new_printf.c  stacksmash.c   virtual_func.c
bufrovrflw.c  cmd.c    file.c  helloworld.c       main.c   my_printf.c  prog.c        test_strace.c</pre>
<p>Now, I create a directory named &#8216;bkup&#8217; and run the following command :</p>
<pre style="overflow: auto; width: 600px;">$ find . -newer ../temp1 ! -newer ../temp2 -exec cp '{}' ./bkup/ ';'</pre>
<p>The <strong>-newer</strong> and <strong>! -newer</strong> options in command above will first find all the files with modification time between 9am and 5pm. Then the <strong>-exec</strong> option makes sure that the cp command is run for every result (<strong>&#8216;{}&#8217;</strong>) of find command and the file is copied to ./bkup/ folder. The terminating &#8216;<strong>;</strong>&#8216; is the indication that <em>cp</em> command terminates here.</p>
<p>Now, if you see the &#8216;bkup&#8217; directroy, you&#8217;ll find all the backed up files there. Here is what I saw in my case :</p>
<pre style="overflow: auto; width: 600px;">$ cd bkup/</pre>
<pre style="overflow: auto; width: 600px;">$ ls
bfrovrflw.c   Cfile.c  env.c   firstPYProgram.py  macro.c  my_fopen.c   new_printf.c  stacksmash.c   virtual_func.c
bufrovrflw.c  cmd.c    file.c  helloworld.c       main.c   my_printf.c  prog.c        test_strace.c</pre>
<p>As all the files were created between 9am and 5pm so all of them were backed up.</p>
<h3>8. Why rm command fails with error &#8216;<em>Argument list too long&#8217;?</em></h3>
<p>This usually happens when you have a directory containing huge number of files. When you do a rm -rf over it, you get something like :</p>
<pre style="overflow: auto; width: 600px;"><code>-bash: /bin/rm: Argument list too long</code></pre>
<p>This issue can be resolved using following command (please switch over to the desired directory before running this command):</p>
<pre style="overflow: auto; width: 600px;"><code>find * -xdev -exec rm -f '{}' ';'</code></pre>
<p>The find command above will supply input to rm command in batches that it can process. This is one of the fastest method to delete files.</p>
<h3>9. How to search for all the files in a directory containing a particular string?</h3>
<p>This can be easily achieved using grep command.</p>
<p>Here are a couple of examples :</p>
<pre style="overflow: auto; width: 600px;">$ grep -l "printf" *.c
bfrovrflw.c
bufrovrflw.c
Cfile.c
cmd.c
env.c
file.c
helloworld.c
macro.c
main.c
my_fopen.c
my_printf.c
new_printf.c
prog.c
stacksmash.c
test_strace.c</pre>
<pre style="overflow: auto; width: 600px;">$ grep -l "buff" *.c
bfrovrflw.c</pre>
<p>If it is desired to view the lines where the string is used in the file, then &#8216;find&#8217; command can be used with &#8216;xargs&#8217; and &#8216;grep&#8217; command in the following way :</p>
<pre style="overflow: auto; width: 600px;">$ <strong>find ./ -name "*.c" | xargs grep "buff"</strong>
./bfrovrflw.c:    char buff[15];
./bfrovrflw.c:    gets(buff);
./bfrovrflw.c:    if(strcmp(buff, "MyLinuxBook"))</pre>
<p>So we see that even the lines containing the string &#8220;buff&#8221; were displayed in the output.</p>
<h3>10. How to Empty a file using &#8216;&gt;&#8217; operator ?</h3>
<p>Suppose you want to empty a file from command line.</p>
<p>Here is how easily you can do it :</p>
<pre style="overflow: auto; width: 600px;">$ &gt; [complete file path]</pre>
<p>For example :</p>
<pre style="overflow: auto; width: 600px;">$ <strong>&gt; ./logfile</strong></pre>
<p>This will delete all the contents of the file &#8216;logfile&#8217; and empty it.</p>
<h3>11. How to search man pages for a particular string?</h3>
<p>You might have used Linux man pages to understand more about a command, function etc. But, what if you want to know which man pages discuss about a particular topic. For example, what if I want to know that which man pages discuss about &#8216;login&#8217;?</p>
<p>Well, there exists an option -k through which you can do this. Here is an example :</p>
<pre style="overflow: auto; width: 600px;"><strong>$ man -k login</strong>
access.conf (5)      - the login access control table file
add-shell (8)        - add shells to the list of valid login shells
chsh (1)             - change login shell
faillog (5)          - login failure logging file
faillog (8)          - display faillog records or set login failure limits
getlogin (3)         - get username
getlogin_r (3)       - get username
gnome-session-properties (1) - Configure applications to start on login
hotot (7)            - lightweight &amp; opensource microbloging client
issue (5)            - prelogin message and identification file
lastlog (8)          - reports the most recent login of all users or of a given user
login (1)            - begin session on the system
login (3)            - write utmp and wtmp entries
login.defs (5)       - shadow password suite configuration
login_tty (3)        - tty utility functions
logname (1)          - print user's login name
...
...
...</pre>
<p>So we see that all the man pages that discuss about &#8216;login&#8217; were displayed in the output.</p>
<h3>12. How to redirect stderr output messages to a file?</h3>
<p>It so happens mostly that standard commands/programs/services stream normal log messages to stdout while error log messages to stderr stream. Now, if you just do something like :</p>
<pre>$ [some-command] &gt; logfile</pre>
<p>Then only the messages that were directed to stdout would be redirected to the file &#8216;logfile&#8217; but no message that was directed to stderr would be redirected to the file.</p>
<p>Here is an example :</p>
<pre style="overflow: auto; width: 600px;">$ touch new &gt; /home/himanshu/practice/logfile 
touch: cannot touch `new': Permission denied</pre>
<pre style="overflow: auto; width: 600px;">$ cat /home/himanshu/practice/logfile 
$</pre>
<p>So we see that error was not redirected to the log file.</p>
<p>Now, to correct this, do something like :</p>
<pre style="overflow: auto; width: 600px;">$ touch new &gt; /home/himanshu/practice/logfile <strong>2&gt;&amp;1</strong></pre>
<pre style="overflow: auto; width: 600px;">$ cat /home/himanshu/practice/logfile 
touch: cannot touch `new': Permission denied</pre>
<p>So we see that this time the error was redirected to the file successfully. Please note that <strong>2&gt;&amp;1</strong> combines both stdout and stderr streams to stdout stream only.</p>
<h3>13. How to follow multiple log files on the go?</h3>
<p>If it is required to follow multiple log files as they are being updated then this can be done through <em><strong>tail</strong></em> command.</p>
<p>Suppose I want to monitor two log files &#8216;logfile&#8217; and &#8216;logfile1&#8242; simultaneously then I will use the tail command as follows :</p>
<pre style="overflow: auto; width: 600px;"><strong>$ tail -f logfile logfile1</strong>
==&gt; logfile &lt;==

==&gt; logfile1 &lt;==

==&gt; logfile &lt;==
hi

==&gt; logfile1 &lt;==
hello</pre>
<p>So you can see that dynamic updates to these log files can easily be monitored through tail command.</p>
<h3>14. How to make a command not to show up in the output of &#8216;history&#8217; command?</h3>
<p>Well, sometimes you would want to run a command but do not want it to appear in the output of Linux <em>history</em> command.</p>
<p><strong>You can achieve this by inserting a space before you type the command on prompt</strong>.</p>
<p>Here is an example :</p>
<pre style="overflow: auto; width: 600px;">$  df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda6       29640780 6174904  21960188  22% /
udev             1536752       4   1536748   1% /dev
tmpfs             617620     892    616728   1% /run
none                5120       0      5120   0% /run/lock
none             1544040     156   1543884   1% /run/shm</pre>
<p>Note that there is a space between &#8216;$&#8217; and &#8216;df&#8217;.</p>
<p>Now, let&#8217;s confirm whether this command appears in the output of &#8216;history&#8217; :</p>
<pre style="overflow: auto; width: 600px;">$ history | grep df
 1633  ls *.pdf
 1634  mv LinuxCommandsPart1.pdf LinuxCommandsPart1
 2245  history | grep df</pre>
<p>The df command was not captured in the output of history command.</p>
<h3>15. How to simulate on-screen typing just like you see in movies?</h3>
<p>Well, to simulate typing just like you see in movies, use &#8216;pv&#8217; command.</p>
<p>Try this out :</p>
<pre style="overflow: auto; width: 600px;"> echo "You can simulate on-screen typing just like in the movies" | pv -qL 10</pre>
<p>Check the output for yourself. <img src='http://mylinuxbook.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h3>16. How to escape the aliased version of a command?</h3>
<p>The alias command, as we all know is used to create aliases of the commands that act as short cuts and save time.</p>
<p>For example, I have created alias of ls command such that whenever I execute ls, its &#8216;ls -lart&#8217; that gets executed.</p>
<pre style="overflow: auto; width: 600px;">$ alias ls='ls -lart'</pre>
<p>Now, if I ever intend to escape the alias and want to execute only ls, then I can do this by beginning the command with a backslash ie &#8216;\&#8217;.</p>
<p>Here is an example :</p>
<pre style="overflow: auto; width: 600px;"><strong>$ \ls</strong>
1                      CPPfile.o            libCPPfile.so    mylinuxbook_new  prog.c        stacksmash.c</pre>
<p>So we see that the original ls command was executed.</p>
<p><em><strong>NOTE</strong></em> &#8211; If you want to suppress an alias for a whole login session, you can use &#8216;unalias&#8217; command for that.</p>
<h3>17. How to get rid of that unknown process that forbids you to delete a file?</h3>
<p>There are situations where you want to delete a file but you get an error like &#8216;file is already in use&#8217;. You try to find which process in using this file but all your effort goes in vain. What would you do in this case?</p>
<p>Well, you can use the &#8216;fuser&#8217; command. It tell you the process that is using a particular file. You can use &#8216;fuser -k [filename]&#8216; command to kill that process.</p>
<p>Read our article on <a href="http://mylinuxbook.com/linux-fuser-command/">fuser command</a> to know more about it.</p>
<h3>18. How to monitor and redirect logs to file simultaneously?</h3>
<p>If you want to redirect logs to a file but also want to monitor them in parallel, you can use the Linux &#8216;tee&#8217; command.</p>
<p>Here is an example :</p>
<pre style="overflow: auto; width: 600px;">./program | tee logfile</pre>
<p>The command above will execute the &#8216;program&#8217;. All the logs will be redirected to &#8216;logfile&#8217; while you can simultaneously view them on stdout (command line in most of the cases) also.</p>
<h3>19. How to check if a command succeeded or failed?</h3>
<p>Well this can be done through &#8216;$<strong>?</strong>&#8216; environment variable. It holds 0 if last run command was success else it holds a non zero value in case of failure.</p>
<p>Here is an example :</p>
<pre style="overflow: auto; width: 600px;">$ touch abc
touch: cannot touch `abc': Permission denied</pre>
<pre style="overflow: auto; width: 600px;">$ echo $?
1</pre>
<p>As the last command failed, so the output was &#8217;1&#8242;.</p>
<h3>20. How to copy paste on command line through keyboard?</h3>
<p>You can copy the text by selecting it first and then by pressing :</p>
<pre style="overflow: auto; width: 600px;"><code>CTRL + SHIFT + C</code></pre>
<p>and paste it using :</p>
<pre style="overflow: auto; width: 600px;"><code>CTRL + SHIFT + V</code></pre>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><em><strong>Well, that was all from my side. I would really appreciate if you can drop in your comments related to these tricks. Also, it would be great if you can provide any useful Linux command line trick that is not listed here.</strong></em></span></p>
<p><span style="color: #ff0000;">WANT TO READ MORE?</span> Read best of MyLinuxBook on <a href="http://mylinuxbook.com/funny-side-of-linux-command-line/">FunnyLinuxCommands</a>, <a href="http://mylinuxbook.com/linux-netcat-command/">Linux netcat command</a>, <a href="http://mylinuxbook.com/bash-shell-scripting-part-i/">Bash scripting Part-I</a>, <a href="http://mylinuxbook.com/bash-shell-scripting-2/">Bash scripting Part-II</a> and <a href="http://mylinuxbook.com/linux-strace-command-a-magnificent-troubleshooter/">Linux strace command</a>.</p>
<p>The post <a href="http://mylinuxbook.com/20-interesting-and-extremely-helpful-linux-command-line-tricks/">20 interesting and extremely helpful Linux command line tricks</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mylinuxbook.com/20-interesting-and-extremely-helpful-linux-command-line-tricks/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Linux newbie &#8211; 10 reasons why I won&#8217;t miss Windows</title>
		<link>http://mylinuxbook.com/linux-newbie-10-reasons-why-i-wont-miss-windows/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linux-newbie-10-reasons-why-i-wont-miss-windows</link>
		<comments>http://mylinuxbook.com/linux-newbie-10-reasons-why-i-wont-miss-windows/#comments</comments>
		<pubDate>Mon, 22 Apr 2013 15:16:08 +0000</pubDate>
		<dc:creator>Piunika</dc:creator>
				<category><![CDATA[Open source software]]></category>
		<category><![CDATA[Linux pros]]></category>
		<category><![CDATA[Linux vs Windows]]></category>
		<category><![CDATA[why Linux is better]]></category>
		<category><![CDATA[Why use Linux]]></category>

		<guid isPermaLink="false">http://mylinuxbook.com/?p=1927</guid>
		<description><![CDATA[<p>Linux has been a persistent subject to debate since its inception. People have various perceptions for this Operating System like some people believe that Linux is meant only for geeks, others believe that it is difficult to understand when compared to Windows and so on. I was not a geek and like any other computer [...]</p><p>The post <a href="http://mylinuxbook.com/linux-newbie-10-reasons-why-i-wont-miss-windows/">Linux newbie &#8211; 10 reasons why I won&#8217;t miss Windows</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Linux has been a persistent subject to debate since its inception. People have various perceptions for this Operating System like some people believe that Linux is meant only for geeks, others believe that it is difficult to understand when compared to Windows and so on. I was not a geek and like any other computer user, I was reluctant to switch to any other OS. But one thing that prompted me to change my machine&#8217;s OS was that I was fed up of Windows day-to-day issues.</p>
<p>Diffidently, I tried my hands over Linux and acclaimed it. After I started using Linux, I found that it is a must have OS on your machine and realized that what crap was I using for years. Undoubtedly during its initial years Linux had &#8220;Gurus Only&#8221; image because of its high difficulty level but these days, those gurus or geeks have simplified it nicely for everyone. Believe me that it is not at all difficult to use, it&#8217;s just that you are new to it. Once you develop a habit of working on Linux, you will get addicted to this robust and versatile OS.</p>
<p><span id="more-1927"></span></p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/04/LinuxVsWindows.png"><img class="aligncenter size-medium wp-image-1932" alt="LinuxVsWindows" src="http://mylinuxbook.com/wp-content/uploads/2013/04/LinuxVsWindows-300x233.png" width="300" height="233" /></a></p>
<p>&nbsp;</p>
<h2><span style="text-decoration: underline;">10 reasons why I won&#8217;t miss Windows</span></h2>
<p>Here are 10 reasons why I love Linux :</p>
<h3>1. Open Source with Zero Cost</h3>
<p>Linux is a free and open source Operating System which means that anyone is allowed to copy the software, check its source code and redistribute it for free under GPL.</p>
<h3>2. Terminates the Need of an Expensive Machine</h3>
<p>Linux is such a sound OS that it works equally good on an obsolete redundant machine and give away new life to that PC. You don&#8217;t need to buy an expensive machine to run Linux.</p>
<h3>3. High on Security</h3>
<p>With Windows, I was always struggling to get viruses out of my system. Sometimes the system used to get dead slow because of all this crap. But, Linux is designed in such a manner that it protects your PC against viruses, malware and other intruders and I have personally experienced that my Linux machine always works smoothly.</p>
<h3>4. Highly Stable</h3>
<p>Yes, No blue screen of death here. With Linux, you need not to fear about loosing your important data as it never crashes down. It keeps your computer stable.</p>
<h3>5. No Need to Install Drivers and Other Important Stuff</h3>
<p>Linux comes with inbuilt drivers and other required stuff like web browser, movie player, image editor etc. So it definitely aborts the need of installing important stuff separately.</p>
<h3>6. Strong Community Support</h3>
<p>A very commendable word about Linux users and developers is that they are always there and happy to help you. There is no dearth of Linux admirers who keep helping people through web forums, emails etc.</p>
<h3>7. Blow the Terms like &#8220;Reboot&#8221; and &#8220;De-fragmentation&#8221;</h3>
<p>Unlike Windows, Linux never slows down because it is far beyond fragmentation and registry problems. It is a fast and efficient OS which will rarely generate the need of rebooting your machine over a very long period of time.</p>
<h3>8. Customizable and Improves Every Second</h3>
<p>Linux is a user&#8217;s OS as it is highly customizable. You can customize it from themes to fonts as per your requirement. People from all over the world are working over this OS and it is improving every second. Even you can confer to its growth and enrich it.</p>
<h3>9. No installation problems</h3>
<p>Linux can be installed along with Windows and you can play any number of games for free with this OS.</p>
<h3>10. So many flavours</h3>
<p>Linux comes in so many flavours that you have a wide variety to choose from. I personally use Ubuntu 12.04 and I love it. You could also try out Linux mint, debian, openSuse etc.</p>
<p>&nbsp;</p>
<p>Well, that was all about my experience with Linux. Please share your Linux story here in comments.</p>
<p>Here are some related articles:</p>
<p><a href="http://www.whylinuxisbetter.net/">http://www.whylinuxisbetter.net/</a><br />
<a href=" http://ubuntu-artists.deviantart.com/journal/8-Advantages-of-using-Linux-over-Windows-291681914"> http://ubuntu-artists.deviantart.com/journal/8-Advantages-of-using-Linux-over-Windows-291681914</a><br />
<a href=" http://www.techrepublic.com/blog/10things/10-reasons-why-linux-will-triumph-over-windows/528"> http://www.techrepublic.com/blog/10things/10-reasons-why-linux-will-triumph-over-windows/528</a><br />
<a href=" http://linuxshark.info/"> http://linuxshark.info/</a></p>
<p>The post <a href="http://mylinuxbook.com/linux-newbie-10-reasons-why-i-wont-miss-windows/">Linux newbie &#8211; 10 reasons why I won&#8217;t miss Windows</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mylinuxbook.com/linux-newbie-10-reasons-why-i-wont-miss-windows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The funny side of Linux command line</title>
		<link>http://mylinuxbook.com/funny-side-of-linux-command-line/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=funny-side-of-linux-command-line</link>
		<comments>http://mylinuxbook.com/funny-side-of-linux-command-line/#comments</comments>
		<pubDate>Mon, 15 Apr 2013 14:00:46 +0000</pubDate>
		<dc:creator>Rupali</dc:creator>
				<category><![CDATA[Commands]]></category>
		<category><![CDATA[Linux administration]]></category>
		<category><![CDATA[funny linux commands]]></category>
		<category><![CDATA[interesting linux commands]]></category>
		<category><![CDATA[Linux command line]]></category>
		<category><![CDATA[tom and jerry on Linux command line]]></category>
		<category><![CDATA[train command on linux]]></category>

		<guid isPermaLink="false">http://mylinuxbook.com/?p=1893</guid>
		<description><![CDATA[<p>Have you ever seen a train running on Linux command line? Have you ever seen &#8216;Tom and Jerry&#8217; on Linux command line? Well, working on Linux command line is not that serious always. There lies a fun factor too. Here in this space, we shall discuss the idiosyncrasies of Linux command line. Assumption: Ubuntu Linux [...]</p><p>The post <a href="http://mylinuxbook.com/funny-side-of-linux-command-line/">The funny side of Linux command line</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Have you ever seen a train running on Linux command line? Have you ever seen &#8216;Tom and Jerry&#8217; on Linux command line? Well, working on Linux command line is not that serious always. There lies a fun factor too. Here in this space, we shall discuss the idiosyncrasies of Linux command line.</p>
<p><span style="text-decoration: underline;"><strong>Assumption</strong></span>: Ubuntu Linux is used for all the examples in this article. The command line utilities described in this article may or may not be present by default on your Linux system.<br />
<span id="more-1893"></span></p>
<p>&nbsp;</p>
<h2><span style="text-decoration: underline;">Funny and interesting Linux command line utilities</span></h2>
<h3>1. Linux ‘sl’ command</h3>
<p>Although ‘sl’ stands for ‘steam locomotive’, it was created to jazz up commandline addicts who, in a haste, sometime mistype ‘ls’ command as ‘sl’. Let us unveil what it does by running it on our system.</p>
<p>First we need to install it as it doesn’t come along with standard Linux. However, it is pretty convenient to install it using ‘apt-get’</p>
<pre style="overflow: auto; width: 600px;">sudo apt-get install sl</pre>
<p>Most of the installation needs sudo privileges. When it is done, type ‘sl’ on the command prompt</p>
<pre style="overflow: auto; width: 600px;">$sl</pre>
<p>We see an impressive animated steam locomotive loving across the screen from right to left. The locomotive has been drawn using ASCII characters.</p>
<p>Here is how the output looked on my machine:</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/04/1_sl.png"><img class="aligncenter size-medium wp-image-1894" alt="1_sl" src="http://mylinuxbook.com/wp-content/uploads/2013/04/1_sl-300x180.png" width="300" height="180" /></a></p>
<p style="text-align: center;">(Click image to enlarge)</p>
<p>Isn’t is so different than what we see and do on Linux Command line everyday? I think it will definitely bring a smile on the face of the lieux user who was deeply absorbed into running something and realises his typo error on seeing something unexpected and amazing as this animation.</p>
<p>Well, even this simple command have certain options to offer. Here is the excerpt from its <a href="http://man.cx/sl%286%29">man page</a></p>
<pre style="overflow: auto; width: 600px;">SYNOPSIS
   	sl [ -alFe ]

DESCRIPTION
   	sl Displays animations aimed to correct users who accidentally enter sl instead of ls.  SL stands for Steam Locomotive.

OPTIONS
   	-a 	An accident seems to happen. You'll feel pity for people who cry for help.

   	-l 	shows little one.

   	-F 	It flies.

   	-e 	Allow interrupt by Ctrl+C.</pre>
<p>One can play a prank on someone by</p>
<pre style="overflow: auto; width: 600px;">$alias ls=sl</pre>
<p>Caveat: Enjoy at your own risk!</p>
<h3>2. Linux ‘yes’ command</h3>
<p>Here is a command which just prints the input string repeatedly unless the process is killed. In case, the user does not specify any input string, the default is ‘y’.</p>
<p>This is how the command runs like</p>
<pre style="overflow: auto; width: 600px;">$yes mylinuxbook
mylinuxbook
mylinuxbook
mylinuxbook
mylinuxbook
mylinuxbook
mylinuxbook
mylinuxbook
mylinuxbook
mylinuxbook
mylinuxbook
mylinuxbook
mylinuxbook
mylinuxbook
^C$</pre>
<p>We kill the foreground running process by ‘ctrl + c’.</p>
<p>Strange, isn’t it? Why would we want a command to keep on printing a string all the life of the process? Though the way it works is silly, but it might not be useless. We can use ‘yes’ command in certain scripts where we want to feed the same answer in a repeated operation. For example, we are doing an operating on a set of files and Linux asks us to confirm for each and every file. We can auto-feed a yes using the ‘yes’ command.</p>
<h3>3. Linux &#8216;rev&#8217; command</h3>
<p>Although very simplistic, I found this command very fascinating. It reverses all the input strings given to it line by line. The name of the command ‘rev’ comes from reverse. To play around, type the command ‘rev’ on the command prompt and press enter</p>
<pre style="overflow: auto; width: 600px;">$rev</pre>
<p>We’ll be prompted by the terminal to provide a string through standard input line by line. We can see the output spontaneously after each line.</p>
<p>Like, here we give the input as ‘mylinuxbook’ and press enter.</p>
<pre style="overflow: auto; width: 600px;">mylinuxbook
koobxunilym</pre>
<p>To get back to the command prompt, the golden trick of ‘ctrl+c’ works.</p>
<p>We see the reversed string as output on the next line. Again we can type the next string which we want it to be reversed and on pressing enter we get the output on the standard output.</p>
<pre style="overflow: auto; width: 600px;">$ rev
google
elgoog
linux is fun
nuf si xunil
^C$</pre>
<p>This command also takes the input in the form of a file, where it reverses all the strings line wise in the file and prints the output to the standard output.</p>
<pre style="overflow: auto; width: 600px;">$ cat strings.txt
MyLinuxBook
Linux is so much fun!
Happy Birthday
$ rev strings.txt
kooBxuniLyM
!nuf hcum os si xuniL
yadhtriB yppaH</pre>
<h3>4. Linux &#8216;fortune&#8217; command</h3>
<p>The fortune command is in the same lines as fortune cookies. We get a random adage or a message when we run this command.<br />
It needs an explicit installation first,</p>
<pre style="overflow: auto; width: 600px;">$sudo apt-get install fortune</pre>
<p>Once the installation is done, the way we run this command is</p>
<pre style="overflow: auto; width: 600px;">$ fortune
You have the power to influence all with whom you come in contact.</pre>
<p>So with this command, Linux can even stand by us as a fortune teller.</p>
<h3>5. Linux &#8216;figlet&#8217; command</h3>
<p>This displays our input string in large characters as banners formed out of ASCII characters.</p>
<p>We need to install this utility as it doesn’t come along with standard.</p>
<pre style="overflow: auto; width: 600px;">$sudo apt-get install figlet</pre>
<p>This is really amusing to watch our string drawn big on the terminal.</p>
<pre style="overflow: auto; width: 600px;">$ figlet mylinuxbook</pre>
<p>The snapshot of output:</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/04/2_figlet.png"><img class="aligncenter size-medium wp-image-1895" alt="2_figlet" src="http://mylinuxbook.com/wp-content/uploads/2013/04/2_figlet-300x72.png" width="300" height="72" /></a></p>
<p style="text-align: center;">(Click image to enlarge)</p>
<p>One can add such banners in the scripts headers or sources using ‘figlet’.</p>
<h3>6. Linux &#8216;toilet&#8217; command</h3>
<p>I have no idea where this command got it’s name. However, its a very colourful command. Similar to figlet, it displays our text as banners but in a prettier way.</p>
<p>First of all, installation:</p>
<pre style="overflow: auto; width: 600px;">$sudo apt-get install toilet</pre>
<p>Lets try the simple command :</p>
<pre style="overflow: auto; width: 600px;">$toilet mylinuxbook</pre>
<p>The output looks like:</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/04/3_toilet.png"><img class="aligncenter size-medium wp-image-1896" alt="3_toilet" src="http://mylinuxbook.com/wp-content/uploads/2013/04/3_toilet-300x60.png" width="300" height="60" /></a></p>
<p style="text-align: center;">(Click image to enlarge)</p>
<p>It is much different and artistic than figlet.</p>
<p>However, it has some colours to offer too. Lets see by running following command</p>
<pre style="overflow: auto; width: 600px;">$toilet -f mono12 -F metal mylinuxbook</pre>
<p>This is what I get on my system :</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/04/4_toilet.png"><img class="aligncenter size-medium wp-image-1897" alt="4_toilet" src="http://mylinuxbook.com/wp-content/uploads/2013/04/4_toilet-300x130.png" width="300" height="130" /></a></p>
<p style="text-align: center;">(Click image to enlarge)</p>
<h3>7. Linux &#8216;cowsay&#8217; command</h3>
<p>The cowsay command is an amusing command. It depicts the power of ASCII characters to draw a cow, sheep, and many other animals. However it might not always be present in every distribution of Linux.</p>
<p>Use following to install on Ubuntu Linux:</p>
<pre style="overflow: auto; width: 600px;">$sudo apt-get install cowsay</pre>
<p>Now run the command giving it a message string,</p>
<pre style="overflow: auto; width: 600px;">$cowsay “Linux is fun”</pre>
<p>We see an interesting figure,</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/04/5_cowsay.png"><img class="aligncenter size-full wp-image-1898" alt="5_cowsay" src="http://mylinuxbook.com/wp-content/uploads/2013/04/5_cowsay.png" width="271" height="139" /></a></p>
<p style="text-align: center;">(Click image to enlarge)</p>
<p>Basically, we see a cow which is saying the message as per the command input. Although the command name suggests a cow, it also offers to draw a sheep which is saying a message.</p>
<pre style="overflow: auto; width: 600px;">$cowsay -f sheep “I too love linux”</pre>
<p>The snapshot image I get is</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/04/6_cowsay.png"><img class="aligncenter size-full wp-image-1899" alt="6_cowsay" src="http://mylinuxbook.com/wp-content/uploads/2013/04/6_cowsay.png" width="272" height="197" /></a></p>
<p style="text-align: center;">(Click image to enlarge)</p>
<p>To have all the capabilities as to what all animals it can draw, just use option ‘-l.</p>
<pre style="overflow: auto; width: 600px;">$cowsay -l</pre>
<p>I get following set on my system.</p>
<pre style="overflow: auto; width: 600px;">Cow files in /usr/share/cowsay/cows:
apt beavis.zen bong bud-frogs bunny calvin cheese cock cower daemon default
dragon dragon-and-cow duck elephant elephant-in-snake eyes flaming-sheep
ghostbusters gnu head-in hellokitty kiss kitty koala kosh luke-koala
mech-and-cow meow milk moofasa moose mutilated pony pony-smaller ren sheep
skeleton snowman sodomized-sheep stegosaurus stimpy suse three-eyes turkey
turtle tux unipony unipony-smaller vader vader-koala www</pre>
<p>Therefore, we can input any of the above animals with the ‘-f’ option.</p>
<p>To make it even more fun, one can pipe fortune message to cowsay as</p>
<pre style="overflow: auto; width: 600px;">$fortune | cowsay</pre>
<p>I get following output</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/04/7_fortune_cowsay.png"><img class="aligncenter size-medium wp-image-1900" alt="7_fortune_cowsay" src="http://mylinuxbook.com/wp-content/uploads/2013/04/7_fortune_cowsay-300x137.png" width="300" height="137" /></a></p>
<p style="text-align: center;">(Click image to enlarge)</p>
<h3>8. Linux &#8216;cmatrix&#8217; command</h3>
<p>This command produces a &#8216;Matrix&#8217; style animation made of ASCII on the terminal.</p>
<p>Lets install it first</p>
<pre style="overflow: auto; width: 600px;">$sudo apt-get install cmatrix</pre>
<p>Now run it,</p>
<pre style="overflow: auto; width: 600px;">cmatrix</pre>
<p>It is really awesome what we get. I won’t say much. Just enjoy!</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/04/8_cmatrix.png"><img class="aligncenter size-medium wp-image-1901" alt="8_cmatrix" src="http://mylinuxbook.com/wp-content/uploads/2013/04/8_cmatrix-300x206.png" width="300" height="206" /></a></p>
<p style="text-align: center;">(Click image to enlarge)</p>
<p>Its an animation so do check it yourself.<br />
To terminate and come out of animation, use ‘ctrl+ c’ key combination.</p>
<h3>9. Linux &#8216;oneko&#8217; command</h3>
<p>This is the best of all. I just love it. We all know &#8216;tom and jerry&#8217;, and this command reminds us their chasing game. With this command, we see a cat (I call it tom) which is chasing our mouse (the mouse pointer, tom calls it jerry).</p>
<p>Without further delay, installing works as</p>
<pre style="overflow: auto; width: 600px;">$sudo apt-get install oneko</pre>
<p>Running the command, we do</p>
<pre style="overflow: auto; width: 600px;">oneko</pre>
<p>And you can enjoy seeing tom running towards wherever we move the mouse pointer. Though a snapshot can do no justice to the actual version. Still, just as a breather here is a snapshot:</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/04/9_oneko.png"><img class="aligncenter size-medium wp-image-1902" alt="9_oneko" src="http://mylinuxbook.com/wp-content/uploads/2013/04/9_oneko-300x159.png" width="300" height="159" /></a></p>
<p style="text-align: center;">(Click image to enlarge)</p>
<p>The cat i.e tom won’t leave the mouse(jerry) even if we switch the application. That is its not limited to the terminal even.<br />
When you are done, just terminate the process from the terminal by ‘ctrl + c’.</p>
<p>&nbsp;</p>
<h2><span style="text-decoration: underline;">Conclusion</span></h2>
<p>We hope the readers enjoyed knowing about these funny and interesting Linux command line utilities. If anyone knows more of such commands, please leave a comment.</p>
<p>The post <a href="http://mylinuxbook.com/funny-side-of-linux-command-line/">The funny side of Linux command line</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mylinuxbook.com/funny-side-of-linux-command-line/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Linux Processes explained &#8211; Part II</title>
		<link>http://mylinuxbook.com/linux-processes-part2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linux-processes-part2</link>
		<comments>http://mylinuxbook.com/linux-processes-part2/#comments</comments>
		<pubDate>Mon, 08 Apr 2013 16:18:59 +0000</pubDate>
		<dc:creator>Rupali</dc:creator>
				<category><![CDATA[Linux concepts]]></category>
		<category><![CDATA[Linux process]]></category>
		<category><![CDATA[linux process tutorial]]></category>

		<guid isPermaLink="false">http://mylinuxbook.com/?p=1868</guid>
		<description><![CDATA[<p>In the part -I, we got a basic understanding of Linux processes and saw how the various Linux commands help us to explore the various processes running in the system. In this part of the discussion, we shall get our hands dirty by creating certain processes and get hold of the memory layout in the [...]</p><p>The post <a href="http://mylinuxbook.com/linux-processes-part2/">Linux Processes explained &#8211; Part II</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>In the <a href="http://mylinuxbook.com/linux-processes-part1/"> part -I</a>, we got a basic understanding of Linux processes and saw how the various Linux commands help us to explore the various processes running in the system. In this part of the discussion, we shall get our hands dirty by creating certain processes and get hold of the memory layout in the RAM.</p>
<p>Sometimes we use the terms process and program interchangeably. However, under legitimate glossary, programs and processes are absolutely different terms. When we write a source code of some logic, it is a file which is stored in the hard disk. This file on the hard disk is called as a program. However, when we run this program (i.e. the program executable, obtained after compiling and linking), it creates its own memory space in the RAM. This running instance is a process. A process can be initiated in two significant ways. One, as we just mentioned above, by running a built executable/command from a Linux shell and other, from within a program. We shall discuss programmatic approach more in further sections.<br />
<span id="more-1868"></span></p>
<p>&nbsp;</p>
<h2><span style="text-decoration: underline;">Linux Processes in Memory</span></h2>
<p>Well, now we know that an active process occupies memory in RAM. An immediate question which pops out is, how is this memory allocated, and what all does it enfold?</p>
<p>A clear and comprehensive understanding of the memory layout of linux processes involves myriad linux operating system concepts and memory management theory. Here in this part, we shall learn about some of the key ideas to grasp the overall understanding.</p>
<p>While a process is running, it is doing certain task, so it might have to use the system resources. A simple example to illustrate a system resource is a file on the disk. In order to read a file from the file system, it has be accessed. Now, what if another process has to access the same file on the disk? Who will decide whether it should be allowed to, and if it is allowed and Linux has to manage all the accesses to the file.</p>
<p>How Linux manages its resources is, it does not allow any user running program to directly access any of the system resource. We have system calls in a program which are called from the user space to use the system resources. Only when a process enters kernel space it can access the file, and kernel keeps track of the opened files in the form of kernel file tables.</p>
<p>In memory, every process is given a 4GB of virtual address space considering a 32-bit architecture. The lower 3GB virtual addresses is accessible to the user space portion of the process and the upper 1GB is accessible to the kernel space portion.</p>
<p>Following is a diagram illustrating the 4GB process virtual address space.</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/04/MemoryLayout.jpg"><img class="aligncenter size-medium wp-image-1879" alt="MemoryLayout" src="http://mylinuxbook.com/wp-content/uploads/2013/04/MemoryLayout-223x300.jpg" width="223" height="300" /></a></p>
<p style="text-align: center;">              (Click to Enlarge)</p>
<p>The above process memory split of 1G to kernel space and 3G to user space is changeable though as per the need. However, in most of the cases, 1G/3G split suits the best. The program which we generally write to create a process is at the user space, and hence we shall be eyeing more for the user space memory layout of the process. Zooming into the user space address memory layout, there are various segments of a process. Following is a diagram to get the picture clear in our minds.</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/04/MemoryLayout1.png"><img class="aligncenter size-medium wp-image-1880" alt="MemoryLayout1" src="http://mylinuxbook.com/wp-content/uploads/2013/04/MemoryLayout1-265x300.png" width="265" height="300" /></a></p>
<p style="text-align: center;">(Click to Enlarge)</p>
<p>The above diagram is an abstract snapshot of a generic process image in memory. We see the memory has been categorized into various segments in accordance with the <a href="http://www.linuxjournal.com/article/1060">ELF</a> format.</p>
<p>Let us walk through these segments and see what is in store there.</p>
<h3>Text Segment</h3>
<p>The executable binary is mapped onto this text segment and therefore is a read only segment for the process. Basically, this segment contains the instructions to be followed by the processor in a language that the processor understands. Hence this is also called the code segment. In certain scenarios, where multiple processes are created out of the same program, Linux allows sharing of the text segment to avoid reloading the same instructions.</p>
<h3>Data Segment</h3>
<p>This segment cannot be shared among processes. The data segment is internally parted into two areas. <em>One part</em> of the segment memory holds all the initialized data variables i.e. initialized global variables or static variables. <em>The second part</em>, also called the BSS segment of the process image enfolds the uninitialized data of the program, which includes the global variables which have not been initialized. However, upon the onset of the process, all the data of the BSS segment is zero-initialized.</p>
<h3>Heap</h3>
<p>When there is a dynamic memory allocation in the process, heap is the segment which is being used for all the dynamic memory allocations. In the C source code of the user program, standard library function ‘malloc()’, ‘calloc()’ or ‘alloc()’ are used to allocate linear memory dynamically.</p>
<h3>Stack</h3>
<p>The stack contains all the local variables used in the program considering their respective local scopes. Whenever a local variable is defined, it is pushed into the stack and whenever the scope for that local variable ends, it is popped out. The stack might be decreasing or increasing in linear addresses depending upon the underlying architecture.</p>
<h3>Shared Libraries</h3>
<p>This is no segment as such. In case we have dynamically linked our program to shared objects, shared objects are loaded at the runtime. This part of memory help the process in mapping and accessing the functions which are used from the shared libraries.</p>
<h2><span style="text-decoration: underline;">The process virtual memory status</span></h2>
<p>We’ve learnt about how the various aspects of a process being held in the memory. Get ready to see the real statistics. However, getting down into the memory, one needs to understand the intricacies of concepts like pages, physical address mappings, etc which is out of scope of our current article.</p>
<p>Anyhow, in this section, we’ll touch base some of it.</p>
<p>To begin with, lets code our ancient hello-world C program.</p>
<pre style="overflow: auto; width: 560px;">#include &lt; stdio.h &gt;
#include &lt; unistd.h &gt;

int main()
{
	char mesg[] = "HelloWorld";

	/*We need time to check process stats*/
	sleep(100);
	printf("%s\n", mesg);
	return 0;
}</pre>
<p>Well, the above program is pretty straightforward, except the ‘sleep()’ call we have before we print our message. This is because, we want the process to be valid for sometime, so that we can explore the memory layout of the process. While the process is sleeping, we can access the status of the memory layout.</p>
<p>We compile the program and run it in the background.</p>
<pre style="overflow: auto; width: 560px;">$gcc helloworld.c -Wall -o helloworld
./helloworld &amp;</pre>
<p>To get any information regarding a process, PID is the prime key. Hence, we need to retrieve the assigned PID of our process. (Refer <a href="http://mylinuxbook.com/linux-processes-part1/#">part I</a> to what know PID is.)</p>
<pre style="overflow: auto; width: 560px;">$ps
  PID TTY      	TIME CMD
 1746 pts/1	00:00:00 bash
 2808 pts/1	00:00:00 helloworld
 2809 pts/1	00:00:00 ps</pre>
<p>In order to get the complete status of our newly created process including the status, size of memory segments, etc, we use command</p>
<pre style="overflow: auto; width: 560px;">$cat /proc/2808/status</pre>
<p>Note: 2808 in the above command is the PID of our process of interest. The generic syntax looks like</p>
<pre style="overflow: auto; width: 560px;">cat /proc//status</pre>
<p>Well, this is a command to retrieve data using /proc file system which is a special linux file system providing information about system and processes. More about /proc file system can be referred <a href="http://en.wikipedia.org/wiki/Procfs">here</a>. We will see, procfs is really helpful in getting more and more about the current processes.</p>
<p>The output I see on my system is</p>
<pre style="overflow: auto; width: 560px;">Name:    helloworld
State:    S (sleeping)
Tgid:    2808
Pid:    2808
PPid:    1746
TracerPid:    0
Uid:    1000    1000    1000    1000
Gid:    1000    1000    1000    1000
FDSize:    256
Groups:    4 24 27 30 46 109 124 1000
VmPeak:    	2048 kB
VmSize:    	1988 kB
VmLck:       	0 kB
VmPin:       	0 kB
VmHWM:     	280 kB
VmRSS:     	280 kB
VmData:      	32 kB
VmStk:     	136 kB
VmExe:       	4 kB
VmLib:    	1788 kB
VmPTE:      	16 kB
VmSwap:       	0 kB
Threads:    1
SigQ:    0/3851
SigPnd:    0000000000000000
ShdPnd:    0000000000000000
SigBlk:    0000000000000000
SigIgn:    0000000000000000
SigCgt:    0000000000000000
CapInh:    0000000000000000
CapPrm:    0000000000000000
CapEff:    0000000000000000
CapBnd:    ffffffffffffffff
Cpus_allowed:    1
Cpus_allowed_list:    0
Mems_allowed:    1
Mems_allowed_list:    0
voluntary_ctxt_switches:    4
nonvoluntary_ctxt_switches:    0</pre>
<p>The output gives us humongous information regarding our process.</p>
<p><strong>Name</strong> : Name of the process<br />
<strong> State</strong>   : Process state<br />
<strong> Tgid</strong>   : Thread group ID, equal to the PID of the process (and this is also the TID of the first thread started in the process).<br />
<strong> Pid     :  </strong>PID i.e. Process Identifier<br />
<strong> PPid  : </strong>PID of the parent process.<br />
<strong> TracerPid</strong> : PID of process tracing this process (0 if the process is not traced).<br />
<strong> Uid</strong>    : Set of four User IDs: <a href="http://en.wikipedia.org/wiki/User_identifier">real, effective, saved, filesystem.</a><br />
<strong> Gid</strong>   : Set of four Group IDs: real, effective, saved, filesystem.<br />
<strong> FDSize</strong> : Number of file descriptors in use.<br />
<strong> Groups</strong> : List of GIDs of supplementary groups.<br />
<strong> VmPeak : </strong>Peak size of the virtual memory of the process.<br />
<strong> VmSize : </strong>Current total size of the virtual memory.<br />
<strong>VmLck</strong> : Size of locked memory.<br />
<strong> VmPIN</strong> : Size of pinned pages i.e. which are never swappable.<br />
<strong> VmHWM</strong> : Peak size of the resident set (&#8220;high water mark&#8221;). The resident set is the part of process memory which currently resides in the physical memory.<br />
<strong> VmRSS</strong> : Current size of the resident set.<br />
<strong> VmData</strong> : Size of the data segment.<br />
<strong> VmStk</strong> : Size of the stack segment.<br />
<strong>VmExe</strong> : Size of the text segment<br />
<strong> VmLib</strong> : Size of shared libraries loaded by this process<br />
<strong> VmPTE</strong> : Size of <a href="http://en.wikipedia.org/wiki/Page_table">page table entries </a><br />
<strong> VmSwap</strong> : Size of <a href="http://www.linux.com/news/software/applications/8208-all-about-linux-swap-space">swap space</a> used by this process.<br />
<strong> Threads : </strong>Number of threads.<br />
<strong> SigQ</strong> : Two values separated by &#8220;/&#8221;: Current number of queued signals/maximum allowed number of queued signals. (Signals are one of the means of communication among processes. They are also used to send alerts/notifications to the processes.)<br />
<strong> SigPnd : </strong>A bitmap (as a hexadecimal value) of pending signals for the thread[2] whose TID == TGID == PID.<br />
<strong> ShdPnd</strong> : A bitmap (as a hexadecimal value) of pending signals targeted on the whole process.<br />
<strong> SigBlk</strong> : A bitmap (as a hexadecimal value) of blocked signals for the thread whose TID == TGID == PID.<br />
<strong> SigIgn : </strong>A bitmap (as a hexadecimal value) of ignored signals (per-process).<br />
<strong> SigCgt</strong> : A bitmap (as a hexadecimal value) of signals a signal handler is installed for (per-process).<br />
<strong> CapInh</strong> : The inheritable capability set (a bitmap shown as a hexadecimal value). More about capabilities <a href="http://www.lindevdoc.org/wiki/Inheritable_capability_set">here</a><br />
<strong> CapPrm</strong> : The permitted capability set (a bitmap shown as a hexadecimal value).<a href="http://www.lindevdoc.org/wiki/Inheritable_capability_set">here</a><br />
<strong> CapEff</strong>  : The effective capability set (a bitmap shown as a hexadecimal value). <a href="http://www.lindevdoc.org/wiki/Inheritable_capability_set">here</a><br />
<strong> CapBnd</strong> : The bounding capability set (a bitmap shown as a hexadecimal value). <a href="http://www.lindevdoc.org/wiki/Inheritable_capability_set">here</a><br />
<strong> Cpus_allowed</strong> : A bitmap (as a hexadecimal value) of CPUs where the process may run.<br />
<strong> Cpus_allowed_list</strong> : A list of CPU numbers where the process may run (same information as Cpus_allowed).<br />
<strong> Mems_allowed</strong> : A bitmap (as a hexadecimal value) of memory nodes the process can use.<br />
<strong> Mems_allowed_list</strong> : A list of memory nodes the process can use<br />
<strong> voluntary_ctxt_switches</strong> : Number of voluntary context switches.<br />
<strong> nonvoluntary_ctxt_switches</strong> : Number of involuntary context switches.</p>
<p>It is fine, if one is not able to understand what each and every value in the output means. Linux processes are like an ocean of concepts and knowledge. Hence, one cannot take-in everything in one gulp. The principle mantra is try to grasp as much as one can. Things will link on its own in the journey of learning.</p>
<p>Although, at the moment it is significant to know following :</p>
<p><b>State: S (sleeping)</b><br />
Since, the process is currently having a valid PID, only because of the sleep() call, hence we understand the process is sleeping.</p>
<p><b>Tgid: 2808</b><br />
The thread group ID(Tgid) here is same as the PID of the process</p>
<p><b>Pid: 2808</b><br />
Nothing new here, we already knew this number.</p>
<p><b>PPid: 1746</b><br />
The parent ID. In our case, the bash shell is the parent process as we executed the binary from the shell. To confirm, just note the PID of ‘bash’ from the ‘ps’ command output.</p>
<pre style="overflow: auto; width: 560px;">$ps 
  PID TTY      	TIME CMD
 1746 pts/1	00:00:00 bash</pre>
<p>So this confirms our understanding.</p>
<p><b>VmPeak: 2048 kB</b><br />
The peak virtual memory size infers that the memory size of the process keeps on varying.</p>
<p><b>VmSize: 1988 kB</b><br />
The current size of the virtual memory being used by the process.</p>
<p><b>VmData: 32 kB</b><br />
The size of the data segment of the process in memory.</p>
<p><b>VmStk: 136 kB</b><br />
The size of the stack segment of the process in memory</p>
<p><b>VmExe: 4 kB</b><br />
The size of the text segment of the process in memory is 4KB</p>
<p><b>VmLib: 1788 kB</b><br />
The size of virtual memory occupied by the shared objects is 1788KB.</p>
<p><b>Threads: 1</b><br />
The number of threads. Since, we never started any new thread, just the main thread is running.</p>
<h2><span style="text-decoration: underline;">The real addresses</span></h2>
<p>It is time to jump into the addresses of the segments which we just discussed in the previous section of this article. The process segments are also termed as virtual areas in the kernel terminology. Worth mentioning, the addresses we see in this section are all virtual addresses.</p>
<p>We shall pick up the same ‘helloworld’ program what we wrote in the previous section.<br />
Let us create our process and get it running and sleeping <img src='http://mylinuxbook.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre style="overflow: auto; width: 560px;">$./helloworld &amp;</pre>
<p>We again will use the procfs to get the absolute process virtual memory mapping to each segment. The generic command would be</p>
<pre style="overflow: auto; width: 560px;"> cat /proc//maps</pre>
<p>The process ID would be different this time, hence we need to get it through linux ‘ps’ command.</p>
<pre style="overflow: auto; width: 560px;">  PID TTY      	TIME CMD
 1746 pts/1	00:00:00 bash
 2866 pts/1	00:00:00 helloworld
 2867 pts/1	00:00:00 ps</pre>
<p>Therefore, with the new process ID as ‘2866’, we read the procfs as:</p>
<pre style="overflow: auto; width: 560px;">$ cat /proc/2866/maps</pre>
<p>The memory maps from my system looks like</p>
<pre style="overflow: auto; width: 560px;">$ cat /proc/2866/maps
08048000-08049000 r-xp 00000000 08:01 393767 	/home/ubuntu/progs/helloworld
08049000-0804a000 r--p 00000000 08:01 393767 	/home/ubuntu/progs/helloworld
0804a000-0804b000 rw-p 00001000 08:01 393767 	/home/ubuntu/progs/helloworld
b75b0000-b75b1000 rw-p 00000000 00:00 0
b75b1000-b7750000 r-xp 00000000 08:01 658874 	/lib/i386-linux-gnu/libc-2.15.so
b7750000-b7752000 r--p 0019f000 08:01 658874 	/lib/i386-linux-gnu/libc-2.15.so
b7752000-b7753000 rw-p 001a1000 08:01 658874 	/lib/i386-linux-gnu/libc-2.15.so
b7753000-b7756000 rw-p 00000000 00:00 0
b7765000-b7768000 rw-p 00000000 00:00 0
b7768000-b7769000 r-xp 00000000 00:00 0      	[vdso]
b7769000-b7789000 r-xp 00000000 08:01 658854 	/lib/i386-linux-gnu/ld-2.15.so
b7789000-b778a000 r--p 0001f000 08:01 658854 	/lib/i386-linux-gnu/ld-2.15.so
b778a000-b778b000 rw-p 00020000 08:01 658854 	/lib/i386-linux-gnu/ld-2.15.so
bf8d2000-bf8f3000 rw-p 00000000 00:00 0      	[stack]</pre>
<p>Plethora of hexadecimal numbers, correct? Welcome to the world of memory addresses!  First of all, let us understand what each column of the output signify.</p>
<ul>
<li>1st column from the left, is the start address and the end address of a particular segment.</li>
<li>2nd column is a string which depicts the permission flags where :</li>
</ul>
<p style="text-align: center;"> <strong>r</strong> means readable<br />
<strong>w</strong> means writable<br />
<strong>x</strong> means executable<br />
<strong>p</strong> means private i.e it is not shared.<br />
<strong>s</strong> means shared</p>
<ul>
<li>3rd column is again a number which indicates the offset in the file where the mapping begins. Not every segment is mapped from a file, so the value of offset is zero in that case.</li>
<li>4th column is of the form “major number : minor number” of the associated device, as in, the file from which this segment is mapped from. Again, the segments which are not mapped from any file, value is 00:00.</li>
<li>5th column is the i-node of the related file.</li>
<li>The last column on the right is the path of the related file. Its blank in case there is no related file.</li>
</ul>
<p>In order to identify the segments, we need to notice the access permissions associated with each segment. Lets take the first segment i.e. the first row of the output.</p>
<pre style="overflow: auto; width: 560px;"> 
08048000-08049000 r-xp 00000000 08:01 393767 	/home/ubuntu/progs/helloworld</pre>
<p>The access permissions implies it is a readable and executable private segment. From the all the segment descriptions, we can make out it is the text segment. The text segment is the read-only with contains the instructions from the binary. Looking at the related file, it is not hard to guess, the region from virtual address ‘08048000’ to ‘08049000’ is the text segment of our helloworld program.<br />
Moving on to the next row</p>
<pre style="overflow: auto; width: 560px;">08049000-0804a000 r--p 00000000 08:01 393767 	/home/ubuntu/progs/helloworld</pre>
<p>From the permissions, this looks like a read-only private segment. This is one of the additional segment a process image can possess.</p>
<p>The next one,</p>
<pre style="overflow: auto; width: 560px;">0804a000-0804b000 rw-p 00001000 08:01 393767 	/home/ubuntu/progs/helloworld</pre>
<p>Again, noticing the access permissions, its a read/write segment which points to the data segment of the process.</p>
<p>The following row again looks like a segment with read/write permissions.</p>
<pre style="overflow: auto; width: 560px;">b75b0000-b75b1000 rw-p 00000000 00:00 0</pre>
<p>However, it is not related to any file (as offset = major # = minor # = inode = 0 and file is blank). It is the BSS segment which is mapped to the zero page and is initialized to zero therefore making it a zeroed memory area.</p>
<p>The next ones, again reads like a text segment, read-only segment and data segment and bss respectively, but the related file is a shared object. Our program is implicitly dynamically linked to the ‘libc’ standard library, which we can see here.</p>
<pre style="overflow: auto; width: 560px;">b75b1000-b7750000 r-xp 00000000 08:01 658874 	/lib/i386-linux-gnu/libc-2.15.so
b7750000-b7752000 r--p 0019f000 08:01 658874 	/lib/i386-linux-gnu/libc-2.15.so
b7752000-b7753000 rw-p 001a1000 08:01 658874 	/lib/i386-linux-gnu/libc-2.15.so
b7753000-b7756000 rw-p 00000000 00:00 0</pre>
<p>Note that, although these segments are mapped out of a shared object, though currently in this virtual memory area, they are not shared. Hence the permissions states them as private memory mapping.</p>
<p>We have similar set of segments (read, read-only and data) for the dynamically linked ld library.</p>
<pre style="overflow: auto; width: 560px;">b7769000-b7789000 r-xp 00000000 08:01 658854 	/lib/i386-linux-gnu/ld-2.15.so
b7789000-b778a000 r--p 0001f000 08:01 658854 	/lib/i386-linux-gnu/ld-2.15.so
b778a000-b778b000 rw-p 00020000 08:01 658854 	/lib/i386-linux-gnu/ld-2.15.so</pre>
<p>Besides, we have three more additional segments as listed below.</p>
<pre style="overflow: auto; width: 560px;">b776or5000-b7768000 rw-p 00000000 00:00 0
b7768000-b7769000 r-xp 00000000 00:00 0      	[vdso]
bf8d2000-bf8f3000 rw-p 00000000 00:00 0      	[stack]</pre>
<p>The first one represents yet another anonymous read/write segment which may be used as a backing store.<br />
The second one, though not related to any file, but specifies itself by [vdso]. It is a special memory area for kernel provided shared library to aid userspace call to kernel-space. The abbreviated full form is virtual dynamically linked shared object.<br />
The third one is the stack segment. It is already know it enfolds all the local variables.</p>
<h3>A simple exercise</h3>
<p>We have one local variable in our helloworld.c program. Let us check out which segment it belongs to in the process image. It is pretty simple. What we need to do is just print the address of the variable and find the correct address range from the memory mapping which includes the address of our variable.</p>
<p>To print the address of the variable, we modify our helloworld.c to</p>
<pre style="overflow: auto; width: 560px;">#include &lt; stdio.h &gt;
#include &lt; unistd.h &gt;

int main()
{

	char mesg[] = "HelloWorld";

	/*We need time to check process stats*/
	sleep(100);

	printf("Address of string mesg is %x\n", mesg);
	printf("%s\n", mesg);

	return 0;
}</pre>
<p>Lets build and run the binary, and in the meantime till we get the address of our ‘mesg’ variable, lets get the memory mapping of the newly created process.</p>
<pre style="overflow: auto; width: 560px;">$gcc helloworld.cl -o helloworld
$./helloworld &amp;
  PID TTY      	TIME CMD
 1746 pts/1	00:00:00 bash
 3036 pts/1	00:00:00 helloworld
 3037 pts/1	00:00:00 ps</pre>
<p>Retrieving the memory segment mapping,</p>
<pre style="overflow: auto; width: 560px;">$ cat /proc/3036/maps
08048000-08049000 r-xp 00000000 08:01 393656 	/home/ubuntu/progs/helloworld
08049000-0804a000 r--p 00000000 08:01 393656 	/home/ubuntu/progs/helloworld
0804a000-0804b000 rw-p 00001000 08:01 393656 	/home/ubuntu/progs/helloworld
b759e000-b759f000 rw-p 00000000 00:00 0
b759f000-b773e000 r-xp 00000000 08:01 658874 	/lib/i386-linux-gnu/libc-2.15.so
b773e000-b7740000 r--p 0019f000 08:01 658874 	/lib/i386-linux-gnu/libc-2.15.so
b7740000-b7741000 rw-p 001a1000 08:01 658874 	/lib/i386-linux-gnu/libc-2.15.so
b7741000-b7744000 rw-p 00000000 00:00 0
b7754000-b7756000 rw-p 00000000 00:00 0
b7756000-b7757000 r-xp 00000000 00:00 0      	[vdso]
b7757000-b7777000 r-xp 00000000 08:01 658854 	/lib/i386-linux-gnu/ld-2.15.so
b7777000-b7778000 r--p 0001f000 08:01 658854 	/lib/i386-linux-gnu/ld-2.15.so
b7778000-b7779000 rw-p 00020000 08:01 658854 	/lib/i386-linux-gnu/ld-2.15.so
bff47000-bff68000 rw-p 00000000 00:00 0      	[stack]</pre>
<p>After 100 secs since the launch of our process, we get,</p>
<pre style="overflow: auto; width: 560px;">Address of string mesg is bff66561
HelloWorld</pre>
<p>We need to find out, the address 0xbff66561 lies in which memory segment.Therefore, look for memory segment whose end-address is greater than 0xbff66561. We can see only one memory segment entry with has its end address greater than 0xbff66561 address value.<br />
That is,</p>
<pre style="overflow: auto; width: 560px;">bff47000-bff68000 rw-p 00000000 00:00 0      	[stack]</pre>
<p>Now, check the start address of this segment if it is less than 0xbff66561. Yes, it is. Hence we are sure the variable ‘mesg’ is stored in the above memory segment which is the stack.</p>
<h3>One more</h3>
<p>So, now, we know the virtual addresses of the process memory areas and we also confirmed our understanding that local variables go to stack. But did we miss heap in the above discussed output? Well, maybe it was never used.<br />
Lets write another program with a dynamic memory allocation which uses heap. To get realistic, let us convert a number to its corresponding string. the C source looks like</p>
<pre style="overflow: auto; width: 560px;">#include &lt; stdio.h &gt;
#include &lt; stdlib.h &gt;
#include &lt; unistd.h &gt;

int g_init_number = 123;
int g_uninit_temp;

/*convert a number to a string*/
int main()
{
	int local_size = 1;
	char *dynmem_str = NULL;
	int local_i = 0;
	int local_temp_int = 0;

	/*Determine the length of our output
    string i.e how many numbers form our number*/
	g_uninit_temp = g_init_number;
	while (1)
	{
    	g_uninit_temp /= 10;
    	if (!g_uninit_temp)
    	{
        	break;
    	}
    	local_size++;
	}

	/*Allocate memory for string of
	*   	 computed size + 1 for terminating
	*   	 null character*/      	 
	dynmem_str = (char*) malloc ((local_size + 1) * sizeof(char));
	if (dynmem_str == NULL)
	{
    	printf("Memory error!\n");
    	exit(1);
	}

	g_uninit_temp = g_init_number;
	for (local_i = local_size - 1;local_i &gt;= 0 ; local_i--)
	{
    	local_temp_int = g_uninit_temp % 10;
    	dynmem_str[local_i] = local_temp_int + '0';
    	g_uninit_temp /= 10;
	}

	dynmem_str[local_size] = 0;

	printf("The output string is %s\n", dynmem_str);

            /*We need time to get hold of the memory maps*/
	sleep(100);

	printf("\n\nAddresses of local variables: &amp;local_size = %x\n \t &amp;local_i = %x\n\t &amp;local_temp_int = %x\n", &amp;local_size, &amp;local_i, &amp;local_temp_int);
	printf("Address of global initialized variable g_init_number = %x\n", &amp;g_init_number);
	printf("Address of global un-initialized variable g_uninit_temp = %x\n", &amp;g_uninit_temp);
	printf("Address of dynamically allocated variable dynmem_str = %x\n", dynmem_str);

	free(dynmem_str);
	return 0;
}</pre>
<p>In the above written source, first of all we determine the size of our output string i.e. number of individual characters that form the number. We make an effort to determine the size, because we wish to dynamically allocate the memory for the output string, for which we need the size.</p>
<p>Once we have the size, allocate that much amount of memory and apply the logic to populate this newly allocated memory with our desired number-equivalent string.</p>
<p>In the end, we print the addresses of all the data i.e. variables used in the program. We’ll repeat the exercise of determining which variable goes in which memory segment. This will help us give a full-proof seal to our understanding.<br />
We are all set for the fun. Lets build and run the program.</p>
<pre style="overflow: auto; width: 560px;">$ gcc memmaps.c  -o memmaps
./memmaps &amp;
[2] 2423</pre>
<p>To clench the PID of our newly created process,</p>
<pre style="overflow: auto; width: 560px;">$ ps
  PID TTY      	TIME CMD
 2004 pts/1	00:00:00 bash
 2423 pts/1	00:00:00 memmaps
 2424 pts/1	00:00:00 ps</pre>
<p>Now using the PID of our ‘memmaps’ process, we retrieve the memory maps</p>
<pre style="overflow: auto; width: 560px;">$ cat /proc/2423/maps
00110000-00111000 r-xp 00000000 00:00 0      	[vdso]
00514000-006b7000 r-xp 00000000 08:01 15729750   /lib/i386-linux-gnu/libc-2.15.so
006b7000-006b8000 ---p 001a3000 08:01 15729750   /lib/i386-linux-gnu/libc-2.15.so
006b8000-006ba000 r--p 001a3000 08:01 15729750   /lib/i386-linux-gnu/libc-2.15.so
006ba000-006bb000 rw-p 001a5000 08:01 15729750   /lib/i386-linux-gnu/libc-2.15.so
006bb000-006be000 rw-p 00000000 00:00 0
00993000-009b3000 r-xp 00000000 08:01 15732611   /lib/i386-linux-gnu/ld-2.15.so
009b3000-009b4000 r--p 0001f000 08:01 15732611   /lib/i386-linux-gnu/ld-2.15.so
009b4000-009b5000 rw-p 00020000 08:01 15732611   /lib/i386-linux-gnu/ld-2.15.so
08048000-08049000 r-xp 00000000 08:01 7345013	/home/ubuntu/aprograms/memmaps
08049000-0804a000 r--p 00000000 08:01 7345013	/home/ubuntu/aprograms/memmaps
0804a000-0804b000 rw-p 00001000 08:01 7345013	/home/ubuntu/aprograms/memmaps
082f1000-08312000 rw-p 00000000 00:00 0      	[heap]
b76ec000-b76ed000 rw-p 00000000 00:00 0
b7700000-b7703000 rw-p 00000000 00:00 0
bfe5a000-bfe7b000 rw-p 00000000 00:00 0      	[stack]</pre>
<p>After 100 seconds of sleeping of the process, we get the addresses of all the variables as well.</p>
<pre style="overflow: auto; width: 560px;">Addresses of local variables: &amp;local_size = bfe79520
	  &amp;local_i = bfe79524
   	   &amp;local_temp_int = bfe79528
Address of global initialized variable g_init_number = 804a028
Address of global un-initialized variable g_uninit_temp = 804a034
Address of dynamically allocated variable dynmem_str = 82f1008</pre>
<p>We got all the data to analyse. First look at the procfs output. we got the memory map entry for heap as well. It is given area from virtual address 082f1000 to 08312000.</p>
<p>Studying the addresses printed by the program, its not that difficult to affirm, the local variables belong to the stack segment, as stack memory begins at address 0xbfe5a000 and end at 0xbfe7b000. The address if local variable ‘local_size’ is 0xbfe79520 which is</p>
<pre style="overflow: auto; width: 560px;">0xbfe5a000	 &gt;	0xbfe79520	 &lt;	 0xbfe7b000
|stack-start-addr|	|local_size addr|	|stack-end-addr|</pre>
<p>Similarly, the address of ‘local_i’ = 0xbfe79524 and ‘local_temp_int’ = bfe79528 lies within the address limits of the stack.</p>
<p>Next, moving on to check which memory segment the global variables belong to. The initialised global variable ‘g_init_number’ is at memory address 0x804a028 and the un-initialized global variable ‘g_uninit_temp’ at memory address 0x804a034 falls in the range of the read/write memory segment</p>
<pre style="overflow: auto; width: 560px;">0804a000-0804b000 rw-p 00001000 08:01 7345013	/home/ubuntu/aprograms/memmaps</pre>
<p>We rightly comprehended it as the data segment. Although internally the the un-initialized globals should be in the bss portion of the data segment as per our understanding.</p>
<p>The last but not the least, we have the pointer ‘dynmem_str’ which stores the address of the dynamically allocated memory i.e. 0x82f1008. Looking at the memory map, this address belongs to</p>
<pre style="overflow: auto; width: 560px;">082f1000-08312000 rw-p 00000000 00:00 0      	[heap]</pre>
<p>This memory area represents the heap. So, we even proved that ‘malloc()’ allocates memory from the heap segment.</p>
<h2><span style="text-decoration: underline;">Creating new processes from existing processes</span></h2>
<p>Standard C facilitates to create new processes from a program in execution. This is called creating processes from a running process, which is generally true in most of the cases. Another paramount fact is that, when a process creates a new process, both the two processes have their own separate memories in the RAM, where each of the process have their own individual memory segments.</p>
<p>There are two popular ways of creating new processes from a program.</p>
<h3>The system() method</h3>
<p>Standard C gives its programmers a convenient option to run commandline commands/executables from within a program. It is done through the system() method.<br />
The syntax from the <a href="http://linux.die.net/man/3/system">man page</a> looks like:</p>
<pre style="overflow: auto; width: 560px;">   	#include &lt; stdlib.h &gt;
   	int system(const char *command);</pre>
<p>It takes a command in the format of a string as its input argument and returns the command status after the command completion.<br />
Here is an example program to illustrate the use of the system() method</p>
<pre style="overflow: auto; width: 560px;">#include &lt; stdio.h &gt;
#include &lt; stdlib.h &gt;

int main()
{
	int retcode = 0;
	retcode = system("cat sys.c");

  	 return retcode;
}</pre>
<p>Compiling and running the built binary,</p>
<pre style="overflow: auto; width: 560px;">$ gcc sys.c -Wall -o sys
$./sys</pre>
<p>The output I get is:</p>
<pre style="overflow: auto; width: 560px;">#include &lt; stdio.h &gt;
#include &lt; stdlib.h &gt;

int main()
{
	int retcode = 0;

	retcode = system("cat sys.c");

   return retcode;
}</pre>
<p>Pretty much as we expected. It runs the command given to the system() method which displays the contents of the ‘sys.c’ file on the standard output.</p>
<p>However, interesting to know is that it isn’t the ‘sys’ process which created the new process running ‘cat’ executable. With the system() method, it creates new process ‘shell’ and hands over the command to it, which in turn triggers the ‘cat’ command and creates that process. To confirm, let us run our ‘helloworld’ binary from our source and check its parent process.</p>
<p>Here is the modified source, to trigger ‘helloworld’</p>
<pre style="overflow: auto; width: 560px;">#include &lt; stdio.h &gt;
#include &lt; stdlib.h &gt;

int main()
{
	int retcode = 0;
	retcode = system("./helloworld");

	return retcode;
}</pre>
<p>We build the source and run the binary in the background.</p>
<pre style="overflow: auto; width: 560px;">$ gcc sys.c -Wall -o sys
$./sys &amp;</pre>
<p>We know running ‘helloworld’ executable is a blocking call as it has a 100 sec sleep().<br />
Therefore, in the meanwhile, first wish to see what all processes are running and their PID’s.</p>
<pre style="overflow: auto; width: 560px;">$ps
  PID TTY      	TIME CMD
 1912 pts/1	00:00:00 bash
 2112 pts/1	00:00:00 sys
 2113 pts/1	00:00:00 sh
 2114 pts/1	00:00:00 helloworld
 2115 pts/1	00:00:00 ps</pre>
<p>We get an inkling from the running ‘sh’ process that it must have been started by the system() call in the ‘sys’ process. Alongwith, we also notice the ‘helloworld’ process running, which has been launched from within our program using the ‘system()’ call.</p>
<p>To check the parent process of ‘helloworld’, we use the Linux command ‘ps’ as</p>
<pre style="overflow: auto; width: 560px;">$ps -f
UID    	PID  PPID  C STIME TTY      	TIME CMD
ubuntu  1912  1902  0 16:12 pts/1	00:00:00 bash
ubuntu  2112  1912  0 18:07 pts/1	00:00:00 ./sys
ubuntu  2113  2112  0 18:07 pts/1	00:00:00 sh -c ./helloworld
ubuntu  2114  2113  0 18:07 pts/1	00:00:00 ./helloworld
ubuntu  2116  1912  0 18:08 pts/1	00:00:00 ps -f</pre>
<p>Note: One can also use the procfs as /proc/2114/status to know the PPID of the ‘helloworld’ process.</p>
<p>From the ‘ps -f’ output, our line of interest i.e.</p>
<pre style="overflow: auto; width: 560px;">ubuntu  2114  2113  0 18:07 pts/1	00:00:00 ./helloworld</pre>
<p>sets forth the PPID as ‘2113’ which is the PID of the shell process. Moreover, the PPID of the shell process is ‘2112’ which is the PID of our ‘sys’ process. The numbers above says it all.</p>
<p><span style="text-decoration: underline;"><b>Caveat</b></span>  : Although, using the ‘system()’ method is pretty convenient, it has limitations and drawbacks too. Since, it uses shell to run the command, the behavior of the command will depend upon what shell it is using. If the shell is compromised in security, using the ‘system()’ method could be a hazard.</p>
<h3>The fork() method</h3>
<p>The fork() call is used to create a duplicate child process as the parent process which is calling it. So, from the point, the fork() call was made, both the parent and the child process starts executing the same program.<br />
The syntax from the <a href="http://linux.die.net/man/2/fork"> man page </a> is</p>
<pre style="overflow: auto; width: 560px;">#include &lt; unistd.h &gt;
pid_t fork(void);</pre>
<p>Since when this method returns, we have two processes running the same program. Therefore, in the main parent process, the return value is the PID of the newly created child process. However, in the newly created child process, the return value is zero. This is a significant distinguishing parameter between a child process and the parent process while in the program. We shall see more in the later discussions.</p>
<p>Although we would be discussing the data-structures related to processes in the next part, we can’t ignore the datatype used for the PID.</p>
<pre style="overflow: auto; width: 560px;">pid_t</pre>
<p>Therefore, if we want to store a PID in a variable, we now know what data-type it should be.</p>
<p>Further, we shall experience using the fork() method in a program.</p>
<pre style="overflow: auto; width: 560px;">#include &lt; stdio.h &gt;
#include &lt; unistd.h &gt;

int main()
{
	pid_t pid_child = 0;
	int a = 12;
	int b = 3;
	int result = -1;

	printf("All set to create another process\n");
	pid_child = fork();
	if (pid_child)
	{
    	result = a + b;
    	printf("Parent process : The result is %d\n", result);
	}
	else
	{
            /*The pid_child = 0*/
    	result = a * b;
    	printf("Child process : The result is %d\n", result);
	}

	/*Buying time to check the running processes*/
	sleep(100);
	return 0;
}</pre>
<p>In the above example source code, we do two different operations in both the child and parent processes. The way we distinguish what to do in the parent process and what has to be done in the child process is by checking the value of returned PID by the fork() call.</p>
<p>In the parent process, the value returned by fork() would be a valid PID i.e. non-zero positive value. However, in the child process instance, the variable value would be just zero, as this process has just been created. Well, we’ve sent both the processes to sleep for 100 seconds.</p>
<p>Time to compile and launch the process:</p>
<pre style="overflow: auto; width: 560px;">$ gcc frk.c -Wall -o frk
$./frk &amp;
[3] 2153
$ All set to create another process
Parent process : The result is 15
Child process : The result is 36</pre>
<p>The process is now sleeping after printing the results. Meanwhile, let us check the active process information.</p>
<pre style="overflow: auto; width: 560px;">$ps -f
UID    	PID  PPID  C STIME TTY      	TIME CMD
ubuntu  1912  1902  0 16:12 pts/1	00:00:00 bash
ubuntu  2153  1912  0 18:57 pts/1	00:00:00 ./frk
ubuntu  2154  2153  0 18:57 pts/1	00:00:00 ./frk
ubuntu  2155  1912  0 18:57 pts/1	00:00:00 ps -f</pre>
<p>From the above output, we identify our two processes with the same command. One of them(1) is a parent process which as the PPID of the ‘bash’ and other(2) is the child process which has the PPID as the PID of (1).</p>
<pre style="overflow: auto; width: 560px;">(1) ubuntu  2153  1912  0 18:57 pts/1	00:00:00 ./frk
(2) ubuntu  2154  2153  0 18:57 pts/1	00:00:00 ./frk</pre>
<h2><span style="text-decoration: underline;">Conclusion</span></h2>
<p>Linux processes part II is an effort to extend the horizons of the readers with how processes reside in the virtual memory of Linux along with a pragmatic approach to visualize the memory areas. The article also talked about how we can create processes programmatically. We hope this could be a little contribution in the vast and diversified topic as Linux Processes and provide a platform to initiate a child process in the mind of readers, which begins playing around with the memory addresses and launching new complex processes.</p>
<p>For now,</p>
<pre> $ps
 PID CMD
 222 Article Linux Process Part II</pre>
<pre> $kill -9 222</pre>
<p>In the Linux processes part III, we shall get apprised with data-structures related to processes and much more.</p>
<p>Want more? Read an interesting article on <a href="http://mylinuxbook.com/file-extensions-in-linux/">file extensions in Linux</a>.</p>
<p>The post <a href="http://mylinuxbook.com/linux-processes-part2/">Linux Processes explained &#8211; Part II</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mylinuxbook.com/linux-processes-part2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LibreOffice For Beginners &#8211; Six Feature Packed Applications To Get You Started</title>
		<link>http://mylinuxbook.com/libreoffice-for-beginners/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=libreoffice-for-beginners</link>
		<comments>http://mylinuxbook.com/libreoffice-for-beginners/#comments</comments>
		<pubDate>Mon, 01 Apr 2013 17:17:12 +0000</pubDate>
		<dc:creator>Piunika</dc:creator>
				<category><![CDATA[Open source software]]></category>
		<category><![CDATA[alternative to ms office]]></category>
		<category><![CDATA[Best Free Office Productivity Suite]]></category>
		<category><![CDATA[libreoffice]]></category>
		<category><![CDATA[libreoffice features]]></category>
		<category><![CDATA[Microsoft office vs libre office]]></category>

		<guid isPermaLink="false">http://mylinuxbook.com/?p=1543</guid>
		<description><![CDATA[<p>LibreOffice is a powerful office productivity suite which is completely free and open source. It comes as an easy alternative for MS-Office with fully loaded features. This product is compatible with various operating systems and office suites including Microsoft Office. It has very intuitive user interface which includes the following : Word processor Impress Calc [...]</p><p>The post <a href="http://mylinuxbook.com/libreoffice-for-beginners/">LibreOffice For Beginners &#8211; Six Feature Packed Applications To Get You Started</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>LibreOffice is a powerful office productivity suite which is completely free and open source. It comes as an easy <a href="http://www.zdnet.com/how-to-affordably-own-your-office-software-7000011449/">alternative for </a><a href="http://mylinuxbook.com/wp-content/uploads/2013/03/libreoffice.png"><img class="alignright size-thumbnail wp-image-1741" alt="libreoffice for beginners" src="http://mylinuxbook.com/wp-content/uploads/2013/03/libreoffice-150x150.png" width="150" height="150" /></a>MS-Office with fully loaded features. This product is compatible with various operating systems and office suites including Microsoft Office. It has very intuitive user interface which includes the following :</p>
<ul>
<li>Word processor</li>
<li>Impress</li>
<li>Calc</li>
<li>Draw</li>
<li>Math</li>
<li>Base.</li>
</ul>
<p>If you are used to MS-Office but want to switch over to a free and open source alternative the you must give LibreOffice a try. This comprehensive office suite gives you high professional quality productivity. In this article, keeping in mind the theme ( <em>LibreOffice for beginners</em> ), we will briefly explain six feature-packed applications of LibreOffice that will definitely help you to get started with this amazing office suite.</p>
<p><span id="more-1543"></span></p>
<p>&nbsp;</p>
<h2><span style="text-decoration: underline;">LibreOffice For Beginners</span></h2>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><strong>1. WRITER</strong></span></p>
<p>LibreOffice Writer is a word processor inside this office productivity suite. User can create text documents like letters, resumes etc. as well as include graphics, tables and charts. You can also merge the long and complex documents in it. Documents can be saved in various formats as it is compatible with ODF, HTML, Word.doc etc.</p>
<p>LibreOffice Writer includes a thesaurus, auto-completion, a spell checker, auto-correct and various templates. With this program, user can design and structure their documents using its style and formatting options. User can create a complete book as it gives you full platform where you can put tables, create diagrams, embed illustrations, create indexes and do much more.</p>
<p>Then user can do desktop publishing, calculations, create drawings, insert graphics with different formats and much more using LibreOffice word processor. Navigation is easier with LibreOffice and drag-drop feature is an add-on. You can create from a simple text document to a very complex book as this office suite has no dearth of options, you just need to explore more.</p>
<p>&nbsp;</p>
<p><a href="http://mylinuxbook.com/libreoffice-for-beginners/writer/" rel="attachment wp-att-1546"><img class="alignleft  wp-image-1546" alt="writer" src="http://mylinuxbook.com/wp-content/uploads/2013/02/writer-1024x640.jpg" width="614" height="384" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p style="text-align: center;">(A Snapshot of LibreOffice Word in action)</p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><strong>2. CALC</strong> </span></p>
<p>LibreOffice Calc is a spreadsheet program which is similar to Microsoft Excel. Calc can be used to calculate, analyse, and manage your data as well as modify and import Microsoft Excel spreadsheets. Users can manage and save their data with spreadsheets like in excel sheets. User can easily organize the data in tabular form which also makes the analysis easier.</p>
<p>You can arrange your data and can quickly perform mathematical calculations over it. Calc has inbuilt functions including statistical and banking functions, that you can use to create formulas to perform complex calculations on your data. User can always add to or reorganize these spreadsheets. This program also lets you present spreadsheet data in dynamic charts as shown in the screen-shot that gets updated automatically when the data changes as well as it can convert files in various formats which LibreOffice Calc is compatible with.</p>
<p>&nbsp;</p>
<p><a href="http://mylinuxbook.com/libreoffice-for-beginners/pic-calc/" rel="attachment wp-att-1548"><img class="alignleft  wp-image-1548" alt="pic Calc" src="http://mylinuxbook.com/wp-content/uploads/2013/02/pic-Calc-1024x640.jpg" width="614" height="384" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p style="text-align: center;"> (A Snapshot of LibreOffice Calc in action)</p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><strong>3. IMPRESS</strong></span></p>
<p>LibreOffice Impress is like Microsoft power point application which lets you create smart presentations. This presentation program enables you to display information in the form of a slide show. Using Impress program, user can create professional slide shows that may include charts, drawing objects, text, multimedia and a various other items. You can even import and modify Microsoft Power-Point presentations with this program as it is compatible with MS-Power Point.</p>
<p>Special effects and stunning inbuilt animations will let you create powerful and effective multimedia presentations. You can create slides using multiple feature options and then choose to run them either automatically or manually. With the help of vector graphic tools, you can create impressive vector graphics in your slides.</p>
<p>&nbsp;</p>
<p><a href="http://mylinuxbook.com/libreoffice-for-beginners/pic-impress/" rel="attachment wp-att-1551"><img class="alignleft  wp-image-1551" alt="pic Impress" src="http://mylinuxbook.com/wp-content/uploads/2013/02/pic-Impress-1024x640.jpg" width="614" height="384" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p style="text-align: center;">(A Snapshot of LibreOffice Impress in action)</p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><strong>4. DRAW</strong></span></p>
<p>LibreOffice Draw is a drawing application like Microsoft Visio that lets you draw and make sketches right from the scratch. You can produce from simplest to complex drawings using this program. User can insert tables, charts, formulas and much more from the gallery which contains images, sounds, animations etc. You can also create vector graphics like ellipses, lines etc.</p>
<p>You can create 3D objects like spheres, cubes etc. and even modify them as per your requirement. Then you can display dimensions, connect objects to show relationships etc. and believe me that it is not at all difficult. It is compatible with common graphic file formats like PNG, JPG, GIF etc.</p>
<p>&nbsp;</p>
<p><a href="http://mylinuxbook.com/libreoffice-for-beginners/pic-draw/" rel="attachment wp-att-1550"><img class="alignleft  wp-image-1550" alt="pic draw" src="http://mylinuxbook.com/wp-content/uploads/2013/02/pic-draw-1024x640.jpg" width="614" height="384" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p style="text-align: center;"> (A Snapshot of LibreOffice Draw in action)</p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><strong>5. BASE and CHART</strong></span></p>
<p>Base is a database component of LibreOffice with which you can create and manage databases like you do with Microsoft Access. This program supports dBase format but you can also use Base to connect to external databases. You can use charts which enable you to present data in a form which is easy to visualize and understand. You can produce a chart from source data in a Calc spreadsheet or a Writer table.</p>
<p>&nbsp;</p>
<p><a href="http://mylinuxbook.com/libreoffice-for-beginners/pic-base/" rel="attachment wp-att-1547"><img class="alignleft  wp-image-1547" alt="pic base" src="http://mylinuxbook.com/wp-content/uploads/2013/02/pic-base-1024x640.jpg" width="614" height="384" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://mylinuxbook.com/libreoffice-for-beginners/pic-chart/" rel="attachment wp-att-1549"><img class="alignleft  wp-image-1549" alt="pic chart" src="http://mylinuxbook.com/wp-content/uploads/2013/02/pic-chart-1024x640.jpg" width="614" height="384" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p style="text-align: center;"> (A Snapshot of LibreOffice Base in action)</p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><strong>6. MATH</strong></span></p>
<p>LibreOffice Math function is an application which is used to type a formula directly or create it with the help of its operators, functions and formatting assistants which are listed in the selection window. This application enables you to create and edit mathematical formulas which include mathematical functions, integrals, fractions, equations and much more. You can create a formula directly in this application and insert it in your document or you can also start this application from within the Writer, Calc and Impress via menu.</p>
<p>&nbsp;</p>
<p><a href="http://mylinuxbook.com/libreoffice-for-beginners/pic-math/" rel="attachment wp-att-1552"><img class="alignleft  wp-image-1552" alt="pic math" src="http://mylinuxbook.com/wp-content/uploads/2013/02/pic-math-1024x640.jpg" width="614" height="384" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p style="text-align: center;"> (A Snapshot of LibreOffice Math in action)</p>
<p>&nbsp;</p>
<h2><span style="text-decoration: underline;">Interested in more?</span></h2>
<p>Here are a few links for you :</p>
<ul>
<li><a href="http://www.libreoffice.org/">Homepage</a></li>
<li><a href="http://www.libreoffice.org/download/">Download</a></li>
<li><a href="http://en.wikipedia.org/wiki/LibreOffice">Wikipedia Link</a></li>
<li><a href="http://www.youtube.com/watch?v=onHJ_5RaNmo">A video for Beginners</a></li>
</ul>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The post <a href="http://mylinuxbook.com/libreoffice-for-beginners/">LibreOffice For Beginners &#8211; Six Feature Packed Applications To Get You Started</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mylinuxbook.com/libreoffice-for-beginners/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Empower Linux Command Line With Screen Capturing Capability Through Scrot</title>
		<link>http://mylinuxbook.com/scrot-command/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=scrot-command</link>
		<comments>http://mylinuxbook.com/scrot-command/#comments</comments>
		<pubDate>Thu, 28 Mar 2013 17:32:21 +0000</pubDate>
		<dc:creator>Himanshu</dc:creator>
				<category><![CDATA[Commands]]></category>
		<category><![CDATA[Linux administration]]></category>

		<guid isPermaLink="false">http://mylinuxbook.com/?p=1822</guid>
		<description><![CDATA[<p>I have been a Linux command line addict for many years now. Though I use Ubuntu 12.04 these days but still I spend most of the time on command line. I like to do most of my tasks through command line only. While I am pretty happy with what all I am able to do [...]</p><p>The post <a href="http://mylinuxbook.com/scrot-command/">Empower Linux Command Line With Screen Capturing Capability Through Scrot</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I have been a Linux command line addict for many years now. Though I use Ubuntu 12.04 these days but still I spend most of the time on command line. I like to do most of my tasks through command line only. While I am pretty happy with what all I am able to do through command line but still there are few tasks for which I have to use other (GUI based) applications. One of these tasks was taking a screen-shot. I have always used graphical applications for taking screen-shots on Linux. Honestly speaking I never thought that Linux command line can be used to take a screen shot until I encountered the scrot utility.</p>
<p>The scrot utility can be used to take screen-shots from command line. There are various options available with this command that make this utility equally powerful and flexible as its graphical peers. In this article we will discuss some important and useful features of scrot utility through practical examples.<br />
<span id="more-1822"></span></p>
<p>&nbsp;</p>
<h2><span style="text-decoration: underline;">Scrot</span></h2>
<p>The scrot utility does not come by default on most of the Linux distributions. You have to download it first. For example, on my Ubuntu machine, I used the following command to download scrot utility :</p>
<pre>sudo apt-get install scrot</pre>
<p>Once the utility is downloaded, it can be used as a command on Linux command line.  Now lets discuss in detail the usage of scrot command along with its options.</p>
<h3>1. Scrot without any options</h3>
<p>If you use the scrot command without any options then it will capture the complete screen in a .PNG image and save it in the current directory. The name of the file would be derived from current date and time.</p>
<p>Here is an example :</p>
<pre>$ scrot</pre>
<pre>$ ls | grep *.png
2013-03-28-204412_1280x800_scrot.png</pre>
<p>So you see that after running scrot command, a date stamped .PNG file was created in current directory.  If I open this image, it looks like :</p>
<p style="text-align: center;"><a href="http://mylinuxbook.com/wp-content/uploads/2013/03/2013-03-28-204412_1280x800_scrot.png"><img class="aligncenter size-medium wp-image-1823" alt="2013-03-28-204412_1280x800_scrot" src="http://mylinuxbook.com/wp-content/uploads/2013/03/2013-03-28-204412_1280x800_scrot-300x187.png" width="300" height="187" /></a> (Click to enlarge)</p>
<p style="text-align: left;">So we see that complete screen was captured when scrot command was run without any option.</p>
<h3 style="text-align: left;">2. Select capturing area using -s option</h3>
<p>Like any other capable screen shot utility, scrot is also capable of capturing user defined area of screen. This can be done by using -s option along with scrot command.</p>
<p>Here is an example :</p>
<pre>$ scrot -s</pre>
<p>When you hit enter after typing the above shown command, the scrot utility waits for user to select a screen area of interest using mouse. You can then select an area using your mouse and as soon as you release the mouse button, a screen shot is taken and stored as .PNG file in current directory.</p>
<p>Here is capture that I did using this option :</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/03/2013-03-28-210243_465x65_scrot.png"><img class="aligncenter size-full wp-image-1828" alt="2013-03-28-210243_465x65_scrot" src="http://mylinuxbook.com/wp-content/uploads/2013/03/2013-03-28-210243_465x65_scrot.png" width="465" height="65" /></a></p>
<h3>3. Store the output in a directory other than current directory.</h3>
<p>As you would have observed till now, the scrot command saves the captured image in current directory. But, if a path is specified along with scrot on command prompt then this utility saves the image in that directory. Also, if you specify the name of file in the path then it even uses that name for the captured file.</p>
<p>Here is an example :</p>
<pre>$ scrot /home/himanshu/Desktop/testScrot.png
$ cd /home/himanshu/Desktop
$ ls | grep test*.png
testScrot.png</pre>
<p>So you can see that the file was stored in the specified directory and with the specified name.</p>
<h3>4. Add delay before taking screen shot through -d option</h3>
<p>Just like a family photograph (that includes the photographer also) , sometimes it is required to introduce a delay before taking a screen-shot on a computer. The scrot utility provides an option -d for doing the same.</p>
<p>For example :</p>
<pre>$ scrot -d10</pre>
<p>The command above would wait for 10 seconds before capturing the screen.</p>
<h3>5. Display a countdown through -c option</h3>
<p>If you are using a delay (-d option) then scrot provides a countdown feature through -c option. If you use -c option with -d option then a countdown is displayed during the delay session.</p>
<p>Here is an example :</p>
<pre>$ scrot -cd10
<strong>Taking shot in 10.. 9.. 8.. 7.. 6.. 5.. 4.. 3.. 2.. 1.. 0.</strong></pre>
<p>As you can see a countdown was displayed during 10 seconds of delay.</p>
<h3>6. Generate a thumbnail through -t option</h3>
<p>The scrot utility also provides an option -t through which a thumbnail of captured image can be generated. This option requires an argument that specifies the percentage of the original size for the thumbnail.</p>
<p>Here is an example :</p>
<pre>$ scrot -t20
$ ls
2013-03-28-220748_1280x800_scrot.png  <strong>2013-03-28-220748_256x160_scrot-thumb.png</strong></pre>
<p>So you can see that along with the captured image, a thumbnail (whose size is 20% of the original) was also produced.</p>
<h3>7. Capture only the currently focused window through -u option</h3>
<p>There are when screen is full of applications each covering small area.</p>
<p>For example :</p>
<p><a href="http://mylinuxbook.com/wp-content/uploads/2013/03/2013-03-28-221425_1280x800_scrot.png"><img class="aligncenter size-medium wp-image-1830" alt="2013-03-28-221425_1280x800_scrot" src="http://mylinuxbook.com/wp-content/uploads/2013/03/2013-03-28-221425_1280x800_scrot-300x187.png" width="300" height="187" /></a></p>
<p style="text-align: center;">(Click to enlarge)</p>
<p>Now, in this kind of scenario, if it is required to take screen shot of a specific window rather than the whole screen then you can use the -u option provided by scrot utility.</p>
<p>If it is desired to take snapshot of the command prompt window the simply run the following command :</p>
<pre>$ scrot -u</pre>
<p>This command will capture only the command prompt window.</p>
<p>If it is desired to take snapshot of some other window then you can use the delay option (-d) with scrot command, run the command and during the delay focus the window (ie make the desired window your current window by clicking on it). The scrot utility will automatically take the screen shot of the focused window.</p>
<h3>8. Open an application to display the screen shot through -e option</h3>
<p>If you have ever used a graphical screen shot utility, you would have observed that it immediately displays the captured screen shot. The scrot utility also provides the same capability through -e option. For example, I used the following command to capture screen through scrot and display it through gimp utility.</p>
<pre>$ scrot -e 'gimp $n'</pre>
<p>This is a special syntax that is required to execute gimp tool with the file saved. It&#8217;s worth noting that $n represents the file-name with which the screen-shot will be saved. Instead of gimp, you can use any other tool but $n will remain same.</p>
<p>Just like $n, there are various other format specifiers :</p>
<blockquote><p>$f image path/filename (ignored when used in the filename)<br />
$n image name (ignored when used in the filename)<br />
$s image size (bytes) (ignored when used in the filename)<br />
$p image pixel size<br />
$w image width<br />
$h image height<br />
$t image format<br />
$$ prints a literal &#8216;$&#8217;</p></blockquote>
<p>Besides displaying a screen shot using a relevant application, the -e option opens up infinite possibilities. For example, if you want to take a screen shot and store its copy to a separate directory (<em>screenshots</em>) then this can be done in the following way :</p>
<pre>$ scrot -e 'cp $n ~/screenshots'</pre>
<p>So you can see that you can do endless stuff with -e option.</p>
<p>Just like we discussed the some format specifiers above, there exists another category of format specifiers for year, month and day :</p>
<blockquote><p>%Y &#8211; For year</p>
<p>%d &#8211; For date</p>
<p>%m &#8211; For month</p></blockquote>
<p>Here is an example using these specifiers :</p>
<pre>$ scrot '%Y-%m-%d_UbuntuLinux.png'</pre>
<pre>$ ls | grep *UbuntuLinux*
2013-03-28_UbuntuLinux.png</pre>
<p>So we see that these format specifiers were replaced by current year, month and date respectively.</p>
<p><em><strong>Note</strong> : To learn about some other interesting Linux commands, read our articles on <a href="http://mylinuxbook.com/linux-netcat-command/">netcat</a> and <a href="http://mylinuxbook.com/linux-strace-command-a-magnificent-troubleshooter/">strace</a> commands.</em></p>
<p>The post <a href="http://mylinuxbook.com/scrot-command/">Empower Linux Command Line With Screen Capturing Capability Through Scrot</a> appeared first on <a href="http://mylinuxbook.com">MyLinuxBook</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mylinuxbook.com/scrot-command/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
