Skip to content

Commit a770e90

Browse files
committed
🤖 Auto-update eBook files and GitHub Pages [skip ci]
1 parent c040c69 commit a770e90

File tree

7 files changed

+476
-12
lines changed

7 files changed

+476
-12
lines changed
19.1 KB
Binary file not shown.
19.3 KB
Binary file not shown.
3.53 KB
Binary file not shown.

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

Lines changed: 238 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,11 @@ <h3>Additional Flags and their Functionalities:</h3>
934934
<td align="left">Like <code>-l</code> but without showing group</td>
935935
</tr>
936936
<tr>
937+
<td align="left"><code>-C</code></td>
938+
<td align="left"><center>-</center></td>
939+
<td align="left">List entries by columns</td>
940+
</tr>
941+
<tr>
937942
<td align="left"><center>-</center></td>
938943
<td align="left"><code>--group-directories-first</code></td>
939944
<td align="left">List directories before files</td>
@@ -1619,19 +1624,40 @@ <h3>Additional Flags and their Functionalities</h3>
16191624
<p>Syntax:</p>
16201625
<pre><code class="language- hljs " data-lang="">tail [OPTION] [FILENAME]
16211626
</code></pre>
1622-
<h3>Get a specific number of lines with <code>tail</code>:</h3>
1623-
<p>Use the <code>-n</code> option with a number(should be an integer) of lines to display.</p>
1627+
<h2>Common Use Cases</h2>
1628+
<h3>Get a specific number of lines:</h3>
1629+
<p>Use the <code>-n</code> option with a number (should be an integer) of lines to display.</p>
16241630
<p>Example:</p>
16251631
<pre><code class="language- hljs " data-lang="">tail -n 10 foo.txt
16261632
</code></pre>
16271633
<p>This command will display the last ten lines of the file <code>foo.txt</code>.</p>
1628-
<h3>Refresh the output on any new entry in a file</h3>
1634+
<h3>Monitor new entry on files in real-time</h3>
16291635
<p>It is possible to let tail output any new line added to the file you are looking into. So, if a new line is written to the file, it will immediately be shown in your output. This can be done using the <code>--follow</code> or <code>-f</code> option. This is especially useful for monitoring log files.</p>
16301636
<p>Example:</p>
16311637
<pre><code class="language- hljs " data-lang="">tail -f foo.txt
16321638
</code></pre>
1633-
<p>Syntax:</p>
1634-
<pre><code class="language-xml hljs xml" data-lang="xml">tail -n <span class="hljs-tag">&lt;<span class="hljs-name">number</span>&gt;</span> foo.txt
1639+
<p>Press <code>Ctrl+C</code> to stop following.</p>
1640+
<h3>Combine options for log monitoring</h3>
1641+
<pre><code class="language-php hljs php" data-lang="php">tail -n <span class="hljs-number">100</span> -f app.log <span class="hljs-comment"># Show last 100 lines, then follow</span>
1642+
tail -f -s <span class="hljs-number">2</span> slow.log <span class="hljs-comment"># Follow with 2-second refresh interval</span>
1643+
</code></pre>
1644+
<h3>Follow multiple files simultaneously</h3>
1645+
<pre><code class="language-php hljs php" data-lang="php">tail -f /<span class="hljs-keyword">var</span>/log/nginx/access.log /<span class="hljs-keyword">var</span>/log/nginx/error.log
1646+
</code></pre>
1647+
<h3>Display specific byte ranges</h3>
1648+
<pre><code class="language-php hljs php" data-lang="php">tail -c <span class="hljs-number">100</span> file.txt <span class="hljs-comment"># Last 100 bytes</span>
1649+
tail -c +<span class="hljs-number">50</span> file.txt <span class="hljs-comment"># From byte 50 to end</span>
1650+
</code></pre>
1651+
<h3>Follow logs even after rotation</h3>
1652+
<pre><code class="language-php hljs php" data-lang="php">tail -F /<span class="hljs-keyword">var</span>/log/app.log
1653+
</code></pre>
1654+
<p>The <code>-F</code> option is crucial for monitoring logs managed by logrotate.</p>
1655+
<h3>Skip header lines</h3>
1656+
<pre><code class="language-php hljs php" data-lang="php">tail -n +<span class="hljs-number">2</span> data.csv <span class="hljs-comment"># Start from line 2 (skip header)</span>
1657+
tail -n +<span class="hljs-number">11</span> file.txt <span class="hljs-comment"># Start from line 11 onwards</span>
1658+
</code></pre>
1659+
<h3>Quiet mode for multiple files</h3>
1660+
<pre><code class="language-bash hljs bash" data-lang="bash">tail -q -n 5 *.<span class="hljs-built_in">log</span> <span class="hljs-comment"># No filename headers</span>
16351661
</code></pre>
16361662
<h3>Additional Flags and their Functionalities</h3>
16371663
<table>
@@ -1679,7 +1705,7 @@ <h3>Additional Flags and their Functionalities</h3>
16791705
<td align="left">Never output headers giving file names</td>
16801706
</tr>
16811707
<tr>
1682-
<td align="left">``</td>
1708+
<td align="left"></td>
16831709
<td align="left"><code>--retry</code></td>
16841710
<td align="left">keep trying to open a file if it is inaccessible</td>
16851711
</tr>
@@ -1710,6 +1736,13 @@ <h3>Additional Flags and their Functionalities</h3>
17101736
</tr>
17111737
</tbody>
17121738
</table>
1739+
<h2>Tips</h2>
1740+
<ul>
1741+
<li>Use <code>-F</code> instead of <code>-f</code> for production log monitoring</li>
1742+
<li>Combine with <code>grep</code>, <code>awk</code>, or <code>sed</code> for filtered monitoring</li>
1743+
<li>For large files, <code>tail</code> is much faster than opening in an editor</li>
1744+
<li>Use <code>-n +N</code> to start from a specific line (useful for skipping headers)</li>
1745+
</ul>
17131746
<div style="page-break-after: always;"></div><h1>The <code>pwd</code> command</h1>
17141747
<p>The <code>pwd</code> stands for Print Working Directory. It prints the path of the current working directory, starting from the root.</p>
17151748
<p>Example:</p>
@@ -19543,6 +19576,205 @@ <h2>Important Notes</h2>
1954319576
</ul>
1954419577
<p>The <code>cfdisk</code> command provides an excellent balance between ease of use and functionality for disk partitioning tasks.</p>
1954519578
<p>For more details, check the manual: <code>man cfdisk</code></p>
19579+
<div style="page-break-after: always;"></div><h1>The ifplugstatus Command</h1>
19580+
<p>The <code>ifplugstatus</code> command is a diagnostic utility used to check the <strong>physical link status</strong> of network interfaces on Linux systems. It reports whether an interface (such as eth0, enp0s3, or wlan0) has a network cable connected or not. This tool is particularly useful for troubleshooting wired network connectivity and detecting unplugged cables.</p>
19581+
<h2>Syntax</h2>
19582+
<pre><code class="language-bash hljs bash" data-lang="bash">ifplugstatus [options] [interface]
19583+
</code></pre>
19584+
<h3>Parameters</h3>
19585+
<ul>
19586+
<li>
19587+
<p>interface — the network interface to check (e.g., eth0, enp0s3, wlan0).</p>
19588+
</li>
19589+
<li>
19590+
<p>options — optional flags for customizing output.</p>
19591+
</li>
19592+
</ul>
19593+
<h2>Installation</h2>
19594+
<p><code>ifplugstatus</code> is part of the <code>ifplugd</code> package.
19595+
It can be installed using the following commands depending on your distribution:</p>
19596+
<pre><code class="language-bash hljs bash" data-lang="bash"><span class="hljs-comment"># Ubuntu/Debian</span>
19597+
sudo apt update
19598+
sudo apt install ifplugd
19599+
19600+
<span class="hljs-comment"># CentOS/RHEL/Fedora</span>
19601+
sudo yum install ifplugd
19602+
<span class="hljs-comment"># or</span>
19603+
sudo dnf install ifplugd
19604+
</code></pre>
19605+
<h3>To verify installation:</h3>
19606+
<pre><code class="language-bash hljs bash" data-lang="bash"><span class="hljs-built_in">which</span> ifplugstatus
19607+
</code></pre>
19608+
<h2>Basic Usage</h2>
19609+
<h3>1. Check the status of a single interface</h3>
19610+
<pre><code class="language-bash hljs bash" data-lang="bash">ifplugstatus eth0
19611+
</code></pre>
19612+
<h3>Sample Output:</h3>
19613+
<pre><code class="language-bash hljs bash" data-lang="bash">eth0: link beat detected
19614+
</code></pre>
19615+
<h3>or</h3>
19616+
<pre><code class="language-bash hljs bash" data-lang="bash">eth0: link beat not detected
19617+
</code></pre>
19618+
<h3>Explanation:</h3>
19619+
<ul>
19620+
<li>
19621+
<p>link beat detected → cable is plugged in and active.</p>
19622+
</li>
19623+
<li>
19624+
<p>link beat not detected → cable is unplugged or inactive.
19625+
<em>Note: 'link beat' is a legacy term from older Ethernet (10/100 Mbps). Modern Gigabit or higher interfaces may use different link detection signals, but the command generally reports an active physical link.</em></p>
19626+
</li>
19627+
</ul>
19628+
<h3>2. Check multiple interfaces</h3>
19629+
<pre><code class="language-bash hljs bash" data-lang="bash">ifplugstatus eth0 wlan0
19630+
</code></pre>
19631+
<h3>Sample Output:</h3>
19632+
<pre><code class="language-bash hljs bash" data-lang="bash">eth0: link beat detected
19633+
wlan0: link beat not detected
19634+
</code></pre>
19635+
<p>This allows quick verification of all available interfaces.</p>
19636+
<h2>Options</h2>
19637+
<p>Some popular option flags include:</p>
19638+
<table>
19639+
<thead>
19640+
<tr>
19641+
<th>Option</th>
19642+
<th>Description</th>
19643+
</tr>
19644+
</thead>
19645+
<tbody>
19646+
<tr>
19647+
<td><code>-a</code></td>
19648+
<td>Show all interfaces (default behavior).</td>
19649+
</tr>
19650+
<tr>
19651+
<td><code>-i</code></td>
19652+
<td>Specify a particular interface.</td>
19653+
</tr>
19654+
<tr>
19655+
<td><code>-s</code></td>
19656+
<td>Display a short summary only.</td>
19657+
</tr>
19658+
<tr>
19659+
<td><code>-v</code></td>
19660+
<td>Verbose output with more details.</td>
19661+
</tr>
19662+
<tr>
19663+
<td><code>-q</code></td>
19664+
<td>Quiet mode — minimal output.</td>
19665+
</tr>
19666+
<tr>
19667+
<td><code>-h</code></td>
19668+
<td>Display help information.</td>
19669+
</tr>
19670+
</tbody>
19671+
</table>
19672+
<h2>Practical Examples</h2>
19673+
<h3>1. Check if the main Ethernet interface is connected</h3>
19674+
<pre><code class="language-bash hljs bash" data-lang="bash">ifplugstatus eth0
19675+
</code></pre>
19676+
<p>Displays the current cable connection status for eth0.</p>
19677+
<h3>2. Check all available network interfaces</h3>
19678+
<pre><code class="language-bash hljs bash" data-lang="bash">ifplugstatus -a
19679+
</code></pre>
19680+
<p>Lists link status for every detected interface.</p>
19681+
<h3>3. Use verbose mode for detailed results</h3>
19682+
<pre><code class="language-bash hljs bash" data-lang="bash">ifplugstatus -v eth0
19683+
</code></pre>
19684+
<p>Provides more descriptive information about the link state.</p>
19685+
<h3>4. Quiet mode for scripting or automation</h3>
19686+
<pre><code class="language-bash hljs bash" data-lang="bash">ifplugstatus -q eth0
19687+
</code></pre>
19688+
<p>Outputs only the essential information, suitable for shell scripts.</p>
19689+
<h2>Understanding the Output</h2>
19690+
<p>A typical output may look like this:</p>
19691+
<pre><code class="language-bash hljs bash" data-lang="bash">eth0: link beat detected
19692+
enp0s3: link beat not detected
19693+
</code></pre>
19694+
<ul>
19695+
<li>
19696+
<p>Interface Name: eth0, enp0s3, etc.</p>
19697+
</li>
19698+
<li>
19699+
<p>Link Status: Indicates whether a physical link (cable or signal) is present.</p>
19700+
</li>
19701+
</ul>
19702+
<p>When integrated into scripts, this helps automate detection of disconnected interfaces or faulty cabling.</p>
19703+
<h2>Common Use Cases</h2>
19704+
<h3>1. Cable Connectivity Testing</h3>
19705+
<pre><code class="language-bash hljs bash" data-lang="bash">ifplugstatus eth0
19706+
</code></pre>
19707+
<p>Quickly verify if a cable is physically connected to the network port.</p>
19708+
<h3>2. Multi-Interface Monitoring</h3>
19709+
<pre><code class="language-bash hljs bash" data-lang="bash">ifplugstatus eth0 wlan0
19710+
</code></pre>
19711+
<p>Check multiple interfaces simultaneously for link activity.</p>
19712+
<h3>3. Continuous Monitoring</h3>
19713+
<pre><code class="language-bash hljs bash" data-lang="bash">watch -n 5 ifplugstatus eth0
19714+
</code></pre>
19715+
<p>Updates the interface status every 5 seconds for real-time link monitoring.</p>
19716+
<h2>Troubleshooting Common Issues</h2>
19717+
<h3>1. Interface Not Found</h3>
19718+
<p>If an incorrect interface name is given:</p>
19719+
<pre><code class="language-bash hljs bash" data-lang="bash">eth5: No such device
19720+
</code></pre>
19721+
<p><strong>Fix:</strong> Use the ip a or ifconfig command to list valid interfaces.</p>
19722+
<h3>2. Permission Denied</h3>
19723+
<p>Some systems may require elevated privileges:</p>
19724+
<pre><code class="language-bash hljs bash" data-lang="bash">sudo ifplugstatus eth0
19725+
</code></pre>
19726+
<h3>3. Command Not Found</h3>
19727+
<p>If the command is missing:</p>
19728+
<pre><code class="language-bash hljs bash" data-lang="bash"> ifplugstatus: <span class="hljs-built_in">command</span> not found
19729+
</code></pre>
19730+
<p><strong>Fix:</strong> Install the ifplugd package using your package manager.</p>
19731+
<p><strong>Tip:</strong> Always ensure the ifplugd package is installed and your user has permission to access network interfaces.</p>
19732+
<h2>Related Commands</h2>
19733+
<table>
19734+
<thead>
19735+
<tr>
19736+
<th>Command</th>
19737+
<th>Description</th>
19738+
</tr>
19739+
</thead>
19740+
<tbody>
19741+
<tr>
19742+
<td><code>ip a</code> (preferred) / <code>ifconfig</code></td>
19743+
<td>Display all network interfaces and details. <code>ip a</code> is the modern tool; <code>ifconfig</code> is legacy.</td>
19744+
</tr>
19745+
<tr>
19746+
<td><code>ethtool eth0</code></td>
19747+
<td>Retrieve advanced information about the network interface.</td>
19748+
</tr>
19749+
<tr>
19750+
<td><code>nmcli device status</code></td>
19751+
<td>Check connection status via NetworkManager.</td>
19752+
</tr>
19753+
<tr>
19754+
<td><code>ping</code></td>
19755+
<td>Test network reachability after confirming cable connection.</td>
19756+
</tr>
19757+
</tbody>
19758+
</table>
19759+
<h2>Important Notes</h2>
19760+
<ul>
19761+
<li>
19762+
<p>Works best with wired Ethernet interfaces.</p>
19763+
</li>
19764+
<li>
19765+
<p>Wireless interfaces may not always report link status accurately.</p>
19766+
</li>
19767+
<li>
19768+
<p>The tool is read-only — it does not modify system settings.</p>
19769+
</li>
19770+
<li>
19771+
<p>Lightweight and safe for use in both desktop and server environments.</p>
19772+
</li>
19773+
</ul>
19774+
<h2>Manual Reference</h2>
19775+
<p>For additional information and advanced usage:</p>
19776+
<pre><code class="language-bash hljs bash" data-lang="bash">man ifplugstatus
19777+
</code></pre>
1954619778
<div style="page-break-after: always;"></div><h1>Conclusion</h1>
1954719779
<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>
1954819780
<h2>What You've Learned</h2>
1.76 KB
Binary file not shown.
1.98 KB
Binary file not shown.

0 commit comments

Comments
 (0)