<?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/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>Micah Elliott &#187; cli</title>
	<atom:link href="http://micahelliott.com/tag/cli/feed/" rel="self" type="application/rss+xml" />
	<link>http://micahelliott.com</link>
	<description>Stories from my Startup Journey</description>
	<lastBuildDate>Mon, 29 Nov 2010 07:46:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
<image>
  <link>http://micahelliott.com</link>
  <url>http://micahelliott.com/mde-gravatar7.png</url>
  <title>Micah Elliott</title>
</image>
	<!-- podcast_generator="podPress/8.8" - maintenance_release="8.8.6.3" -->
	<copyright>Copyright &#38;#xA9; Micah Elliott 2010 </copyright>
	<managingEditor>mde@micahelliott.com (Micah Elliott)</managingEditor>
	<webMaster>mde@micahelliott.com (Micah Elliott)</webMaster>
	<category>posts</category>
	<image>
		<url>http://micahelliott.com/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
		<title>Micah Elliott &#187; cli</title>
		<link>http://micahelliott.com</link>
		<width>144</width>
		<height>144</height>
	</image>
	<itunes:subtitle></itunes:subtitle>
	<itunes:summary>Stories from my Startup Journey</itunes:summary>
	<itunes:keywords></itunes:keywords>
	<itunes:category text="Society &amp; Culture" />
	<itunes:author>Micah Elliott</itunes:author>
	<itunes:owner>
		<itunes:name>Micah Elliott</itunes:name>
		<itunes:email>mde@micahelliott.com</itunes:email>
	</itunes:owner>
	<itunes:block>no</itunes:block>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://micahelliott.com/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<item>
		<title>Get On Top</title>
		<link>http://micahelliott.com/2008/06/get-on-top/</link>
		<comments>http://micahelliott.com/2008/06/get-on-top/#comments</comments>
		<pubDate>Sun, 15 Jun 2008 13:00:00 +0000</pubDate>
		<dc:creator>Micah</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.micahelliott.com/?p=53</guid>
		<description><![CDATA[I&#8217;ve used top for years to monitor machine activity. It&#8217;s grown some new features and behavior in the last few years that you might not be aware of. Good ol&#8217; top. For years it&#8217;s been the cornerstone of process control. It&#8217;s the first place we turn to hunt down a rogue process, or just to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://bp2.blogger.com/_DzStaE_3-vk/SFKWN83TVXI/AAAAAAAAAC4/Pt_4o4IBm3I/s1600-h/top.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5211392885241632114" style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp2.blogger.com/_DzStaE_3-vk/SFKWN83TVXI/AAAAAAAAAC4/Pt_4o4IBm3I/s200/top.jpg" border="0" alt="" /></a><span style="font-style: italic;">I&#8217;ve used <span style="font-family:courier new;">top</span> for years to monitor machine activity.  It&#8217;s grown some new features and behavior in the last few years that you might not be aware of.</span></p>
<p>Good ol&#8217; <span style="font-family:courier new;">top</span>.  For years it&#8217;s been the cornerstone of process control.  It&#8217;s the first place we turn to hunt down a rogue process, or just to watch how resources are consumed.  Sure, you could use a handful of GUI tools, but <span style="font-weight: bold;">I frequently find myself working strictly in a terminal on remote machines, where </span><span style="font-weight: bold;font-family:courier new;">top</span><span style="font-weight: bold;"> is indispensable</span>.  This is a short overview of <span style="font-family:courier new;">top</span>&#8216;s most important features that weren&#8217;t obvious to me until I got to practicing for the <a href="http://www.lpi.org/">LPI exam</a> a short while back.  Now I&#8217;m making use of them quite regularly.  To save you from wading through the 1,000-line manpage, <span style="font-weight: bold;">here are the most useful interactive commands</span> (you don&#8217;t have to worry about the CLI options).</p>
<p><span id="more-53"></span></p>
<ul>
<li><span style="font-weight: bold;">z</span> &#8212; Turn on color.  Beautiful!  Don&#8217;t change them unless you&#8217;re looking to waste a lot of time</li>
<li><span style="font-weight: bold;font-family:courier new;">s</span> &#8212; This is the refresh interval.  The default of 3 seconds can leave you puzzled.  I like to set it to one or half a second.   An alternative is to just press  a bunch of times whenever you want to see an update.</li>
<li><span style="font-weight: bold;font-family:courier new;">1</span> &#8212; Change the number of processors shown.  Though not a default, this is critical now that every machine we get on has 2 to 16 procs.</li>
<li><span style="font-weight: bold;font-family:courier new;">H</span> &#8212; Show threads.  Try looking at Apache with and without this.</li>
<li><span style="font-weight: bold;font-family:courier new;">i</span> &#8212; Ignore idle processes.  This helps you focus only on what&#8217;s really active; and makes everything fit on the screen.</li>
<li><span style="font-weight: bold;font-family:courier new;">O</span><span style="font-weight: bold;"> </span>&#8211; Order by some field.  The most useful sub-selections here are <span style="font-family:courier new;">q</span> (resident memory), <span style="font-family:courier new;">k</span> (%cpu), and <span style="font-family:courier new;">a</span> (pid).  Setting this helps keep your list from bouncing its order all around.</li>
<li><span style="font-weight: bold;font-family:courier new;">c</span> &#8212; Show whole command.  Essential when you&#8217;ve got multiples of a similar command running.</li>
<li><span style="font-weight: bold;font-family:courier new;">u</span> &#8212; Only show what&#8217;s happening with a single user.  That&#8217;s often <span style="font-family:courier new;">$USER</span> (you!), or some other <span style="font-style: italic;">luser</span>.</li>
<li><span style="font-weight: bold;font-family:courier new;">k</span> &#8212; Kill a process with signal of your choosing.  <span style="font-style: italic;">(Bonus: look into <span style="font-family:courier new;">pgrep</span>/<span style="font-family:courier new;">pkill</span>.)</span></li>
<li><span style="font-weight: bold;font-family:courier new;">?</span> &#8212;  Show the built-in help screen.</li>
<li><span style="font-weight: bold;font-family:courier new;">^g</span> &#8212; Escape out of any menu screen.</li>
</ul>
<p>You could have seen most of this on the built-in help screen by simply pressing <span style="font-family:courier new;">h</span> or <span style="font-family:courier new;">?</span>.  But that menu has a pretty unintuitive layout, and the above is limited to the minimal set you really need.  Now that you understand how everything works, and you&#8217;ve got it looking nice, just press <span style="font-family:courier new;">W</span> to write the configuration for permanent use.  If you&#8217;re unhappy with the damage you just caused, just blow it away with: <span style="font-family:courier new;">rm ~/.toprc</span></p>
<p><span style="font-style: italic;">BONUS:</span> You may have surprisingly seen &#8220;windows&#8221; in your <span style="font-family:courier new;">top</span> session, depending on what distro you get onto (maybe it was a Fedora?); that&#8217;s how I discovered them.  Press <span style="font-family:courier new;">h</span> twice to get to the windows menu.  I won&#8217;t get into all those details here &#8212; I don&#8217;t find the windows terribly useful, though they do appear to offer some sophisticated views.  If you decide to use them, you can get started by pressing <span style="font-family:courier new;">A</span>, and then <span style="font-family:courier new;">a</span> continuously to cycle through displays.  See if you can make sense of them, and then talk to me. <img src='http://micahelliott.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><span style="font-style: italic;">CAVEATS:</span> Be careful not to run top with a fast refresh during any sort of benchmarking.  It can chew up a bit of CPU time.  Also, <span style="font-family:courier new;">top</span> versions vary widely depending on the distro you use; you might notice some different behavior than what I&#8217;ve described.<br />
<span style="font-style: italic;">(This list also makes for a great sticky, as you see in the picture.)</span></p>
<p><span style="font-weight: bold;font-family:courier new;">top</span><span style="font-weight: bold;"> is a powerful tool that gives you a lot of information.</span> If you got this far, you should now be able to make sense of most of the cryptic display, and be able to find your way around configuring it.</p>
]]></content:encoded>
			<wfw:commentRss>http://micahelliott.com/2008/06/get-on-top/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

