<?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>gHacks Technology News &#124; Latest Tech News, Software And Tutorials &#187; linux command line</title> <atom:link href="http://www.ghacks.net/tag/linux-command-line/feed/" rel="self" type="application/rss+xml" /><link>http://www.ghacks.net</link> <description>A technology news blog covering software, mobile phones, gadgets, security, the Internet and other relevant areas.</description> <lastBuildDate>Sat, 11 Feb 2012 21:54:04 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/> <item><title>Get to know Linux: Using grep</title><link>http://www.ghacks.net/2010/09/06/get-to-know-linux-using-grep/</link> <comments>http://www.ghacks.net/2010/09/06/get-to-know-linux-using-grep/#comments</comments> <pubDate>Mon, 06 Sep 2010 11:49:54 +0000</pubDate> <dc:creator>Jack Wallen</dc:creator> <category><![CDATA[Advice]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Open Source]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Tutorials Basic]]></category> <category><![CDATA[file search]]></category> <category><![CDATA[grep]]></category> <category><![CDATA[LCI]]></category> <category><![CDATA[linux command line]]></category> <category><![CDATA[regular expressions]]></category> <category><![CDATA[search files]]></category> <guid
isPermaLink="false">http://www.ghacks.net/?p=33971</guid> <description><![CDATA[If you use Linux long enough, you are going to wind up getting to know (and using) the command line. And if you use the command line long enough, you are going to find yourself using the grep tool. Grep is one of the most useful linux utilities in that it will search WITHIN a [...]]]></description> <content:encoded><![CDATA[<p>If you use Linux long enough, you are going to wind up getting to know (and using) the command line. And if you use the command line long enough, you are going to find yourself using the <em>grep</em> tool. Grep is one of the most useful linux utilities in that it will search WITHIN a text file for a string of characters. Grep is such a useful tool that it is often used in shell scripts and much, much more.</p><p>In this article I am going to introduce you to the <em>grep </em> command and how it is used. Once you know this command, your life with the Linux command line will be made much easier.</p><p><span
id="more-33971"></span><strong>Limitations</strong></p><p>Although grep is a very versatile command to know, it does have its limitations. One of the biggest limitations it has is that it can not search within binary files. That&#8217;s all fine, because your typical binary file would be searchable with the application that created said binary file.</p><p>Grep also has a line limit of 2048 lines. This means if your file is beyond that, grep will stop searching at the line limit.</p><p><strong>Installation</strong></p><p>You are in luck. Grep is a tool that comes pre-installed with all Linux distributions. So no installation is required.</p><p><strong>Usage</strong></p><p>The basic usage of <em>grep </em>is:</p><p><em>grep [OPTIONS] [PATTERN] file</em></p><p>Their are numerous options to use with the Grep command. The more helpful of these options are:</p><p><code>-E Interpret the PATTERN section as an extended regular expression.<br
/> -P Interpret the PATTERN section as a Perl regular expression.<br
/> -e Use PATTERN as the pattern. If searching a single PATTERN you do not need the -e option. But this option allows you to search for multiple search patterns.<br
/> -f  Obtain patterns from a file, one per line.<br
/> -i Ignore case.<br
/> -c Suppress normal output and only output count of matching lines.<br
/> --color Display the matched strings in color.<br
/> -n Display the line number associated with the matching entry.</code></p><p><strong>Examples</strong></p><p>Let&#8217;s take a look at a very basic example first. You want to search the file <strong>/etc/test.conf</strong> for the string <em>input</em>. The grep command for this would be:</p><p><code>grep input /etc/test.conf</code></p><p>Now, let&#8217;s say that <strong>test.conf</strong> is a larger file and you need to know the line number the string <em>input</em> is on. For this the command would look like:</p><p><code>grep -n input /etc/test.conf</code></p><p>The above output would then include the line number associated with each matching entry. Now, let&#8217;s say you wanted to search the same file for both <em>input </em>and <em>output </em>and you want to know the line numbers associated with each. For this the command would look like:</p><p><code>grep -n -e input -e output /etc/test.conf</code></p><p>But what if you only want to know how many times the string <em>input</em> is found in the file <strong>/etc/test.conf</strong>. For this you could use the command like so:</p><p><code>grep -c input /etc/test.conf</code></p><p><strong>Final thoughts</strong></p><p>Grep is one of those commands that you will use time and again, in many, various ways. I always tell new users that, once you reach the point where you begin using the command line, <em>grep </em>is one of the first commands you should master.</p> ]]></content:encoded> <wfw:commentRss>http://www.ghacks.net/2010/09/06/get-to-know-linux-using-grep/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Guake: Hide-able terminal goodness</title><link>http://www.ghacks.net/2010/06/21/guake-hide-able-terminal-goodness/</link> <comments>http://www.ghacks.net/2010/06/21/guake-hide-able-terminal-goodness/#comments</comments> <pubDate>Mon, 21 Jun 2010 11:19:21 +0000</pubDate> <dc:creator>Jack Wallen</dc:creator> <category><![CDATA[Desktop Manager]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Open Source]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Tutorials Basic]]></category> <category><![CDATA[bash]]></category> <category><![CDATA[cli]]></category> <category><![CDATA[command-line]]></category> <category><![CDATA[GNOME]]></category> <category><![CDATA[linux command line]]></category> <category><![CDATA[terminal]]></category> <guid
isPermaLink="false">http://www.ghacks.net/?p=26885</guid> <description><![CDATA[As you well know, I am a big fan of the Linux command line. Because of this I use the terminal a lot. I am also a fan of Linux eye candy and making my desktop as clean and sleek as possible. I don&#8217;t like to have things in the way and I like easy [...]]]></description> <content:encoded><![CDATA[<p>As you well know, I am a big fan of the Linux command line. Because of this I use the terminal a lot. I am also a fan of Linux eye candy and making my desktop as clean and sleek as possible. I don&#8217;t like to have things in the way and I like easy access to the tools I use. That is why I want my terminal to be easily accessed, always ready, and quick to disappear.</p><p>Guake is a drop-down terminal that fits all of these needs perfectly. It&#8217;s for the GNOME environment and is easy to use and is one of those tools that, once you start using, you&#8217;ll wonder why you hadn&#8217;t been using all along. In this article I will show you how to install and use the Guake drop-down terminal so your Linux command line can be as finger-tip ready as possible.</p><p><span
id="more-26885"></span><strong>Installation</strong></p><p>Fortunately the installation of Guake is simple. Because it lives in the standard repositories of all of the major distributions, you can install Guake with a command like this:</p><p><em>yum install guake</em></p><p><em><span
style="font-style: normal">or</span></em></p><p><em>sudo apt-get install guake</em></p><div
id="attachment_26886" class="wp-caption alignleft" style="width: 435px"><a
href="http://www.ghacks.net/wp-content/uploads/2010/06/guake_icon.png"><img
class="size-full wp-image-26886" src="http://www.ghacks.net/wp-content/uploads/2010/06/guake_icon.png" alt="" width="425" height="48" /></a><p
class="wp-caption-text">Figure 1</p></div><p>If you use the former command you will have to do so after you<em> su</em> to the root user. Once installed you will need to start Guake. You do so by clicking <strong>Applications &gt; Acesssories &gt; Guake Terminal</strong>. Once started Guake will reside in your notification area as an icon (see Figure 1). The icon is the Green downward pointing arrow. If you right-click that icon can access the Guake preferences.</p><p><strong>Configuration</strong></p><p><a
href="http://www.ghacks.net/wp-content/uploads/2010/06/guake_prefs.png"><img
class="alignright size-full wp-image-26887" src="http://www.ghacks.net/wp-content/uploads/2010/06/guake_prefs.png" alt="" width="209" height="244" /></a>There isn&#8217;t too much to configure with Guake. From the preferences window you can take care of such items as:</p><ul><li>The default shell: You will most likely want to stick with the default here.</li><li>Main window height: How tall do you want Guake when it is opened?</li><li>Appearance: Text color/font, background color/transparency/image.</li><li>Various keyboard shortcuts</li></ul><p>By default Guake is not set to start up on login. One of the surprises that always catches me with Guake is you can not set this through the properties window. Instead you will have to set this through the GNOME Start up Applications tool. Access this by clicking <strong>System &gt; Preferences &gt; Startup Applications.</strong> When this window is open scroll down until you find the Guake entry, click the Guake checkbox, and click Close. Now Guake will start up when you log in.</p><p><strong>Usage</strong></p><div
id="attachment_26888" class="wp-caption alignleft" style="width: 310px"><a
href="http://www.ghacks.net/wp-content/uploads/2010/06/guake_open.png"><img
class="size-medium wp-image-26888 " src="http://www.ghacks.net/wp-content/uploads/2010/06/guake_open-500x281.png" alt="" width="300" height="169" /></a><p
class="wp-caption-text">Figure 3</p></div><p>To use Guake you simply click the keyboard shortcut configured in the Preferences window. By default that key is F12.  When you click the Open key Guake will drop down for you to use. Figure 3 shows Guake in action, running the top command. By default Guake will remain above all other windows until you dismiss it (by clicking the same key you did to open it).</p><p>You can use Guake as you would a normal terminal window. And, like most good modern terminals, you can have multiple tabs open. To open a new tab in Guake, by default, you higt &lt;Ctrl&gt;&lt;Shift&gt;t.</p><p>If you want to know other handy keyboard shortcuts, go back to the Preferences window and look at the Keyboard shortcuts tab.</p><p><strong>Final thoughts</strong></p><p>If you frequently use the command line, you will very much be glad you have found Guake. With a terminal window so accessible, your work will be that much more efficient. And we all know efficiency is a key factor in every day computing (at least for many of us).</p> ]]></content:encoded> <wfw:commentRss>http://www.ghacks.net/2010/06/21/guake-hide-able-terminal-goodness/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Get to know Linux: shutdown, reboot, startx</title><link>http://www.ghacks.net/2010/03/13/get-to-know-linux-shutdown-reboot-startx/</link> <comments>http://www.ghacks.net/2010/03/13/get-to-know-linux-shutdown-reboot-startx/#comments</comments> <pubDate>Sat, 13 Mar 2010 18:15:45 +0000</pubDate> <dc:creator>Jack Wallen</dc:creator> <category><![CDATA[Advice]]></category> <category><![CDATA[Desktop Manager]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Open Source]]></category> <category><![CDATA[Tutorials Basic]]></category> <category><![CDATA[linux command line]]></category> <category><![CDATA[reboot linux machine]]></category> <category><![CDATA[shutdown linux]]></category> <category><![CDATA[start linux desktop]]></category> <category><![CDATA[startx]]></category> <guid
isPermaLink="false">http://www.ghacks.net/?p=23669</guid> <description><![CDATA[If you use Linux long enough you are going to come face to face with a situation where you are in a GUI-less log in and you&#8217;re either going to know what to do or you are not.  If you don&#8217;t know what to do, you will find yourself in a bit of a bind. [...]]]></description> <content:encoded><![CDATA[<p>If you use Linux long enough you are going to come face to face with a situation where you are in a GUI-less log in and you&#8217;re either going to know what to do or you are not.  If you don&#8217;t know what to do, you will find yourself in a bit of a bind. You might find yourself face-to-face with a GUI-less server or have to reboot a machine remotely. With not GUI &#8211; how will you manage?</p><p>Simple. You use the commands that have been around since the early days of Linux: <em>shutdown, reboot, and startx. </em>In this article I will introduce you to these commands so you will have a solid understanding of how they are used.  And hopefully the <em>shutdown</em> and <em>reboot </em>commands will rarely (if ever) be used.</p><p><span
id="more-23669"></span><strong>Startx</strong></p><p>Let&#8217;s begin with the <em>startx </em>command. This command is rarely used now, because most all distributions boot into graphical mode. But there are occasions where you will want to have a GUI-enabled machine stop at console login. And when you do have to get to that GUI running, you need to know <em>startx</em>.</p><p>Generally speaking the use of <em>startx</em> command is simple. After you log in you issue, aptly enough, <em>startx</em>. This command will bring up your GUI. The <em>starx </em>command is actually a &#8220;front end&#8221; for the xinit system and allows a single instance of the X Windows system to start. One neat trick with startx is that you can add an <strong>.xinitrc</strong> file to your <strong>~/</strong> directory to tell startx which desktop environment to run. Say you want to run KDE. For this your <strong>.xinitrc </strong>file would contain the line:</p><p><em>exec startkde</em></p><p>Or, if you wanted to start GNOME, the line would look like:</p><p><em>exec gnome</em></p><p>You can also start just about any window manager in the same way.</p><p><strong>Reboot</strong></p><p>If you have a console-only machine, and you have a need to reboot that machine, the easiest way to do this is to issue the command <em>reboot</em>. Now in some distributions the reboot command is limited to administrator-level users. So you might have to either <em>su </em>to root or use the <em>sudo </em>command in conjunction with <em>reboot</em> in order to successfully reboot your machine.</p><p><strong>Shutdown</strong></p><p>Shutdown is a bit more complicated than reboot.  With shutdown you need to indicate a time when the process is to take place. This, of course, means you can time your shutdowns. But most often the shutdown command will look like:</p><p><em>shutdown -h now</em></p><p>The <em>h </em>option tells shutdown to halt the machine. Shutdown can actually reboot the machine as well (with the use of the <em>r</em> option). Using the <em>now </em>option informs <em>shutdown</em> that the action is to take place immediately. You can also tell <em>shutdown </em>to run the process at a given time. For time you can use either the +m (where m = minutes) or hh:mm (where hh is hour and mm is minutes). So if I wanted to shutdown the machine in an hour I could issue the command:</p><p><em>shutdown -h +60</em></p><p>Or, if I wanted to shutdown the machine at midnight, I could issue the command:</p><p><em>shutdown -h 12:00</em></p><p><strong>Final thoughts</strong></p><p>Although these commands won&#8217;t be used that often, it is wise to have them in your toolkit. You never know when you are going to be faced with the Linux console!</p> ]]></content:encoded> <wfw:commentRss>http://www.ghacks.net/2010/03/13/get-to-know-linux-shutdown-reboot-startx/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Linux Tips: Handy ways to grep</title><link>http://www.ghacks.net/2009/07/09/linux-tips-handy-ways-to-grep/</link> <comments>http://www.ghacks.net/2009/07/09/linux-tips-handy-ways-to-grep/#comments</comments> <pubDate>Wed, 08 Jul 2009 22:11:29 +0000</pubDate> <dc:creator>Jack Wallen</dc:creator> <category><![CDATA[Advice]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Open Source]]></category> <category><![CDATA[Tutorials Basic]]></category> <category><![CDATA[command-line]]></category> <category><![CDATA[grep]]></category> <category><![CDATA[linux command line]]></category> <guid
isPermaLink="false">http://www.ghacks.net/?p=14085</guid> <description><![CDATA[The grep command is one of the handiest Linux commands you will use. The grep utitility was originally writing for UNIX and stands for Global Regular Expression Print. What grep does is search for strings in practically anything you need to search. You can search nearly any type of file, output, logs&#8230;you name it, grep [...]]]></description> <content:encoded><![CDATA[<p>The grep command is one of the handiest Linux commands you will use. The grep utitility was originally writing for UNIX and stands for Global Regular Expression Print. What grep does is search for strings in practically anything you need to search. You can search nearly any type of file, output, logs&#8230;you name it, grep can search it.</p><p>But because grep is so handy, it&#8217;s hard to know where to start. Of course you can use grep in the standard way, but when you can do so much with a command, why not learn some cool tricks. And that&#8217;s what we&#8217;ll do here &#8211; learn how to use grep to really make it useful.</p><p><span
id="more-14085"></span><strong>Basic usage</strong></p><p>Before we get into some fun stuff, we should look at the basic command structure. To use <em>grep</em> in its most basic form you follow this structure:</p><p>grep STRING FILE</p><p>Where STRING is the string of characters you want to search for and FILE is the file you want to search.</p><p>Say, for instance, I want to search the file <strong>test.txt </strong>for the string &#8220;Linux&#8221; (no quotes). I can do this with the command:</p><p><em>grep Linux test.txt</em></p><p>What grep will do is print out (at the prompt) every line in the file that contains the word Linux. But what if you are searching a large configuration file and you need to find the location of a specific option. To do this you can add the &#8220;n&#8221; switch which will print out the line numbers associated with each line. Let&#8217;s look at a different example. Say you need to find out what port Dansguardian listens to. Instead of scrolling through every line of the <strong>/etc/dansguardian/dansguardian.conf</strong> file for the string &#8220;port&#8221; (no quotes), you could issue the command:</p><p>grep -n port /etc/dansguardian/dansguardian.conf</p><p>which would report back something like:</p><p><code>6:# Web Access Denied Reporting (does not affect logging)<br
/> 10:#  1 = report why but not what denied phrase<br
/> 11:#  2 = report fully<br
/> 14:reportinglevel = 3<br
/> 17:# The HTML template within this dir is only used when reportinglevel<br
/> 87:# the port that DansGuardian listens to.<br
/> 88:filterport = 8080<br
/> 93:# the port DansGuardian connects to proxy on<br
/> 94:proxyport = 3128<br
/> 97:# dansguardian reporting script was copied. Only used in reporting levels 1 and 2.<br
/> 153:# the naughtyness limit will be log</code></p><p>So you can see that line 88 is the filter port and 94 is the proxy port. Easy. Now let&#8217;s see what else grep can do.</p><p><strong>Lines before and after</strong></p><p>What if you not only want to see the single line associated with a string, but also a certain amount of lines above and below that line. You can do this using the -A and -B switches like so (we&#8217;ll stick with our dansguardian example):</p><p><em>grep -B1 -A2 -n port dansguardian.conf</em></p><p>The above command would print out not only each line containing the string &#8220;port&#8221; (no quotes) but also the 1 line above it and the next two lines below it.</p><p><strong>Pipe other commands</strong></p><p>You remember the <em>dmesg </em>command. This command prints out the kernel buffer &#8211; it&#8217;s where you learn a lot about your machine. What if you want to check out CPU information in the <em>dmesg </em>output. You can issue the command <em>dmesg | less</em> and scroll around until you find it, or you can issue the command:</p><p><em>dmesg | grep -n CPU</em></p><p>which will print out all the dmesg output that contains the string CPU and the lines numbers associated with each line.</p><p><strong>Search directories</strong></p><p>You can also have <em>grep </em>help you in your search of directories. To do this you would use it in conjunction with, say, the <em>find </em>command. Say you were looking for the configuration file for the nano text editor but you had no idea what it was called or where it was located. You could pipe the output of the <em>find</em> command to <em>grep </em>(as the root or sudo user) like so:</p><p><em>find / | grep nano | less </em></p><p>and you would see among the output:</p><p>/etc/nanorc<br
/> Bingo! There&#8217;s your configuration file.</p><p><strong>Final thoughts</strong></p><p>As you can see there are a number of ways that the <em>grep</em> command can be of assistance. And this is only scratching the surface. Do you have a nifty way to use <em>grep</em>? If so, share it with your fellow ghacks members.</p> ]]></content:encoded> <wfw:commentRss>http://www.ghacks.net/2009/07/09/linux-tips-handy-ways-to-grep/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> </channel> </rss>
