TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Htop explained

716 pointsby p8donaldover 8 years ago

28 comments

guessmynameover 8 years ago
I switched to macOS from Linux two weeks ago and I am starting to regret that decision. Most — if not all — the commands that I thought I had mastered after years working on Linux environments stopped working because their BSD counterparts have slightly differences that completely break everything I try to do. It is even more frustrating when I realize that I have to deactivate security features built-in the new Apple computers in order to make things like "dtrace" (the strace alternative) work.
评论 #13089413 未加载
评论 #13089359 未加载
评论 #13090042 未加载
评论 #13089704 未加载
评论 #13089381 未加载
评论 #13089364 未加载
评论 #13091155 未加载
评论 #13091281 未加载
评论 #13093248 未加载
评论 #13093753 未加载
评论 #13089834 未加载
评论 #13093542 未加载
camtarnover 8 years ago
&quot;[explanation of acpid] But I&#x27;m on a virtual server that I don&#x27;t intend to suspend&#x2F;resume. I am going to remove it for fun and see what happens. ... I was able to successfully reboot the droplet but after halt Digital Ocean thought it was still on so I had to Power Off using the web interface. So I should probably keep this.&quot;<p>Science! :D<p>I love the approach of systematically going through and prodding everything to see what things do and whether they&#x27;re actually required. I remember doing this on my Windows 95 machine, stripping down running tasks using Task Manager. Of course, in Windows 95, if you killed the wrong task the system would just reboot... :P
评论 #13092638 未加载
评论 #13090680 未加载
baldfatover 8 years ago
htop is one of the most missed tools when I am on a non-Linux OS.<p>On servers I find atop to actually be a better tool for finding issues that happen incrementally and not an obvious issue. I think that atop and htop both are very complimentary.<p><a href="http:&#x2F;&#x2F;www.atoptool.nl&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.atoptool.nl&#x2F;</a><p>&quot;Atop is an ASCII full-screen performance monitor for Linux that is capable of reporting the activity of all processes (even if processes have finished during the interval), daily logging of system and process activity for long-term analysis, highlighting overloaded system resources by using colors, etc. At regular intervals, it shows system-level activity related to the CPU, memory, swap, disks (including LVM) and network layers, and for every process (and thread) it shows e.g. the CPU utilization, memory growth, disk utilization, priority, username, state, and exit code. In combination with the optional kernel module netatop, it even shows network activity per process&#x2F;thread.&quot;
评论 #13088936 未加载
makkesover 8 years ago
&gt; The second number is how much of that time the machine has spent idle, in seconds<p>Actually, the second number is the sum of the number of seconds that all cores on the machine have spent idle, so that number may be higher than the first one. Source: <a href="https:&#x2F;&#x2F;access.redhat.com&#x2F;documentation&#x2F;en-US&#x2F;Red_Hat_Enterprise_Linux&#x2F;6&#x2F;html&#x2F;Deployment_Guide&#x2F;s2-proc-uptime.html" rel="nofollow">https:&#x2F;&#x2F;access.redhat.com&#x2F;documentation&#x2F;en-US&#x2F;Red_Hat_Enterp...</a>
评论 #13089169 未加载
j_sover 8 years ago
Slightly related utility I discovered to my great delight today: ncdu - &quot;htop for disk space usage&quot;<p><a href="https:&#x2F;&#x2F;dev.yorhel.nl&#x2F;ncdu" rel="nofollow">https:&#x2F;&#x2F;dev.yorhel.nl&#x2F;ncdu</a>
评论 #13091169 未加载
评论 #13091049 未加载
Waterluvianover 8 years ago
I LOVE this style of documentation&#x2F;teaching.<p>What is it? How does it know that? How did I figure that out?<p>The second and third question are far more useful but usually not included in documentation or commentary.
TeMPOraLover 8 years ago
Thank you! Great writeup!<p>I applaud the way you approached it - figuring out every single thing about a tool.<p>Also, I didn&#x27;t know about &#x27;od&#x27; command. Thanks again!
评论 #13089581 未加载
idsoutover 8 years ago
You swapped the child and parent in the printf statements here <a href="https:&#x2F;&#x2F;peteris.rocks&#x2F;blog&#x2F;htop&#x2F;#z-defunct-zombie-process-terminated-but-not-reaped-by-its-parent" rel="nofollow">https:&#x2F;&#x2F;peteris.rocks&#x2F;blog&#x2F;htop&#x2F;#z-defunct-zombie-process-te...</a>.<p><pre><code> printf(&quot;The parent process is exiting now\n&quot;);</code></pre> This should read child is exiting.<p><pre><code> printf(&quot;The child process is sleeping now\n&quot;);</code></pre> This should read parent is sleeping.<p>Overall, I really enjoyed the article.
评论 #13092685 未加载
camtarnover 8 years ago
&quot;You&#x27;ll probably want to keep cron. But if you don&#x27;t, then you should stop and disable the service. Because otherwise when trying to remove it with apt remove cron it will try to install postfix!&quot;<p>...wat?<p>Is that actually a thing?
评论 #13089878 未加载
nodesocketover 8 years ago
Wow so much unix and shell goodness in this post.<p>Useful bits&#x2F;tricks to me:<p><pre><code> # see what files a given program opens strace PROGRAM_HERE 2&gt;&amp;1 | grep open # get last pid echo $! # all sorts of useful commands and information on a given PID ls -alh &#x2F;proc&#x2F;PID_HERE # get a tree listing of all processes pstree -a # echo into a file using sudo echo &quot;some text here&quot; | sudo tee -a FILE_PATH_HERE</code></pre>
CoolGuySteveover 8 years ago
Is there a resource out there on how to write these beautiful terminal HUDs?<p>I&#x27;d really like to step up my game for GUI monitoring apps without having to choose between either terminal log spam, PyQT, or a web server. Ideally I&#x27;d have something like htop&#x2F;wavemon&#x2F;power top that I could stream compactly via ssh.
评论 #13090171 未加载
评论 #13090136 未加载
评论 #13092109 未加载
azinman2over 8 years ago
Can every technical article be written this well and using this way? It&#x27;s a far more interesting read than the title suggests...
arca_voragoover 8 years ago
I love htop and use it daily on desktops and servers, but I admit I didn&#x27;t know half these things. Great practical writeup!
piotrjurkiewiczover 8 years ago
Well, his &#x27;Extreme edition&#x27; is actually not so extreme. This is how Debian base installation looks like.<p>A server can perfectly run without dbus, accountsservice, logind, policykit and acpid. And, unlike he wrote, timesyncd NTP synchronization works well without dbus.<p>(Debian base has also cron and rsyslog running by default, for legacy reasons.)
AceJohnny2over 8 years ago
&gt; <i>It turns out that id gets this information from the &#x2F;etc&#x2F;passwd and &#x2F;etc&#x2F;group files.</i><p><pre><code> $ strace -e open id 1000 open(&quot;&#x2F;etc&#x2F;passwd&quot;, O_RDONLY|O_CLOEXEC) = 3 open(&quot;&#x2F;etc&#x2F;group&quot;, O_RDONLY|O_CLOEXEC) = 3 </code></pre> Well, by default yes. But if your system is configured to use NIS&#x2F;YP or LDAP (through NSS&#x2F;Name Service Switch), then these files won&#x27;t have all the information (though they&#x27;ll likely have a few, it&#x27;s important to have local fallbacks in case of network issues!)<p>A more generic tool is &#x27;getent&#x27;, which will query all the underlying databases for you. For example: &quot;getent passwd&quot; or &quot;getent group&quot;.<p>Nevertheless, using strace to get a first approximation is an excellent exercise :)
评论 #13094260 未加载
Debonnysover 8 years ago
&gt; If I had two cores, my CPU usage would be 50% since my computer can run two processes at the same time. The load average of a computer with 2 cores that has a 100% CPU usage would be 2.00.<p>If I recall correctly the CPU usage would still be 100% but could go up to 200% if both cores are fully used.
评论 #13089601 未加载
ameliusover 8 years ago
Nice explanation, but too much to remember in practice.<p>If only the UI had something like hover-tips to show what each field actually means...
syrrimover 8 years ago
kill as a shell built-in also allows you to pass it job numbers rather than PIDs. For example, kill -9 %1 would kill the first process you sent into the background, either with &amp; or ^Z
creebleover 8 years ago
I like the investigation into various cruft that Ubuntu installs (and runs) that can safely be turned off.<p>Goodbye polkit!
评论 #13090542 未加载
mxuribeover 8 years ago
This is fantastic write up! I&#x27;ve bookmarked this one for future reference. Kudos to the author!
dorfsmayover 8 years ago
I tend to use &quot;atop&quot; because it gives me a better overall picture of my system. But, there is something really cool about &quot;htoo&quot; that many users don&#x27;t realise and that I hadn&#x27;t realised until somebody pointed it to me recently:<p>You can use your mouse&#x2F;TrackPoint in htop to click on menu options, processes etc...
评论 #13089898 未加载
eyeinskyover 8 years ago
Beware -- not only about htop :)
eltoozeroover 8 years ago
Love this post, first function explanation for &#x27;uptime&#x27; module gives a concise &#x27;strace&#x27; demo showing how to determine the files the standard &#x27;uptime&#x27; binary opens.<p>Really excellent example of showing your work!
234dd57d2c8dbover 8 years ago
If you have python available, I find `glances` to be a great tool (`pip install glances`)<p>Has disk, network, proc, mem, cpu, etc. all wrapped up in a a curses interface. very slick and useful.
zythonover 8 years ago
love it, good overview over all functionalities of htop and easy to follow<p>Good job.
brokenmachineover 8 years ago
Wow, that was very interesting and much more information about how Linux works in a general sense than I would have expected a discussion on htop to contain!
vram22over 8 years ago
lsof (LiSt Open Files), which used to be a third-party tool and needed to be install on Unixes, may be built-in by now in some, and fuser (built-in, usually) are also useful tools for investigating processes and files that they open (including sockets), and so on. lsof was written by someone at HP, IIRC. Has a big list of command-line options. Possibly some of the other tools mentioned in this thread call lsof internally.
sabujpover 8 years ago
this has nothing to do with htop, it might as well have been top explained, man ps for crying out loud.