Skip to content

Commit 69ce0f2

Browse files
committed
🤖 Auto-update eBook files and GitHub Pages [skip ci]
1 parent 8236063 commit 69ce0f2

File tree

7 files changed

+654
-46
lines changed

7 files changed

+654
-46
lines changed
16.6 KB
Binary file not shown.
16.7 KB
Binary file not shown.
3.83 KB
Binary file not shown.

ebook/en/export/101-linux-commands.html

Lines changed: 327 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4277,30 +4277,133 @@ <h3>Additional Flags and their Functionalities:</h3>
42774277
</tbody>
42784278
</table>
42794279
<div style="page-break-after: always;"></div><h1>The <code>ps</code> command</h1>
4280-
<p>The <code>ps</code> command is used to identify programs and processes that are running on the system and the resources they are using.
4281-
Its frequently <a href="https://en.wikipedia.org/wiki/Pipeline_(Unix)">pipelined</a> with other commands like <code>grep</code> to search for a program/process or <code>less</code>
4282-
so that the user can analyze the output one page at a time.</p>
4283-
<p>Let's say you have a program like openshot which is notorious for hogging system resources when exporting a video, and you want to close it, but the GUI has become unresponsive.</p>
4284-
<h3>Example</h3>
4285-
<ol>
4286-
<li>You want to find the PID of openshot and kill it.</li>
4287-
</ol>
4288-
<pre><code class="language-xml hljs xml" data-lang="xml">ps aux | grep openshot
4289-
kill - <span class="hljs-tag">&lt;<span class="hljs-name">openshot</span> <span class="hljs-attr">PID</span>&gt;</span>
4280+
<p>The <code>ps</code> command (process status) is used to display information about running processes on a Linux system — such as their PID, memory usage, CPU time, and associated users.</p>
4281+
<p>It’s often <strong>piped</strong> with commands like <code>grep</code> to search for a specific process or <code>less</code> to scroll through large outputs.</p>
4282+
<h2>Why Use <code>ps</code></h2>
4283+
<p>Imagine your system feels slow or an app becomes unresponsive — you can use <code>ps</code> to:</p>
4284+
<ul>
4285+
<li>Identify processes consuming high CPU/memory</li>
4286+
<li>Find a program’s PID (Process ID)</li>
4287+
<li>Kill or debug a stuck process</li>
4288+
<li>Check who’s running what on a shared system</li>
4289+
</ul>
4290+
<h2>Basic Syntax</h2>
4291+
<pre><code class="language- hljs " data-lang="">ps [options]
42904292
</code></pre>
4291-
<ol start="2">
4292-
<li>To Show all the running processes:</li>
4293-
</ol>
4294-
<pre><code class="language- hljs " data-lang="">ps -A
4293+
<p>Without any options, <code>ps</code> only shows processes in the current terminal session.</p>
4294+
<p>Example:</p>
4295+
<pre><code class="language-bash hljs bash" data-lang="bash">ps
42954296
</code></pre>
4296-
<h3>Syntax</h3>
4297-
<p><code>ps [options]</code></p>
4298-
<p>When run without any options, it's useless and will print: <code>CMD</code> - the executable processes/(program) running, their <code>PID</code> - process ID, <code>TTY</code> - terminal type and <code>Time</code> - How long the process has utilized the CPU or thread.</p>
4299-
<h3>Common Option</h3>
4300-
<p>If you are going to remember only one thing from this page let it be these three letter <code>aux</code>:
4301-
<code>a</code> - which displays all processes running, including those being run by other users.
4302-
<code>u</code> - which shows the effective user of a process, i.e. the person whose file access permissions are used by the process.
4303-
<code>x</code> - which shows processes that do not have a <code>TTY</code> associated with them.</p>
4297+
<p>Output:</p>
4298+
<pre><code class="language- hljs " data-lang=""> PID TTY TIME CMD
4299+
4587 pts/0 00:00:00 bash
4300+
4621 pts/0 00:00:00 ps
4301+
</code></pre>
4302+
<h2>Essential Usage</h2>
4303+
<p><strong>The one combo to remember:</strong> <code>ps aux</code></p>
4304+
<ul>
4305+
<li><code>a</code> = all processes (all users)</li>
4306+
<li><code>u</code> = show user/owner info</li>
4307+
<li><code>x</code> = include processes without terminals</li>
4308+
</ul>
4309+
<pre><code class="language- hljs " data-lang="">ps aux
4310+
</code></pre>
4311+
<p>Output example:</p>
4312+
<pre><code class="language- hljs " data-lang="">USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
4313+
root 1 0.0 0.1 168208 1100 ? Ss 10:15 0:02 /sbin/init
4314+
myuser 2471 0.5 1.2 431204 24500 ? Sl 10:17 1:05 code
4315+
myuser 2523 2.3 0.7 230940 14860 pts/0 R+ 10:22 0:01 ps aux
4316+
</code></pre>
4317+
<h2>Some More Practical Day to Day Examples</h2>
4318+
<h3>Finding and Killing a process</h3>
4319+
<p>You want to stop a frozen <strong>OpenShot</strong> process.</p>
4320+
<pre><code class="language- hljs " data-lang="">ps aux | grep openshot
4321+
</code></pre>
4322+
<p>Output:</p>
4323+
<pre><code class="language- hljs " data-lang="">myuser 3625 99.9 6.1 1243924 252340 ? Rl 10:30 25:17 openshot
4324+
myuser 3649 0.0 0.0 6348 740 pts/0 S+ 10:31 0:00 grep --color=auto openshot
4325+
</code></pre>
4326+
<p>Now, kill it:</p>
4327+
<pre><code class="language-bash hljs bash" data-lang="bash"><span class="hljs-built_in">kill</span> -9 3625
4328+
</code></pre>
4329+
<h3>Show Processes by User</h3>
4330+
<pre><code class="language-bash hljs bash" data-lang="bash">ps -u username
4331+
</code></pre>
4332+
<p>Output:</p>
4333+
<pre><code class="language- hljs " data-lang=""> PID TTY TIME CMD
4334+
2284 ? 00:00:00 sshd
4335+
2455 ? 00:00:02 bash
4336+
</code></pre>
4337+
<h3>Filtering &amp; Sorting Output</h3>
4338+
<p>Show top 10 memory-consuming processes:</p>
4339+
<pre><code class="language- hljs " data-lang="">ps aux --sort=-%mem | head -10
4340+
</code></pre>
4341+
<p>Show top 10 CPU-consuming processes:</p>
4342+
<pre><code class="language- hljs " data-lang="">ps aux --sort=-%cpu | head -10
4343+
</code></pre>
4344+
<h3>Checking Parent/Child Process Hierarchy</h3>
4345+
<pre><code class="language-bash hljs bash" data-lang="bash">ps -ef --forest
4346+
</code></pre>
4347+
<p>This gives a tree-like structure showing parent-child relationships — useful when debugging service spawns.</p>
4348+
<h3>Custom Output Format</h3>
4349+
<p>To Show only PID, user, memory, and command:</p>
4350+
<pre><code class="language- hljs " data-lang="">ps -eo pid,user,%mem,cmd
4351+
</code></pre>
4352+
<h2>Real-Life DevOps Examples</h2>
4353+
<h3>1. Checking which process uses a specific port</h3>
4354+
<pre><code class="language-javascript hljs javascript" data-lang="javascript">sudo ps -fp $(sudo lsof -t -i:<span class="hljs-number">8080</span>)
4355+
</code></pre>
4356+
<h3>2. Monitoring Jenkins, Nginx, or Docker processes</h3>
4357+
<pre><code class="language- hljs " data-lang="">ps aux | grep nginx
4358+
ps aux | grep jenkins
4359+
ps aux | grep docker
4360+
</code></pre>
4361+
<h3>3. Find Zombie Processes</h3>
4362+
<pre><code class="language-php hljs php" data-lang="php">ps aux | awk <span class="hljs-string">'{ if ($8 == "Z") print $0; }'</span>
4363+
</code></pre>
4364+
<h2>Key Options for Quick Reference</h2>
4365+
<table>
4366+
<thead>
4367+
<tr>
4368+
<th align="left">Option</th>
4369+
<th align="left">Description</th>
4370+
</tr>
4371+
</thead>
4372+
<tbody>
4373+
<tr>
4374+
<td align="left"><code>aux</code></td>
4375+
<td align="left">All processes with detailed info</td>
4376+
</tr>
4377+
<tr>
4378+
<td align="left"><code>-ef</code></td>
4379+
<td align="left">Full listing (alternative to aux)</td>
4380+
</tr>
4381+
<tr>
4382+
<td align="left"><code>-eo format</code></td>
4383+
<td align="left">Custom output columns</td>
4384+
</tr>
4385+
<tr>
4386+
<td align="left"><code>--sort</code></td>
4387+
<td align="left">Sort by column (-%mem, -%cpu)</td>
4388+
</tr>
4389+
<tr>
4390+
<td align="left"><code>-p PID</code></td>
4391+
<td align="left">Show specific PID</td>
4392+
</tr>
4393+
<tr>
4394+
<td align="left"><code>-C name</code></td>
4395+
<td align="left">Show processes by command name</td>
4396+
</tr>
4397+
<tr>
4398+
<td align="left"><code>-u user</code></td>
4399+
<td align="left">Show user's processes</td>
4400+
</tr>
4401+
<tr>
4402+
<td align="left"><code>f</code></td>
4403+
<td align="left">ASCII art process tree</td>
4404+
</tr>
4405+
</tbody>
4406+
</table>
43044407
<h3>Additional Options:</h3>
43054408
<table>
43064409
<thead>
@@ -4356,7 +4459,13 @@ <h3>Additional Options:</h3>
43564459
</tr>
43574460
</tbody>
43584461
</table>
4359-
<p>Another useful command which give a realtime snapshot of the processes and the resources they are using about every ten seconds is <code>top</code>.</p>
4462+
<h2>Related Tools</h2>
4463+
<p>If you need <strong>real-time</strong> monitoring, use:</p>
4464+
<pre><code class="language- hljs " data-lang="">top
4465+
</code></pre>
4466+
<p>or the more user-friendly modern version:</p>
4467+
<pre><code class="language- hljs " data-lang="">htop
4468+
</code></pre>
43604469
<div style="page-break-after: always;"></div><h1>The <code>kill</code> command</h1>
43614470
<p><code>kill</code> command in Linux (located in /bin/kill), is a built-in command which is used to terminate processes manually. The <code>kill</code> command sends a signal to a process which terminates the process. If the user doesn’t specify any signal which is to be sent along with kill command then default <em>TERM</em> signal is sent that terminates the process.</p>
43624471
<p>Signals can be specified in three ways:</p>
@@ -21124,6 +21233,201 @@ <h2>Further Reading</h2>
2112421233
<li><code>man column</code> - manual page for the column command</li>
2112521234
<li><a href="https://www.gnu.org/software/coreutils/">GNU Coreutils</a></li>
2112621235
</ul>
21236+
<div style="page-break-after: always;"></div><h1>The <code>nmtui</code> Command</h1>
21237+
<p>The <strong><code>nmtui</code></strong> (Network Manager Text User Interface) command is a <strong>menu-driven tool</strong> for configuring network connections in Linux.<br />
21238+
It provides a simple, text-based interface to manage network settings such as Wi-Fi, Ethernet, hostname, and more — without using complex command-line options.</p>
21239+
<hr />
21240+
<h3>🔹 What it Does</h3>
21241+
<p><code>nmtui</code> allows you to:</p>
21242+
<ul>
21243+
<li>View and edit <strong>network connections</strong></li>
21244+
<li><strong>Activate or deactivate</strong> interfaces</li>
21245+
<li><strong>Set or change</strong> the system <strong>hostname</strong></li>
21246+
<li>Connect to <strong>Wi-Fi networks</strong></li>
21247+
<li>Manage <strong>IPv4 / IPv6 settings</strong></li>
21248+
</ul>
21249+
<p>It is especially useful on servers or systems <strong>without a graphical desktop environment</strong>.</p>
21250+
<hr />
21251+
<h3>🧠 Syntax</h3>
21252+
<p>nmtui [OPTION]</p>
21253+
<hr />
21254+
<h3>🖥️ Examples</h3>
21255+
<ol>
21256+
<li>
21257+
<p><strong>Open the main menu interface:</strong></p>
21258+
<p>nmtui<br />
21259+
Opens the main TUI (text user interface) window with options to <em>Edit a connection</em>, <em>Activate a connection</em>, or <em>Set system hostname</em>.</p>
21260+
</li>
21261+
<li>
21262+
<p><strong>Directly edit a network connection:</strong></p>
21263+
<p>nmtui edit<br />
21264+
Lets you create, modify, or delete network connections (both Ethernet and Wi-Fi).</p>
21265+
</li>
21266+
<li>
21267+
<p><strong>Directly activate or deactivate connections:</strong></p>
21268+
<p>nmtui connect<br />
21269+
Opens the <em>Activate a connection</em> menu where you can enable or disable network interfaces.</p>
21270+
</li>
21271+
<li>
21272+
<p><strong>Set or change the system hostname:</strong></p>
21273+
<p>nmtui hostname<br />
21274+
Opens a dialog box to set your system’s hostname (used for identification on a network).</p>
21275+
</li>
21276+
<li>
21277+
<p><strong>Connect directly to a specific Wi-Fi network:</strong></p>
21278+
<p>nmtui connect &quot;MyWiFiNetwork&quot;<br />
21279+
Connects to the specified Wi-Fi network if it exists in range.</p>
21280+
</li>
21281+
<li>
21282+
<p><strong>Quit the interface:</strong><br />
21283+
Simply use <strong>Tab → Quit</strong> or press <strong>Esc</strong>.</p>
21284+
</li>
21285+
</ol>
21286+
<hr />
21287+
<h3>🧩 Common Options and Subcommands</h3>
21288+
<table>
21289+
<thead>
21290+
<tr>
21291+
<th align="left"><strong>Command</strong></th>
21292+
<th align="left"><strong>Description</strong></th>
21293+
</tr>
21294+
</thead>
21295+
<tbody>
21296+
<tr>
21297+
<td align="left"><code>nmtui</code></td>
21298+
<td align="left">Launches the interactive main menu</td>
21299+
</tr>
21300+
<tr>
21301+
<td align="left"><code>nmtui edit</code></td>
21302+
<td align="left">Opens the “Edit a connection” screen</td>
21303+
</tr>
21304+
<tr>
21305+
<td align="left"><code>nmtui connect</code></td>
21306+
<td align="left">Opens the “Activate a connection” screen</td>
21307+
</tr>
21308+
<tr>
21309+
<td align="left"><code>nmtui hostname</code></td>
21310+
<td align="left">Opens the “Set system hostname” dialog</td>
21311+
</tr>
21312+
<tr>
21313+
<td align="left"><code>nmtui connect &lt;SSID&gt;</code></td>
21314+
<td align="left">Connects to a specific Wi-Fi network directly</td>
21315+
</tr>
21316+
<tr>
21317+
<td align="left"><code>nmtui help</code></td>
21318+
<td align="left">Displays basic usage help</td>
21319+
</tr>
21320+
</tbody>
21321+
</table>
21322+
<hr />
21323+
<h3>⚙️ Interface Navigation</h3>
21324+
<ul>
21325+
<li>Use the <strong>arrow keys</strong> or <strong>Tab</strong> to move between fields.</li>
21326+
<li>Press <strong>Enter</strong> to select.</li>
21327+
<li>Use <strong>Spacebar</strong> to toggle checkboxes or options.</li>
21328+
<li>Press <strong>Esc</strong> or select <strong>Quit</strong> to exit safely.</li>
21329+
</ul>
21330+
<hr />
21331+
<h3>📡 Common Use Cases</h3>
21332+
<p><strong>1. Configure a static IP address:</strong></p>
21333+
<p>nmtui edit<br />
21334+
→ Choose your Ethernet connection<br />
21335+
→ Set “IPv4 CONFIGURATION” to <em>Manual</em><br />
21336+
→ Enter IP, Gateway, and DNS<br />
21337+
→ Save → Activate connection</p>
21338+
<hr />
21339+
<p><strong>2. Connect to Wi-Fi from terminal:</strong></p>
21340+
<p>nmtui connect<br />
21341+
→ Select your wireless interface<br />
21342+
→ Choose the SSID<br />
21343+
→ Enter the password<br />
21344+
→ Activate connection</p>
21345+
<hr />
21346+
<p><strong>3. Change the hostname:</strong></p>
21347+
<p>nmtui hostname<br />
21348+
→ Type your new hostname<br />
21349+
→ Confirm and exit<br />
21350+
→ The new hostname will apply immediately.</p>
21351+
<hr />
21352+
<h3>🛠 Troubleshooting</h3>
21353+
<table>
21354+
<thead>
21355+
<tr>
21356+
<th align="left"><strong>Issue</strong></th>
21357+
<th align="left"><strong>Possible Solution</strong></th>
21358+
</tr>
21359+
</thead>
21360+
<tbody>
21361+
<tr>
21362+
<td align="left"><code>nmtui</code> command not found</td>
21363+
<td align="left">Install NetworkManager TUI: <code>sudo apt install network-manager</code> (Debian/Ubuntu) or <code>sudo dnf install NetworkManager-tui</code> (Fedora/RHEL/CentOS)</td>
21364+
</tr>
21365+
<tr>
21366+
<td align="left">Changes don’t take effect</td>
21367+
<td align="left">Restart NetworkManager: <code>sudo systemctl restart NetworkManager</code></td>
21368+
</tr>
21369+
<tr>
21370+
<td align="left">Interface not showing</td>
21371+
<td align="left">Ensure your interface is managed by NetworkManager: check <code>/etc/NetworkManager/NetworkManager.conf</code></td>
21372+
</tr>
21373+
<tr>
21374+
<td align="left">Wi-Fi missing</td>
21375+
<td align="left">Make sure wireless drivers are installed and <code>nmcli device status</code> shows the Wi-Fi adapter</td>
21376+
</tr>
21377+
</tbody>
21378+
</table>
21379+
<hr />
21380+
<h3>🧰 Related Commands</h3>
21381+
<table>
21382+
<thead>
21383+
<tr>
21384+
<th align="left"><strong>Command</strong></th>
21385+
<th align="left"><strong>Purpose</strong></th>
21386+
</tr>
21387+
</thead>
21388+
<tbody>
21389+
<tr>
21390+
<td align="left"><code>nmcli</code></td>
21391+
<td align="left">Command-line (non-interactive) NetworkManager control</td>
21392+
</tr>
21393+
<tr>
21394+
<td align="left"><code>ip addr</code></td>
21395+
<td align="left">Show IP addresses of all interfaces</td>
21396+
</tr>
21397+
<tr>
21398+
<td align="left"><code>ifconfig</code></td>
21399+
<td align="left">(Deprecated) Interface configuration command</td>
21400+
</tr>
21401+
<tr>
21402+
<td align="left"><code>systemctl restart NetworkManager</code></td>
21403+
<td align="left">Restart NetworkManager service</td>
21404+
</tr>
21405+
<tr>
21406+
<td align="left"><code>hostnamectl</code></td>
21407+
<td align="left">Manage the system hostname directly</td>
21408+
</tr>
21409+
</tbody>
21410+
</table>
21411+
<hr />
21412+
<h3>🧾 Example: Configuring Ethernet via <code>nmtui</code></h3>
21413+
<p>sudo nmtui<br />
21414+
→ Select <strong>Edit a connection</strong><br />
21415+
→ Choose <strong>Wired connection 1</strong><br />
21416+
→ Set IPv4 to <strong>Manual</strong><br />
21417+
→ Fill in:
21418+
Address: 192.168.1.50/24<br />
21419+
Gateway: 192.168.1.1<br />
21420+
DNS: 8.8.8.8<br />
21421+
→ Save → Back → <strong>Activate a connection</strong> → Select <strong>Wired connection 1</strong></p>
21422+
<p>✅ Your network connection will now use a static IP.</p>
21423+
<hr />
21424+
<h3>📘 Notes</h3>
21425+
<ul>
21426+
<li>Changes made with <code>nmtui</code> are persistent across reboots.</li>
21427+
<li>Requires <strong>NetworkManager</strong> to be active.</li>
21428+
<li><code>nmtui</code> provides the same functionality as <code>nmcli</code> but in a more user-friendly interface.</li>
21429+
<li>Perfect for <strong>server environments</strong> or <strong>SSH sessions</strong> where GUI tools are unavailable.</li>
21430+
</ul>
2112721431
<div style="page-break-after: always;"></div><h1>Conclusion</h1>
2112821432
<p>Congratulations! You've reached the end of the <strong>101 Linux Commands eBook</strong>. Throughout this journey, you've explored over 135 essential Linux commands that form the foundation of system administration, development, and everyday Linux usage.</p>
2112921433
<h2>What You've Learned</h2>
72 Bytes
Binary file not shown.
72 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)