<?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>DuCommand &#8211; CPYNET</title>
	<atom:link href="https://cpynet.com/tag/ducommand/feed/" rel="self" type="application/rss+xml" />
	<link>https://cpynet.com</link>
	<description>NextGen Tech Hub</description>
	<lastBuildDate>Fri, 22 Nov 2024 08:00:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://cpynet.com/wp-content/uploads/2024/11/cropped-favicon-2-32x32.png</url>
	<title>DuCommand &#8211; CPYNET</title>
	<link>https://cpynet.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Monitoring Linux Server Performance: Top, du, and netstat Explained</title>
		<link>https://cpynet.com/monitoring-linux-server-performance-top-du-and-netstat-explained/</link>
		
		<dc:creator><![CDATA[Emin Buyuk]]></dc:creator>
		<pubDate>Fri, 22 Nov 2024 08:00:14 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[DuCommand]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[NetstatCommand]]></category>
		<category><![CDATA[SystemMonitoring]]></category>
		<category><![CDATA[TopCommand]]></category>
		<guid isPermaLink="false">https://cpynet.com/?p=3999</guid>

					<description><![CDATA[When managing a Linux server, monitoring system resources such as CPU usage, memory consumption, disk space, and network&#8230;]]></description>
										<content:encoded><![CDATA[
<p>When managing a Linux server, monitoring system resources such as CPU usage, memory consumption, disk space, and network activity is crucial for optimal performance and security. Three essential Linux commands that help server administrators track these resources are <code>top</code>, <code>du</code>, and <code>netstat</code>. These commands provide real-time information on how the system is performing, and they are invaluable for troubleshooting and performance tuning.</p>



<p>In this comprehensive guide, we will explore these three key commands in detail, providing both basic and advanced usage examples. By the end of this tutorial, you will understand how to effectively monitor your server&#8217;s resources on Ubuntu 20.04, although the concepts can be applied to any Linux distribution.</p>



<h3 class="wp-block-heading">Table of Contents:</h3>



<ol class="wp-block-list">
<li>Prerequisites</li>



<li>Updating the System</li>



<li>Using the <code>top</code> Command: Process Management and Performance Monitoring</li>



<li>Using the <code>du</code> Command: Disk Usage Analysis</li>



<li>Using the <code>netstat</code> Command: Network Connections and Statistics</li>



<li>Conclusion</li>
</ol>



<h3 class="wp-block-heading">1. Prerequisites</h3>



<p>Before diving into the command usage, ensure that you have the following prerequisites:</p>



<ul class="wp-block-list">
<li><strong>Server:</strong> A server running Ubuntu 20.04 (the commands also work on other Linux distributions).</li>



<li><strong>User Permissions:</strong> You need either root access or sudo privileges to execute certain commands.</li>
</ul>



<p>For simplicity, we will assume you have a fresh Ubuntu 20.04 server setup for this guide. If you&#8217;re using a different version or Linux distribution, the process remains largely the same.</p>



<h3 class="wp-block-heading">2. Updating the System</h3>



<p>When you first install Ubuntu, it is always a good idea to ensure that your system is up-to-date. To do this, run the following commands:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="sudo apt update -y &amp;&amp; sudo apt upgrade -y" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #50FA7B">sudo</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">apt</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">update</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">-y</span><span style="color: #F8F8F2"> &amp;&amp; </span><span style="color: #50FA7B">sudo</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">apt</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">upgrade</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">-y</span></span></code></pre></div>



<p>These commands will update your package index and upgrade the installed packages to the latest versions. After updating, you&#8217;re ready to start exploring the resource-monitoring commands.</p>



<h3 class="wp-block-heading">3. Using the <code>top</code> Command: Process Management and Performance Monitoring</h3>



<p>The <code>top</code> command is one of the most commonly used tools for monitoring system performance in real-time. It shows the processes running on the server and provides detailed statistics on CPU usage, memory usage, load averages, and more.</p>



<h4 class="wp-block-heading">Basic Usage</h4>



<p>To run <code>top</code>, simply open your terminal and type:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="top" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #50FA7B">top</span></span></code></pre></div>



<p>You will see a continuously updated list of processes with various statistics, including CPU usage, memory usage, load average, and process IDs. Here&#8217;s an example output:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="top - 11:24:59 up 7 days, 11:27,  2 users,  load average: 0.00, 0.00, 0.00
Tasks: 109 total,   1 running, 108 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.1 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.2 si,  0.0 st
MiB Mem :   3931.4 total,   2473.6 free,    139.8 used,   1318.0 buff/cache
MiB Swap:   1024.0 total,   1024.0 free,      0.0 used.   3475.6 avail Mem" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #50FA7B">top</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">-</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">11</span><span style="color: #F1FA8C">:24:59</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">up</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">7</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">days,</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">11</span><span style="color: #F1FA8C">:27,</span><span style="color: #F8F8F2">  </span><span style="color: #BD93F9">2</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">users,</span><span style="color: #F8F8F2">  </span><span style="color: #F1FA8C">load</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">average:</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">0.00</span><span style="color: #F1FA8C">,</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">0.00</span><span style="color: #F1FA8C">,</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">0.00</span></span>
<span class="line"><span style="color: #50FA7B">Tasks:</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">109</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">total,</span><span style="color: #F8F8F2">   </span><span style="color: #BD93F9">1</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">running,</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">108</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">sleeping,</span><span style="color: #F8F8F2">   </span><span style="color: #BD93F9">0</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">stopped,</span><span style="color: #F8F8F2">   </span><span style="color: #BD93F9">0</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">zombie</span></span>
<span class="line"><span style="color: #50FA7B">%Cpu(s</span><span style="color: #F8F8F2">):  0.0 us,  0.1 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.2 si,  0.0 st</span></span>
<span class="line"><span style="color: #50FA7B">MiB</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">Mem</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">:</span><span style="color: #F8F8F2">   </span><span style="color: #BD93F9">3931.4</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">total,</span><span style="color: #F8F8F2">   </span><span style="color: #BD93F9">2473.6</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">free,</span><span style="color: #F8F8F2">    </span><span style="color: #BD93F9">139.8</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">used,</span><span style="color: #F8F8F2">   </span><span style="color: #BD93F9">1318.0</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">buff/cache</span></span>
<span class="line"><span style="color: #50FA7B">MiB</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">Swap:</span><span style="color: #F8F8F2">   </span><span style="color: #BD93F9">1024.0</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">total,</span><span style="color: #F8F8F2">   </span><span style="color: #BD93F9">1024.0</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">free,</span><span style="color: #F8F8F2">      </span><span style="color: #BD93F9">0.0</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">used.</span><span style="color: #F8F8F2">   </span><span style="color: #BD93F9">3475.6</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">avail</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">Mem</span></span></code></pre></div>



<h4 class="wp-block-heading">Explanation of Output</h4>



<ul class="wp-block-list">
<li><strong>Load Average:</strong> Shows the system load for the past 1, 5, and 15 minutes.</li>



<li><strong>CPU Usage:</strong> Displays the CPU time percentage for user processes, system processes, idle time, etc.</li>



<li><strong>Memory Usage:</strong> Shows the total, free, and used memory, including buffer and cache memory.</li>



<li><strong>Swap Usage:</strong> Indicates swap space usage.</li>
</ul>



<h4 class="wp-block-heading">Advanced Usage</h4>



<p>The <code>top</code> command has several options that can be used to refine the output and focus on specific aspects of system performance.</p>



<ul class="wp-block-list">
<li><strong>-i:</strong> Ignore idle processes (only show active processes).</li>



<li><strong>-n [number]:</strong> Repeat the command for a specified number of updates.</li>



<li><strong>-H:</strong> Display threads of processes, rather than just the processes themselves.</li>
</ul>



<p>For example, to run <code>top</code> and update the display five times before exiting, you would use:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="top -n 5" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #50FA7B">top</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">-n</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">5</span></span></code></pre></div>



<h3 class="wp-block-heading">4. Using the <code>du</code> Command: Disk Usage Analysis</h3>



<p>The <code>du</code> (disk usage) command is used to check the amount of disk space used by files and directories. It’s especially useful for identifying which directories and files are consuming the most disk space.</p>



<h4 class="wp-block-heading">Basic Usage</h4>



<p>To see the disk usage of all files and directories in the root (<code>/</code>) directory, use:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="du -sh /*" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #50FA7B">du</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">-sh</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">/</span><span style="color: #BD93F9; font-style: italic">*</span></span></code></pre></div>



<p>The <code>-s</code> flag summarizes the total usage of each directory, and the <code>-h</code> flag provides human-readable output (e.g., KB, MB, GB). The output might look something like this:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="7       bin
301M    boot
12K     dev
3.0M    etc
2.4G    usr
710M    var" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #50FA7B">7</span><span style="color: #F8F8F2">       </span><span style="color: #F1FA8C">bin</span></span>
<span class="line"><span style="color: #50FA7B">301M</span><span style="color: #F8F8F2">    </span><span style="color: #F1FA8C">boot</span></span>
<span class="line"><span style="color: #50FA7B">12K</span><span style="color: #F8F8F2">     </span><span style="color: #F1FA8C">dev</span></span>
<span class="line"><span style="color: #50FA7B">3.0M</span><span style="color: #F8F8F2">    </span><span style="color: #F1FA8C">etc</span></span>
<span class="line"><span style="color: #50FA7B">2.4G</span><span style="color: #F8F8F2">    </span><span style="color: #F1FA8C">usr</span></span>
<span class="line"><span style="color: #50FA7B">710M</span><span style="color: #F8F8F2">    </span><span style="color: #F1FA8C">var</span></span></code></pre></div>



<h4 class="wp-block-heading">Advanced Usage</h4>



<p>The <code>du</code> command also supports a variety of options that allow you to analyze disk usage more effectively:</p>



<ul class="wp-block-list">
<li><strong>-d [depth]:</strong> Limits the depth of the directory tree displayed.</li>



<li><strong>&#8211;max-depth=1:</strong> Only shows the total usage of directories at the specified level.</li>
</ul>



<p>For instance, to check disk usage in the <code>/var</code> directory and its immediate subdirectories, use:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="du -d 1 /var" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #50FA7B">du</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">-d</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">1</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">/var</span></span></code></pre></div>



<p>This will list the sizes of the directories under <code>/var</code> without displaying their contents recursively.</p>



<h3 class="wp-block-heading">5. Using the <code>netstat</code> Command: Network Connections and Statistics</h3>



<p>The <code>netstat</code> command is used to display network connections, routing tables, and other network-related information. It&#8217;s crucial for monitoring active network connections and diagnosing networking issues.</p>



<h4 class="wp-block-heading">Basic Usage</h4>



<p>To see active network connections and the associated status, simply type:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="netstat" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #50FA7B">netstat</span></span></code></pre></div>



<p>You’ll see a list of connections and listening ports, along with information about the protocol (TCP/UDP), local and foreign addresses, and the state of the connection.</p>



<p>Example output:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0    240 24625403.test:7022      ctel-78-157-7-19.:55913  ESTABLISHED" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #50FA7B">Proto</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">Recv-Q</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">Send-Q</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">Local</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">Address</span><span style="color: #F8F8F2">           </span><span style="color: #F1FA8C">Foreign</span><span style="color: #F8F8F2"> </span><span style="color: #F1FA8C">Address</span><span style="color: #F8F8F2">         </span><span style="color: #F1FA8C">State</span></span>
<span class="line"><span style="color: #50FA7B">tcp</span><span style="color: #F8F8F2">        </span><span style="color: #BD93F9">0</span><span style="color: #F8F8F2">    </span><span style="color: #BD93F9">240</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">24625403</span><span style="color: #F1FA8C">.test:7022</span><span style="color: #F8F8F2">      </span><span style="color: #F1FA8C">ctel-78-157-7-19.:55913</span><span style="color: #F8F8F2">  </span><span style="color: #F1FA8C">ESTABLISHED</span></span></code></pre></div>



<h4 class="wp-block-heading">Advanced Usage</h4>



<p><code>netstat</code> offers a variety of options to filter and refine the output:</p>



<ul class="wp-block-list">
<li><strong>-t:</strong> Show only TCP connections.</li>



<li><strong>-u:</strong> Show only UDP connections.</li>



<li><strong>-n:</strong> Show numerical addresses (instead of resolving hostnames).</li>



<li><strong>-l:</strong> Display only listening sockets (ports waiting for connections).</li>



<li><strong>-p:</strong> Show the process ID (PID) that owns each connection.</li>
</ul>



<p>For example, to list all TCP and UDP connections, including listening ports and process information, use:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="netstat -tunlp" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #50FA7B">netstat</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">-tunlp</span></span></code></pre></div>



<p>This command will show active connections and the associated process IDs, which is useful for diagnosing which applications are using which ports.</p>



<h3 class="wp-block-heading">Conclusion</h3>



<p>In this guide, we explored three essential Linux commands for monitoring server resources: <code>top</code>, <code>du</code>, and <code>netstat</code>. Each command serves a unique purpose—<code>top</code> for process and performance monitoring, <code>du</code> for disk usage analysis, and <code>netstat</code> for network connections and statistics.</p>



<p>By mastering these commands, you can ensure your server is running smoothly, optimize resource usage, and quickly diagnose performance or network issues. Additionally, we covered both basic and advanced usages of these commands, helping you get the most out of each tool.</p>



<p>Whether you&#8217;re managing a web server, a database server, or any other type of system, these commands will provide you with the insights needed to maintain optimal performance.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
