<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hamed Farazi</title>
    <description>The latest articles on DEV Community by Hamed Farazi (@hamedfarazi).</description>
    <link>https://dev.to/hamedfarazi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4067999%2F9c7fd54d-faf4-4322-9ee3-2f6a69327307.jpg</url>
      <title>DEV Community: Hamed Farazi</title>
      <link>https://dev.to/hamedfarazi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hamedfarazi"/>
    <language>en</language>
    <item>
      <title>Stop Using JavaScript Libraries for These 15 Things</title>
      <dc:creator>Hamed Farazi</dc:creator>
      <pubDate>Sun, 15 Nov 2026 12:40:52 +0000</pubDate>
      <link>https://dev.to/hamedfarazi/stop-using-javascript-libraries-for-these-15-things-3ppi</link>
      <guid>https://dev.to/hamedfarazi/stop-using-javascript-libraries-for-these-15-things-3ppi</guid>
      <description>&lt;p&gt;&lt;em&gt;Your browser already has more built-in features than you think.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let's be honest: how many npm packages have you installed without checking whether JavaScript or the browser could already do the same thing?&lt;/p&gt;

&lt;p&gt;Need to detect when an element enters the viewport? Install a library.&lt;/p&gt;

&lt;p&gt;Need to copy text? Install a package.&lt;/p&gt;

&lt;p&gt;Need to clone an object? Install Lodash.&lt;/p&gt;

&lt;p&gt;Need to make HTTP requests? Install Axios.&lt;/p&gt;

&lt;p&gt;Need to format dates? Install Moment.js.&lt;/p&gt;

&lt;p&gt;But here's the thing:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modern browsers have evolved. And some of the dependencies we used to consider essential are no longer necessary for everyday tasks.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Web Platform provides powerful native APIs that can help you reduce dependencies, simplify your code, improve performance, and keep your bundle smaller.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore 15 things you can do without installing another npm package.&lt;/p&gt;

&lt;p&gt;Let's get into it.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Stop Using jQuery for DOM Selection
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Instead of:&lt;/strong&gt; &lt;code&gt;jquery&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Remember when almost every JavaScript project started with jQuery?&lt;/p&gt;

&lt;p&gt;Today, modern browsers provide native DOM methods that handle most everyday selection and manipulation tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="s2"&gt;"#app"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addClass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"active"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Hello World"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;After:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"#app"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"active"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Hello World"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Need to select multiple elements?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;buttons&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"button"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;buttons&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;button&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"click"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Clicked!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Need to find the closest parent matching a selector?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;card&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;closest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;".card"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why use the native API?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No additional dependency.&lt;/li&gt;
&lt;li&gt;Direct access to browser DOM functionality.&lt;/li&gt;
&lt;li&gt;Less abstraction for simple operations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Keep jQuery if:&lt;/strong&gt; You're maintaining a legacy application or relying heavily on its ecosystem and plugins.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Stop Using Axios for Simple HTTP Requests
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Instead of:&lt;/strong&gt; &lt;code&gt;axios&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The Fetch API is built directly into modern browsers.&lt;/p&gt;

&lt;p&gt;You don't need an external library just to make an HTTP request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;axios&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"axios"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;axios&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/api/users"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;After:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/api/users"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`HTTP error: ${response.status}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Posting JSON is straightforward too:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/api/users"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Hamed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Developer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One important difference: Fetch doesn't reject its Promise for HTTP errors such as 404 or 500. You must check &lt;code&gt;response.ok&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keep Axios if:&lt;/strong&gt; You need interceptors, automatic request/response transformations, extensive client configuration, or an existing shared HTTP infrastructure.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Stop Using Lodash for Deep Cloning
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Instead of:&lt;/strong&gt; &lt;code&gt;_.cloneDeep()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;JavaScript now has a native &lt;code&gt;structuredClone()&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;It handles many types that JSON-based cloning cannot correctly preserve.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cloneDeep&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"lodash/cloneDeep"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;copy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;cloneDeep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;originalObject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;After:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;copy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;structuredClone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;originalObject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;original&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Hamed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;createdAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"JavaScript"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"React"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"JavaScript"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"React"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;copy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;structuredClone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;original&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;createdAt&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tags&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scores&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It also supports circular references.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; &lt;code&gt;structuredClone()&lt;/code&gt; cannot clone functions or DOM nodes. It also doesn't preserve custom class prototypes and methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keep Lodash if:&lt;/strong&gt; You need specialized cloning behavior or support for values that structured cloning cannot handle.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Stop Using Scroll Event Libraries for Visibility Detection
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Instead of:&lt;/strong&gt; &lt;code&gt;lazysizes&lt;/code&gt;, custom scroll listeners, or visibility plugins.&lt;/p&gt;

&lt;p&gt;Want to know when an element enters the viewport?&lt;/p&gt;

&lt;p&gt;Meet &lt;code&gt;IntersectionObserver&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It allows you to observe elements without manually checking their positions on every scroll event.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;observer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;IntersectionObserver&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isIntersecting&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Element is visible!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

      &lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"visible"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

      &lt;span class="n"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;unobserve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;".animate-on-scroll"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lazy loading.&lt;/li&gt;
&lt;li&gt;Infinite scrolling.&lt;/li&gt;
&lt;li&gt;Scroll-triggered animations.&lt;/li&gt;
&lt;li&gt;Analytics visibility tracking.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For ordinary image lazy loading, you might not even need JavaScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"image.jpg"&lt;/span&gt; &lt;span class="na"&gt;loading&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"lazy"&lt;/span&gt; &lt;span class="na"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Example"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Keep a library if:&lt;/strong&gt; You need complex scroll choreography, advanced animation timelines, or sophisticated visibility management.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Stop Using Resize Event Hacks for Element Sizing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Instead of:&lt;/strong&gt; Custom resize listeners and element-resize plugins.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;ResizeObserver&lt;/code&gt; API lets you monitor changes to an individual element's dimensions.&lt;/p&gt;

&lt;p&gt;Traditional approach:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"resize"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Check element dimensions manually&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Native approach:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;observer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ResizeObserver&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Width:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contentRect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Height:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contentRect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;container&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;".container"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;container&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why is this better?&lt;/p&gt;

&lt;p&gt;Because an element can change size without the browser window changing size.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A sidebar opens.&lt;/li&gt;
&lt;li&gt;A parent container changes dimensions.&lt;/li&gt;
&lt;li&gt;A grid layout changes.&lt;/li&gt;
&lt;li&gt;Content is dynamically inserted.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;ResizeObserver&lt;/code&gt; handles these cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keep a library if:&lt;/strong&gt; You need higher-level responsive layout behavior or complex element measurement utilities.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Stop Using Moment.js for Basic Date Formatting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Instead of:&lt;/strong&gt; &lt;code&gt;moment()&lt;/code&gt; or basic date-formatting packages.&lt;/p&gt;

&lt;p&gt;JavaScript already provides the &lt;code&gt;Intl&lt;/code&gt; API.&lt;/p&gt;

&lt;p&gt;Need to format dates based on a user's locale?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"2026-11-15T12:30:00"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;formatted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Intl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DateTimeFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"en-US"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;dateStyle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"full"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;timeStyle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"short"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;formatted&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Want a different locale?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Intl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DateTimeFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"de-DE"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Intl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DateTimeFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"fa-IR"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Intl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DateTimeFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"ja-JP"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also format relative time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;relativeTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Intl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;RelativeTimeFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"en"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;numeric&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"auto"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;relativeTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"day"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// 2 days ago&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And currency:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Intl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;NumberFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"en-US"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"currency"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"USD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1299.99&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// $1,299.99&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Keep a date library if:&lt;/strong&gt; You need advanced date arithmetic, parsing, recurring schedules, or complex timezone operations. &lt;code&gt;Intl&lt;/code&gt; formats dates; it isn't a complete date manipulation library.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. Stop Installing UUID Packages for Basic IDs
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Instead of:&lt;/strong&gt; &lt;code&gt;uuid&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you only need a random UUID v4, the browser already provides one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;crypto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;randomUUID&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;f47ac10b-58cc-4372-a567-0e02b2c3d479
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use it for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Temporary identifiers.&lt;/li&gt;
&lt;li&gt;Client-side records.&lt;/li&gt;
&lt;li&gt;UI keys.&lt;/li&gt;
&lt;li&gt;Local application data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; &lt;code&gt;crypto.randomUUID()&lt;/code&gt; requires a secure context in browsers (usually HTTPS or localhost).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keep the UUID package if:&lt;/strong&gt; You need other UUID versions, custom generation, or support for environments without the native API.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. Stop Using Libraries for Query String Manipulation
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Instead of:&lt;/strong&gt; &lt;code&gt;qs&lt;/code&gt; or manually splitting URL strings.&lt;/p&gt;

&lt;p&gt;JavaScript provides &lt;code&gt;URL&lt;/code&gt; and &lt;code&gt;URLSearchParams&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Need to read query parameters?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URLSearchParams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;search&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;search&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"search"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"page"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;search&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Need to create a URL?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="no"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://example.com/products"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;searchParams&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"category"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"laptops"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;searchParams&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"page"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Need to remove a parameter?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;searchParams&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"page"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Need to check whether a parameter exists?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;searchParams&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"category"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Category filter exists"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Keep a library if:&lt;/strong&gt; You need complex nested query structures or serialization rules that &lt;code&gt;URLSearchParams&lt;/code&gt; doesn't provide.&lt;/p&gt;




&lt;h2&gt;
  
  
  9. Stop Using Clipboard Libraries for Copy Buttons
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Instead of:&lt;/strong&gt; &lt;code&gt;clipboard.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Copying text is now a built-in browser capability.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;copyText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clipboard&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Copied successfully!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Clipboard failed:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;copyText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Hello from JavaScript!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A practical React example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;CopyButton&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;handleCopy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clipboard&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Copied!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Unable to copy text"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;button&lt;/span&gt; &lt;span class="n"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;handleCopy&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nc"&gt;Copy&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;button&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Clipboard access generally requires HTTPS or localhost and may require user interaction or permission.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keep a library if:&lt;/strong&gt; You need extensive legacy-browser fallbacks or advanced clipboard formats.&lt;/p&gt;




&lt;h2&gt;
  
  
  10. Stop Using Modal Libraries for Simple Dialogs
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Instead of:&lt;/strong&gt; Basic modal implementations with custom JavaScript.&lt;/p&gt;

&lt;p&gt;HTML has a native &lt;code&gt;&amp;lt;dialog&amp;gt;&lt;/code&gt; element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"openModal"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Open Modal&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;dialog&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"myDialog"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;Hello!&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is a native HTML dialog.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"dialog"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Close&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/dialog&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JavaScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;dialog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"#myDialog"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"#openModal"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"click"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;dialog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;showModal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You automatically get:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Native modal behavior.&lt;/li&gt;
&lt;li&gt;Escape-key dismissal.&lt;/li&gt;
&lt;li&gt;Focus management.&lt;/li&gt;
&lt;li&gt;A top-layer rendering mechanism.&lt;/li&gt;
&lt;li&gt;A customizable backdrop.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can style the backdrop too:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;dialog&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nt"&gt;backdrop&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;rgb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="kt"&gt;%&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;backdrop-filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;blur&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Keep a library if:&lt;/strong&gt; You need advanced animations, complex nested dialogs, or highly customized interaction patterns.&lt;/p&gt;




&lt;h2&gt;
  
  
  11. Stop Using Libraries for Simple Tooltips and Popovers
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Instead of:&lt;/strong&gt; Basic dropdown and popover implementations.&lt;/p&gt;

&lt;p&gt;The native Popover API makes simple interactive UI elements much easier.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;popovertarget&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"myPopover"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  Open Menu
&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"myPopover"&lt;/span&gt; &lt;span class="na"&gt;popover&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Hello from the Popover API!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it.&lt;/p&gt;

&lt;p&gt;No JavaScript event listeners required.&lt;/p&gt;

&lt;p&gt;You can also control it programmatically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;popover&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"#myPopover"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;popover&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;showPopover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;popover&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hidePopover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;popover&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;togglePopover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simple menus.&lt;/li&gt;
&lt;li&gt;Share panels.&lt;/li&gt;
&lt;li&gt;Contextual content.&lt;/li&gt;
&lt;li&gt;Lightweight popovers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; The Popover API handles showing and dismissing elements, not all positioning or tooltip behavior. For sophisticated positioning, Floating UI is still valuable.&lt;/p&gt;




&lt;h2&gt;
  
  
  12. Stop Using Custom Event Listeners for DOM Changes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Instead of:&lt;/strong&gt; Polling the DOM or repeatedly checking whether an element exists.&lt;/p&gt;

&lt;p&gt;Meet &lt;code&gt;MutationObserver&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It lets you observe changes to the DOM tree.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;observer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MutationObserver&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mutations&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;mutations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mutation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"DOM changed:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mutation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;childList&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;subtree&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;attributes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also watch a specific element:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"#app"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;observer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MutationObserver&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Something changed inside #app"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;childList&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;subtree&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Browser extensions.&lt;/li&gt;
&lt;li&gt;Third-party DOM integrations.&lt;/li&gt;
&lt;li&gt;Monitoring dynamically inserted content.&lt;/li&gt;
&lt;li&gt;Integrating with legacy interfaces.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Keep a library if:&lt;/strong&gt; You need a higher-level abstraction for complex DOM synchronization.&lt;/p&gt;




&lt;h2&gt;
  
  
  13. Stop Using Libraries for Basic Animations
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Instead of:&lt;/strong&gt; Installing an animation library for simple transitions.&lt;/p&gt;

&lt;p&gt;CSS already handles many UI animations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;translateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;opacity&lt;/span&gt; &lt;span class="mi"&gt;300ms&lt;/span&gt; &lt;span class="n"&gt;ease&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;transform&lt;/span&gt; &lt;span class="mi"&gt;300ms&lt;/span&gt; &lt;span class="n"&gt;ease&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card.visible&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;translateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For animations controlled directly through JavaScript, use the Web Animations API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;".card"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"translateY(20px)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"translateY(0)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;easing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ease-out"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"forwards"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also control the animation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;animation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"scale(1)"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"scale(1.1)"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"forwards"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pause&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Keep a library if:&lt;/strong&gt; You need complex physics-based animations, gesture-driven interactions, orchestration, or sophisticated layout transitions.&lt;/p&gt;




&lt;h2&gt;
  
  
  14. Stop Writing Custom Request Cancellation Logic
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Instead of:&lt;/strong&gt; Extra utilities just to cancel outdated requests.&lt;/p&gt;

&lt;p&gt;The browser provides &lt;code&gt;AbortController&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This is especially useful when users type into a search box and each keystroke triggers a new request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;searchUsers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="n"&gt;controller&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;AbortController&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="sb"&gt;`/api/users?q=${encodeURIComponent(query)}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Request failed"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"AbortError"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Previous request cancelled"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when a new search begins, the previous request can be cancelled.&lt;/p&gt;

&lt;p&gt;You can also set a timeout:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/api/data"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;AbortSignal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Keep a library if:&lt;/strong&gt; You need advanced retry policies, request queues, caching, or complex network orchestration.&lt;/p&gt;




&lt;h2&gt;
  
  
  15. Stop Using Libraries for Simple Page Transitions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Instead of:&lt;/strong&gt; Building custom transition animations for every simple view change.&lt;/p&gt;

&lt;p&gt;The View Transition API provides a native way to animate visual changes between page states.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;updateContent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;update&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"#content"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
      &lt;span class="s2"&gt;"Welcome to the new page!"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startViewTransition&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startViewTransition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;update&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can customize the animation using CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nf"&gt;view-transition-old&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;fade-out&lt;/span&gt; &lt;span class="mi"&gt;200ms&lt;/span&gt; &lt;span class="n"&gt;ease&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nf"&gt;view-transition-new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;fade-in&lt;/span&gt; &lt;span class="mi"&gt;300ms&lt;/span&gt; &lt;span class="n"&gt;ease&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="nt"&gt;fade-out&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="nt"&gt;fade-in&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;from&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is particularly useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tab transitions.&lt;/li&gt;
&lt;li&gt;Content replacement.&lt;/li&gt;
&lt;li&gt;Filtered lists.&lt;/li&gt;
&lt;li&gt;Simple page navigation.&lt;/li&gt;
&lt;li&gt;Single-page application transitions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Keep a library if:&lt;/strong&gt; You need advanced gesture-driven animations, spring physics, complex shared-element choreography, or extensive animation control.&lt;/p&gt;




&lt;h1&gt;
  
  
  Bonus: A Quick Comparison Table
&lt;/h1&gt;

&lt;p&gt;Here's a quick summary of everything we've covered.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What you need&lt;/th&gt;
&lt;th&gt;Library you might use&lt;/th&gt;
&lt;th&gt;Native alternative&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;DOM manipulation&lt;/td&gt;
&lt;td&gt;jQuery&lt;/td&gt;
&lt;td&gt;DOM API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTTP requests&lt;/td&gt;
&lt;td&gt;Axios&lt;/td&gt;
&lt;td&gt;Fetch API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deep cloning&lt;/td&gt;
&lt;td&gt;Lodash&lt;/td&gt;
&lt;td&gt;&lt;code&gt;structuredClone()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Visibility detection&lt;/td&gt;
&lt;td&gt;lazysizes&lt;/td&gt;
&lt;td&gt;&lt;code&gt;IntersectionObserver&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Element resizing&lt;/td&gt;
&lt;td&gt;Resize plugins&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ResizeObserver&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Date formatting&lt;/td&gt;
&lt;td&gt;Moment.js&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Intl.DateTimeFormat&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UUID generation&lt;/td&gt;
&lt;td&gt;uuid&lt;/td&gt;
&lt;td&gt;&lt;code&gt;crypto.randomUUID()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Query parameters&lt;/td&gt;
&lt;td&gt;qs&lt;/td&gt;
&lt;td&gt;&lt;code&gt;URLSearchParams&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Copy to clipboard&lt;/td&gt;
&lt;td&gt;clipboard.js&lt;/td&gt;
&lt;td&gt;Clipboard API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Modal dialogs&lt;/td&gt;
&lt;td&gt;Micromodal&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;dialog&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Popovers&lt;/td&gt;
&lt;td&gt;Tippy.js&lt;/td&gt;
&lt;td&gt;Popover API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DOM observation&lt;/td&gt;
&lt;td&gt;Mutation plugins&lt;/td&gt;
&lt;td&gt;&lt;code&gt;MutationObserver&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Simple animations&lt;/td&gt;
&lt;td&gt;Anime.js&lt;/td&gt;
&lt;td&gt;CSS / Web Animations API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Request cancellation&lt;/td&gt;
&lt;td&gt;Custom utilities&lt;/td&gt;
&lt;td&gt;&lt;code&gt;AbortController&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Page transitions&lt;/td&gt;
&lt;td&gt;Transition libraries&lt;/td&gt;
&lt;td&gt;View Transition API&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  So, Should You Stop Using JavaScript Libraries?
&lt;/h1&gt;

&lt;p&gt;Absolutely not.&lt;/p&gt;

&lt;p&gt;This isn't an argument against npm, open source, or third-party libraries.&lt;/p&gt;

&lt;p&gt;Libraries solve real problems. Some provide better abstractions, more consistent behavior, and features that the browser doesn't offer natively.&lt;/p&gt;

&lt;p&gt;The real problem is installing dependencies without understanding what they do.&lt;/p&gt;

&lt;p&gt;Before adding another package to your project, ask yourself:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Does the browser already provide this functionality?&lt;/li&gt;
&lt;li&gt;Does the library offer something beyond the native API?&lt;/li&gt;
&lt;li&gt;Do I actually need that additional functionality?&lt;/li&gt;
&lt;li&gt;Does the dependency justify its maintenance and bundle-size cost?&lt;/li&gt;
&lt;li&gt;What browsers and environments do I need to support?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Sometimes the best dependency is the one you never install.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learn the platform before adding another package.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What's Your Take?
&lt;/h2&gt;

&lt;p&gt;Let's make this interesting.&lt;/p&gt;

&lt;p&gt;What's one npm package you used to install regularly but have almost completely stopped using?&lt;/p&gt;

&lt;p&gt;For me, the most interesting shift is how many everyday frontend tasks can now be handled directly by browser APIs.&lt;/p&gt;

&lt;p&gt;Drop your answer in the comments. I'd love to see which dependencies developers are removing from their projects.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
      <category>programming</category>
    </item>
    <item>
      <title>Terminal Commands Every Developer Should Know (Windows, macOS &amp; Linux)</title>
      <dc:creator>Hamed Farazi</dc:creator>
      <pubDate>Sun, 15 Nov 2026 11:31:33 +0000</pubDate>
      <link>https://dev.to/hamedfarazi/the-ultimate-terminal-cheat-sheet-windows-macos-linux-24ab</link>
      <guid>https://dev.to/hamedfarazi/the-ultimate-terminal-cheat-sheet-windows-macos-linux-24ab</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;One command reference. Three operating systems. Everything developers need to navigate the terminal.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Whether you're working on Windows, macOS, or Linux, knowing your way around the terminal is an essential developer skill.&lt;/p&gt;

&lt;p&gt;But there's one annoying problem:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The same task often requires different commands depending on your operating system.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows: &lt;code&gt;dir&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;macOS / Linux: &lt;code&gt;ls&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that's just the beginning.&lt;/p&gt;

&lt;p&gt;This cheat sheet brings together the most commonly used terminal commands across all three platforms, organized by category so you can quickly find what you need.&lt;/p&gt;

&lt;p&gt;Bookmark this page. You'll probably need it again.&lt;/p&gt;




&lt;h1&gt;
  
  
  1. Terminal Environments
&lt;/h1&gt;

&lt;p&gt;Before we start, understand the difference between these environments:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operating System&lt;/th&gt;
&lt;th&gt;Terminal Environment&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;td&gt;Command Prompt (CMD)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;td&gt;PowerShell&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;macOS&lt;/td&gt;
&lt;td&gt;Terminal (Zsh / Bash)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Linux&lt;/td&gt;
&lt;td&gt;Terminal (Bash / Zsh)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Windows CMD and PowerShell are different shells. Some commands work in both, while others have completely different syntax.&lt;/p&gt;

&lt;p&gt;Throughout this article:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;CMD&lt;/code&gt; = Windows Command Prompt&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;PowerShell&lt;/code&gt; = Windows PowerShell&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;macOS / Linux&lt;/code&gt; = Unix-like shells&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  2. Navigation Commands
&lt;/h1&gt;

&lt;p&gt;The first thing you'll learn in any terminal is how to move around.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;CMD&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;th&gt;macOS / Linux&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Show current directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Location&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pwd&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List files&lt;/td&gt;
&lt;td&gt;&lt;code&gt;dir&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-ChildItem&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ls&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List all files, including hidden&lt;/td&gt;
&lt;td&gt;&lt;code&gt;dir /a&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-ChildItem -Force&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ls -la&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd folder&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Set-Location folder&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd folder&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Go up one level&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd ..&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd ..&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd ..&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Go to home directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd %USERPROFILE%&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd ~&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd ~&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Go to root directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd \&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd \&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd /&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Clear terminal&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cls&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Clear-Host&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;clear&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Practical examples
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Navigate into a project&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; my-project

&lt;span class="c"&gt;# Move one directory up&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ..

&lt;span class="c"&gt;# Go to your home directory&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ~

&lt;span class="c"&gt;# Display the current location&lt;/span&gt;
&lt;span class="nb"&gt;pwd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: &lt;code&gt;pwd&lt;/code&gt; and &lt;code&gt;~&lt;/code&gt; are native Unix shell conventions. PowerShell supports them too, but CMD does not.&lt;/p&gt;

&lt;h1&gt;
  
  
  3. File and Directory Management
&lt;/h1&gt;

&lt;p&gt;Creating, copying, moving, and deleting files are everyday terminal operations.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;CMD&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;th&gt;macOS / Linux&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Create directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mkdir app&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;New-Item -ItemType Directory app&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mkdir app&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create empty file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;type nul &amp;gt; file.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;New-Item file.txt -ItemType File&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;touch file.txt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Copy file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;copy a.txt b.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Copy-Item a.txt b.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cp a.txt b.txt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Move file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;move a.txt folder&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Move-Item a.txt folder&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mv a.txt folder&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rename file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ren old.txt new.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Rename-Item old.txt new.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mv old.txt new.txt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delete file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;del file.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Remove-Item file.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;rm file.txt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delete directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;rmdir folder /s /q&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Remove-Item folder -Recurse -Force&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;rm -r folder&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remove empty directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;rmdir folder&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Remove-Item folder&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;rmdir folder&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Display file contents&lt;/td&gt;
&lt;td&gt;&lt;code&gt;type file.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Content file.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cat file.txt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Useful examples
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create a project directory&lt;/span&gt;
mkdir my-app

&lt;span class="c"&gt;# Create a file&lt;/span&gt;
touch index.html

&lt;span class="c"&gt;# Copy a file&lt;/span&gt;
cp index.html backup.html

&lt;span class="c"&gt;# Rename a file&lt;/span&gt;
mv old-name.txt new-name.txt

&lt;span class="c"&gt;# Display file contents&lt;/span&gt;
cat package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
  &lt;strong&gt;⚠️ Be careful with deletion commands.&lt;/strong&gt;

  Commands such as `rm -rf` and `Remove-Item -Recurse -Force` can permanently delete files and directories. Always verify the target before executing them.
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  4. Searching for Files and Text
&lt;/h1&gt;

&lt;p&gt;Finding files and searching inside them are essential skills when working with large projects.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;CMD&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;th&gt;macOS / Linux&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Find a file by name&lt;/td&gt;
&lt;td&gt;&lt;code&gt;where /r . file.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-ChildItem -Recurse -Filter file.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;find . -name "file.txt"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Search text in a file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;findstr "hello" file.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Select-String "hello" file.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;grep "hello" file.txt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Search recursively&lt;/td&gt;
&lt;td&gt;&lt;code&gt;findstr /s "hello" *.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;`Get-ChildItem -Recurse -File \&lt;/td&gt;
&lt;td&gt;Select-String "hello"`&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Find executable location&lt;/td&gt;
&lt;td&gt;&lt;code&gt;where node&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Command node&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;which node&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Search command history&lt;/td&gt;
&lt;td&gt;&lt;code&gt;doskey /history&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-History&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;history&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Find all JavaScript files&lt;/span&gt;
find . -name &lt;span class="s2"&gt;"*.js"&lt;/span&gt;

&lt;span class="c"&gt;# Search for a specific word&lt;/span&gt;
grep &lt;span class="s2"&gt;"useState"&lt;/span&gt; App.jsx

&lt;span class="c"&gt;# Search recursively&lt;/span&gt;
grep -r &lt;span class="s2"&gt;"TODO"&lt;/span&gt; src/

&lt;span class="c"&gt;# Find files with a specific extension&lt;/span&gt;
find . -name &lt;span class="s2"&gt;"*.tsx"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  5. System Information
&lt;/h1&gt;

&lt;p&gt;Sometimes you need to inspect your machine without opening system settings.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;CMD&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;th&gt;macOS / Linux&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;System information&lt;/td&gt;
&lt;td&gt;&lt;code&gt;systeminfo&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-ComputerInfo&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;uname -a&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Operating system&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ver&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-CimInstance Win32_OperatingSystem&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;cat /etc/os-release&lt;/code&gt; (Linux)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Current username&lt;/td&gt;
&lt;td&gt;&lt;code&gt;whoami&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;whoami&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;whoami&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hostname&lt;/td&gt;
&lt;td&gt;&lt;code&gt;hostname&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;hostname&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;hostname&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Date and time&lt;/td&gt;
&lt;td&gt;&lt;code&gt;date /t&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Date&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;date&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Environment variables&lt;/td&gt;
&lt;td&gt;&lt;code&gt;set&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-ChildItem Env:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;printenv&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Display a variable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;echo %PATH%&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;$env:PATH&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;echo $PATH&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check your username&lt;/span&gt;
whoami

&lt;span class="c"&gt;# Check your hostname&lt;/span&gt;
hostname

&lt;span class="c"&gt;# Display environment variables&lt;/span&gt;
printenv

&lt;span class="c"&gt;# Display PATH&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$PATH&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  6. Process Management
&lt;/h1&gt;

&lt;p&gt;When an application freezes or a development server refuses to stop, process management becomes important.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;CMD&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;th&gt;macOS / Linux&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;List running processes&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tasklist&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Process&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ps aux&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Find process by name&lt;/td&gt;
&lt;td&gt;`tasklist \&lt;/td&gt;
&lt;td&gt;findstr node`&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Process node&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kill process by PID&lt;/td&gt;
&lt;td&gt;&lt;code&gt;taskkill /PID 1234 /F&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Stop-Process -Id 1234 -Force&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kill -9 1234&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kill by process name&lt;/td&gt;
&lt;td&gt;&lt;code&gt;taskkill /IM node.exe /F&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Stop-Process -Name node -Force&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pkill node&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Display live processes&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tasklist&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Process&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;top&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Interactive process monitor&lt;/td&gt;
&lt;td&gt;Task Manager&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Process&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;htop&lt;/code&gt; (if installed)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Developer example
&lt;/h3&gt;

&lt;p&gt;Imagine your React development server is stuck on port 5173.&lt;/p&gt;

&lt;p&gt;First, find the process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# macOS / Linux&lt;/span&gt;
lsof -i :5173
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Windows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Find the process using port 5173&lt;/span&gt;
&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetTCPConnection&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;LocalPort&lt;/span&gt; &lt;span class="mi"&gt;5173&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then terminate the process using its PID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Windows PowerShell&lt;/span&gt;
&lt;span class="nc"&gt;Stop&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="mi"&gt;1234&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# macOS / Linux&lt;/span&gt;
&lt;span class="nb"&gt;kill&lt;/span&gt; 1234
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;1234&lt;/code&gt; with the actual process ID.&lt;/p&gt;

&lt;h1&gt;
  
  
  7. Networking Commands
&lt;/h1&gt;

&lt;p&gt;Networking commands help you troubleshoot connectivity, inspect IP addresses, and diagnose DNS problems.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;CMD&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;th&gt;macOS / Linux&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Show IP configuration&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ipconfig&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-NetIPConfiguration&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ip addr&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Detailed IP information&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ipconfig /all&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-NetIPConfiguration&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ip addr show&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Test connectivity&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ping google.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Test-Connection google.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ping google.com&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DNS lookup&lt;/td&gt;
&lt;td&gt;&lt;code&gt;nslookup google.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Resolve-DnsName google.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;nslookup google.com&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Display network connections&lt;/td&gt;
&lt;td&gt;&lt;code&gt;netstat -ano&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-NetTCPConnection&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ss -tulnp&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Trace network route&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tracert google.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Test-NetConnection google.com -TraceRoute&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;traceroute google.com&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Display routing table&lt;/td&gt;
&lt;td&gt;&lt;code&gt;route print&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-NetRoute&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ip route&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Flush DNS cache&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ipconfig /flushdns&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Clear-DnsClientCache&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Depends on OS and resolver&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Useful examples
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check internet connectivity&lt;/span&gt;
ping google.com

&lt;span class="c"&gt;# Check DNS resolution&lt;/span&gt;
nslookup github.com

&lt;span class="c"&gt;# Inspect network routes&lt;/span&gt;
traceroute google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  8. Package Managers
&lt;/h1&gt;

&lt;p&gt;Package managers make installing and updating development tools much easier.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Windows&lt;/th&gt;
&lt;th&gt;macOS&lt;/th&gt;
&lt;th&gt;Linux&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Install Node.js&lt;/td&gt;
&lt;td&gt;&lt;code&gt;winget install OpenJS.NodeJS&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;brew install node&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sudo apt install nodejs npm&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Install Git&lt;/td&gt;
&lt;td&gt;&lt;code&gt;winget install Git.Git&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;brew install git&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sudo apt install git&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Install Python&lt;/td&gt;
&lt;td&gt;&lt;code&gt;winget install Python.Python.3.12&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;brew install python&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sudo apt install python3&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Update packages&lt;/td&gt;
&lt;td&gt;&lt;code&gt;winget upgrade --all&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;brew upgrade&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Search packages&lt;/td&gt;
&lt;td&gt;&lt;code&gt;winget search node&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;brew search node&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;apt search nodejs&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remove package&lt;/td&gt;
&lt;td&gt;&lt;code&gt;winget uninstall Git.Git&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;brew uninstall git&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sudo apt remove git&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; These examples assume Windows Package Manager (winget), Homebrew on macOS, and APT-based Linux distributions such as Ubuntu and Debian.&lt;/p&gt;

&lt;p&gt;Other Linux distributions use different package managers, such as &lt;code&gt;dnf&lt;/code&gt; or &lt;code&gt;pacman&lt;/code&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  9. Git Commands
&lt;/h1&gt;

&lt;p&gt;Git works almost identically across Windows, macOS, and Linux.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Check Git version&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git --version&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Initialize repository&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git init&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Clone repository&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git clone URL&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Check status&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git status&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stage all changes&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git add .&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Commit changes&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git commit -m "message"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;View commit history&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git log&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create branch&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git branch feature&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Switch branch&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git switch feature&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create and switch branch&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git switch -c feature&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pull changes&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git pull&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Push changes&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git push&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List branches&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git branch&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Merge branch&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git merge feature&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;View differences&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git diff&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Typical Git workflow
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git status
git add .
git commit -m &lt;span class="s2"&gt;"Add new feature"&lt;/span&gt;
git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  10. Archive and Compression Commands
&lt;/h1&gt;

&lt;p&gt;Working with ZIP and compressed files is another common terminal task.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;CMD&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;th&gt;macOS / Linux&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Create ZIP&lt;/td&gt;
&lt;td&gt;Not built-in&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Compress-Archive -Path folder -DestinationPath app.zip&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;zip -r app.zip folder&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Extract ZIP&lt;/td&gt;
&lt;td&gt;Not built-in&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Expand-Archive app.zip -DestinationPath output&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;unzip app.zip&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create TAR archive&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tar -cf app.tar folder&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tar -cf app.tar folder&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tar -cf app.tar folder&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Extract TAR&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tar -xf app.tar&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tar -xf app.tar&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tar -xf app.tar&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Extract TAR.GZ&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tar -xzf app.tar.gz&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tar -xzf app.tar.gz&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tar -xzf app.tar.gz&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h1&gt;
  
  
  11. Permissions and Administrative Commands
&lt;/h1&gt;

&lt;p&gt;Permissions control who can access, modify, and execute files.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;CMD&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;th&gt;macOS / Linux&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Display file permissions&lt;/td&gt;
&lt;td&gt;&lt;code&gt;icacls file.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Acl file.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ls -l file.txt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change permissions&lt;/td&gt;
&lt;td&gt;&lt;code&gt;icacls file.txt /grant User:F&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;icacls file.txt /grant User:F&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;chmod 755 file.txt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change file owner&lt;/td&gt;
&lt;td&gt;&lt;code&gt;takeown /f file.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;takeown /f file.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;chown user file.txt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Run as administrator&lt;/td&gt;
&lt;td&gt;Run CMD as Administrator&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Start-Process powershell -Verb RunAs&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sudo command&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Permission example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Give the owner read, write and execute permissions&lt;/span&gt;
chmod 755 script.sh

&lt;span class="c"&gt;# Make a script executable for everyone&lt;/span&gt;
chmod +x script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Be careful when using administrator privileges or &lt;code&gt;sudo&lt;/code&gt;. Elevated commands can modify critical system files.&lt;/p&gt;

&lt;h1&gt;
  
  
  12. Disk and Storage Commands
&lt;/h1&gt;

&lt;p&gt;Need to check available storage?&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;CMD&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;th&gt;macOS / Linux&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Show disk usage&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;wmic logicaldisk get size,freespace&lt;/code&gt; (legacy)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Volume&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;df -h&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Show directory size&lt;/td&gt;
&lt;td&gt;No simple built-in equivalent&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Get-ChildItem&lt;/code&gt; with size calculation&lt;/td&gt;
&lt;td&gt;&lt;code&gt;du -sh folder&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List disks&lt;/td&gt;
&lt;td&gt;&lt;code&gt;diskpart&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Disk&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;lsblk&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Check disk&lt;/td&gt;
&lt;td&gt;&lt;code&gt;chkdsk&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Repair-Volume&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;fsck&lt;/code&gt; (unmounted filesystem)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Note: Disk repair commands often require administrator privileges and should not be run casually.&lt;/p&gt;

&lt;h1&gt;
  
  
  13. Environment Variables
&lt;/h1&gt;

&lt;p&gt;Environment variables are especially important for developers working with Node.js, React, Docker, and backend applications.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;CMD&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;th&gt;macOS / Linux&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Display PATH&lt;/td&gt;
&lt;td&gt;&lt;code&gt;echo %PATH%&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;$env:PATH&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;echo $PATH&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Set temporary variable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;set API_KEY=123&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;$env:API_KEY="123"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;export API_KEY=123&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Display variable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;echo %API_KEY%&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;$env:API_KEY&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;echo $API_KEY&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remove variable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;set API_KEY=&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Remove-Item Env:API_KEY&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;unset API_KEY&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; These examples set variables only for the current shell session. Permanent environment variables require different configuration methods.&lt;/p&gt;

&lt;h1&gt;
  
  
  14. Useful Terminal Shortcuts
&lt;/h1&gt;

&lt;p&gt;You don't always need a command. Keyboard shortcuts can save a lot of time.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Shortcut&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Ctrl + C&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Interrupt a running command&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Ctrl + L&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Clear the terminal screen (supported shells)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Ctrl + A&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Move to the beginning of the line&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Ctrl + E&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Move to the end of the line&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Ctrl + R&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Search command history (common Unix shells)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Tab&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Autocomplete commands and paths&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;↑ / ↓&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Navigate command history&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Ctrl + D&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;End input / exit shell (Unix shells)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Shortcut behavior can vary depending on the terminal application and shell.&lt;/p&gt;

&lt;h1&gt;
  
  
  15. Bonus: Developer-Specific Commands
&lt;/h1&gt;

&lt;p&gt;If you're a frontend or full-stack developer, these commands will probably be part of your daily workflow.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Check Node.js version&lt;/td&gt;
&lt;td&gt;&lt;code&gt;node -v&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Check npm version&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npm -v&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Check pnpm version&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pnpm -v&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Install dependencies&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npm install&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Start development server&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npm run dev&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Build project&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npm run build&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Run tests&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npm test&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Install a package&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npm install package-name&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Install dev dependency&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npm install -D package-name&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remove package&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npm uninstall package-name&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Run a package without installing globally&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npx package-name&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Check Python version&lt;/td&gt;
&lt;td&gt;&lt;code&gt;python --version&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Check Docker version&lt;/td&gt;
&lt;td&gt;&lt;code&gt;docker --version&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List Docker containers&lt;/td&gt;
&lt;td&gt;&lt;code&gt;docker ps -a&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List Docker images&lt;/td&gt;
&lt;td&gt;&lt;code&gt;docker images&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These commands are generally cross-platform, provided the relevant tools are installed.&lt;/p&gt;




&lt;h1&gt;
  
  
  16. Quick Reference: The Commands You'll Use Most
&lt;/h1&gt;

&lt;p&gt;Here's the compact version for when you don't have time to read the entire article.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Windows CMD&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;th&gt;macOS / Linux&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;List files&lt;/td&gt;
&lt;td&gt;&lt;code&gt;dir&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ls&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ls&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Current directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pwd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pwd&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Clear screen&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cls&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cls&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;clear&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create folder&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mkdir&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mkdir&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mkdir&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delete file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;del&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;rm&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;rm&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Copy file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;copy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cp&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Move file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;move&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mv&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mv&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Show processes&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tasklist&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ps&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ps aux&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kill process&lt;/td&gt;
&lt;td&gt;&lt;code&gt;taskkill&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Stop-Process&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kill&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Show IP&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ipconfig&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ipconfig&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ip addr&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Find executable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;where&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Command&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;which&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Display file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;type&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cat&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cat&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;You don't need to memorize every command in this article.&lt;/p&gt;

&lt;p&gt;Instead, focus on understanding the patterns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigation helps you move around.&lt;/li&gt;
&lt;li&gt;File commands help you manage projects.&lt;/li&gt;
&lt;li&gt;Process commands help you troubleshoot applications.&lt;/li&gt;
&lt;li&gt;Networking commands help you diagnose connectivity.&lt;/li&gt;
&lt;li&gt;Package managers help you install development tools.&lt;/li&gt;
&lt;li&gt;Git commands help you manage your code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you understand the concepts, switching between Windows, macOS, and Linux becomes much easier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The terminal isn't something to be afraid of. It's one of the most powerful tools a developer can learn.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;⭐ &lt;strong&gt;Save this cheat sheet for later!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Which operating system do you use most for development: Windows, macOS, or Linux?&lt;/p&gt;

&lt;p&gt;Share your favorite terminal command in the comments!&lt;/p&gt;

&lt;h1&gt;
  
  
  terminal #commandline #windows #linux #macos #programming #webdev #beginners #cheatsheet #productivity
&lt;/h1&gt;

</description>
      <category>windows</category>
      <category>linux</category>
      <category>macos</category>
    </item>
    <item>
      <title>Terminal Mastery-Advanced Terminal Workflows and Troubleshooting</title>
      <dc:creator>Hamed Farazi</dc:creator>
      <pubDate>Sun, 15 Nov 2026 11:26:36 +0000</pubDate>
      <link>https://dev.to/hamedfarazi/terminal-mastery-advanced-terminal-workflows-and-troubleshooting-2j80</link>
      <guid>https://dev.to/hamedfarazi/terminal-mastery-advanced-terminal-workflows-and-troubleshooting-2j80</guid>
      <description>&lt;p&gt;10/10 --Advanced Terminal Workflows and Troubleshooting&lt;br&gt;
You've learned how to navigate directories, manage files, search through content, control processes, troubleshoot networks, and write shell scripts.&lt;/p&gt;

&lt;p&gt;Now it's time to connect all those skills.&lt;/p&gt;

&lt;p&gt;Real terminal proficiency isn't about memorizing hundreds of commands. It's about knowing how to combine a few powerful tools to investigate problems, understand your system, and complete complex tasks efficiently.&lt;/p&gt;

&lt;p&gt;In this final chapter of &lt;strong&gt;Terminal Mastery: Windows, macOS &amp;amp; Linux&lt;/strong&gt;, we'll explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Advanced command-line workflows&lt;/li&gt;
&lt;li&gt;Systematic troubleshooting techniques&lt;/li&gt;
&lt;li&gt;Environment variables and PATH management&lt;/li&gt;
&lt;li&gt;SSH and remote development&lt;/li&gt;
&lt;li&gt;Logs and diagnostic information&lt;/li&gt;
&lt;li&gt;Package and disk management&lt;/li&gt;
&lt;li&gt;Developer workflow automation&lt;/li&gt;
&lt;li&gt;Terminal productivity and customization&lt;/li&gt;
&lt;li&gt;Practical troubleshooting scenarios&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's bring everything together.&lt;/p&gt;


&lt;h2&gt;
  
  
  1. Think in Workflows, Not Individual Commands
&lt;/h2&gt;

&lt;p&gt;A beginner often thinks:&lt;/p&gt;

&lt;p&gt;"I need to find a file. Which command should I use?"&lt;/p&gt;

&lt;p&gt;An experienced developer thinks:&lt;/p&gt;

&lt;p&gt;"I need to locate the file, inspect its contents, identify the relevant information, and possibly modify it."&lt;/p&gt;

&lt;p&gt;That's a workflow.&lt;/p&gt;

&lt;p&gt;A workflow is a sequence of operations that solves a larger problem.&lt;/p&gt;

&lt;p&gt;Consider this example:&lt;/p&gt;

&lt;p&gt;You want to find every occurrence of &lt;code&gt;TODO&lt;/code&gt; in a project, excluding dependency directories.&lt;/p&gt;
&lt;h3&gt;
  
  
  Linux and macOS
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rg -n &lt;span class="s2"&gt;"TODO"&lt;/span&gt; . \
  --glob &lt;span class="s1"&gt;'!node_modules/**'&lt;/span&gt; \
  --glob &lt;span class="s1"&gt;'!dist/**'&lt;/span&gt; \
  --glob &lt;span class="s1"&gt;'!vendor/**'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Windows PowerShell
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Where&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FullName&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;notmatch&lt;/span&gt; &lt;span class="s1"&gt;'[\\/](node_modules|dist|vendor)[\\/]'&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Pattern&lt;/span&gt; &lt;span class="s2"&gt;"TODO"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Both commands solve the same problem, but use different approaches.&lt;/p&gt;

&lt;p&gt;The Bash example uses &lt;code&gt;ripgrep&lt;/code&gt;, while PowerShell combines file discovery, filtering, and text search.&lt;/p&gt;

&lt;p&gt;The important lesson:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't just learn commands. Learn how to combine them.&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Build a Systematic Troubleshooting Process
&lt;/h2&gt;

&lt;p&gt;When something breaks, randomly trying commands usually wastes time.&lt;/p&gt;

&lt;p&gt;A better approach is to investigate problems in a consistent order.&lt;/p&gt;

&lt;p&gt;Here's a practical troubleshooting framework:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reproduce the problem.&lt;/li&gt;
&lt;li&gt;Identify the affected component.&lt;/li&gt;
&lt;li&gt;Check the relevant process or service.&lt;/li&gt;
&lt;li&gt;Inspect logs and error messages.&lt;/li&gt;
&lt;li&gt;Check configuration and environment variables.&lt;/li&gt;
&lt;li&gt;Verify filesystem permissions.&lt;/li&gt;
&lt;li&gt;Test network connectivity if necessary.&lt;/li&gt;
&lt;li&gt;Apply one change at a time.&lt;/li&gt;
&lt;li&gt;Verify that the problem is resolved.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's apply this process to a real development scenario.&lt;/p&gt;
&lt;h3&gt;
  
  
  Scenario: Your development server isn't starting
&lt;/h3&gt;

&lt;p&gt;Suppose you run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But the application fails to start.&lt;/p&gt;

&lt;p&gt;Instead of immediately reinstalling dependencies, investigate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Check Node.js and npm&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Linux, macOS, PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node --version
npm --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Check whether the expected files exist&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -la
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look for:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package.json
node_modules/
src/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Inspect the package scripts&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays the available scripts defined in &lt;code&gt;package.json&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Check whether the port is already in use&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ss -ltnp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lsof -iTCP -sTCP:LISTEN -P -n
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Windows PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetTCPConnection&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;State&lt;/span&gt; &lt;span class="nc"&gt;Listen&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nc"&gt;LocalAddress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;LocalPort&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;OwningProcess&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5: Identify the process&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ps aux &lt;span class="o"&gt;|&lt;/span&gt; grep node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 6: Inspect the error&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Don't ignore the actual error message.&lt;/p&gt;

&lt;p&gt;It might indicate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A missing dependency.&lt;/li&gt;
&lt;li&gt;A syntax error.&lt;/li&gt;
&lt;li&gt;An occupied port.&lt;/li&gt;
&lt;li&gt;A missing environment variable.&lt;/li&gt;
&lt;li&gt;An invalid configuration file.&lt;/li&gt;
&lt;li&gt;A permission problem.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is to identify the cause before changing the system.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Understand Environment Variables and PATH
&lt;/h2&gt;

&lt;p&gt;Environment variables are values provided to processes by their execution environment.&lt;/p&gt;

&lt;p&gt;They're commonly used for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Configuration&lt;/li&gt;
&lt;li&gt;API endpoints&lt;/li&gt;
&lt;li&gt;Runtime settings&lt;/li&gt;
&lt;li&gt;Credentials&lt;/li&gt;
&lt;li&gt;Tool locations&lt;/li&gt;
&lt;li&gt;Application modes&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Display environment variables
&lt;/h3&gt;

&lt;p&gt;Bash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;printenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="nc"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Windows CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Read a specific variable
&lt;/h3&gt;

&lt;p&gt;Bash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$HOME"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$PATH"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="no"&gt;USERPROFILE&lt;/span&gt;
&lt;span class="nv"&gt;$env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="no"&gt;PATH&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo %USERPROFILE%
echo %PATH%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create an environment variable
&lt;/h3&gt;

&lt;p&gt;Bash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;APP_ENV&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"development"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="no"&gt;APP_ENV&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"development"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set APP_ENV=development
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These examples set variables for the current shell session and its child processes.&lt;/p&gt;

&lt;p&gt;They don't automatically create permanent system-wide settings.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is PATH?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;PATH&lt;/code&gt; is an environment variable containing directories where the operating system looks for executable commands.&lt;/p&gt;

&lt;p&gt;For example, when you type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your shell or operating system searches the relevant executable locations.&lt;/p&gt;

&lt;p&gt;If Node.js is installed but isn't available as a command, its installation directory might be missing from PATH.&lt;/p&gt;

&lt;p&gt;Check where an executable is located:&lt;/p&gt;

&lt;p&gt;Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;command&lt;/span&gt; -v node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;which node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Command&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Windows CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;where node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is one of the first things to check when a command suddenly stops working.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inspect your PATH
&lt;/h3&gt;

&lt;p&gt;Bash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$PATH"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; tr &lt;span class="s1"&gt;':'&lt;/span&gt; &lt;span class="s1"&gt;'\n'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="no"&gt;PATH&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt; &lt;span class="s1"&gt;';'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo %PATH%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Be careful when modifying PATH. Accidentally replacing its existing value can make other applications unavailable from the command line.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. SSH: Work with Remote Machines
&lt;/h2&gt;

&lt;p&gt;Developers frequently work with remote servers.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deploying applications.&lt;/li&gt;
&lt;li&gt;Accessing Linux servers.&lt;/li&gt;
&lt;li&gt;Managing cloud infrastructure.&lt;/li&gt;
&lt;li&gt;Running commands on development machines.&lt;/li&gt;
&lt;li&gt;Transferring files between computers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SSH stands for &lt;strong&gt;Secure Shell&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It provides an encrypted connection to a remote machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  Connect to a server
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh username@192.168.1.100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the server uses a non-default SSH port:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh -p 7991 username@192.168.1.100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works from Linux, macOS, and modern Windows systems with an OpenSSH client installed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use an SSH key
&lt;/h3&gt;

&lt;p&gt;Generate a key pair:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-keygen -t ed25519 -C &lt;span class="s2"&gt;"developer@example.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a private key and a public key.&lt;/p&gt;

&lt;p&gt;The private key must remain private.&lt;/p&gt;

&lt;p&gt;The public key can be installed on the remote server.&lt;/p&gt;

&lt;p&gt;On many Linux systems, you can add your public key with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-copy-id username@server-address
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If &lt;code&gt;ssh-copy-id&lt;/code&gt; isn't available, you can install the public key manually using the server's authorized-keys mechanism.&lt;/p&gt;

&lt;p&gt;Then connect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh username@server-address
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Use SSH config
&lt;/h3&gt;

&lt;p&gt;Typing a long connection command repeatedly is inconvenient.&lt;/p&gt;

&lt;p&gt;Create or edit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/.ssh/config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Host dev-server
    HostName 192.168.1.100
    User developer
    Port 7991
    IdentityFile ~/.ssh/id_ed25519
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now connect using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh dev-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works with OpenSSH clients on Linux, macOS, and Windows.&lt;/p&gt;

&lt;h3&gt;
  
  
  Copy files using SCP
&lt;/h3&gt;

&lt;p&gt;Upload a file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;scp app.zip username@server-address:/home/username/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Download a file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;scp username@server-address:/home/username/app.log .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy a directory recursively:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;scp -r ./project username@server-address:/home/username/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more advanced synchronization, &lt;code&gt;rsync&lt;/code&gt; is another useful tool on systems where it's available.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rsync -avz ./project/ username@server-address:/home/username/project/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SSH is an essential tool for developers who work with remote environments.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Inspect Logs Like a Professional
&lt;/h2&gt;

&lt;p&gt;Logs are one of the most valuable sources of diagnostic information.&lt;/p&gt;

&lt;p&gt;Applications, servers, and operating systems generate logs to record events.&lt;/p&gt;

&lt;p&gt;When an application fails, logs can help explain what happened.&lt;/p&gt;

&lt;h3&gt;
  
  
  Read the last lines of a log
&lt;/h3&gt;

&lt;p&gt;Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tail -n 50 app.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Windows PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;\&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Tail&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Follow a log in real time
&lt;/h3&gt;

&lt;p&gt;Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tail -f app.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;\&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Wait&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is particularly useful when testing an application while watching its output.&lt;/p&gt;

&lt;h3&gt;
  
  
  Search for errors
&lt;/h3&gt;

&lt;p&gt;Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep -i &lt;span class="s2"&gt;"error"&lt;/span&gt; app.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;\&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Pattern&lt;/span&gt; &lt;span class="s2"&gt;"error"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Combine filtering and following
&lt;/h3&gt;

&lt;p&gt;You can filter a live log stream:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tail -f app.log &lt;span class="o"&gt;|&lt;/span&gt; grep -i &lt;span class="s2"&gt;"error"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you'll see matching error lines as they appear.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inspect system logs on Linux
&lt;/h3&gt;

&lt;p&gt;Many Linux distributions use &lt;code&gt;systemd&lt;/code&gt; and its journal.&lt;/p&gt;

&lt;p&gt;View recent system logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;journalctl -n 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Follow logs in real time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;journalctl -f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inspect a specific service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;journalctl -u nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;View logs from the current boot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;journalctl -b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Not every Linux distribution uses systemd, so these commands may not be available everywhere.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inspect Windows event logs
&lt;/h3&gt;

&lt;p&gt;PowerShell provides access to Windows event logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;WinEvent&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;LogName&lt;/span&gt; &lt;span class="nc"&gt;System&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;MaxEvents&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For application events:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;WinEvent&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;LogName&lt;/span&gt; &lt;span class="nc"&gt;Application&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;MaxEvents&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can filter by level:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;WinEvent&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;FilterHashtable&lt;/span&gt; @&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;LogName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"System"&lt;/span&gt;
    &lt;span class="nc"&gt;Level&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;MaxEvents&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Event level &lt;code&gt;2&lt;/code&gt; represents an error.&lt;/p&gt;

&lt;p&gt;Knowing where to look is often half the troubleshooting process.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Disk Space and Storage Diagnostics
&lt;/h2&gt;

&lt;p&gt;A full disk can cause unexpected problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Applications fail to write files.&lt;/li&gt;
&lt;li&gt;Package installations stop.&lt;/li&gt;
&lt;li&gt;Databases become unavailable.&lt;/li&gt;
&lt;li&gt;Docker containers fail.&lt;/li&gt;
&lt;li&gt;Build processes crash.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Check available disk space
&lt;/h3&gt;

&lt;p&gt;Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;df -h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;df -h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;PSDrive&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;PSProvider&lt;/span&gt; &lt;span class="nc"&gt;FileSystem&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Windows CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wmic logicaldisk get DeviceID,Size,FreeSpace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: WMIC is deprecated and may not be installed on newer Windows versions. PowerShell is generally preferable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Find large directories
&lt;/h3&gt;

&lt;p&gt;Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;du -sh *
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;du -sh *
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Directory&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="k"&gt;ForEach&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FullName&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ErrorAction&lt;/span&gt; &lt;span class="nc"&gt;SilentlyContinue&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
                &lt;span class="nc"&gt;Measure&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Property&lt;/span&gt; &lt;span class="nc"&gt;Length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Sum&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Sum&lt;/span&gt;

        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;PSCustomObject&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;@&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;Directory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt;
            &lt;span class="nc"&gt;SizeMB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;Round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$size&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1MB&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Sort&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nc"&gt;SizeMB&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Descending&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PowerShell example recursively measures files and can take time on large directories. It may also omit inaccessible files.&lt;/p&gt;

&lt;h3&gt;
  
  
  Find large files
&lt;/h3&gt;

&lt;p&gt;Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find . -type f -size +100M
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find . -type f -size +100M
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Where&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;gt&lt;/span&gt; &lt;span class="mi"&gt;100MB&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nc"&gt;FullName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Length&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Check Docker disk usage
&lt;/h3&gt;

&lt;p&gt;If you're a developer using Docker, inspect its storage usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker system df
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can inspect containers and images:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker ps -a
docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't blindly run cleanup commands such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker system prune -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;They can remove unused images, containers, networks, and build cache. Understand what will be removed before confirming a cleanup operation.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Package Managers: Keep Your Tools Updated
&lt;/h2&gt;

&lt;p&gt;Package managers make it easier to install, update, and remove software.&lt;/p&gt;

&lt;p&gt;Different operating systems commonly use different package managers.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Platform&lt;/th&gt;
&lt;th&gt;Package manager&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;td&gt;Winget&lt;/td&gt;
&lt;td&gt;&lt;code&gt;winget install Git.Git&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;macOS&lt;/td&gt;
&lt;td&gt;Homebrew&lt;/td&gt;
&lt;td&gt;&lt;code&gt;brew install git&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ubuntu/Debian&lt;/td&gt;
&lt;td&gt;APT&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sudo apt install git&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fedora&lt;/td&gt;
&lt;td&gt;DNF&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sudo dnf install git&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Arch Linux&lt;/td&gt;
&lt;td&gt;Pacman&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sudo pacman -S git&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Update package information and software
&lt;/h3&gt;

&lt;p&gt;Ubuntu/Debian:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt update
sudo apt upgrade
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fedora:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo dnf upgrade
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew update
brew upgrade
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Windows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;winget&lt;/span&gt; &lt;span class="n"&gt;upgrade&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;all&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Package managers are not interchangeable.&lt;/p&gt;

&lt;p&gt;Always check the package manager available on your system and review what an upgrade will change.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Advanced Pipelines: Connect Tools Together
&lt;/h2&gt;

&lt;p&gt;One of the most powerful terminal concepts is the pipeline.&lt;/p&gt;

&lt;p&gt;A pipeline sends the output of one command into another command.&lt;/p&gt;

&lt;h3&gt;
  
  
  Find the most frequently occurring values
&lt;/h3&gt;

&lt;p&gt;Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sort access.log &lt;span class="o"&gt;|&lt;/span&gt;
    uniq -c &lt;span class="o"&gt;|&lt;/span&gt;
    sort -nr &lt;span class="o"&gt;|&lt;/span&gt;
    head -10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sorts the lines.&lt;/li&gt;
&lt;li&gt;Counts repeated lines.&lt;/li&gt;
&lt;li&gt;Sorts the counts numerically in descending order.&lt;/li&gt;
&lt;li&gt;Displays the first ten results.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It is a simple way to discover repeated log entries.&lt;/p&gt;

&lt;h3&gt;
  
  
  Find large files and sort them
&lt;/h3&gt;

&lt;p&gt;Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find . -type f -printf &lt;span class="s1"&gt;'%s %p\n'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    sort -nr &lt;span class="o"&gt;|&lt;/span&gt;
    head -10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This particular &lt;code&gt;find&lt;/code&gt; format is supported by GNU find, not the default BSD &lt;code&gt;find&lt;/code&gt; on macOS.&lt;/p&gt;

&lt;p&gt;A more portable macOS alternative is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find . -type f -exec du -h &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt; + &lt;span class="o"&gt;|&lt;/span&gt;
    sort -hr &lt;span class="o"&gt;|&lt;/span&gt;
    head -10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output and sorting behavior can vary slightly across platforms.&lt;/p&gt;

&lt;h3&gt;
  
  
  PowerShell pipeline example
&lt;/h3&gt;

&lt;p&gt;PowerShell pipelines pass objects rather than just plain text.&lt;/p&gt;

&lt;p&gt;Find the ten largest files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Sort&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nc"&gt;Length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Descending&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;First&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="nc"&gt;FullName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Length&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a major PowerShell advantage.&lt;/p&gt;

&lt;p&gt;Instead of parsing formatted text, you can directly work with object properties such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Name&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;FullName&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Length&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;LastWriteTime&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Extension&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding the difference between text pipelines and object pipelines helps you write much more reliable scripts.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Manage Background Tasks and Long-Running Commands
&lt;/h2&gt;

&lt;p&gt;Not every command finishes immediately.&lt;/p&gt;

&lt;p&gt;Build processes, downloads, database operations, and development servers may run for a long time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bash: run a process in the background
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;&amp;amp;&lt;/code&gt; starts the command in the background.&lt;/p&gt;

&lt;p&gt;See background jobs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;jobs&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bring a job to the foreground:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;fg&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also run a process with &lt;code&gt;nohup&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nohup npm run dev &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; app.log 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1 &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This allows the process to continue after the terminal session ends in common shell environments.&lt;/p&gt;

&lt;p&gt;However, it is not a full service manager. For production services, use an appropriate process manager or operating-system service mechanism.&lt;/p&gt;

&lt;h3&gt;
  
  
  PowerShell: Start-Process
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Start&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;FilePath&lt;/span&gt; &lt;span class="s2"&gt;"node"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ArgumentList&lt;/span&gt; &lt;span class="s2"&gt;"server.js"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start a process and redirect its output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Start&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="sb"&gt;`
    -FilePath "node" `&lt;/span&gt;
    &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ArgumentList&lt;/span&gt; &lt;span class="s2"&gt;"server.js"&lt;/span&gt; &lt;span class="sb"&gt;`
    -RedirectStandardOutput "output.log" `&lt;/span&gt;
    &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;RedirectStandardError&lt;/span&gt; &lt;span class="s2"&gt;"error.log"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Inspect running processes
&lt;/h3&gt;

&lt;p&gt;Bash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ps aux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stop a process
&lt;/h3&gt;

&lt;p&gt;Bash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;kill&lt;/span&gt; 1234
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Stop&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="mi"&gt;1234&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Always verify the process ID before stopping a process, especially on shared or production systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Terminal Productivity: Work Faster Without Memorizing Everything
&lt;/h2&gt;

&lt;p&gt;A professional terminal workflow is not just about powerful commands.&lt;/p&gt;

&lt;p&gt;It's also about reducing friction.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Use command history
&lt;/h3&gt;

&lt;p&gt;Bash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;history&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Search interactively in many Bash configurations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ctrl + R
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;History&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use &lt;code&gt;Ctrl + R&lt;/code&gt; in common PSReadLine configurations to search history.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Use aliases
&lt;/h3&gt;

&lt;p&gt;Bash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;ll&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'ls -lah'&lt;/span&gt;
&lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;gs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'git status'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Alias&lt;/span&gt; &lt;span class="n"&gt;ll&lt;/span&gt; &lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a more customized PowerShell alias, define a function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;gs&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Aliases are useful for frequently repeated commands, but don't overuse them.&lt;/p&gt;

&lt;p&gt;A script should remain understandable to someone who doesn't know your personal aliases.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Use tab completion
&lt;/h3&gt;

&lt;p&gt;Instead of typing an entire directory name, start typing and press:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Tab
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most modern shells support some form of completion.&lt;/p&gt;

&lt;p&gt;It can help complete:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;File names&lt;/li&gt;
&lt;li&gt;Directory paths&lt;/li&gt;
&lt;li&gt;Commands&lt;/li&gt;
&lt;li&gt;Parameters&lt;/li&gt;
&lt;li&gt;Git branches, with suitable configuration&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Use terminal multiplexers
&lt;/h3&gt;

&lt;p&gt;On Linux and macOS, tools such as &lt;code&gt;tmux&lt;/code&gt; allow you to manage multiple terminal sessions in one window.&lt;/p&gt;

&lt;p&gt;Start a session:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tmux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Detach from a session:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ctrl + B, then D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;List sessions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tmux ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reattach:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tmux attach
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is especially useful when working with remote servers over SSH.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Customize your shell
&lt;/h3&gt;

&lt;p&gt;Popular options include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Zsh with Oh My Zsh&lt;/li&gt;
&lt;li&gt;Starship prompt&lt;/li&gt;
&lt;li&gt;PowerShell profiles&lt;/li&gt;
&lt;li&gt;PSReadLine&lt;/li&gt;
&lt;li&gt;Fish shell&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A good terminal setup can provide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git branch information&lt;/li&gt;
&lt;li&gt;Command execution duration&lt;/li&gt;
&lt;li&gt;Current directory&lt;/li&gt;
&lt;li&gt;Tool versions&lt;/li&gt;
&lt;li&gt;Useful completions&lt;/li&gt;
&lt;li&gt;Syntax highlighting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keep customization practical. A beautiful prompt is nice, but a fast and understandable workflow is more important.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. Practical Troubleshooting Scenarios
&lt;/h2&gt;

&lt;p&gt;Let's test everything with some realistic problems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scenario A: Port Already in Use
&lt;/h3&gt;

&lt;p&gt;You start a development server and receive:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: listen EADDRINUSE: address already in use
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means another process is already listening on the requested port.&lt;/p&gt;

&lt;p&gt;Find the process.&lt;/p&gt;

&lt;p&gt;Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo ss -ltnp &lt;span class="o"&gt;|&lt;/span&gt; grep &lt;span class="s1"&gt;':3000'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lsof -i :3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Windows PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetTCPConnection&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;LocalPort&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;State&lt;/span&gt; &lt;span class="nc"&gt;Listen&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nc"&gt;LocalAddress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;LocalPort&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;OwningProcess&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Find the process name in PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="mi"&gt;1234&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it's safe to stop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Stop&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="mi"&gt;1234&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or on Linux/macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;kill&lt;/span&gt; 1234
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't terminate a process until you know what it is and whether stopping it is safe.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scenario B: Command Not Found
&lt;/h3&gt;

&lt;p&gt;You run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But the shell responds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;command not found
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Possible causes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git isn't installed.&lt;/li&gt;
&lt;li&gt;Git isn't in PATH.&lt;/li&gt;
&lt;li&gt;The current shell hasn't loaded updated environment settings.&lt;/li&gt;
&lt;li&gt;The executable has a different name.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;command&lt;/span&gt; -v git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Command&lt;/span&gt; &lt;span class="n"&gt;git&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;where git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If Git isn't installed, use the appropriate package manager for your platform.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scenario C: Permission Denied
&lt;/h3&gt;

&lt;p&gt;You try to execute a script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./deploy.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And receive:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Permission denied
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check its permissions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -l deploy.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it is your script and should be executable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chmod +x deploy.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bash deploy.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Windows, permission problems may involve NTFS permissions, application access, or PowerShell execution policies. Diagnose the actual error rather than applying Unix permission commands to Windows.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scenario D: DNS Resolution Failure
&lt;/h3&gt;

&lt;p&gt;You try to access an API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://api.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But the hostname cannot be resolved.&lt;/p&gt;

&lt;p&gt;Check DNS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nslookup api.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig api.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Resolve&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;DnsName&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then check basic connectivity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ping api.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember that some servers block ICMP, so a failed ping does not necessarily mean the service is unreachable.&lt;/p&gt;

&lt;p&gt;You can also test HTTPS connectivity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Test&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetConnection&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Port&lt;/span&gt; &lt;span class="mi"&gt;443&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Scenario E: Application Works Locally but Not on Another Device
&lt;/h3&gt;

&lt;p&gt;You start a development server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It works on your own computer but isn't accessible from another device on the same network.&lt;/p&gt;

&lt;p&gt;Possible causes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The development server listens only on &lt;code&gt;localhost&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The firewall blocks incoming connections.&lt;/li&gt;
&lt;li&gt;The devices are on different networks.&lt;/li&gt;
&lt;li&gt;The server is using an unexpected port.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For Vite, you can expose the development server to the local network:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev -- --host 0.0.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then find your local IP address.&lt;/p&gt;

&lt;p&gt;Windows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;ipconfig&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip addr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ifconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the application from another device using the host's LAN address and the development server's port.&lt;/p&gt;

&lt;p&gt;Only expose development servers on networks you trust. Binding to &lt;code&gt;0.0.0.0&lt;/code&gt; makes the service listen on all available network interfaces, which can expose it beyond the intended audience depending on your network and firewall configuration.&lt;/p&gt;




&lt;h2&gt;
  
  
  12. Create Your Personal Terminal Toolkit
&lt;/h2&gt;

&lt;p&gt;At this point, you have learned many commands.&lt;/p&gt;

&lt;p&gt;But you don't need to memorize all of them.&lt;/p&gt;

&lt;p&gt;Instead, build a small collection of reusable scripts and notes.&lt;/p&gt;

&lt;p&gt;A possible structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terminal-toolkit/
├── bash/
│   ├── backup.sh
│   ├── create-project.sh
│   └── system-info.sh
│
├── powershell/
│   ├── Backup-Project.ps1
│   ├── Create-Project.ps1
│   └── Get-SystemInfo.ps1
│
├── docs/
│   ├── networking.md
│   ├── permissions.md
│   └── troubleshooting.md
│
└── README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep the toolkit in a Git repository.&lt;/p&gt;

&lt;p&gt;That gives you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Version history&lt;/li&gt;
&lt;li&gt;Reusable scripts&lt;/li&gt;
&lt;li&gt;Documentation&lt;/li&gt;
&lt;li&gt;A way to share improvements&lt;/li&gt;
&lt;li&gt;A personal reference for future projects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can gradually add scripts as you discover repetitive tasks in your daily work.&lt;/p&gt;

&lt;h2&gt;
  
  
  13. A Professional Terminal Checklist
&lt;/h2&gt;

&lt;p&gt;Before finishing this series, check whether you can perform the following tasks.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Navigate between directories using absolute and relative paths.&lt;/li&gt;
&lt;li&gt;[ ] Create, copy, move, rename, and delete files.&lt;/li&gt;
&lt;li&gt;[ ] Search files and inspect their contents.&lt;/li&gt;
&lt;li&gt;[ ] Combine commands using pipes and redirection.&lt;/li&gt;
&lt;li&gt;[ ] Understand file permissions and administrative privileges.&lt;/li&gt;
&lt;li&gt;[ ] Inspect and manage running processes.&lt;/li&gt;
&lt;li&gt;[ ] Diagnose basic networking problems.&lt;/li&gt;
&lt;li&gt;[ ] Use developer-oriented terminal tools.&lt;/li&gt;
&lt;li&gt;[ ] Write Bash and PowerShell scripts.&lt;/li&gt;
&lt;li&gt;[ ] Work with variables, arguments, loops, and functions.&lt;/li&gt;
&lt;li&gt;[ ] Read logs and identify common errors.&lt;/li&gt;
&lt;li&gt;[ ] Inspect environment variables and PATH.&lt;/li&gt;
&lt;li&gt;[ ] Connect to remote machines using SSH.&lt;/li&gt;
&lt;li&gt;[ ] Diagnose port conflicts and DNS failures.&lt;/li&gt;
&lt;li&gt;[ ] Build reusable automation workflows.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you can do most of these without constantly searching for examples, you're developing a strong command-line foundation.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion: The Terminal Is a Developer's Superpower
&lt;/h2&gt;

&lt;p&gt;The terminal isn't an old-fashioned alternative to graphical interfaces.&lt;/p&gt;

&lt;p&gt;It's a powerful environment for controlling your computer, automating repetitive tasks, managing remote systems, and solving problems.&lt;/p&gt;

&lt;p&gt;Throughout this series, we've covered:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Terminal fundamentals.&lt;/li&gt;
&lt;li&gt;Filesystem navigation.&lt;/li&gt;
&lt;li&gt;Searching and managing files.&lt;/li&gt;
&lt;li&gt;Pipes and command chaining.&lt;/li&gt;
&lt;li&gt;Users and permissions.&lt;/li&gt;
&lt;li&gt;Process management.&lt;/li&gt;
&lt;li&gt;Networking.&lt;/li&gt;
&lt;li&gt;Developer terminal tools.&lt;/li&gt;
&lt;li&gt;Shell scripting.&lt;/li&gt;
&lt;li&gt;Advanced workflows and troubleshooting.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The most important lesson is simple:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't try to memorize every command. Learn how to investigate problems, combine tools, and build workflows.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's how you move from someone who occasionally uses the terminal to someone who can confidently work with it.&lt;/p&gt;

&lt;p&gt;And remember: the best terminal workflow is the one that makes your work simpler, safer, and more repeatable.&lt;/p&gt;

&lt;p&gt;Thanks for following this series!&lt;/p&gt;

&lt;p&gt;Happy coding. 🚀&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Tags:&lt;/strong&gt; &lt;code&gt;terminal&lt;/code&gt; &lt;code&gt;productivity&lt;/code&gt; &lt;code&gt;devtools&lt;/code&gt; &lt;code&gt;beginners&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Series:&lt;/strong&gt; Terminal Mastery: Windows, macOS &amp;amp; Linux&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reading level:&lt;/strong&gt; Intermediate&lt;/p&gt;

</description>
      <category>terminal</category>
      <category>productivity</category>
      <category>devtools</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Terminal Mastery-Automate Your Workflow with Shell Scripting</title>
      <dc:creator>Hamed Farazi</dc:creator>
      <pubDate>Sun, 15 Nov 2026 11:16:30 +0000</pubDate>
      <link>https://dev.to/hamedfarazi/terminal-mastery-automate-your-workflow-with-shell-scripting-5a08</link>
      <guid>https://dev.to/hamedfarazi/terminal-mastery-automate-your-workflow-with-shell-scripting-5a08</guid>
      <description>&lt;p&gt;09/10 -Automate Your Workflow with Shell Scripting&lt;br&gt;
You've learned how to navigate directories, search files, manage processes, troubleshoot networks, and use powerful command-line tools.&lt;/p&gt;

&lt;p&gt;But there's another level of terminal mastery:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What if you could turn a sequence of commands into a reusable program?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of typing the same commands every morning, you could run one script. Instead of manually creating project folders, you could generate them automatically. Instead of copying files one by one, you could build a backup workflow that does the job for you.&lt;/p&gt;

&lt;p&gt;That's what shell scripting is all about.&lt;/p&gt;

&lt;p&gt;In this article, we'll learn how to write practical scripts for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linux and macOS using Bash&lt;/li&gt;
&lt;li&gt;Windows using PowerShell&lt;/li&gt;
&lt;li&gt;Variables, arguments, conditions, loops, and functions&lt;/li&gt;
&lt;li&gt;Error handling and exit codes&lt;/li&gt;
&lt;li&gt;Automating real developer workflows&lt;/li&gt;
&lt;li&gt;Debugging and maintaining scripts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By the end, you'll have the knowledge to automate repetitive tasks across all three operating systems.&lt;/p&gt;


&lt;h2&gt;
  
  
  1. What Is a Shell Script?
&lt;/h2&gt;

&lt;p&gt;A shell script is a file containing commands that a shell executes in sequence.&lt;/p&gt;

&lt;p&gt;Think about a task you perform regularly:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a project directory.&lt;/li&gt;
&lt;li&gt;Create &lt;code&gt;src&lt;/code&gt;, &lt;code&gt;tests&lt;/code&gt;, and &lt;code&gt;docs&lt;/code&gt; folders.&lt;/li&gt;
&lt;li&gt;Add a README file.&lt;/li&gt;
&lt;li&gt;Create a &lt;code&gt;.gitignore&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Print a success message.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You could execute every command manually.&lt;/p&gt;

&lt;p&gt;Or you could save those commands in a file and run that file whenever you need the same setup.&lt;/p&gt;

&lt;p&gt;That's a script.&lt;/p&gt;
&lt;h3&gt;
  
  
  Commands vs. scripts
&lt;/h3&gt;

&lt;p&gt;A command is usually a single instruction:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir my-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A script can combine multiple instructions, variables, conditions, loops, and functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

mkdir -p my-project/src
mkdir -p my-project/tests
mkdir -p my-project/docs

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Project structure created!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important difference is reusability.&lt;/p&gt;

&lt;p&gt;You write the workflow once and execute it whenever you need it.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Bash vs. PowerShell
&lt;/h2&gt;

&lt;p&gt;Before writing scripts, let's understand the two environments we'll use.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Bash&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Common platforms&lt;/td&gt;
&lt;td&gt;Linux, macOS&lt;/td&gt;
&lt;td&gt;Windows, Linux, macOS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typical extension&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.sh&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.ps1&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Common interactive shell&lt;/td&gt;
&lt;td&gt;Bash / Zsh&lt;/td&gt;
&lt;td&gt;PowerShell&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Variables&lt;/td&gt;
&lt;td&gt;&lt;code&gt;$name&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;$name&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Comments&lt;/td&gt;
&lt;td&gt;&lt;code&gt;#&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;#&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Main pipeline model&lt;/td&gt;
&lt;td&gt;Text streams&lt;/td&gt;
&lt;td&gt;Objects&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Common script command&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bash script.sh&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.\script.ps1&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Bash is widely used on Linux servers and macOS development machines.&lt;/p&gt;

&lt;p&gt;PowerShell is the primary scripting environment in modern Windows administration, but it also runs on Linux and macOS.&lt;/p&gt;

&lt;p&gt;You don't need to learn both at once. Start with the environment you use most often, then learn the other.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Creating Your First Script
&lt;/h2&gt;

&lt;p&gt;Let's create a simple script that prints a message.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bash
&lt;/h3&gt;

&lt;p&gt;Create a file named &lt;code&gt;hello.sh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello from Bash!"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Welcome to shell scripting."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first line is called a &lt;em&gt;shebang&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It tells the operating system which interpreter should execute the script when you run it directly.&lt;/p&gt;

&lt;p&gt;Run it using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bash hello.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Linux and macOS, you can also make it executable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chmod +x hello.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./hello.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PowerShell
&lt;/h3&gt;

&lt;p&gt;Create a file named &lt;code&gt;hello.ps1&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"Hello from PowerShell!"&lt;/span&gt;
&lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"Welcome to shell scripting."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it from PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="p"&gt;.&lt;/span&gt;\&lt;span class="n"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ps1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the &lt;code&gt;.\&lt;/code&gt; prefix.&lt;/p&gt;

&lt;p&gt;It tells PowerShell to execute a script from the current directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  A note about PowerShell execution policies
&lt;/h3&gt;

&lt;p&gt;You might encounter an error saying that script execution is disabled.&lt;/p&gt;

&lt;p&gt;Check your current policies with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ExecutionPolicy&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell execution policies control the conditions under which scripts can run. They are not a complete security boundary.&lt;/p&gt;

&lt;p&gt;On managed computers, follow your organization's policy rather than changing it yourself. Avoid setting the policy to &lt;code&gt;Unrestricted&lt;/code&gt; as a general workaround.&lt;/p&gt;

&lt;p&gt;If you are using a personal machine, understand the scope and implications of any policy change before making one.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Variables: Store and Reuse Values
&lt;/h2&gt;

&lt;p&gt;Variables let you store information and use it throughout a script.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bash
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Hamed"&lt;/span&gt;
&lt;span class="nv"&gt;language&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Bash"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello, $name!"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"You are learning $language."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Important: Bash does not allow spaces around the assignment operator.&lt;/p&gt;

&lt;p&gt;Correct:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Hamed"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Incorrect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;name &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Hamed"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PowerShell
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Hamed"&lt;/span&gt;
&lt;span class="nv"&gt;$language&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"PowerShell"&lt;/span&gt;

&lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"Hello, $name!"&lt;/span&gt;
&lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"You are learning $language."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell variable names begin with &lt;code&gt;$&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why variables matter
&lt;/h3&gt;

&lt;p&gt;Imagine writing a backup script that copies a project directory.&lt;/p&gt;

&lt;p&gt;Without variables, you might hardcode the same directory in several places.&lt;/p&gt;

&lt;p&gt;With variables, you define it once:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;project_dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/home/user/my-project"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then reuse it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Backing up $project_dir"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes scripts easier to update and maintain.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Getting Input from the User
&lt;/h2&gt;

&lt;p&gt;Scripts become more flexible when users can provide information.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bash: &lt;code&gt;read&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nb"&gt;read&lt;/span&gt; -r -p &lt;span class="s2"&gt;"What is your name? "&lt;/span&gt; name

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello, $name!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;read&lt;/code&gt; command waits for user input and stores it in a variable.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;-r&lt;/code&gt; option prevents backslashes from being interpreted as escape characters.&lt;/p&gt;

&lt;h3&gt;
  
  
  PowerShell: &lt;code&gt;Read-Host&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Read&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"What is your name?"&lt;/span&gt;

&lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"Hello, $name!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both scripts ask a question and use the answer.&lt;/p&gt;

&lt;p&gt;This is useful when building setup scripts, interactive tools, and small automation utilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Passing Arguments to Scripts
&lt;/h2&gt;

&lt;p&gt;Sometimes you don't want a script to ask questions.&lt;/p&gt;

&lt;p&gt;You want to provide information when executing it.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bash greet.sh Hamed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Bash arguments
&lt;/h3&gt;

&lt;p&gt;Inside a Bash script:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Variable&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Script name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;First argument&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$2&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Second argument&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$@&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;All arguments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$#&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Number of arguments&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${1:-Developer}"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello, $name!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bash greet.sh Hamed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, Hamed!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If no argument is provided, the script uses &lt;code&gt;Developer&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;One important rule: quote arguments when passing them to other commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;some_command &lt;span class="s2"&gt;"$@"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This preserves arguments containing spaces and prevents unwanted word splitting.&lt;/p&gt;

&lt;h3&gt;
  
  
  PowerShell arguments
&lt;/h3&gt;

&lt;p&gt;PowerShell supports a &lt;code&gt;param&lt;/code&gt; block:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="k"&gt;param&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="nv"&gt;$Name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Developer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="nv"&gt;$Age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"Name: $Name"&lt;/span&gt;
&lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"Age: $Age"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="p"&gt;.&lt;/span&gt;\&lt;span class="n"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ps1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="s2"&gt;"Hamed"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Age&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Named parameters make PowerShell scripts easier to understand and maintain.&lt;/p&gt;

&lt;p&gt;For reusable scripts, prefer &lt;code&gt;param()&lt;/code&gt; over manually reading values from &lt;code&gt;$args&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Conditions: Make Decisions in Your Scripts
&lt;/h2&gt;

&lt;p&gt;A script should sometimes behave differently depending on the situation.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does a directory exist?&lt;/li&gt;
&lt;li&gt;Was a required argument provided?&lt;/li&gt;
&lt;li&gt;Is a file empty?&lt;/li&gt;
&lt;li&gt;Did a command succeed?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's where conditions come in.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bash: &lt;code&gt;if&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${1:-}"&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; -z &lt;span class="s2"&gt;"$name"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Please provide a name."&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello, $name!"&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;-z&lt;/code&gt; checks whether a string is empty.&lt;/p&gt;

&lt;p&gt;Some useful Bash comparisons:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operator&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-z&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;String is empty&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-n&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;String is not empty&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;==&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Strings are equal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-eq&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Numbers are equal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-gt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Greater than&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-lt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Less than&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-f&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Regular file exists&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-d&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Directory exists&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;age&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;20

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$age"&lt;/span&gt; -ge 18 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"You are an adult."&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"You are under 18."&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PowerShell: &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;elseif&lt;/code&gt;, and &lt;code&gt;else&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$age&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ge&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"You are an adult."&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;elseif&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$age&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ge&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"You are a teenager."&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"You are a child."&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some useful PowerShell comparison operators:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operator&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-eq&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Equal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-ne&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Not equal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-gt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Greater than&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-lt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Less than&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-ge&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Greater than or equal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-le&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Less than or equal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-like&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Wildcard matching&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-match&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Regular expression matching&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Unlike many programming languages, PowerShell uses comparison operators such as &lt;code&gt;-eq&lt;/code&gt; and &lt;code&gt;-gt&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Loops: Repeat Tasks Automatically
&lt;/h2&gt;

&lt;p&gt;Loops are especially useful when processing multiple files or directories.&lt;/p&gt;

&lt;p&gt;Imagine you have 100 text files and want to perform the same operation on each one.&lt;/p&gt;

&lt;p&gt;You don't need to write the command 100 times.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bash: &lt;code&gt;for&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; name &lt;span class="k"&gt;in&lt;/span&gt; Alice Bob Charlie&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello, $name!"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also loop through files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; file &lt;span class="k"&gt;in&lt;/span&gt; *.txt&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Processing: $file"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example uses filename expansion.&lt;/p&gt;

&lt;p&gt;One detail: if no files match &lt;code&gt;*.txt&lt;/code&gt;, Bash normally leaves the pattern unchanged. For scripts where that matters, consider enabling &lt;code&gt;nullglob&lt;/code&gt; or checking whether the file exists before processing it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bash: &lt;code&gt;while&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$counter"&lt;/span&gt; -le 5 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Count: $counter"&lt;/span&gt;
    &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;counter++&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PowerShell: &lt;code&gt;foreach&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; @&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Alice"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Bob"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Charlie"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$name&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$names&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"Hello, $name!"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PowerShell: &lt;code&gt;for&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;le&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"Count: $i"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PowerShell: &lt;code&gt;while&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$counter&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;le&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"Count: $counter"&lt;/span&gt;
    &lt;span class="nv"&gt;$counter&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Loops are the foundation of file processing, batch operations, and repetitive automation.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Functions: Organize Your Scripts
&lt;/h2&gt;

&lt;p&gt;As scripts become larger, repeating the same code makes them harder to maintain.&lt;/p&gt;

&lt;p&gt;Functions solve this problem.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bash functions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

greet&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$1"&lt;/span&gt;

    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello, $name!"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

greet &lt;span class="s2"&gt;"Hamed"&lt;/span&gt;
greet &lt;span class="s2"&gt;"Developer"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;local&lt;/code&gt; keyword keeps the variable inside the function's scope.&lt;/p&gt;

&lt;p&gt;A useful Bash detail: &lt;code&gt;return&lt;/code&gt; is primarily used to return an exit status, not a string value. To produce text from a function, use standard output.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;get_greeting&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'Hello, %s!\n'&lt;/span&gt; &lt;span class="s2"&gt;"$1"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="nv"&gt;message&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$(get_greeting "&lt;/span&gt;Hamed&lt;span class="s2"&gt;")"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$message"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PowerShell functions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Greeting&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;param&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="nv"&gt;$Name&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="s2"&gt;"Hello, $Name!"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nv"&gt;$message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Greeting&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="s2"&gt;"Hamed"&lt;/span&gt;

&lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="nv"&gt;$message&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell functions can emit objects through the pipeline. Their output is not limited to strings.&lt;/p&gt;

&lt;p&gt;This is one of the major differences between Bash and PowerShell: PowerShell is designed around structured objects rather than treating everything as plain text.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Exit Codes: Know Whether a Command Succeeded
&lt;/h2&gt;

&lt;p&gt;Automation isn't just about running commands.&lt;/p&gt;

&lt;p&gt;It's also about knowing whether they worked.&lt;/p&gt;

&lt;p&gt;Most command-line programs communicate success or failure through an exit code.&lt;/p&gt;

&lt;p&gt;A common convention is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;0&lt;/code&gt;: Success&lt;/li&gt;
&lt;li&gt;Non-zero: Some kind of failure&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Bash
&lt;/h3&gt;

&lt;p&gt;The special variable &lt;code&gt;$?&lt;/code&gt; contains the exit status of the most recently executed command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir test-folder

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$?"&lt;/span&gt; -eq 0 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Directory created successfully."&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Something went wrong."&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A more reliable approach is to use the command directly in a condition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; mkdir test-folder&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Directory created successfully."&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Could not create directory."&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also explicitly exit a script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;exit&lt;/span&gt; 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or indicate failure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PowerShell
&lt;/h3&gt;

&lt;p&gt;PowerShell has two important variables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;$?&lt;/code&gt;: Indicates whether the most recent PowerShell operation succeeded.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;$LASTEXITCODE&lt;/code&gt;: Contains the exit code returned by the last native executable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;node&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$LASTEXITCODE&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;eq&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"Node.js is available."&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"Node.js command failed."&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't confuse &lt;code&gt;$?&lt;/code&gt; with &lt;code&gt;$LASTEXITCODE&lt;/code&gt;. When working with external programs such as &lt;code&gt;node&lt;/code&gt;, &lt;code&gt;git&lt;/code&gt;, or &lt;code&gt;npm&lt;/code&gt;, check &lt;code&gt;$LASTEXITCODE&lt;/code&gt; when you need the native program's actual exit code.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. Error Handling: Make Scripts More Reliable
&lt;/h2&gt;

&lt;p&gt;A script that works only when everything goes perfectly isn't very useful.&lt;/p&gt;

&lt;p&gt;Real automation needs to handle unexpected situations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bash: safer execution
&lt;/h3&gt;

&lt;p&gt;You'll often see this near the beginning of Bash scripts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;set&lt;/span&gt; -Eeuo pipefail
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's what the options generally mean:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-e&lt;/code&gt;: Exit when an eligible command fails.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-E&lt;/code&gt;: Allow &lt;code&gt;ERR&lt;/code&gt; traps to be inherited by functions and certain command contexts.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-u&lt;/code&gt;: Treat unset variables as errors.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-o pipefail&lt;/code&gt;: Make a pipeline fail if a command within it fails, rather than only considering the last command.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These options improve reliability, but they aren't a complete error-handling system. In particular, &lt;code&gt;-e&lt;/code&gt; has exceptions and context-dependent behavior. Explicitly check important operations.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nb"&gt;set&lt;/span&gt; -Eeuo pipefail

&lt;span class="k"&gt;if&lt;/span&gt; ! mkdir -p &lt;span class="s2"&gt;"my-project"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Could not create project directory."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
    &lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Project directory is ready."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;&amp;gt;&amp;amp;2&lt;/code&gt; redirects the error message to standard error.&lt;/p&gt;

&lt;h3&gt;
  
  
  PowerShell: try and catch
&lt;/h3&gt;

&lt;p&gt;PowerShell provides structured exception handling:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ErrorActionPreference&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Stop"&lt;/span&gt;

&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;Directory&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="s2"&gt;"my-project"&lt;/span&gt;

    &lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"Project directory created."&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Error&lt;/span&gt; &lt;span class="s2"&gt;"Something went wrong: $_"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="s2"&gt;"Operation finished."&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The three main blocks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;try&lt;/code&gt;: Code that might fail.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;catch&lt;/code&gt;: Handles terminating errors.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;finally&lt;/code&gt;: Runs whether an error occurs or not.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Setting &lt;code&gt;$ErrorActionPreference&lt;/code&gt; to &lt;code&gt;Stop&lt;/code&gt; makes many otherwise non-terminating PowerShell errors catchable.&lt;/p&gt;

&lt;p&gt;However, native programs have their own exit-code behavior. Check &lt;code&gt;$LASTEXITCODE&lt;/code&gt; separately when running external executables.&lt;/p&gt;

&lt;h2&gt;
  
  
  12. Practical Project: Automatically Create a Project Structure
&lt;/h2&gt;

&lt;p&gt;Let's put our knowledge into practice.&lt;/p&gt;

&lt;p&gt;Suppose you frequently create small development projects and want a standard directory structure.&lt;/p&gt;

&lt;p&gt;Every project should contain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my-project/
├── src/
├── tests/
├── docs/
├── README.md
└── .gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll create one script for Bash and another for PowerShell.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bash version
&lt;/h3&gt;

&lt;p&gt;Create &lt;code&gt;create-project.sh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nb"&gt;set&lt;/span&gt; -Eeuo pipefail

&lt;span class="nv"&gt;PROJECT_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${1:-my-project}"&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; -e &lt;span class="s2"&gt;"$PROJECT_NAME"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Error: '$PROJECT_NAME' already exists."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
    &lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;span class="k"&gt;fi&lt;/span&gt;

mkdir -p &lt;span class="s2"&gt;"$PROJECT_NAME"&lt;/span&gt;/&lt;span class="o"&gt;{&lt;/span&gt;src,tests,docs&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"$PROJECT_NAME"&lt;/span&gt;

cat &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; README.md &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;EOF
&lt;span class="c"&gt;# $PROJECT_NAME&lt;/span&gt;

Project documentation.
EOF

cat &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .gitignore &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s1"&gt;'EOF'&lt;/span&gt;
node_modules/
dist/
.env
EOF

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Project '$PROJECT_NAME' created successfully!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make it executable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chmod +x create-project.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./create-project.sh my-awesome-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PowerShell version
&lt;/h3&gt;

&lt;p&gt;Create &lt;code&gt;Create-Project.ps1&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="k"&gt;param&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="nv"&gt;$ProjectName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"my-project"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nv"&gt;$ErrorActionPreference&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Stop"&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Test&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;LiteralPath&lt;/span&gt; &lt;span class="nv"&gt;$ProjectName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;"The project '$ProjectName' already exists."&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;Directory&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="nv"&gt;$ProjectName&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Out&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="kc"&gt;Null&lt;/span&gt;

&lt;span class="nv"&gt;$directories&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; @&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"src"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"tests"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"docs"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$directory&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$directories&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;Directory&lt;/span&gt; &lt;span class="sb"&gt;`
        -Path (Join-Path $ProjectName $directory) |
        Out-Null
}

$readme = "# $ProjectName`&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="sb"&gt;`nProject documentation."

$gitignore = @"
node_modules/
dist/
.env
"@

Set-Content `&lt;/span&gt;
    &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Join&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="nv"&gt;$ProjectName&lt;/span&gt; &lt;span class="s2"&gt;"README.md"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="sb"&gt;`
    -Value $readme

Set-Content `&lt;/span&gt;
    &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Join&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="nv"&gt;$ProjectName&lt;/span&gt; &lt;span class="s2"&gt;".gitignore"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="sb"&gt;`
    -Value $gitignore

Write-Host "Project '$ProjectName' created successfully!"
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="p"&gt;.&lt;/span&gt;\&lt;span class="nc"&gt;Create&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Project&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ps1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ProjectName&lt;/span&gt; &lt;span class="s2"&gt;"my-awesome-app"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both scripts create the same basic structure.&lt;/p&gt;

&lt;p&gt;That's the beauty of automation: different shells, same outcome.&lt;/p&gt;

&lt;h2&gt;
  
  
  13. Practical Project: Create a Backup Script
&lt;/h2&gt;

&lt;p&gt;Let's build something more useful.&lt;/p&gt;

&lt;p&gt;Imagine you have a project directory that you want to back up regularly.&lt;/p&gt;

&lt;p&gt;Instead of manually copying it, we'll create a script that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Checks whether the source directory exists.&lt;/li&gt;
&lt;li&gt;Creates a backup directory if necessary.&lt;/li&gt;
&lt;li&gt;Adds a timestamp to the backup name.&lt;/li&gt;
&lt;li&gt;Copies the source directory.&lt;/li&gt;
&lt;li&gt;Prints the backup location.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Bash backup script
&lt;/h3&gt;

&lt;p&gt;Create &lt;code&gt;backup.sh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nb"&gt;set&lt;/span&gt; -Eeuo pipefail

&lt;span class="nv"&gt;SOURCE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${1:-}"&lt;/span&gt;
&lt;span class="nv"&gt;BACKUP_ROOT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${2:-$HOME/backups}"&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; -z &lt;span class="s2"&gt;"$SOURCE"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Usage: ./backup.sh &amp;lt;source-directory&amp;gt; [backup-directory]"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
    &lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; ! -d &lt;span class="s2"&gt;"$SOURCE"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Error: Source directory does not exist."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
    &lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="nv"&gt;SOURCE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$(cd -- "&lt;/span&gt;&lt;span class="nv"&gt;$SOURCE&lt;/span&gt;&lt;span class="s2"&gt;" &amp;amp;&amp;amp; pwd)"&lt;/span&gt;

mkdir -p &lt;span class="s2"&gt;"$BACKUP_ROOT"&lt;/span&gt;

&lt;span class="nv"&gt;TIMESTAMP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$(date +%Y%m%d-%H%M%S)"&lt;/span&gt;
&lt;span class="nv"&gt;PROJECT_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$(basename "&lt;/span&gt;&lt;span class="nv"&gt;$SOURCE&lt;/span&gt;&lt;span class="s2"&gt;")"&lt;/span&gt;

&lt;span class="nv"&gt;DESTINATION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$BACKUP_ROOT/${PROJECT_NAME}-${TIMESTAMP}"&lt;/span&gt;

cp -a &lt;span class="s2"&gt;"$SOURCE"&lt;/span&gt; &lt;span class="s2"&gt;"$DESTINATION"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Backup completed successfully!"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Saved to: $DESTINATION"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chmod +x backup.sh

./backup.sh ~/projects/my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or provide a custom backup location:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./backup.sh ~/projects/my-app ~/external-backups
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;cp -a&lt;/code&gt; option preserves important file attributes where supported and copies directories recursively.&lt;/p&gt;

&lt;h3&gt;
  
  
  PowerShell backup script
&lt;/h3&gt;

&lt;p&gt;Create &lt;code&gt;Backup-Project.ps1&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="k"&gt;param&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;Parameter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Mandatory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="nv"&gt;$Source&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="nv"&gt;$BackupRoot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Join&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt; &lt;span class="s2"&gt;"backups"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nv"&gt;$ErrorActionPreference&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Stop"&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Test&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;LiteralPath&lt;/span&gt; &lt;span class="nv"&gt;$Source&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;PathType&lt;/span&gt; &lt;span class="nc"&gt;Container&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;"Source directory does not exist: $Source"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nv"&gt;$Source&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Resolve&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;LiteralPath&lt;/span&gt; &lt;span class="nv"&gt;$Source&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Test&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;LiteralPath&lt;/span&gt; &lt;span class="nv"&gt;$BackupRoot&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;Directory&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="nv"&gt;$BackupRoot&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
        &lt;span class="nc"&gt;Out&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="kc"&gt;Null&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nv"&gt;$timestamp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Date&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Format&lt;/span&gt; &lt;span class="s2"&gt;"yyyyMMdd-HHmmss"&lt;/span&gt;

&lt;span class="nv"&gt;$projectName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Split&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="nv"&gt;$Source&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Leaf&lt;/span&gt;

&lt;span class="nv"&gt;$destination&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Join&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="sb"&gt;`
    $BackupRoot `&lt;/span&gt;
    &lt;span class="s2"&gt;"$projectName-$timestamp"&lt;/span&gt;

&lt;span class="nc"&gt;Copy&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="sb"&gt;`
    -LiteralPath $Source `&lt;/span&gt;
    &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Destination&lt;/span&gt; &lt;span class="nv"&gt;$destination&lt;/span&gt; &lt;span class="sb"&gt;`
    -Recurse

Write-Host "Backup completed successfully!"
Write-Host "Saved to: $destination"
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="p"&gt;.&lt;/span&gt;\&lt;span class="nc"&gt;Backup&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Project&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ps1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Source&lt;/span&gt; &lt;span class="s2"&gt;"C:\Projects\My App"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or specify another backup directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="p"&gt;.&lt;/span&gt;\&lt;span class="nc"&gt;Backup&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Project&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ps1&lt;/span&gt; &lt;span class="sb"&gt;`
    -Source "C:\Projects\My App" `&lt;/span&gt;
    &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;BackupRoot&lt;/span&gt; &lt;span class="s2"&gt;"D:\Backups"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice how we quote paths containing spaces.&lt;/p&gt;

&lt;p&gt;This is an important habit in shell scripting. Paths are not always simple strings without spaces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; These examples create new timestamped backups. They don't automatically delete older backups. That's intentional: deleting backups is a destructive operation and should be added only with a clear retention policy and careful testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  14. Script Paths: Don't Depend on the Current Directory
&lt;/h2&gt;

&lt;p&gt;Here's a common scripting mistake.&lt;/p&gt;

&lt;p&gt;You write a script that reads a file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cat config.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It works when you run the script from its own directory.&lt;/p&gt;

&lt;p&gt;But when you run it from somewhere else, it fails.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because the relative path is resolved from the current working directory, not necessarily from the script's location.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bash: find the script directory
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;SCRIPT_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$(cd -- "&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;dirname -- &lt;span class="s2"&gt;"${BASH_SOURCE[0]}"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;" &amp;amp;&amp;amp; pwd)"&lt;/span&gt;

&lt;span class="nv"&gt;CONFIG_FILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$SCRIPT_DIR/config.json"&lt;/span&gt;

cat &lt;span class="s2"&gt;"$CONFIG_FILE"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the script can locate &lt;code&gt;config.json&lt;/code&gt; relative to itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  PowerShell: use &lt;code&gt;$PSScriptRoot&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$configFile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Join&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="nv"&gt;$PSScriptRoot&lt;/span&gt; &lt;span class="s2"&gt;"config.json"&lt;/span&gt;

&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="nv"&gt;$configFile&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;$PSScriptRoot&lt;/code&gt; contains the directory where the current script is stored.&lt;/p&gt;

&lt;p&gt;This is especially useful when distributing scripts to other developers or running them through automation tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  15. Debugging Your Scripts
&lt;/h2&gt;

&lt;p&gt;Scripts don't always work on the first attempt.&lt;/p&gt;

&lt;p&gt;The ability to debug them is just as important as the ability to write them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bash debugging
&lt;/h3&gt;

&lt;p&gt;Run a script with execution tracing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bash -x script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bash prints commands as they execute.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Hamed"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello, $name!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running it with &lt;code&gt;bash -x&lt;/code&gt; shows the expanded commands and helps you understand what happened.&lt;/p&gt;

&lt;h3&gt;
  
  
  PowerShell debugging
&lt;/h3&gt;

&lt;p&gt;Enable tracing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;PSDebug&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Trace&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="p"&gt;.&lt;/span&gt;\&lt;span class="n"&gt;script&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ps1&lt;/span&gt;

&lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;PSDebug&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Off&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell displays additional execution information.&lt;/p&gt;

&lt;p&gt;Remember to turn tracing off after debugging.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common scripting mistakes
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem&lt;/th&gt;
&lt;th&gt;Possible cause&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Command not found&lt;/td&gt;
&lt;td&gt;Tool isn't installed or isn't in &lt;code&gt;PATH&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Permission denied&lt;/td&gt;
&lt;td&gt;Missing execute permission or insufficient access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;File not found&lt;/td&gt;
&lt;td&gt;Incorrect working directory or path&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Unexpected variable value&lt;/td&gt;
&lt;td&gt;Incorrect quoting or variable expansion&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Script works manually but fails elsewhere&lt;/td&gt;
&lt;td&gt;Environment or working-directory differences&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PowerShell script won't run&lt;/td&gt;
&lt;td&gt;Execution policy or script invocation issue&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pipeline reports success unexpectedly&lt;/td&gt;
&lt;td&gt;Exit code or pipeline error handling isn't being checked&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;When debugging, don't immediately assume the shell is broken.&lt;/p&gt;

&lt;p&gt;Check the command, its arguments, the current directory, permissions, and environment first.&lt;/p&gt;

&lt;h2&gt;
  
  
  16. Best Practices for Writing Maintainable Scripts
&lt;/h2&gt;

&lt;p&gt;A script is still software.&lt;/p&gt;

&lt;p&gt;Treat it with the same care you would give to an application.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Use meaningful names
&lt;/h3&gt;

&lt;p&gt;Avoid:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"my-project"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Prefer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;project_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"my-project"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Quote paths and variables
&lt;/h3&gt;

&lt;p&gt;Bash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir -p &lt;span class="s2"&gt;"$project_name"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;Directory&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="nv"&gt;$projectName&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Quoting and using literal-path parameters appropriately helps avoid problems with spaces and special characters.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Validate input
&lt;/h3&gt;

&lt;p&gt;Don't assume users will always provide the correct arguments.&lt;/p&gt;

&lt;p&gt;Check required values and verify that files or directories exist before using them.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Avoid hardcoding secrets
&lt;/h3&gt;

&lt;p&gt;Never store passwords, API keys, or access tokens directly in scripts that might be committed to Git.&lt;/p&gt;

&lt;p&gt;Use environment variables or an appropriate secret-management solution.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Make failures visible
&lt;/h3&gt;

&lt;p&gt;Print useful error messages and return meaningful exit codes.&lt;/p&gt;

&lt;p&gt;A script should tell the user what went wrong, not silently continue.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Avoid destructive operations by default
&lt;/h3&gt;

&lt;p&gt;Be especially careful with commands such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rm -rf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And their PowerShell equivalents:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Remove&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test scripts with temporary directories and sample files before using them on important data.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Keep scripts focused
&lt;/h3&gt;

&lt;p&gt;A script that does one thing well is usually easier to understand, test, and reuse than one enormous script that handles everything.&lt;/p&gt;




&lt;h2&gt;
  
  
  17. Practice: Build Your Own Automation Scripts
&lt;/h2&gt;

&lt;p&gt;Now it's your turn.&lt;/p&gt;

&lt;p&gt;Try these exercises without looking at the examples above.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exercise 1: Personal Greeting
&lt;/h3&gt;

&lt;p&gt;Create a script that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Accepts a user's name.&lt;/li&gt;
&lt;li&gt;Accepts their programming language.&lt;/li&gt;
&lt;li&gt;Prints a personalized message.&lt;/li&gt;
&lt;li&gt;Uses default values if arguments are missing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 2: File Organizer
&lt;/h3&gt;

&lt;p&gt;Create a script that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Accepts a directory path.&lt;/li&gt;
&lt;li&gt;Finds all &lt;code&gt;.jpg&lt;/code&gt; files.&lt;/li&gt;
&lt;li&gt;Creates an &lt;code&gt;images&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;Moves the matching files into that directory.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Test it on a temporary folder first.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exercise 3: Project Generator
&lt;/h3&gt;

&lt;p&gt;Improve the project generator from this article.&lt;/p&gt;

&lt;p&gt;Add:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A choice between JavaScript and TypeScript.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;src/components&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;src/utils&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;tests/unit&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;A generated README containing the project name and creation date.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 4: Automated Backup
&lt;/h3&gt;

&lt;p&gt;Improve the backup script.&lt;/p&gt;

&lt;p&gt;Add:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A check that the destination is writable.&lt;/li&gt;
&lt;li&gt;A log file containing backup results.&lt;/li&gt;
&lt;li&gt;A clear error message if copying fails.&lt;/li&gt;
&lt;li&gt;A way to choose a custom backup location.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 5: Cross-Platform Challenge
&lt;/h3&gt;

&lt;p&gt;Write the same small automation task twice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once in Bash.&lt;/li&gt;
&lt;li&gt;Once in PowerShell.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Compare the two implementations.&lt;/p&gt;

&lt;p&gt;Which language feels more natural? Which one handles structured data more conveniently? What differences did you notice?&lt;/p&gt;




&lt;h2&gt;
  
  
  18. Quick Reference: Bash vs. PowerShell
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Bash&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Print text&lt;/td&gt;
&lt;td&gt;&lt;code&gt;echo "Hello"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Write-Host "Hello"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create variable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;name="Hamed"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;$name = "Hamed"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Read input&lt;/td&gt;
&lt;td&gt;&lt;code&gt;read -r name&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Read-Host&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First argument&lt;/td&gt;
&lt;td&gt;&lt;code&gt;$1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;param()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Condition&lt;/td&gt;
&lt;td&gt;&lt;code&gt;if [[ ... ]]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;if (...)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Loop&lt;/td&gt;
&lt;td&gt;&lt;code&gt;for ...; do&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;foreach (...)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Function&lt;/td&gt;
&lt;td&gt;&lt;code&gt;greet() { }&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;function Greet { }&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mkdir -p app&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;New-Item -ItemType Directory app&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Check file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[[ -f file ]]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Test-Path file -PathType Leaf&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Copy directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cp -a source destination&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Copy-Item source destination -Recurse&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Exit code&lt;/td&gt;
&lt;td&gt;&lt;code&gt;$?&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;$LASTEXITCODE&lt;/code&gt; for native programs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Debug&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bash -x script.sh&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Set-PSDebug -Trace 1&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;You've now moved beyond executing individual terminal commands.&lt;/p&gt;

&lt;p&gt;You know how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create reusable shell scripts.&lt;/li&gt;
&lt;li&gt;Work with variables and arguments.&lt;/li&gt;
&lt;li&gt;Accept user input.&lt;/li&gt;
&lt;li&gt;Make decisions with conditions.&lt;/li&gt;
&lt;li&gt;Repeat operations with loops.&lt;/li&gt;
&lt;li&gt;Organize code using functions.&lt;/li&gt;
&lt;li&gt;Handle failures and exit codes.&lt;/li&gt;
&lt;li&gt;Automate project creation and backups.&lt;/li&gt;
&lt;li&gt;Debug scripts across different environments.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The real value of scripting isn't just saving a few keystrokes.&lt;/p&gt;

&lt;p&gt;It's turning repetitive work into reliable, reusable workflows.&lt;/p&gt;

&lt;p&gt;And once you start automating your everyday tasks, you'll notice that many terminal operations can become much simpler.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next up:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Article 10, we'll bring everything together with advanced terminal workflows and troubleshooting. We'll explore how to combine commands, investigate difficult problems, improve productivity, and build a more professional command-line workflow across Windows, macOS, and Linux.&lt;/p&gt;

&lt;p&gt;See you in the final chapter!&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Tags:&lt;/strong&gt; &lt;code&gt;terminal&lt;/code&gt; &lt;code&gt;automation&lt;/code&gt; &lt;code&gt;bash&lt;/code&gt; &lt;code&gt;powershell&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Series:&lt;/strong&gt; Terminal Mastery: Windows, macOS &amp;amp; Linux&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reading level:&lt;/strong&gt; Beginner to Intermediate&lt;/p&gt;

</description>
      <category>terminal</category>
      <category>automation</category>
      <category>bash</category>
      <category>powershell</category>
    </item>
    <item>
      <title>Terminal Mastery-The Developer's Terminal Toolkit</title>
      <dc:creator>Hamed Farazi</dc:creator>
      <pubDate>Sun, 15 Nov 2026 10:47:56 +0000</pubDate>
      <link>https://dev.to/hamedfarazi/terminal-mastery-the-developers-terminal-toolkit-497k</link>
      <guid>https://dev.to/hamedfarazi/terminal-mastery-the-developers-terminal-toolkit-497k</guid>
      <description>&lt;p&gt;08/10 — The Developer's Terminal Toolkit&lt;br&gt;
A terminal is already a powerful tool.&lt;/p&gt;

&lt;p&gt;But here's something many developers discover over time:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The real power of the terminal comes from combining small, specialized tools.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can search thousands of files in seconds, navigate large projects interactively, inspect JSON responses, browse Git history, and manage files without constantly switching between graphical applications.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore eight useful command-line tools that can improve your daily development workflow.&lt;/p&gt;

&lt;p&gt;We'll cover:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;ripgrep&lt;/code&gt; — Search through code quickly.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fd&lt;/code&gt; — Find files with a simpler interface.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fzf&lt;/code&gt; — Interactive fuzzy finding.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bat&lt;/code&gt; — A better way to read files.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;eza&lt;/code&gt; — A modern alternative to &lt;code&gt;ls&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;jq&lt;/code&gt; — Process JSON from the command line.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;delta&lt;/code&gt; — Make Git diffs easier to read.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tldr&lt;/code&gt; — Learn commands through practical examples.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We'll also look at installation, practical workflows, and alternatives for Windows, macOS, and Linux.&lt;/p&gt;

&lt;p&gt;Let's get started.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. ripgrep: Search Through Code at Incredible Speed
&lt;/h2&gt;

&lt;p&gt;If you've ever worked on a large project, you probably know how frustrating it can be to search through hundreds or thousands of files.&lt;/p&gt;

&lt;p&gt;You could use &lt;code&gt;grep&lt;/code&gt;, but there's another excellent tool:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ripgrep (&lt;code&gt;rg&lt;/code&gt;).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ripgrep is a fast recursive search tool designed for searching files and directories.&lt;/p&gt;

&lt;p&gt;It respects common ignore rules, including &lt;code&gt;.gitignore&lt;/code&gt;, by default.&lt;/p&gt;
&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;On Windows with winget:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;winget&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="nc"&gt;BurntSushi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ripgrep&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MSVC&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew install ripgrep
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Ubuntu or Debian:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install ripgrep
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Search for Text
&lt;/h3&gt;

&lt;p&gt;Imagine you have a React project and want to find every occurrence of &lt;code&gt;useState&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rg &lt;span class="s2"&gt;"useState"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ripgrep searches files recursively from the current directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Search in a Specific Directory
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rg &lt;span class="s2"&gt;"useState"&lt;/span&gt; src/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Search Without Case Sensitivity
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rg -i &lt;span class="s2"&gt;"error"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Search for a Specific File Type
&lt;/h3&gt;

&lt;p&gt;For example, search only JavaScript and TypeScript files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rg &lt;span class="s2"&gt;"useState"&lt;/span&gt; -g &lt;span class="s2"&gt;"*.js"&lt;/span&gt; -g &lt;span class="s2"&gt;"*.ts"&lt;/span&gt; -g &lt;span class="s2"&gt;"*.tsx"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Show Matching Line Numbers
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rg -n &lt;span class="s2"&gt;"useState"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Search for a Regular Expression
&lt;/h3&gt;

&lt;p&gt;Find function declarations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rg &lt;span class="s2"&gt;"function\s+\w+"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Search Including Ignored Files
&lt;/h3&gt;

&lt;p&gt;By default, ripgrep respects ignore rules.&lt;/p&gt;

&lt;p&gt;If you want to include ignored files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rg --no-ignore &lt;span class="s2"&gt;"secret"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Be careful with this option because it can search large directories such as &lt;code&gt;node_modules&lt;/code&gt; and build outputs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Developers Love ripgrep
&lt;/h3&gt;

&lt;p&gt;Imagine searching for a component named &lt;code&gt;UserProfile&lt;/code&gt; in a large application.&lt;/p&gt;

&lt;p&gt;Instead of opening files one by one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rg &lt;span class="s2"&gt;"UserProfile"&lt;/span&gt; src/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You immediately get matching files, line numbers, and matching content.&lt;/p&gt;

&lt;p&gt;It's one of the most useful tools you can add to your development environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. fd: Find Files Without Complicated Commands
&lt;/h2&gt;

&lt;p&gt;Traditional &lt;code&gt;find&lt;/code&gt; is powerful, but its syntax can become difficult to remember.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find . -type f -name &lt;span class="s2"&gt;"*.tsx"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;fd&lt;/code&gt; utility provides a simpler and more intuitive interface for finding files and directories.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;Windows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;winget&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;sharkdp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew install fd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ubuntu or Debian:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install fd-find
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On some Debian-based distributions, the executable is named &lt;code&gt;fdfind&lt;/code&gt; instead of &lt;code&gt;fd&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can check its availability with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fdfind --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Find Files by Name
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fd &lt;span class="s2"&gt;"App"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This searches for files and directories whose names match &lt;code&gt;App&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Find TypeScript Files
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fd -e ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Find React Components
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fd -e tsx src/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Find Only Directories
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fd -t d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Find Only Files
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fd -t f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Search Hidden Files
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fd --hidden &lt;span class="s2"&gt;"config"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Exclude a Directory
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fd -E node_modules &lt;span class="s2"&gt;"App"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This excludes &lt;code&gt;node_modules&lt;/code&gt; from the search.&lt;/p&gt;

&lt;h3&gt;
  
  
  fd vs. find
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Traditional find&lt;/th&gt;
&lt;th&gt;fd&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Find TypeScript files&lt;/td&gt;
&lt;td&gt;&lt;code&gt;find . -name "*.ts"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;fd -e ts&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Find directories&lt;/td&gt;
&lt;td&gt;&lt;code&gt;find . -type d&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;fd -t d&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Find files&lt;/td&gt;
&lt;td&gt;&lt;code&gt;find . -type f&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;fd -t f&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Find hidden files&lt;/td&gt;
&lt;td&gt;Requires additional options&lt;/td&gt;
&lt;td&gt;&lt;code&gt;fd --hidden&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Both tools are useful.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;find&lt;/code&gt; is widely available on Unix-like systems, while &lt;code&gt;fd&lt;/code&gt; offers a more convenient interface for everyday searches.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. fzf: Interactive Fuzzy Finding
&lt;/h2&gt;

&lt;p&gt;Now let's explore something especially useful.&lt;/p&gt;

&lt;p&gt;Have you ever wanted to search through a long list of files, commands, or Git branches interactively?&lt;/p&gt;

&lt;p&gt;Meet &lt;code&gt;fzf&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fzf&lt;/code&gt; is a general-purpose command-line fuzzy finder.&lt;/p&gt;

&lt;p&gt;Instead of typing an exact filename, you can enter part of a name and interactively narrow down the results.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;Windows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;winget&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;junegunn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fzf&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew install fzf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ubuntu or Debian:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install fzf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Start fzf
&lt;/h3&gt;

&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fzf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It opens an interactive search interface using files from the current directory.&lt;/p&gt;

&lt;p&gt;Start typing a few characters to filter the results.&lt;/p&gt;

&lt;p&gt;Use the arrow keys to navigate and press Enter to select an item.&lt;/p&gt;

&lt;p&gt;Press Escape or Ctrl+C to cancel.&lt;/p&gt;

&lt;h3&gt;
  
  
  Combine fzf with fd
&lt;/h3&gt;

&lt;p&gt;This is where things become interesting.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fd -t f &lt;span class="o"&gt;|&lt;/span&gt; fzf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;fd -t f&lt;/code&gt; finds files.&lt;/li&gt;
&lt;li&gt;The pipe sends the results to &lt;code&gt;fzf&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fzf&lt;/code&gt; lets you search through them interactively.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Search Through Command History
&lt;/h3&gt;

&lt;p&gt;In supported shell integrations, press:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ctrl + R
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This opens an interactive history search.&lt;/p&gt;

&lt;p&gt;It is much more convenient than repeatedly pressing the up arrow.&lt;/p&gt;

&lt;p&gt;The exact experience depends on your shell and whether the fzf key bindings have been installed and configured.&lt;/p&gt;

&lt;h3&gt;
  
  
  Search Git Branches
&lt;/h3&gt;

&lt;p&gt;You can also use fzf to interactively select Git branches:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git branch --all &lt;span class="o"&gt;|&lt;/span&gt; fzf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a simple example of how flexible the tool can be.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why fzf Is Powerful
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;fzf&lt;/code&gt; doesn't need to understand files, Git, or command history.&lt;/p&gt;

&lt;p&gt;It simply filters input.&lt;/p&gt;

&lt;p&gt;That means it can work with almost any command that produces a list of text items.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. bat: A Better Way to Read Files
&lt;/h2&gt;

&lt;p&gt;You've already learned how to use &lt;code&gt;cat&lt;/code&gt; to display file contents.&lt;/p&gt;

&lt;p&gt;But there's a more visually convenient alternative:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;bat.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bat&lt;/code&gt; is a command-line file viewer with syntax highlighting, line numbers, and Git integration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;Windows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;winget&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;sharkdp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bat&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew install bat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ubuntu or Debian:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install bat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On some Debian-based distributions, the executable is named &lt;code&gt;batcat&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Check its availability:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;batcat --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Read a File
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bat README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of displaying plain text, bat highlights Markdown syntax and adds line numbers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Display Multiple Files
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bat package.json tsconfig.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Display a Specific Range of Lines
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bat --line-range 10:30 App.tsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays lines 10 through 30.&lt;/p&gt;

&lt;h3&gt;
  
  
  Disable Paging
&lt;/h3&gt;

&lt;p&gt;For simple output without an interactive pager:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bat --paging=never README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why Use bat?
&lt;/h3&gt;

&lt;p&gt;It makes reading source code and configuration files more comfortable.&lt;/p&gt;

&lt;p&gt;It's particularly useful when inspecting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React components&lt;/li&gt;
&lt;li&gt;TypeScript files&lt;/li&gt;
&lt;li&gt;JSON configuration&lt;/li&gt;
&lt;li&gt;Markdown documentation&lt;/li&gt;
&lt;li&gt;Shell scripts&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. eza: A Modern Alternative to ls
&lt;/h2&gt;

&lt;p&gt;The traditional &lt;code&gt;ls&lt;/code&gt; command is available on Linux and macOS.&lt;/p&gt;

&lt;p&gt;On Windows, PowerShell provides &lt;code&gt;Get-ChildItem&lt;/code&gt;, while CMD uses &lt;code&gt;dir&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;But if you want a more informative directory listing, try &lt;code&gt;eza&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;eza&lt;/code&gt; is a modern replacement for &lt;code&gt;ls&lt;/code&gt;, with features such as colors, icons, Git status, and tree views.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;Windows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;winget&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;eza&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;community&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;eza&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew install eza
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ubuntu or Debian:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install eza
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Package availability depends on the Linux distribution and its repositories.&lt;/p&gt;

&lt;h3&gt;
  
  
  List Files
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eza
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Show Hidden Files
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eza --all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Show Detailed Information
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eza --long
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Display a Tree Structure
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eza --tree
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also limit the depth:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eza --tree --level=2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Display Git Status
&lt;/h3&gt;

&lt;p&gt;Inside a Git repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eza --long --git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can display Git-related information alongside directory entries.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why eza Is Useful
&lt;/h3&gt;

&lt;p&gt;When working with large projects, a visual directory structure can make navigation much easier.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eza --tree --level=2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can quickly understand the structure of a project without opening your editor.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. jq: Process JSON from the Terminal
&lt;/h2&gt;

&lt;p&gt;This is one of the most valuable tools for web developers.&lt;/p&gt;

&lt;p&gt;Modern applications work with JSON constantly.&lt;/p&gt;

&lt;p&gt;APIs return JSON responses, configuration files use JSON, and many development tools communicate through JSON.&lt;/p&gt;

&lt;p&gt;But reading large JSON documents in a terminal can be difficult.&lt;/p&gt;

&lt;p&gt;That's where &lt;code&gt;jq&lt;/code&gt; comes in.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;jq&lt;/code&gt; is a command-line JSON processor.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;Windows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;winget&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;jqlang&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;jq&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew install jq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ubuntu or Debian:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install jq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Pretty-Print JSON
&lt;/h3&gt;

&lt;p&gt;Imagine you have a file named &lt;code&gt;user.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Hamed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"developer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"skills"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"React"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"TypeScript"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Node.js"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq . user.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This formats the JSON in a readable way.&lt;/p&gt;

&lt;h3&gt;
  
  
  Extract a Property
&lt;/h3&gt;

&lt;p&gt;To retrieve the user's name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq &lt;span class="s1"&gt;'.name'&lt;/span&gt; user.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="s2"&gt;"Hamed"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Extract Multiple Properties
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq &lt;span class="s1"&gt;'{name, role}'&lt;/span&gt; user.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Hamed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"developer"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Extract an Array
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq &lt;span class="s1"&gt;'.skills'&lt;/span&gt; user.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Get an Array Element
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq &lt;span class="s1"&gt;'.skills[0]'&lt;/span&gt; user.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="s2"&gt;"React"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember: array indexes start at zero.&lt;/p&gt;

&lt;h3&gt;
  
  
  Filter an Array of Objects
&lt;/h3&gt;

&lt;p&gt;Imagine you have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"users"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Alex"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"active"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Sam"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"active"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Jordan"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"active"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Find only active users:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq &lt;span class="s1"&gt;'.users[] | select(.active == true)'&lt;/span&gt; users.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is especially useful when inspecting API responses.&lt;/p&gt;

&lt;h3&gt;
  
  
  Combine curl and jq
&lt;/h3&gt;

&lt;p&gt;Now let's combine two tools.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s https://api.github.com/users/octocat &lt;span class="o"&gt;|&lt;/span&gt; jq &lt;span class="s1"&gt;'.login, .public_repos'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's what happens:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;curl&lt;/code&gt; sends an HTTP request.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-s&lt;/code&gt; enables silent mode.&lt;/li&gt;
&lt;li&gt;The pipe passes the response to &lt;code&gt;jq&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;jq&lt;/code&gt; extracts the requested properties.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is a practical example of how small command-line tools work together.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; When testing authenticated APIs, avoid placing access tokens directly in shell history or sharing commands that contain credentials.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. delta: Make Git Diffs Easier to Read
&lt;/h2&gt;

&lt;p&gt;If you work with Git, you've probably used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git diff
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It shows changes between versions of files.&lt;/p&gt;

&lt;p&gt;But large diffs can become difficult to read.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;delta&lt;/code&gt; is a syntax-highlighting pager for Git and other diff output.&lt;/p&gt;

&lt;p&gt;It improves the visual presentation of changes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;Windows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;winget&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;dandavison&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;delta&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew install git-delta
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ubuntu or Debian:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install git-delta
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Run delta Directly
&lt;/h3&gt;

&lt;p&gt;You can pipe diff output into delta:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git diff &lt;span class="o"&gt;|&lt;/span&gt; delta
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Configure delta as Git's Pager
&lt;/h3&gt;

&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config --global core.pager delta
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now Git can use delta when displaying supported paged output.&lt;/p&gt;

&lt;p&gt;You can inspect the configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config --global core.pager
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What Does delta Improve?
&lt;/h3&gt;

&lt;p&gt;Depending on your configuration and terminal, delta can provide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Syntax highlighting&lt;/li&gt;
&lt;li&gt;Improved line formatting&lt;/li&gt;
&lt;li&gt;Better visual separation of changes&lt;/li&gt;
&lt;li&gt;Easier navigation through large diffs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's particularly useful when reviewing pull requests and debugging changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. tldr: Learn Commands Through Practical Examples
&lt;/h2&gt;

&lt;p&gt;Traditional manual pages are comprehensive, but sometimes you just want a quick example.&lt;/p&gt;

&lt;p&gt;For instance, you remember the command &lt;code&gt;tar&lt;/code&gt;, but you don't remember how to extract an archive.&lt;/p&gt;

&lt;p&gt;Instead of reading a long manual, you can use &lt;code&gt;tldr&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tldr&lt;/code&gt; provides community-maintained practical examples for command-line tools.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;On macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew install tldr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Ubuntu or Debian:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install tldr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Windows, you can install a supported client through package managers or use the official project instructions.&lt;/p&gt;

&lt;h3&gt;
  
  
  View Examples
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tldr tar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tldr grep
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get concise examples showing common ways to use each command.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Use tldr?
&lt;/h3&gt;

&lt;p&gt;It's useful when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You know the command but forgot its syntax.&lt;/li&gt;
&lt;li&gt;You want a practical example quickly.&lt;/li&gt;
&lt;li&gt;You're learning a new utility.&lt;/li&gt;
&lt;li&gt;You don't want to search through a lengthy manual.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remember that &lt;code&gt;tldr&lt;/code&gt; is community-maintained. For authoritative behavior and advanced options, consult the command's official documentation or manual.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Combining Tools into Real Developer Workflows
&lt;/h2&gt;

&lt;p&gt;Now let's combine several tools to solve practical problems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Workflow 1: Find a Component in a Large React Project
&lt;/h3&gt;

&lt;p&gt;Imagine you're searching for a component named &lt;code&gt;UserProfile&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fd -e tsx src &lt;span class="o"&gt;|&lt;/span&gt; fzf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This lets you interactively search TypeScript React files.&lt;/p&gt;

&lt;p&gt;Once you know which file you need, search for the component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rg -n &lt;span class="s2"&gt;"UserProfile"&lt;/span&gt; src/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then inspect the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bat src/components/UserProfile.tsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You've combined three tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;fd&lt;/code&gt; finds files.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fzf&lt;/code&gt; filters them interactively.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;rg&lt;/code&gt; searches their contents.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bat&lt;/code&gt; displays the source code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Workflow 2: Inspect an API Response
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s https://api.github.com/users/octocat &lt;span class="o"&gt;|&lt;/span&gt; jq .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Extract only a few properties:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s https://api.github.com/users/octocat &lt;span class="o"&gt;|&lt;/span&gt; jq &lt;span class="s1"&gt;'{login, name, public_repos}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes API debugging much faster.&lt;/p&gt;

&lt;h3&gt;
  
  
  Workflow 3: Understand a Project's Structure
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eza --tree --level=3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This provides a quick overview of the project directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Workflow 4: Review Your Git Changes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git diff &lt;span class="o"&gt;|&lt;/span&gt; delta
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Review your changes with improved formatting.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Finding Installed Tools on Different Operating Systems
&lt;/h2&gt;

&lt;p&gt;After installing new utilities, you may want to check whether they are available in your terminal.&lt;/p&gt;

&lt;p&gt;Here are useful commands.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux and macOS
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;command&lt;/span&gt; -v rg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;which rg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PowerShell
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Command&lt;/span&gt; &lt;span class="n"&gt;rg&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Windows CMD
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;where.exe rg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a command isn't found immediately after installation, you may need to restart your terminal or update your &lt;code&gt;PATH&lt;/code&gt; environment variable.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. A Note About Windows, macOS, and Linux
&lt;/h2&gt;

&lt;p&gt;Not every tool is installed by default.&lt;/p&gt;

&lt;p&gt;Also, installation commands and executable names can vary between distributions.&lt;/p&gt;

&lt;p&gt;Here are a few things to remember:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows users can install many of these tools through WinGet or other package managers.&lt;/li&gt;
&lt;li&gt;macOS users commonly use Homebrew.&lt;/li&gt;
&lt;li&gt;Linux users can use their distribution's package manager.&lt;/li&gt;
&lt;li&gt;Some Linux distributions package a utility under a different executable name.&lt;/li&gt;
&lt;li&gt;PowerShell supports many Unix-inspired tools, but its native commands and pipelines have different behavior.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don't need to install every tool immediately.&lt;/p&gt;

&lt;p&gt;Start with the ones that solve problems you encounter regularly.&lt;/p&gt;

&lt;h2&gt;
  
  
  12. Practice Exercises
&lt;/h2&gt;

&lt;p&gt;Let's put these tools into practice.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exercise 1: Search a React Project
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Install &lt;code&gt;ripgrep&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Search for &lt;code&gt;useEffect&lt;/code&gt; in your project.&lt;/li&gt;
&lt;li&gt;Display matching line numbers.&lt;/li&gt;
&lt;li&gt;Search only &lt;code&gt;.tsx&lt;/code&gt; files.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 2: Explore Files
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Install &lt;code&gt;fd&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Find all TypeScript files.&lt;/li&gt;
&lt;li&gt;Find all directories.&lt;/li&gt;
&lt;li&gt;Exclude &lt;code&gt;node_modules&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 3: Use Interactive Search
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Install &lt;code&gt;fzf&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Combine it with &lt;code&gt;fd&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Search through your project's files.&lt;/li&gt;
&lt;li&gt;Explore the interactive command-history integration.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 4: Inspect JSON
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Create a JSON file containing a list of users.&lt;/li&gt;
&lt;li&gt;Format it using &lt;code&gt;jq&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Extract one property.&lt;/li&gt;
&lt;li&gt;Filter active users.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 5: Improve Git Diffs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Install &lt;code&gt;delta&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Configure it as your Git pager.&lt;/li&gt;
&lt;li&gt;Make a change in a Git repository.&lt;/li&gt;
&lt;li&gt;Compare the output of &lt;code&gt;git diff&lt;/code&gt; before and after configuration.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 6: Build Your Own Workflow
&lt;/h3&gt;

&lt;p&gt;Combine at least three tools to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find a file.&lt;/li&gt;
&lt;li&gt;Search its contents.&lt;/li&gt;
&lt;li&gt;Display the relevant source code.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Quick Reference
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Main purpose&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;rg&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Search file contents&lt;/td&gt;
&lt;td&gt;&lt;code&gt;rg "useState"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;fd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Find files&lt;/td&gt;
&lt;td&gt;&lt;code&gt;fd -e tsx&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;fzf&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Interactive filtering&lt;/td&gt;
&lt;td&gt;`fd -t f \&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;{% raw %}&lt;code&gt;bat&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Read files with highlighting&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bat App.tsx&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;eza&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Improved directory listing&lt;/td&gt;
&lt;td&gt;&lt;code&gt;eza --tree&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;jq&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Process JSON&lt;/td&gt;
&lt;td&gt;&lt;code&gt;jq '.name' user.json&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;delta&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Improved Git diffs&lt;/td&gt;
&lt;td&gt;`git diff \&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;{% raw %}&lt;code&gt;tldr&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Practical command examples&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tldr tar&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;You've now discovered a collection of tools that can make everyday development tasks faster, more convenient, and more efficient.&lt;/p&gt;

&lt;p&gt;But there's one more step.&lt;/p&gt;

&lt;p&gt;What if you could combine these commands into reusable programs?&lt;/p&gt;

&lt;p&gt;What if you could automate repetitive tasks, process files in batches, and build your own development utilities?&lt;/p&gt;

&lt;p&gt;That's exactly what we'll explore in the next article:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Automate Your Workflow with Shell Scripting.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We'll learn how to write scripts, use variables, work with conditions and loops, process arguments, and automate real development tasks using Bash and PowerShell.&lt;/p&gt;

&lt;p&gt;See you in Article 09!&lt;/p&gt;

</description>
      <category>terminal</category>
      <category>productivity</category>
      <category>devtools</category>
      <category>programming</category>
    </item>
    <item>
      <title>Terminal Mastery-Networking from the Command Line</title>
      <dc:creator>Hamed Farazi</dc:creator>
      <pubDate>Sun, 15 Nov 2026 09:42:06 +0000</pubDate>
      <link>https://dev.to/hamedfarazi/terminal-mastery-networking-from-the-command-line-49d1</link>
      <guid>https://dev.to/hamedfarazi/terminal-mastery-networking-from-the-command-line-49d1</guid>
      <description>&lt;p&gt;07/10 — Networking from the Command Line&lt;br&gt;
Your application works perfectly on your computer.&lt;/p&gt;

&lt;p&gt;But suddenly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An API request fails.&lt;/li&gt;
&lt;li&gt;A website refuses to load.&lt;/li&gt;
&lt;li&gt;A development server is unreachable.&lt;/li&gt;
&lt;li&gt;A database connection times out.&lt;/li&gt;
&lt;li&gt;A domain name cannot be resolved.&lt;/li&gt;
&lt;li&gt;A port is already in use.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Where should you start?&lt;/p&gt;

&lt;p&gt;Before opening a graphical network diagnostic tool, you can investigate many of these problems directly from your terminal.&lt;/p&gt;

&lt;p&gt;Command-line networking tools help you understand how your computer communicates with other devices, servers, and services.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IP addresses and network interfaces&lt;/li&gt;
&lt;li&gt;Testing network connectivity with &lt;code&gt;ping&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Understanding DNS and domain resolution&lt;/li&gt;
&lt;li&gt;Inspecting network routes&lt;/li&gt;
&lt;li&gt;Checking open ports&lt;/li&gt;
&lt;li&gt;Testing TCP connections&lt;/li&gt;
&lt;li&gt;Making HTTP requests with &lt;code&gt;curl&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Troubleshooting common network problems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We'll cover Windows, macOS, and Linux.&lt;/p&gt;

&lt;p&gt;Let's get started.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Understanding Basic Networking Concepts
&lt;/h2&gt;

&lt;p&gt;Before running networking commands, let's understand a few essential terms.&lt;/p&gt;
&lt;h3&gt;
  
  
  IP Address
&lt;/h3&gt;

&lt;p&gt;An IP address identifies a device or network interface on an IP network.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;192.168.1.100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is an example of a private IPv4 address.&lt;/p&gt;

&lt;p&gt;There are two commonly used IP versions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IPv4: &lt;code&gt;192.168.1.100&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;IPv6: &lt;code&gt;2001:db8::1&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;IPv4 uses 32-bit addresses, while IPv6 uses 128-bit addresses.&lt;/p&gt;

&lt;h3&gt;
  
  
  Public vs. Private IP Addresses
&lt;/h3&gt;

&lt;p&gt;A private IP address is used inside private networks, such as your home or office network.&lt;/p&gt;

&lt;p&gt;Common private IPv4 ranges include:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Range&lt;/th&gt;
&lt;th&gt;Typical use&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;10.0.0.0/8&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Private networks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;172.16.0.0/12&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Private networks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;192.168.0.0/16&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Home and office networks&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A public IP address is globally routable on the internet.&lt;/p&gt;

&lt;p&gt;Your computer may have a private IP address while your router uses a public IP address to communicate with the internet.&lt;/p&gt;

&lt;h3&gt;
  
  
  DNS
&lt;/h3&gt;

&lt;p&gt;DNS stands for Domain Name System.&lt;/p&gt;

&lt;p&gt;It translates domain names into IP addresses.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A DNS resolver can return an IP address associated with that domain.&lt;/p&gt;

&lt;p&gt;Without DNS, users would need to remember IP addresses instead of convenient domain names.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ports
&lt;/h3&gt;

&lt;p&gt;An IP address identifies a network interface, while a port identifies a particular communication endpoint.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;localhost:3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;localhost&lt;/code&gt; refers to your own computer.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;3000&lt;/code&gt; is the port number.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Web development tools commonly use ports such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;3000&lt;/code&gt; — Commonly used by development servers&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;5173&lt;/code&gt; — Vite's default development port&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;8080&lt;/code&gt; — Often used by local web servers&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;5432&lt;/code&gt; — PostgreSQL's default port&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;3306&lt;/code&gt; — MySQL's default port&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are conventions, not guarantees. Applications can use different ports.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Inspecting Your Network Configuration
&lt;/h2&gt;

&lt;p&gt;The first step in diagnosing a network issue is understanding your current network configuration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows: ipconfig
&lt;/h3&gt;

&lt;p&gt;Open PowerShell or CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ipconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays information about your network adapters.&lt;/p&gt;

&lt;p&gt;For more detailed information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ipconfig /all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You may see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IPv4 Address . . . . . . . . . . : 192.168.1.100
Subnet Mask . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . : 192.168.1.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's understand these values:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IPv4 Address: Your local IP address.&lt;/li&gt;
&lt;li&gt;Subnet Mask: Defines the network portion of the IPv4 address.&lt;/li&gt;
&lt;li&gt;Default Gateway: The router or next-hop device used to reach destinations outside your local network.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Linux: ip
&lt;/h3&gt;

&lt;p&gt;Modern Linux distributions commonly use the &lt;code&gt;ip&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;To display network interfaces and their addresses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip addr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A shorter version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To display routing information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip route
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To inspect network interfaces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip link
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  macOS: ifconfig
&lt;/h3&gt;

&lt;p&gt;On macOS, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ifconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays network interfaces and their configuration.&lt;/p&gt;

&lt;p&gt;To inspect the default route:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;route -n get default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To find the IP address of a specific interface, you can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ipconfig getifaddr en0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On many Macs, &lt;code&gt;en0&lt;/code&gt; is the Wi-Fi interface, but interface names can vary.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Testing Network Connectivity with ping
&lt;/h2&gt;

&lt;p&gt;One of the most familiar networking commands is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ping
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It sends ICMP Echo Request packets and waits for Echo Replies.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ping example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the destination responds, you'll see information about the replies and round-trip time.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;64 bytes from 93.184.216.34: icmp_seq=1 ttl=56 time=24.5 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells us that an ICMP response was received.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ping example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By default, Windows sends four requests.&lt;/p&gt;

&lt;p&gt;To continuously send requests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ping -t example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Stop it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ctrl + C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Linux and macOS
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ping example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On most Linux and macOS systems, &lt;code&gt;ping&lt;/code&gt; continues until you stop it.&lt;/p&gt;

&lt;p&gt;Use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ping -c 4 example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sends four requests.&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing Your Local Network
&lt;/h3&gt;

&lt;p&gt;You can also ping your router:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ping 192.168.1.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace the address with your actual default gateway.&lt;/p&gt;

&lt;h3&gt;
  
  
  Important: A Failed Ping Doesn't Always Mean the Server Is Down
&lt;/h3&gt;

&lt;p&gt;Some servers and network configurations block ICMP traffic.&lt;/p&gt;

&lt;p&gt;A destination may refuse to respond to &lt;code&gt;ping&lt;/code&gt; while still accepting HTTP or HTTPS connections.&lt;/p&gt;

&lt;p&gt;Therefore, don't rely on &lt;code&gt;ping&lt;/code&gt; as your only connectivity test.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Understanding DNS with nslookup
&lt;/h2&gt;

&lt;p&gt;Imagine you try to access an API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://api.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But your application reports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Could not resolve host
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This may indicate a DNS resolution problem.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;nslookup&lt;/code&gt; command helps investigate it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nslookup example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Linux and macOS
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nslookup example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Name:    example.com
Address: 93.184.216.34
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This shows that the DNS resolver returned an address for the domain.&lt;/p&gt;

&lt;h3&gt;
  
  
  Query a Specific DNS Server
&lt;/h3&gt;

&lt;p&gt;You can also specify which DNS server to query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nslookup example.com 8.8.8.8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;8.8.8.8&lt;/code&gt; is a public DNS resolver operated by Google.&lt;/p&gt;

&lt;p&gt;Another commonly used public resolver is Cloudflare's:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nslookup example.com 1.1.1.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is useful when comparing the results returned by different DNS resolvers.&lt;/p&gt;

&lt;h3&gt;
  
  
  PowerShell: Resolve-DnsName
&lt;/h3&gt;

&lt;p&gt;PowerShell provides a more native DNS command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Resolve&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;DnsName&lt;/span&gt; &lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To request an IPv4 record:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Resolve&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;DnsName&lt;/span&gt; &lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Type&lt;/span&gt; &lt;span class="no"&gt;A&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To request an IPv6 record:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Resolve&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;DnsName&lt;/span&gt; &lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Type&lt;/span&gt; &lt;span class="no"&gt;AAAA&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Understanding DNS Record Types
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Record&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;Maps a name to an IPv4 address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AAAA&lt;/td&gt;
&lt;td&gt;Maps a name to an IPv6 address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CNAME&lt;/td&gt;
&lt;td&gt;Points one name to another name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MX&lt;/td&gt;
&lt;td&gt;Identifies mail servers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NS&lt;/td&gt;
&lt;td&gt;Identifies authoritative name servers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TXT&lt;/td&gt;
&lt;td&gt;Stores text information, often used for verification and email security&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you want more advanced DNS diagnostics, you can also use &lt;code&gt;dig&lt;/code&gt; on Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On some systems, &lt;code&gt;dig&lt;/code&gt; may need to be installed separately.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Understanding Network Routes with traceroute
&lt;/h2&gt;

&lt;p&gt;Sometimes a connection fails even though your local network appears to work.&lt;/p&gt;

&lt;p&gt;The problem might be somewhere between your computer and the destination.&lt;/p&gt;

&lt;p&gt;This is where route-tracing tools become useful.&lt;/p&gt;

&lt;p&gt;They help reveal the network path that packets take toward a destination.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows: tracert
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tracert example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Linux: traceroute
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;traceroute example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Depending on your Linux distribution, you may need to install &lt;code&gt;traceroute&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  macOS: traceroute
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;traceroute example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example output might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1    192.168.1.1
2    10.20.0.1
3    203.0.113.10
4    example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each line represents a hop along the route.&lt;/p&gt;

&lt;p&gt;A hop is typically a router or another network device involved in forwarding traffic.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Does an Asterisk Mean?
&lt;/h3&gt;

&lt;p&gt;You may see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3    *    *    *
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means the tool didn't receive a response for those probes within the timeout.&lt;/p&gt;

&lt;p&gt;It doesn't necessarily mean the route is broken.&lt;/p&gt;

&lt;p&gt;Some routers filter or deprioritize diagnostic traffic while forwarding normal traffic successfully.&lt;/p&gt;

&lt;h3&gt;
  
  
  Alternative: mtr
&lt;/h3&gt;

&lt;p&gt;On Linux, and on macOS if installed, you may encounter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mtr example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;mtr&lt;/code&gt; combines aspects of &lt;code&gt;ping&lt;/code&gt; and route tracing, providing repeated measurements along the route.&lt;/p&gt;

&lt;p&gt;It's useful for investigating intermittent packet loss and latency.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Inspecting Network Connections and Open Ports
&lt;/h2&gt;

&lt;p&gt;This is particularly important for developers.&lt;/p&gt;

&lt;p&gt;Imagine your application runs on port &lt;code&gt;3000&lt;/code&gt;, but another process is already using it.&lt;/p&gt;

&lt;p&gt;Or perhaps you want to know whether your application is listening for incoming connections.&lt;/p&gt;

&lt;p&gt;Let's explore the available tools.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows: netstat
&lt;/h3&gt;

&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;netstat -ano
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays network connections and listening ports.&lt;/p&gt;

&lt;p&gt;The options mean:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-a&lt;/code&gt;: Display all connections and listening ports.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-n&lt;/code&gt;: Display addresses and port numbers numerically.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-o&lt;/code&gt;: Display the associated process ID.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To show listening ports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;netstat -ano | findstr LISTENING
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To investigate a specific port:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;netstat -ano | findstr :3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Linux: ss
&lt;/h3&gt;

&lt;p&gt;Modern Linux systems commonly use &lt;code&gt;ss&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ss -tuln
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-t&lt;/code&gt;: TCP sockets&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-u&lt;/code&gt;: UDP sockets&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-l&lt;/code&gt;: Listening sockets&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-n&lt;/code&gt;: Numeric addresses and ports&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To include process information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo ss -tulnp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  macOS: lsof
&lt;/h3&gt;

&lt;p&gt;On macOS, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lsof -i
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To display listening TCP ports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lsof -nP -iTCP -sTCP:LISTEN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To inspect a specific port:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lsof -nP -iTCP:3000 -sTCP:LISTEN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PowerShell: Get-NetTCPConnection
&lt;/h3&gt;

&lt;p&gt;PowerShell provides a useful networking command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetTCPConnection&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To display listening TCP connections:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetTCPConnection&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;State&lt;/span&gt; &lt;span class="nc"&gt;Listen&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To inspect a specific port:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetTCPConnection&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;LocalPort&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To display the process ID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetTCPConnection&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;LocalPort&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nc"&gt;LocalAddress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;LocalPort&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;OwningProcess&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can then identify the process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="mi"&gt;4820&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;4820&lt;/code&gt; with the actual process ID.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Testing TCP Connections with PowerShell
&lt;/h2&gt;

&lt;p&gt;Sometimes you don't need to inspect every network connection.&lt;/p&gt;

&lt;p&gt;You just want to know whether a specific server and port are reachable.&lt;/p&gt;

&lt;p&gt;PowerShell provides:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Test&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetConnection&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Test&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetConnection&lt;/span&gt; &lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Port&lt;/span&gt; &lt;span class="mi"&gt;443&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tests TCP connectivity to port &lt;code&gt;443&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A successful result includes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TcpTestSucceeded : True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A failed result may show:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TcpTestSucceeded : False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also test a local development server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Test&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetConnection&lt;/span&gt; &lt;span class="n"&gt;localhost&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Port&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is particularly useful when debugging:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API connectivity&lt;/li&gt;
&lt;li&gt;Database connections&lt;/li&gt;
&lt;li&gt;Remote development servers&lt;/li&gt;
&lt;li&gt;SSH access&lt;/li&gt;
&lt;li&gt;Web server availability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; &lt;code&gt;Test-NetConnection&lt;/code&gt; tests TCP connectivity. It doesn't prove that an HTTP application is working correctly or that its API returns valid responses.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Making HTTP Requests with curl
&lt;/h2&gt;

&lt;p&gt;Now let's move to one of the most important networking tools for developers.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;curl&lt;/code&gt; is a command-line tool for transferring data using URLs.&lt;/p&gt;

&lt;p&gt;It supports many protocols, including HTTP and HTTPS.&lt;/p&gt;

&lt;p&gt;It's extremely useful when working with APIs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Make a Simple HTTP Request
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sends an HTTP request and displays the response body.&lt;/p&gt;

&lt;h3&gt;
  
  
  Display Response Headers
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -I https://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-I&lt;/code&gt; option requests headers only using an HTTP HEAD request.&lt;/p&gt;

&lt;p&gt;You may see something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/2 200
content-type: text/html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;200&lt;/code&gt; status code indicates success.&lt;/p&gt;

&lt;h3&gt;
  
  
  Display Detailed Connection Information
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -v https://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The verbose option displays additional information about the request and connection.&lt;/p&gt;

&lt;p&gt;This is useful when debugging TLS, HTTP, and connection problems.&lt;/p&gt;

&lt;p&gt;Be careful when sharing verbose output because it may contain sensitive request information.&lt;/p&gt;

&lt;h3&gt;
  
  
  Save a Response to a File
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -o page.html https://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response body is saved as &lt;code&gt;page.html&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Follow Redirects
&lt;/h3&gt;

&lt;p&gt;Some websites redirect requests to another URL.&lt;/p&gt;

&lt;p&gt;Use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -L https://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-L&lt;/code&gt; option tells curl to follow HTTP redirects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Make a POST Request
&lt;/h3&gt;

&lt;p&gt;When testing APIs, you often need to send data.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -X POST https://api.example.com/users \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"name":"Hamed","role":"developer"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sends a JSON request body to the API.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using curl on Windows
&lt;/h3&gt;

&lt;p&gt;Modern Windows versions include curl.&lt;/p&gt;

&lt;p&gt;However, Windows PowerShell has historically defined &lt;code&gt;curl&lt;/code&gt; as an alias for &lt;code&gt;Invoke-WebRequest&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To explicitly run the native curl executable, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;curl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exe&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use PowerShell's native HTTP commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Invoke&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;WebRequest&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Uri&lt;/span&gt; &lt;span class="s2"&gt;"https://example.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For API requests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Invoke&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;RestMethod&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Uri&lt;/span&gt; &lt;span class="s2"&gt;"https://api.example.com/users"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Invoke-RestMethod&lt;/code&gt; is particularly useful when working with JSON APIs because it can convert JSON responses into PowerShell objects.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Understanding HTTP Status Codes
&lt;/h2&gt;

&lt;p&gt;When you work with APIs, you'll frequently encounter HTTP status codes.&lt;/p&gt;

&lt;p&gt;These codes describe the result of an HTTP request.&lt;/p&gt;

&lt;p&gt;Here are some important examples:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Status&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;200&lt;/td&gt;
&lt;td&gt;OK&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;201&lt;/td&gt;
&lt;td&gt;Created&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;204&lt;/td&gt;
&lt;td&gt;No Content&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;301&lt;/td&gt;
&lt;td&gt;Moved Permanently&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;302&lt;/td&gt;
&lt;td&gt;Found&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;400&lt;/td&gt;
&lt;td&gt;Bad Request&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;401&lt;/td&gt;
&lt;td&gt;Unauthorized&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;403&lt;/td&gt;
&lt;td&gt;Forbidden&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;404&lt;/td&gt;
&lt;td&gt;Not Found&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;405&lt;/td&gt;
&lt;td&gt;Method Not Allowed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;429&lt;/td&gt;
&lt;td&gt;Too Many Requests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;500&lt;/td&gt;
&lt;td&gt;Internal Server Error&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;502&lt;/td&gt;
&lt;td&gt;Bad Gateway&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;503&lt;/td&gt;
&lt;td&gt;Service Unavailable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;504&lt;/td&gt;
&lt;td&gt;Gateway Timeout&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -I https://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you receive:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/2 404
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server responded, but the requested resource wasn't found.&lt;/p&gt;

&lt;p&gt;If you receive:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/2 500
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server encountered an internal error.&lt;/p&gt;

&lt;p&gt;This distinction matters:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A successful network connection doesn't necessarily mean the application request succeeded.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You need to inspect both the network connection and the HTTP response.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Checking Your Network Configuration and DNS Cache
&lt;/h2&gt;

&lt;p&gt;Sometimes your computer has outdated DNS information.&lt;/p&gt;

&lt;p&gt;Operating systems maintain DNS caches to reduce repeated lookups.&lt;/p&gt;

&lt;p&gt;You can inspect or clear these caches when troubleshooting.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows
&lt;/h3&gt;

&lt;p&gt;Display DNS cache entries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ipconfig /displaydns
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Clear the DNS cache:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ipconfig /flushdns
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see a confirmation that the DNS Resolver Cache was flushed.&lt;/p&gt;

&lt;h3&gt;
  
  
  macOS
&lt;/h3&gt;

&lt;p&gt;On modern macOS versions, you can request a DNS cache flush with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo dscacheutil -flushcache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also restart the system DNS responder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo killall -HUP mDNSResponder
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These commands may vary in relevance depending on the macOS version and DNS configuration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux
&lt;/h3&gt;

&lt;p&gt;DNS caching depends on the services installed and enabled on your distribution.&lt;/p&gt;

&lt;p&gt;For systems using &lt;code&gt;systemd-resolved&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;resolvectl statistics
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To flush its cache:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo resolvectl flush-caches
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Not every Linux system uses &lt;code&gt;systemd-resolved&lt;/code&gt;, so these commands may not be available everywhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. Practical Troubleshooting Scenarios
&lt;/h2&gt;

&lt;p&gt;Let's combine what we've learned.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scenario 1: A Website Doesn't Load
&lt;/h3&gt;

&lt;p&gt;You try to open:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But the browser cannot connect.&lt;/p&gt;

&lt;p&gt;Start by checking DNS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nslookup example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then test basic connectivity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ping example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember that ICMP may be blocked.&lt;/p&gt;

&lt;p&gt;Next, test HTTPS connectivity from PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Test&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetConnection&lt;/span&gt; &lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Port&lt;/span&gt; &lt;span class="mi"&gt;443&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, inspect the HTTP response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -I https://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each command investigates a different part of the connection.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scenario 2: Your React Development Server Is Unreachable
&lt;/h3&gt;

&lt;p&gt;Your Vite server starts successfully:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But another device on your network cannot access it.&lt;/p&gt;

&lt;p&gt;First, identify your local IP address.&lt;/p&gt;

&lt;p&gt;Windows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ipconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip addr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ifconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, verify that your development server is listening on the correct interface.&lt;/p&gt;

&lt;p&gt;A server bound only to &lt;code&gt;127.0.0.1&lt;/code&gt; or &lt;code&gt;localhost&lt;/code&gt; generally accepts connections only from the same computer.&lt;/p&gt;

&lt;p&gt;For Vite, you can expose the development server to your local network with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev -- --host 0.0.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, from another device on the same network, try:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://YOUR_LOCAL_IP:5173
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://192.168.1.100:5173
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You may also need to allow the connection through your firewall.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security note:&lt;/strong&gt; Binding to &lt;code&gt;0.0.0.0&lt;/code&gt; makes the server listen on all available IPv4 interfaces. Only do this on networks you trust, and avoid exposing development servers directly to the public internet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scenario 3: An API Request Fails
&lt;/h3&gt;

&lt;p&gt;Your frontend sends a request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://api.example.com/users"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But it fails.&lt;/p&gt;

&lt;p&gt;You can investigate the endpoint independently:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -v https://api.example.com/users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then inspect DNS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nslookup api.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And test the HTTPS port:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Test&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetConnection&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Port&lt;/span&gt; &lt;span class="mi"&gt;443&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helps distinguish DNS, TCP, TLS, and HTTP-level problems.&lt;/p&gt;

&lt;p&gt;If curl succeeds but the browser request fails, investigate browser-specific issues such as CORS, cookies, authentication, and browser security policies.&lt;/p&gt;

&lt;h2&gt;
  
  
  12. Common Networking Mistakes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Assuming ping proves a website is available&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ping tests ICMP connectivity, not HTTP availability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Confusing an IP address with a port&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An IP address identifies a network interface; a port identifies a communication endpoint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Assuming DNS problems are always caused by the website&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your local DNS configuration, resolver, VPN, or network may be responsible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Ignoring firewall rules&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A service may be running and listening while a firewall blocks incoming connections.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Assuming an HTTP 404 means the network is broken&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A 404 is an HTTP response. The server was reachable enough to return that response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Exposing local development servers unnecessarily&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Listening on &lt;code&gt;0.0.0.0&lt;/code&gt; can make an application accessible to other devices on the network.&lt;/p&gt;

&lt;p&gt;Understand the security implications before doing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  13. Practice Exercises
&lt;/h2&gt;

&lt;p&gt;Try these exercises in your own environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exercise 1: Inspect Your Network
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Display your network interfaces.&lt;/li&gt;
&lt;li&gt;Find your local IPv4 address.&lt;/li&gt;
&lt;li&gt;Identify your default gateway.&lt;/li&gt;
&lt;li&gt;Find your DNS configuration.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 2: Test Connectivity
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Ping your default gateway.&lt;/li&gt;
&lt;li&gt;Ping a public domain.&lt;/li&gt;
&lt;li&gt;Compare the response times.&lt;/li&gt;
&lt;li&gt;Try the same test against another destination.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 3: Investigate DNS
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Resolve &lt;code&gt;example.com&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Query an A record.&lt;/li&gt;
&lt;li&gt;Query an AAAA record.&lt;/li&gt;
&lt;li&gt;Compare DNS results using two different resolvers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 4: Inspect Open Ports
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Start a local development server.&lt;/li&gt;
&lt;li&gt;Find the port it uses.&lt;/li&gt;
&lt;li&gt;Identify the process listening on that port.&lt;/li&gt;
&lt;li&gt;Verify whether the port is reachable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 5: Test an API
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Send an HTTP GET request with curl.&lt;/li&gt;
&lt;li&gt;Display response headers.&lt;/li&gt;
&lt;li&gt;Inspect the HTTP status code.&lt;/li&gt;
&lt;li&gt;Send a JSON POST request to a test API.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Quick Reference
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Linux&lt;/th&gt;
&lt;th&gt;macOS&lt;/th&gt;
&lt;th&gt;Windows&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Network configuration&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ip addr&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ifconfig&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ipconfig&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Test connectivity&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ping&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ping&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ping&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DNS lookup&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;nslookup&lt;/code&gt; / &lt;code&gt;dig&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;nslookup&lt;/code&gt; / &lt;code&gt;dig&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;nslookup&lt;/code&gt; / &lt;code&gt;Resolve-DnsName&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Trace route&lt;/td&gt;
&lt;td&gt;&lt;code&gt;traceroute&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;traceroute&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tracert&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inspect connections&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ss&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;lsof&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;netstat&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Find listening ports&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ss -tuln&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;lsof -iTCP -sTCP:LISTEN&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;netstat -ano&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Test TCP port&lt;/td&gt;
&lt;td&gt;&lt;code&gt;nc&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;nc&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Test-NetConnection&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTTP requests&lt;/td&gt;
&lt;td&gt;&lt;code&gt;curl&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;curl&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;curl.exe&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Flush DNS cache&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;resolvectl&lt;/code&gt; (if available)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;dscacheutil&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ipconfig /flushdns&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;You've now learned how to inspect network interfaces, test connectivity, resolve domain names, investigate open ports, and troubleshoot HTTP requests.&lt;/p&gt;

&lt;p&gt;These skills are incredibly useful when building web applications, debugging APIs, connecting to remote servers, and managing development environments.&lt;/p&gt;

&lt;p&gt;In the next article, we'll focus on tools that make everyday development work faster and more efficient.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Developer's Terminal Toolkit.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We'll explore utilities such as &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;ripgrep&lt;/code&gt;, &lt;code&gt;jq&lt;/code&gt;, &lt;code&gt;fzf&lt;/code&gt;, &lt;code&gt;bat&lt;/code&gt;, and other tools that can transform the way you work in the terminal.&lt;/p&gt;

&lt;p&gt;See you in Article 08!&lt;/p&gt;

</description>
      <category>termina</category>
      <category>networking</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Terminal Mastery-Process Management and System Monitoring</title>
      <dc:creator>Hamed Farazi</dc:creator>
      <pubDate>Sun, 15 Nov 2026 09:36:56 +0000</pubDate>
      <link>https://dev.to/hamedfarazi/terminal-mastery-process-management-and-system-monitoring-4chn</link>
      <guid>https://dev.to/hamedfarazi/terminal-mastery-process-management-and-system-monitoring-4chn</guid>
      <description>&lt;p&gt;06/10— Process Management and System Monitoring&lt;br&gt;
Have you ever started a development server and forgotten which terminal window is running it?&lt;/p&gt;

&lt;p&gt;Have you ever encountered a frozen application, a process consuming too much CPU, or a Node.js server that refuses to stop?&lt;/p&gt;

&lt;p&gt;Every operating system runs multiple processes in the background.&lt;/p&gt;

&lt;p&gt;Your browser, code editor, database, development server, and even the terminal itself are all examples of running processes.&lt;/p&gt;

&lt;p&gt;Understanding how to inspect, monitor, and manage these processes is an essential skill for developers and system administrators.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understand processes and process IDs (PIDs)&lt;/li&gt;
&lt;li&gt;List running processes&lt;/li&gt;
&lt;li&gt;Monitor CPU and memory usage&lt;/li&gt;
&lt;li&gt;Find processes using specific ports&lt;/li&gt;
&lt;li&gt;Stop and terminate processes&lt;/li&gt;
&lt;li&gt;Manage background tasks&lt;/li&gt;
&lt;li&gt;Monitor system resources&lt;/li&gt;
&lt;li&gt;Troubleshoot unresponsive applications&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We'll cover Linux, macOS, Windows PowerShell, and Windows CMD.&lt;/p&gt;

&lt;p&gt;Let's get started.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. What Is a Process?
&lt;/h2&gt;

&lt;p&gt;A process is an instance of a running program.&lt;/p&gt;

&lt;p&gt;For example, when you open Google Chrome, the operating system creates one or more processes to run it.&lt;/p&gt;

&lt;p&gt;When you start a development server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The operating system creates a process to execute the command.&lt;/p&gt;

&lt;p&gt;Every process has its own Process ID, commonly called a PID.&lt;/p&gt;

&lt;p&gt;A PID is a numeric identifier assigned by the operating system.&lt;/p&gt;

&lt;p&gt;You can use it to inspect or manage a specific process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Process vs. Program
&lt;/h3&gt;

&lt;p&gt;These two terms are related but different.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;program&lt;/strong&gt; is an executable file stored on disk.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;process&lt;/strong&gt; is a running instance of that program.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can start the same program multiple times, creating multiple processes.&lt;/p&gt;

&lt;p&gt;For example, opening several terminal windows may create several terminal-related processes.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Listing Running Processes
&lt;/h2&gt;

&lt;p&gt;The first thing we need to learn is how to see what's currently running.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux
&lt;/h3&gt;

&lt;p&gt;Use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays processes associated with your current terminal session.&lt;/p&gt;

&lt;p&gt;For a more detailed list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ps aux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Common columns include:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Column&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;USER&lt;/td&gt;
&lt;td&gt;Process owner&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PID&lt;/td&gt;
&lt;td&gt;Process ID&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%CPU&lt;/td&gt;
&lt;td&gt;CPU usage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%MEM&lt;/td&gt;
&lt;td&gt;Memory usage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;COMMAND&lt;/td&gt;
&lt;td&gt;Executed command&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;To search for a specific process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ps aux &lt;span class="o"&gt;|&lt;/span&gt; grep node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This searches the process list for entries containing &lt;code&gt;node&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Keep in mind that &lt;code&gt;grep&lt;/code&gt; may also match the search command itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  macOS
&lt;/h3&gt;

&lt;p&gt;macOS also supports &lt;code&gt;ps&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ps aux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To find Node.js processes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ps aux &lt;span class="o"&gt;|&lt;/span&gt; grep node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Windows PowerShell
&lt;/h3&gt;

&lt;p&gt;Use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays running processes.&lt;/p&gt;

&lt;p&gt;To find Node.js processes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To display selected information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nc"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;CPU&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;WorkingSet&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Name&lt;/code&gt; is the process name.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Id&lt;/code&gt; is the process ID.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;CPU&lt;/code&gt; represents accumulated processor time in seconds.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;WorkingSet&lt;/code&gt; represents the amount of physical memory currently used by the process.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Windows CMD
&lt;/h3&gt;

&lt;p&gt;Use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tasklist
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To find a specific process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tasklist | findstr node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To display detailed process information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tasklist /v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Understanding Process IDs (PIDs)
&lt;/h2&gt;

&lt;p&gt;Let's say you find this process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node.exe    4820
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The number &lt;code&gt;4820&lt;/code&gt; is its PID.&lt;/p&gt;

&lt;p&gt;You can use this identifier to inspect or terminate the process.&lt;/p&gt;

&lt;p&gt;In PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="mi"&gt;4820&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ps -p 4820
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tasklist /FI "PID eq 4820"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PIDs are particularly useful when multiple instances of the same application are running.&lt;/p&gt;

&lt;p&gt;Instead of terminating every Node.js process, you can target one specific process.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Monitoring CPU and Memory Usage
&lt;/h2&gt;

&lt;p&gt;Knowing which processes are running isn't enough.&lt;/p&gt;

&lt;p&gt;We also need to understand how much of the system's resources they consume.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux: top
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;top&lt;/code&gt; command provides a live overview of running processes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;top
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It displays information such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CPU usage&lt;/li&gt;
&lt;li&gt;Memory usage&lt;/li&gt;
&lt;li&gt;Load average&lt;/li&gt;
&lt;li&gt;Running processes&lt;/li&gt;
&lt;li&gt;Process IDs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Press &lt;code&gt;q&lt;/code&gt; to exit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux: htop
&lt;/h3&gt;

&lt;p&gt;Another popular tool is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;htop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It provides an interactive process monitor with a more convenient interface.&lt;/p&gt;

&lt;p&gt;However, &lt;code&gt;htop&lt;/code&gt; may not be installed by default.&lt;/p&gt;

&lt;p&gt;On Ubuntu or Debian:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install htop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  macOS: top
&lt;/h3&gt;

&lt;p&gt;macOS also supports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;top
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can inspect live CPU and memory usage directly in the terminal.&lt;/p&gt;

&lt;p&gt;To exit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;q
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Windows PowerShell
&lt;/h3&gt;

&lt;p&gt;To inspect processes and their memory usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Sort&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nc"&gt;WorkingSet&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Descending&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;First&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="nc"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;WorkingSet&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays the ten processes using the most physical memory.&lt;/p&gt;

&lt;p&gt;To sort by accumulated CPU time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Sort&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="no"&gt;CPU&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Descending&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;First&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="nc"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;CPU&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; The &lt;code&gt;CPU&lt;/code&gt; property represents accumulated CPU time, not the current CPU percentage. Sorting by it helps identify processes that have consumed significant CPU time since starting, but it isn't a live CPU usage measurement.&lt;/p&gt;

&lt;p&gt;For live performance monitoring, Windows provides additional tools such as Task Manager and Performance Monitor.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows CMD
&lt;/h3&gt;

&lt;p&gt;You can inspect basic resource information with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tasklist
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more detailed performance information, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resmon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This opens Windows Resource Monitor.&lt;/p&gt;

&lt;p&gt;You can also launch Task Manager:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;taskmgr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Finding Which Process Is Using a Port
&lt;/h2&gt;

&lt;p&gt;This is one of the most useful skills for web developers.&lt;/p&gt;

&lt;p&gt;Imagine you start a React or Node.js development server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But the terminal displays:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Port 5173 is already in use.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What happened?&lt;/p&gt;

&lt;p&gt;Another process is already listening on that port.&lt;/p&gt;

&lt;p&gt;We need to identify it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux
&lt;/h3&gt;

&lt;p&gt;Use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo lsof -i :5173
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays processes associated with port &lt;code&gt;5173&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Another option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo ss -ltnp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays listening TCP sockets and, when permissions allow, the associated processes.&lt;/p&gt;

&lt;h3&gt;
  
  
  macOS
&lt;/h3&gt;

&lt;p&gt;Use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lsof -i :5173
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To focus on listening TCP connections:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lsof -nP -iTCP:5173 -sTCP:LISTEN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Windows PowerShell
&lt;/h3&gt;

&lt;p&gt;Use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetTCPConnection&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;LocalPort&lt;/span&gt; &lt;span class="mi"&gt;5173&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To find the process using that port:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetTCPConnection&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;LocalPort&lt;/span&gt; &lt;span class="mi"&gt;5173&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nc"&gt;LocalAddress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;LocalPort&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;OwningProcess&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then inspect the process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="mi"&gt;4820&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;4820&lt;/code&gt; with the actual &lt;code&gt;OwningProcess&lt;/code&gt; value.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows CMD
&lt;/h3&gt;

&lt;p&gt;Use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;netstat -ano | findstr :5173
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TCP    0.0.0.0:5173    0.0.0.0:0    LISTENING    4820
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The final number is the PID.&lt;/p&gt;

&lt;p&gt;To identify the process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tasklist /FI "PID eq 4820"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This technique is especially useful when working with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React development servers&lt;/li&gt;
&lt;li&gt;Vite&lt;/li&gt;
&lt;li&gt;Next.js&lt;/li&gt;
&lt;li&gt;Node.js applications&lt;/li&gt;
&lt;li&gt;Local APIs&lt;/li&gt;
&lt;li&gt;Databases&lt;/li&gt;
&lt;li&gt;Docker containers&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  6. Stopping and Terminating Processes
&lt;/h2&gt;

&lt;p&gt;Sometimes a process needs to be stopped.&lt;/p&gt;

&lt;p&gt;Maybe an application is frozen, a development server is unresponsive, or a background task is consuming too many resources.&lt;/p&gt;

&lt;p&gt;Different operating systems provide different commands.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux and macOS: kill
&lt;/h3&gt;

&lt;p&gt;To terminate a process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;kill&lt;/span&gt; 4820
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sends the default termination signal, &lt;code&gt;SIGTERM&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It gives the process an opportunity to shut down gracefully.&lt;/p&gt;

&lt;p&gt;If the process doesn't stop, you can send a stronger signal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;kill&lt;/span&gt; -9 4820
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sends &lt;code&gt;SIGKILL&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The process cannot catch or ignore this signal, so it is terminated by the operating system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; Avoid using &lt;code&gt;kill -9&lt;/code&gt; as your first option. It prevents the application from performing its normal cleanup.&lt;/p&gt;

&lt;h3&gt;
  
  
  Find and Terminate by Process Name
&lt;/h3&gt;

&lt;p&gt;Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pkill node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sends a termination signal to matching processes.&lt;/p&gt;

&lt;p&gt;Be careful: it may terminate multiple Node.js processes.&lt;/p&gt;

&lt;p&gt;To inspect matching processes first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pgrep -a node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Windows PowerShell: Stop-Process
&lt;/h3&gt;

&lt;p&gt;To stop a process by PID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Stop&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="mi"&gt;4820&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To stop a process by name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Stop&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To force termination:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Stop&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="mi"&gt;4820&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Windows CMD: taskkill
&lt;/h3&gt;

&lt;p&gt;To terminate a process by PID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;taskkill /PID 4820
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To force termination:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;taskkill /PID 4820 /F
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To terminate by process name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;taskkill /IM node.exe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To terminate all matching processes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;taskkill /IM node.exe /F
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use these commands carefully, especially when several applications share the same process name.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Understanding Background Processes
&lt;/h2&gt;

&lt;p&gt;Sometimes you want to run a command without keeping the terminal occupied.&lt;/p&gt;

&lt;p&gt;Linux and macOS shells provide several ways to manage background jobs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Run a Command in the Background
&lt;/h3&gt;

&lt;p&gt;Add &lt;code&gt;&amp;amp;&lt;/code&gt; at the end:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;long-running-command &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The shell starts the command as a background job and returns control to your terminal.&lt;/p&gt;

&lt;h3&gt;
  
  
  List Background Jobs
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;jobs&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays jobs associated with the current shell session.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bring a Job to the Foreground
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;fg&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To bring a specific job forward:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;fg&lt;/span&gt; %1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Suspend a Running Process
&lt;/h3&gt;

&lt;p&gt;Press:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ctrl + Z
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This suspends the foreground job in shells that support job control.&lt;/p&gt;

&lt;p&gt;You can then resume it in the background:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;bg&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Important: Background Jobs vs. Independent Services
&lt;/h3&gt;

&lt;p&gt;A background job started with &lt;code&gt;&amp;amp;&lt;/code&gt; is still associated with its shell session.&lt;/p&gt;

&lt;p&gt;It isn't automatically a persistent service.&lt;/p&gt;

&lt;p&gt;If you close the terminal, the process may receive a hangup signal and terminate, depending on the shell and how the process was started.&lt;/p&gt;

&lt;p&gt;For longer-running tasks, Linux and macOS users may encounter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nohup long-running-command &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For production services, use a proper service manager instead of relying on a terminal background job.&lt;/p&gt;

&lt;p&gt;On Linux, a common example is &lt;code&gt;systemd&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Managing Processes in Windows
&lt;/h2&gt;

&lt;p&gt;Windows doesn't use the same Unix-style shell job-control commands.&lt;/p&gt;

&lt;p&gt;However, PowerShell provides useful process-management features.&lt;/p&gt;

&lt;h3&gt;
  
  
  Start a Process
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Start&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="n"&gt;notepad&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This starts Notepad as a separate process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Start a Process with Arguments
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Start&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="n"&gt;notepad&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ArgumentList&lt;/span&gt; &lt;span class="s2"&gt;"C:\temp\notes.txt"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Start a Process and Wait for It
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Start&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="n"&gt;notepad&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Wait&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PowerShell command waits until the launched process exits.&lt;/p&gt;

&lt;h3&gt;
  
  
  Start a Process in the Background
&lt;/h3&gt;

&lt;p&gt;PowerShell supports background jobs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Start&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Job&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ScriptBlock&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To inspect jobs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Job&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To receive job results:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Receive&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Job&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To remove a completed job:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Remove&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Job&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell jobs are not identical to Unix background processes. They are managed by PowerShell and have their own lifecycle.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. System Monitoring Commands
&lt;/h2&gt;

&lt;p&gt;Let's look beyond individual processes.&lt;/p&gt;

&lt;p&gt;Sometimes you need information about the entire operating system.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux
&lt;/h3&gt;

&lt;p&gt;Display system uptime:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uptime
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Display memory information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;free -h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Display disk usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;df -h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Display directory sizes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;du -sh *
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  macOS
&lt;/h3&gt;

&lt;p&gt;Display uptime:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uptime
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Display memory statistics:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vm_stat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Display disk usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;df -h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a more detailed system overview, you can also use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;system_profiler SPSoftwareDataType
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Windows PowerShell
&lt;/h3&gt;

&lt;p&gt;Display operating system information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;CimInstance&lt;/span&gt; &lt;span class="nc"&gt;Win32_OperatingSystem&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Display memory information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;CimInstance&lt;/span&gt; &lt;span class="nc"&gt;Win32_OperatingSystem&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nc"&gt;TotalVisibleMemorySize&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;FreePhysicalMemory&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Display disk information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Volume&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Display logical disk information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;CimInstance&lt;/span&gt; &lt;span class="nc"&gt;Win32_LogicalDisk&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nc"&gt;DeviceID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;FreeSpace&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Windows CMD
&lt;/h3&gt;

&lt;p&gt;Display system information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systeminfo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Display available disk space:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wmic logicaldisk get caption,size,freespace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: WMIC is deprecated and may not be installed or available on newer Windows versions. PowerShell's CIM commands are the recommended modern alternative.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Practical Workflow: Fixing a Busy Development Port
&lt;/h2&gt;

&lt;p&gt;Let's put everything together.&lt;/p&gt;

&lt;p&gt;Imagine you're running a Vite project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But the application reports that port &lt;code&gt;5173&lt;/code&gt; is already in use.&lt;/p&gt;

&lt;p&gt;Here's how to troubleshoot it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Find the Process
&lt;/h3&gt;

&lt;p&gt;On Linux or macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lsof -nP -iTCP:5173 -sTCP:LISTEN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Windows CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;netstat -ano | findstr :5173
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NetTCPConnection&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;LocalPort&lt;/span&gt; &lt;span class="mi"&gt;5173&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;State&lt;/span&gt; &lt;span class="nc"&gt;Listen&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Identify the Process
&lt;/h3&gt;

&lt;p&gt;On Linux or macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ps -p 4820 -o pid,comm,args
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="mi"&gt;4820&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Windows CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tasklist /FI "PID eq 4820"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;4820&lt;/code&gt; with the PID you discovered.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Stop It if Appropriate
&lt;/h3&gt;

&lt;p&gt;Linux or macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;kill&lt;/span&gt; 4820
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Stop&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="mi"&gt;4820&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;taskkill /PID 4820
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Start Your Development Server Again
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should now be able to use the port if the previous process released it successfully.&lt;/p&gt;

&lt;p&gt;Always verify that the process you are terminating is actually the one you intend to stop.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. Common Mistakes to Avoid
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Killing processes without checking their PID&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A process name alone may match multiple applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Using force termination immediately&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Try graceful termination first whenever possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Confusing CPU time with CPU percentage&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In PowerShell, &lt;code&gt;Get-Process&lt;/code&gt;'s &lt;code&gt;CPU&lt;/code&gt; property is accumulated CPU time, not instantaneous CPU usage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Assuming background jobs survive terminal closure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A background job isn't automatically a persistent service.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Ignoring administrative permissions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Some process-management operations require elevated privileges.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Forgetting that process IDs can change&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A PID is not a permanent identifier. A process can exit, and its PID may eventually be reused.&lt;/p&gt;

&lt;h2&gt;
  
  
  12. Practice Exercises
&lt;/h2&gt;

&lt;p&gt;Try these exercises in your own environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exercise 1: Inspect Running Processes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Display all running processes.&lt;/li&gt;
&lt;li&gt;Find the Node.js processes.&lt;/li&gt;
&lt;li&gt;Identify their PIDs.&lt;/li&gt;
&lt;li&gt;Display selected information about them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 2: Monitor Resource Usage
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Find the processes using the most memory.&lt;/li&gt;
&lt;li&gt;Compare their resource usage.&lt;/li&gt;
&lt;li&gt;Identify an application consuming more resources than expected.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 3: Find a Busy Port
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Start a local development server.&lt;/li&gt;
&lt;li&gt;Identify the port it uses.&lt;/li&gt;
&lt;li&gt;Find the PID listening on that port.&lt;/li&gt;
&lt;li&gt;Identify the associated application.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 4: Terminate a Process
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Start Notepad on Windows or a simple application on macOS/Linux.&lt;/li&gt;
&lt;li&gt;Find its PID.&lt;/li&gt;
&lt;li&gt;Terminate it gracefully.&lt;/li&gt;
&lt;li&gt;Verify that it has stopped.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Exercise 5: Explore Background Jobs
&lt;/h3&gt;

&lt;p&gt;On Linux or macOS:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start a long-running command in the background.&lt;/li&gt;
&lt;li&gt;List your jobs.&lt;/li&gt;
&lt;li&gt;Bring one to the foreground.&lt;/li&gt;
&lt;li&gt;Suspend and resume it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On PowerShell:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start a background job.&lt;/li&gt;
&lt;li&gt;Inspect it.&lt;/li&gt;
&lt;li&gt;Receive its output.&lt;/li&gt;
&lt;li&gt;Remove the completed job.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Quick Reference
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Linux / macOS&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;th&gt;CMD&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;List processes&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ps aux&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Process&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tasklist&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Find process&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pgrep node&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Process node&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;`tasklist \&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inspect PID&lt;/td&gt;
&lt;td&gt;{% raw %}&lt;code&gt;ps -p 4820&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Process -Id 4820&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tasklist /FI "PID eq 4820"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stop process&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kill 4820&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Stop-Process -Id 4820&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;taskkill /PID 4820&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Force stop&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kill -9 4820&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Stop-Process -Id 4820 -Force&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;taskkill /PID 4820 /F&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Find port usage&lt;/td&gt;
&lt;td&gt;&lt;code&gt;lsof -i :5173&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-NetTCPConnection -LocalPort 5173&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;netstat -ano&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Show uptime&lt;/td&gt;
&lt;td&gt;&lt;code&gt;uptime&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;CIM / system information&lt;/td&gt;
&lt;td&gt;&lt;code&gt;systeminfo&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Show disk usage&lt;/td&gt;
&lt;td&gt;&lt;code&gt;df -h&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Volume&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;diskpart&lt;/code&gt; / &lt;code&gt;fsutil&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;You've now learned how to inspect running processes, identify resource usage, find applications occupying ports, and terminate unresponsive programs.&lt;/p&gt;

&lt;p&gt;These skills are particularly valuable when developing applications, managing servers, and troubleshooting local environments.&lt;/p&gt;

&lt;p&gt;In the next article, we'll explore another essential developer skill:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Networking from the Command Line.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We'll learn how to test network connectivity, inspect DNS records, analyze IP addresses, diagnose connection problems, and investigate ports using terminal commands.&lt;/p&gt;

&lt;p&gt;See you in Article 07!&lt;/p&gt;

</description>
      <category>terminal</category>
      <category>linux</category>
      <category>windows</category>
      <category>devtools</category>
    </item>
    <item>
      <title>Terminal Mastery-Users, Permissions and Administrative Privileges</title>
      <dc:creator>Hamed Farazi</dc:creator>
      <pubDate>Sun, 15 Nov 2026 08:26:47 +0000</pubDate>
      <link>https://dev.to/hamedfarazi/terminal-mastery-users-permissions-and-administrative-privileges-576</link>
      <guid>https://dev.to/hamedfarazi/terminal-mastery-users-permissions-and-administrative-privileges-576</guid>
      <description>&lt;p&gt;05/10 Terminal Mastery&lt;br&gt;
Have you ever tried to modify a file and received a message like this?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Permission denied
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or perhaps you've run a command and received:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Access is denied.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These messages aren't random errors. They're part of an important security mechanism used by operating systems to control who can access files, modify data, and execute programs.&lt;/p&gt;

&lt;p&gt;Every modern operating system has an access control system.&lt;/p&gt;

&lt;p&gt;Whether you're using Linux, macOS, or Windows, understanding users and permissions is essential for working confidently in the terminal.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users and groups&lt;/li&gt;
&lt;li&gt;File ownership&lt;/li&gt;
&lt;li&gt;Read, write, and execute permissions&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;chmod&lt;/code&gt;, &lt;code&gt;chown&lt;/code&gt;, and &lt;code&gt;chgrp&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sudo&lt;/code&gt; and root privileges&lt;/li&gt;
&lt;li&gt;Windows Administrator privileges&lt;/li&gt;
&lt;li&gt;PowerShell access control commands&lt;/li&gt;
&lt;li&gt;Practical security examples&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's begin.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Understanding Users and Groups
&lt;/h2&gt;

&lt;p&gt;Operating systems use user accounts to identify who is performing an action.&lt;/p&gt;

&lt;p&gt;For example, a typical Linux or macOS system might have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A regular user account&lt;/li&gt;
&lt;li&gt;An administrator account&lt;/li&gt;
&lt;li&gt;A system account&lt;/li&gt;
&lt;li&gt;A root account&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Windows has a similar concept, although its permission model is different.&lt;/p&gt;

&lt;h3&gt;
  
  
  Find Your Current User
&lt;/h3&gt;

&lt;p&gt;First, let's identify which user is currently running our terminal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linux and macOS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;whoami
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Windows PowerShell:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;whoami&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Windows CMD:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;whoami
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All three environments support &lt;code&gt;whoami&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You might see something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hamed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Windows, the output may include the computer name or domain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DESKTOP-123\hamed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Find Your Groups
&lt;/h3&gt;

&lt;p&gt;Users can belong to one or more groups.&lt;/p&gt;

&lt;p&gt;Groups make permission management easier because administrators can assign access to a group instead of configuring every user individually.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;groups
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To see more detailed identity information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;macOS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;groups
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PowerShell:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;whoami&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;groups&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CMD:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;whoami /groups
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These commands help you understand which groups your current account belongs to.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Understanding Linux and macOS File Permissions
&lt;/h2&gt;

&lt;p&gt;Linux and macOS use a permission model based on three primary permission categories:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Category&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;User (u)&lt;/td&gt;
&lt;td&gt;The file owner&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Group (g)&lt;/td&gt;
&lt;td&gt;Members of the file's group&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Others (o)&lt;/td&gt;
&lt;td&gt;Everyone else&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each category can have three basic permissions:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Permission&lt;/th&gt;
&lt;th&gt;Symbol&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Read&lt;/td&gt;
&lt;td&gt;r&lt;/td&gt;
&lt;td&gt;Read file contents&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Write&lt;/td&gt;
&lt;td&gt;w&lt;/td&gt;
&lt;td&gt;Modify file contents&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Execute&lt;/td&gt;
&lt;td&gt;x&lt;/td&gt;
&lt;td&gt;Execute a file or access a directory&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Let's inspect a file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -l
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-rwxr-xr-- 1 hamed developers 1024 Nov 15 script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break down the permission string:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-rwxr-xr--
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first character represents the file type.&lt;/p&gt;

&lt;p&gt;The remaining nine characters are divided into three groups:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- rwx r-x r--
  |   |   |
  |   |   └── Others
  |   └────── Group
  └────────── Owner
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Owner: read, write, execute&lt;/li&gt;
&lt;li&gt;Group: read, execute&lt;/li&gt;
&lt;li&gt;Others: read only&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This means the owner can modify and execute the file, group members can read and execute it, and other users can only read it.&lt;/p&gt;

&lt;h3&gt;
  
  
  File Permissions vs. Directory Permissions
&lt;/h3&gt;

&lt;p&gt;An important detail:&lt;/p&gt;

&lt;p&gt;Permissions have slightly different meanings for files and directories.&lt;/p&gt;

&lt;p&gt;For files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;r&lt;/code&gt;: Read the file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;w&lt;/code&gt;: Modify the file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;x&lt;/code&gt;: Execute the file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For directories:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;r&lt;/code&gt;: List directory entries.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;w&lt;/code&gt;: Create, delete, or rename entries, subject to other access controls.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;x&lt;/code&gt;: Traverse the directory and access entries when other permissions allow it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This distinction is especially important when troubleshooting permission problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Changing Permissions with chmod
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;chmod&lt;/code&gt; command changes file and directory permissions on Linux and macOS.&lt;/p&gt;

&lt;p&gt;There are two common ways to use it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Symbolic mode&lt;/li&gt;
&lt;li&gt;Numeric mode&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Symbolic Mode
&lt;/h3&gt;

&lt;p&gt;Let's start with a simple example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chmod u+x script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This adds execute permission for the file owner.&lt;/p&gt;

&lt;p&gt;Here are some useful examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chmod u+w file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add write permission for the owner.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chmod g-r file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remove read permission from the group.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chmod o+x script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add execute permission for others.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chmod a+r file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add read permission for everyone.&lt;/p&gt;

&lt;p&gt;The symbols are straightforward:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symbol&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;u&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;User / owner&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;g&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Group&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;o&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Others&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;a&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;All&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;+&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Add permission&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Remove permission&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;=&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Set exact permissions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Numeric Mode
&lt;/h3&gt;

&lt;p&gt;You can also represent permissions using numbers.&lt;/p&gt;

&lt;p&gt;Each permission has a numeric value:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Permission&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Read (&lt;code&gt;r&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Write (&lt;code&gt;w&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Execute (&lt;code&gt;x&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Add the values to calculate each permission group.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chmod 755 script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Owner: 7 = 4 + 2 + 1 = read, write, execute&lt;/li&gt;
&lt;li&gt;Group: 5 = 4 + 1 = read, execute&lt;/li&gt;
&lt;li&gt;Others: 5 = 4 + 1 = read, execute&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Another common example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chmod 644 file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Owner: read and write&lt;/li&gt;
&lt;li&gt;Group: read only&lt;/li&gt;
&lt;li&gt;Others: read only&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A few common permission patterns:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;chmod 755 file&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Owner can read, write, execute; others can read and execute&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;chmod 644 file&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Owner can read and write; others can read&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;chmod 600 file&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Only the owner can read and write&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;chmod 700 directory&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Only the owner has full access&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Security tip:&lt;/strong&gt; Avoid using &lt;code&gt;chmod 777&lt;/code&gt; as a quick fix for permission problems. It grants read, write, and execute permissions to everyone, which can create serious security risks.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Changing File Ownership
&lt;/h2&gt;

&lt;p&gt;Sometimes you need to change who owns a file or directory.&lt;/p&gt;

&lt;p&gt;On Linux and macOS, use &lt;code&gt;chown&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo chown hamed file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This changes the owner of &lt;code&gt;file.txt&lt;/code&gt; to &lt;code&gt;hamed&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To change both the owner and group:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo chown hamed:developers file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To apply ownership changes recursively:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo chown -R hamed:developers project/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-R&lt;/code&gt; option applies the change to the directory and its contents.&lt;/p&gt;

&lt;p&gt;Be careful with recursive ownership changes. Applying them to the wrong directory can break system services or applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Changing the Group
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;chgrp&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo chgrp developers file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This changes the file's group to &lt;code&gt;developers&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can also use &lt;code&gt;chown&lt;/code&gt; to change only the group:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo chown :developers file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Understanding sudo and the Root User
&lt;/h2&gt;

&lt;p&gt;On Linux and macOS, &lt;code&gt;root&lt;/code&gt; is the superuser account.&lt;/p&gt;

&lt;p&gt;Root has extensive privileges over the system.&lt;/p&gt;

&lt;p&gt;Regular users usually don't have permission to perform every administrative operation.&lt;/p&gt;

&lt;p&gt;That's where &lt;code&gt;sudo&lt;/code&gt; comes in.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo&lt;/code&gt; allows an authorized user to execute a command with elevated privileges.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Ubuntu and Debian-based Linux distributions, this runs the package update command with administrative privileges.&lt;/p&gt;

&lt;p&gt;Another example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl restart nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This restarts the Nginx service.&lt;/p&gt;

&lt;p&gt;You might be asked to enter your password.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; When typing a password in many Unix-like terminals, the terminal doesn't display characters or asterisks. This is normal behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  Running a Shell with Elevated Privileges
&lt;/h3&gt;

&lt;p&gt;You may also encounter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo -i
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This starts an interactive root login shell on systems using sudo.&lt;/p&gt;

&lt;p&gt;You can leave it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, it's generally safer to use &lt;code&gt;sudo&lt;/code&gt; for individual commands rather than staying in a privileged shell unnecessarily.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Difference Between sudo and su
&lt;/h3&gt;

&lt;p&gt;Another command worth knowing is &lt;code&gt;su&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;su -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This attempts to switch to another user, usually root.&lt;/p&gt;

&lt;p&gt;The difference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sudo&lt;/code&gt;: Runs a command with elevated privileges according to the system's sudo configuration.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;su&lt;/code&gt;: Switches to another user account.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not every Linux distribution configures these commands in the same way.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Windows Administrator Privileges
&lt;/h2&gt;

&lt;p&gt;Windows uses a different security model.&lt;/p&gt;

&lt;p&gt;Instead of relying on Unix-style root permissions, Windows uses user accounts, security groups, access control lists (ACLs), and User Account Control (UAC).&lt;/p&gt;

&lt;p&gt;A standard user may be unable to perform certain administrative operations.&lt;/p&gt;

&lt;p&gt;For example, modifying protected system directories may require an elevated PowerShell or CMD session.&lt;/p&gt;

&lt;h3&gt;
  
  
  Check Whether PowerShell Is Running as Administrator
&lt;/h3&gt;

&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$currentIdentity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;Security&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Principal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;WindowsIdentity&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;GetCurrent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nv"&gt;$principal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nc"&gt;Security&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Principal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;WindowsPrincipal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$currentIdentity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nv"&gt;$principal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IsInRole&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;Security&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Principal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;WindowsBuiltInRole&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;Administrator&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;True&lt;/code&gt; means the current PowerShell process has an elevated Administrator token.&lt;/p&gt;

&lt;p&gt;Simply belonging to the Administrators group doesn't necessarily mean the current terminal is elevated. UAC can run an administrator account with a filtered token until elevation is requested.&lt;/p&gt;

&lt;h3&gt;
  
  
  Open PowerShell as Administrator
&lt;/h3&gt;

&lt;p&gt;You can open an elevated PowerShell window using:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the Start menu.&lt;/li&gt;
&lt;li&gt;Search for PowerShell.&lt;/li&gt;
&lt;li&gt;Right-click it.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Run as administrator&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Approve the UAC prompt.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can also request an elevated PowerShell process from an existing PowerShell session:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Start&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="n"&gt;powershell&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Verb&lt;/span&gt; &lt;span class="nc"&gt;RunAs&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For PowerShell 7:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Start&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="n"&gt;pwsh&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Verb&lt;/span&gt; &lt;span class="nc"&gt;RunAs&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A new elevated window will open after UAC approval.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Managing Windows File Permissions with icacls
&lt;/h2&gt;

&lt;p&gt;Windows uses Access Control Lists (ACLs) to determine who can access files and directories.&lt;/p&gt;

&lt;p&gt;One important command-line utility is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;icacls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's explore some examples.&lt;/p&gt;

&lt;h3&gt;
  
  
  View Permissions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;icacls file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays the file's access control entries.&lt;/p&gt;

&lt;h3&gt;
  
  
  Grant Read Access
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;icacls file.txt /grant username:R
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This grants the specified user read access.&lt;/p&gt;

&lt;h3&gt;
  
  
  Grant Modify Access
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;icacls file.txt /grant username:M
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This grants modify access.&lt;/p&gt;

&lt;h3&gt;
  
  
  Remove an Explicit Permission
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;icacls file.txt /remove username
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This removes matching explicit access control entries for that user.&lt;/p&gt;

&lt;p&gt;It does not necessarily remove access inherited from parent directories.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding Common Permission Codes
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Code&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;F&lt;/td&gt;
&lt;td&gt;Full control&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;M&lt;/td&gt;
&lt;td&gt;Modify&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RX&lt;/td&gt;
&lt;td&gt;Read and execute&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R&lt;/td&gt;
&lt;td&gt;Read&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;W&lt;/td&gt;
&lt;td&gt;Write&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You can inspect permissions before changing them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Be careful when modifying ACLs on Windows system directories. Incorrect permissions can prevent applications or Windows components from working correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Managing Permissions in PowerShell
&lt;/h2&gt;

&lt;p&gt;PowerShell also provides access to Windows security information.&lt;/p&gt;

&lt;h3&gt;
  
  
  Get File Permissions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Acl&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This returns an ACL object.&lt;/p&gt;

&lt;h3&gt;
  
  
  Store the ACL in a Variable
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$acl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Acl&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can inspect its access rules:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$acl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Access&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  View the File Owner
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$acl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Owner&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Understanding the Difference
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Get-Acl&lt;/code&gt; retrieves security information.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Set-Acl&lt;/code&gt; applies security information.&lt;/p&gt;

&lt;p&gt;For example, after making a deliberate change to an ACL object, you can apply it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Acl&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;AclObject&lt;/span&gt; &lt;span class="nv"&gt;$acl&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't run this blindly without modifying or understanding the ACL object first.&lt;/p&gt;

&lt;p&gt;For many everyday permission-management tasks, &lt;code&gt;icacls&lt;/code&gt; is more direct.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Understanding Hidden Files and Permissions
&lt;/h2&gt;

&lt;p&gt;Hidden files and file permissions are two different concepts.&lt;/p&gt;

&lt;p&gt;A hidden file is not necessarily protected.&lt;/p&gt;

&lt;p&gt;On Linux and macOS, filenames beginning with a dot are conventionally treated as hidden:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -la
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Windows, hidden files have a file attribute.&lt;/p&gt;

&lt;p&gt;To show hidden files in PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To inspect file attributes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Force&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Format&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt; &lt;span class="nc"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Attributes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A file can be hidden and still readable by users who have permission to access it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remember:&lt;/strong&gt; Hiding a file is not a security mechanism.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Real-World Permission Scenarios
&lt;/h2&gt;

&lt;p&gt;Let's apply these concepts to common development situations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scenario 1: A Shell Script Won't Execute
&lt;/h3&gt;

&lt;p&gt;You try to run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./deploy.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But receive:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Permission denied
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inspect the permissions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -l deploy.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the file doesn't have execute permission for you, add it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chmod u+x deploy.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run it again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./deploy.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Scenario 2: You Cannot Modify a File
&lt;/h3&gt;

&lt;p&gt;On Linux or macOS, inspect ownership and permissions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -l config.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you own the file but lack write permission:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chmod u+w config.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If another account owns it, you may need an administrator to change its ownership or permissions.&lt;/p&gt;

&lt;p&gt;Don't automatically use &lt;code&gt;sudo&lt;/code&gt; to edit every file that produces a permission error. First understand why access is restricted.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scenario 3: A Windows Directory Rejects Your Changes
&lt;/h3&gt;

&lt;p&gt;You try to modify a protected Windows directory and receive an access-denied error.&lt;/p&gt;

&lt;p&gt;First, determine whether the terminal is elevated.&lt;/p&gt;

&lt;p&gt;Then inspect the file's ACL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Acl&lt;/span&gt; &lt;span class="s2"&gt;"C:\SomeFolder\config.txt"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have a legitimate reason to modify the file, use the appropriate administrative permissions.&lt;/p&gt;

&lt;p&gt;Don't take ownership of system directories or grant broad access just to bypass an error.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. Security Best Practices
&lt;/h2&gt;

&lt;p&gt;Understanding permissions isn't just about making commands work.&lt;/p&gt;

&lt;p&gt;It's about keeping your system secure.&lt;/p&gt;

&lt;p&gt;Here are some important habits:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Use the least privilege principle.&lt;/strong&gt; Give users only the permissions they actually need.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid unnecessary administrator sessions.&lt;/strong&gt; Use elevated privileges only when required.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Be careful with recursive changes.&lt;/strong&gt; Commands like &lt;code&gt;chmod -R&lt;/code&gt; and &lt;code&gt;chown -R&lt;/code&gt; can affect thousands of files.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid &lt;code&gt;chmod 777&lt;/code&gt;.&lt;/strong&gt; It gives everyone extensive access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inspect before modifying.&lt;/strong&gt; Use &lt;code&gt;ls -l&lt;/code&gt;, &lt;code&gt;Get-Acl&lt;/code&gt;, or &lt;code&gt;icacls&lt;/code&gt; before changing permissions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't blindly copy commands using &lt;code&gt;sudo&lt;/code&gt;.&lt;/strong&gt; Understand what a privileged command will do.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Protect sensitive files.&lt;/strong&gt; Configuration files, private keys, and credentials should have appropriately restricted access.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  12. Practice Exercises
&lt;/h2&gt;

&lt;p&gt;Try these exercises in your own environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux / macOS
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create a file called &lt;code&gt;script.sh&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Inspect its permissions using &lt;code&gt;ls -l&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Add execute permission for the owner.&lt;/li&gt;
&lt;li&gt;Change its permissions to &lt;code&gt;644&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Change them again to &lt;code&gt;755&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;whoami&lt;/code&gt; and &lt;code&gt;groups&lt;/code&gt; to inspect your current identity.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Windows PowerShell
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create a file named &lt;code&gt;permissions.txt&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Inspect its security information using &lt;code&gt;Get-Acl&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Display its owner.&lt;/li&gt;
&lt;li&gt;Display its access rules.&lt;/li&gt;
&lt;li&gt;Check whether PowerShell is running with elevated privileges.&lt;/li&gt;
&lt;li&gt;Inspect the file's permissions using &lt;code&gt;icacls&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Try to understand what each command changes rather than simply copying it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Reference
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Linux / macOS&lt;/th&gt;
&lt;th&gt;Windows&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Current user&lt;/td&gt;
&lt;td&gt;&lt;code&gt;whoami&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;whoami&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;User groups&lt;/td&gt;
&lt;td&gt;&lt;code&gt;groups&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;whoami /groups&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Identity details&lt;/td&gt;
&lt;td&gt;&lt;code&gt;id&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;whoami /all&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;View permissions&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ls -l&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;icacls file.txt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change permissions&lt;/td&gt;
&lt;td&gt;&lt;code&gt;chmod&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;icacls&lt;/code&gt; / &lt;code&gt;Set-Acl&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change owner&lt;/td&gt;
&lt;td&gt;&lt;code&gt;chown&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;icacls&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>webdev</category>
      <category>terminal</category>
    </item>
    <item>
      <title>Terminal Mastery-Pipes, Redirection and Command Chaining</title>
      <dc:creator>Hamed Farazi</dc:creator>
      <pubDate>Sun, 15 Nov 2026 08:24:15 +0000</pubDate>
      <link>https://dev.to/hamedfarazi/terminal-mastery-pipes-redirection-and-command-chaining-32o1</link>
      <guid>https://dev.to/hamedfarazi/terminal-mastery-pipes-redirection-and-command-chaining-32o1</guid>
      <description>&lt;p&gt;4/10 Terminal Mastery&lt;/p&gt;

&lt;h1&gt;
  
  
  Pipes, Redirection and Command Chaining: Mastering Terminal Workflows
&lt;/h1&gt;

&lt;p&gt;So far in this series, we've learned how to navigate the file system, create and manage files, and search through their contents.&lt;/p&gt;

&lt;p&gt;But there's a skill that takes terminal usage to another level:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Combining commands to build powerful workflows.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of running one command, reading its output, and manually passing the result to another command, we can connect commands together, redirect their output, and automate sequences of operations.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore three essential concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pipes (&lt;code&gt;|&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Input and output redirection (&lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Command chaining (&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;, &lt;code&gt;||&lt;/code&gt;, &lt;code&gt;;&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We'll cover Windows PowerShell, Windows CMD, macOS, and Linux.&lt;/p&gt;

&lt;p&gt;Let's get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Understanding Standard Input and Output
&lt;/h2&gt;

&lt;p&gt;Before learning pipes and redirection, we need to understand how command-line programs communicate.&lt;/p&gt;

&lt;p&gt;Most command-line applications use three standard streams:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stream&lt;/th&gt;
&lt;th&gt;Number&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Standard Input&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;Receives input&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Standard Output&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Displays normal output&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Standard Error&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Displays error messages&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Think of them as three separate communication channels.&lt;/p&gt;

&lt;p&gt;For example, when you run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command sends its normal output to &lt;strong&gt;Standard Output&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But if you run a command that fails, its error message usually goes to &lt;strong&gt;Standard Error&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This distinction becomes extremely useful when you want to save successful results without saving error messages, or the other way around.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. What Is a Pipe?
&lt;/h2&gt;

&lt;p&gt;A pipe connects the output of one command to the input of another.&lt;/p&gt;

&lt;p&gt;The symbol is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;|&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Imagine you have a list of files and want to search that list for a specific filename.&lt;/p&gt;

&lt;p&gt;On Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -la &lt;span class="o"&gt;|&lt;/span&gt; grep &lt;span class="s2"&gt;"report"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's what happens:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;ls -la&lt;/code&gt; lists directory contents.&lt;/li&gt;
&lt;li&gt;The pipe (&lt;code&gt;|&lt;/code&gt;) takes its output.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;grep "report"&lt;/code&gt; searches that output.&lt;/li&gt;
&lt;li&gt;Only matching lines are displayed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Instead of manually copying the output of one command into another, the shell connects them automatically.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pipes in Windows PowerShell
&lt;/h3&gt;

&lt;p&gt;PowerShell also supports pipes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Where&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;like&lt;/span&gt; &lt;span class="s2"&gt;"*report*"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Get-ChildItem&lt;/code&gt; retrieves directory items.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Where-Object&lt;/code&gt; filters them.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;$_&lt;/code&gt; represents the current object being processed.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.Name&lt;/code&gt; accesses the item's name.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's an important difference:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bash and Zsh generally pass streams of text or bytes through pipes. PowerShell pipelines pass .NET objects between PowerShell commands.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That means PowerShell can filter and manipulate properties directly without first parsing text.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pipes in Windows CMD
&lt;/h3&gt;

&lt;p&gt;CMD also supports pipes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dir | findstr "report"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works similarly to the Linux example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;dir&lt;/code&gt; lists directory contents.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;findstr&lt;/code&gt; searches the output.&lt;/li&gt;
&lt;li&gt;Matching lines are displayed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Connecting Multiple Commands
&lt;/h3&gt;

&lt;p&gt;You can connect more than two commands.&lt;/p&gt;

&lt;p&gt;Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -la &lt;span class="o"&gt;|&lt;/span&gt; grep &lt;span class="s2"&gt;"\.log"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Where&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nc"&gt;Extension&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;eq&lt;/span&gt; &lt;span class="s2"&gt;".log"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Sort&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nc"&gt;Name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dir /b | findstr "\.log" | sort
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is where the terminal becomes powerful: each command performs one small task, and together they solve a larger problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Redirecting Output to a File
&lt;/h2&gt;

&lt;p&gt;By default, commands usually display their output in the terminal.&lt;/p&gt;

&lt;p&gt;But what if you want to save that output into a file?&lt;/p&gt;

&lt;p&gt;That's where redirection comes in.&lt;/p&gt;

&lt;h3&gt;
  
  
  The &lt;code&gt;&amp;gt;&lt;/code&gt; Operator: Overwrite a File
&lt;/h3&gt;

&lt;p&gt;Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -la &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; files.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;files&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dir &amp;gt; files.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All three examples redirect normal output into &lt;code&gt;files.txt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; If the file already exists, &lt;code&gt;&amp;gt;&lt;/code&gt; replaces its previous contents.&lt;/p&gt;

&lt;p&gt;Be careful when using it with important files.&lt;/p&gt;

&lt;h3&gt;
  
  
  The &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; Operator: Append to a File
&lt;/h3&gt;

&lt;p&gt;What if you want to add new output without deleting the existing contents?&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"New log entry"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; app.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="s2"&gt;"New log entry"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo New log entry &amp;gt;&amp;gt; app.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This adds the new content to the end of the file.&lt;/p&gt;

&lt;p&gt;A useful way to remember the difference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&amp;gt;&lt;/code&gt; replaces existing content.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; appends new content.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Redirecting Error Messages
&lt;/h2&gt;

&lt;p&gt;Remember the three standard streams?&lt;/p&gt;

&lt;p&gt;We can redirect them separately.&lt;/p&gt;

&lt;p&gt;The number &lt;code&gt;2&lt;/code&gt; represents Standard Error.&lt;/p&gt;

&lt;p&gt;For example, in Bash and Zsh:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls /this-folder-does-not-exist 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; errors.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="no"&gt;C&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;\&lt;span class="nc"&gt;ThisFolderDoesNotExist&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dir C:\ThisFolderDoesNotExist 2&amp;gt; errors.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of displaying the error in the terminal, the error output is redirected to &lt;code&gt;errors.txt&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Redirecting Both Normal Output and Errors
&lt;/h3&gt;

&lt;p&gt;Sometimes you want to capture everything.&lt;/p&gt;

&lt;p&gt;In Bash and Zsh:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;some-command &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; output.txt 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Redirect Standard Output to &lt;code&gt;output.txt&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Redirect Standard Error to wherever Standard Output is currently going.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The order matters.&lt;/p&gt;

&lt;p&gt;In PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;some&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="o"&gt;*&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;*&amp;gt;&lt;/code&gt; operator redirects all PowerShell streams to the specified destination.&lt;/p&gt;

&lt;p&gt;In Windows CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;some-command &amp;gt; output.txt 2&amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CMD syntax is the same as Bash for this operation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A useful detail:&lt;/strong&gt; In PowerShell, &lt;code&gt;2&amp;gt;&amp;amp;1&lt;/code&gt; merges the error stream into the success output stream. It doesn't mean exactly the same thing as redirecting every PowerShell stream with &lt;code&gt;*&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Redirecting Input from a File
&lt;/h2&gt;

&lt;p&gt;We've seen how to redirect command output into a file.&lt;/p&gt;

&lt;p&gt;But can we do the opposite?&lt;/p&gt;

&lt;p&gt;Can a command receive its input from a file?&lt;/p&gt;

&lt;p&gt;In Bash and Zsh:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sort &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; names.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The shell sends the contents of &lt;code&gt;names.txt&lt;/code&gt; to the command's standard input.&lt;/p&gt;

&lt;p&gt;In CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sort &amp;lt; names.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same syntax works.&lt;/p&gt;

&lt;h3&gt;
  
  
  What About PowerShell?
&lt;/h3&gt;

&lt;p&gt;PowerShell doesn't use &lt;code&gt;&amp;lt;&lt;/code&gt; as a general native stdin redirection operator in the same way.&lt;/p&gt;

&lt;p&gt;Instead, you can use the pipeline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Sort&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, for a native executable that reads standard input:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;some&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;native&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;command&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This distinction matters when working across different shells.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. The &lt;code&gt;tee&lt;/code&gt; Command: Display and Save Output
&lt;/h2&gt;

&lt;p&gt;Sometimes you want to see command output in the terminal and save it to a file at the same time.&lt;/p&gt;

&lt;p&gt;On Linux and macOS, use &lt;code&gt;tee&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -la &lt;span class="o"&gt;|&lt;/span&gt; tee files.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output is displayed in the terminal and written to &lt;code&gt;files.txt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To append instead of replacing the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -la &lt;span class="o"&gt;|&lt;/span&gt; tee -a files.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The PowerShell Equivalent
&lt;/h3&gt;

&lt;p&gt;PowerShell provides &lt;code&gt;Tee-Object&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Tee&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;FilePath&lt;/span&gt; &lt;span class="n"&gt;files&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To append:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Tee&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;FilePath&lt;/span&gt; &lt;span class="n"&gt;files&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Append&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What About CMD?
&lt;/h3&gt;

&lt;p&gt;CMD doesn't include a built-in equivalent of &lt;code&gt;tee&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can use PowerShell for this task or install an external utility that provides similar functionality.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Command Chaining: Running Commands Together
&lt;/h2&gt;

&lt;p&gt;So far, we've connected commands using pipes.&lt;/p&gt;

&lt;p&gt;But sometimes we don't want to pass output between commands.&lt;/p&gt;

&lt;p&gt;We simply want to execute multiple commands in sequence.&lt;/p&gt;

&lt;p&gt;That's called command chaining.&lt;/p&gt;

&lt;p&gt;There are three important operators:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operator&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Run commands sequentially&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Run the next command only if the previous command succeeds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;`&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Let's understand each one.&lt;/p&gt;

&lt;h3&gt;
  
  
  The {% raw %}&lt;code&gt;;&lt;/code&gt; Operator
&lt;/h3&gt;

&lt;p&gt;In Bash, Zsh, and PowerShell 7+:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir project&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; project&lt;span class="o"&gt;;&lt;/span&gt; touch README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The commands execute sequentially.&lt;/p&gt;

&lt;p&gt;The next command runs regardless of whether the previous command succeeded.&lt;/p&gt;

&lt;p&gt;In CMD, use &lt;code&gt;&amp;amp;&lt;/code&gt; instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir project &amp;amp; cd project &amp;amp; echo Hello &amp;gt; README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; &lt;code&gt;;&lt;/code&gt; is not the general-purpose command separator in Windows CMD.&lt;/p&gt;

&lt;h3&gt;
  
  
  The &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; Operator
&lt;/h3&gt;

&lt;p&gt;This operator runs the next command only if the previous command succeeds.&lt;/p&gt;

&lt;p&gt;Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir project &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; project &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; touch README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell 7+:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;Directory&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Location&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir project &amp;amp;&amp;amp; cd project &amp;amp;&amp;amp; echo Hello &amp;gt; README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the directory creation fails, the next command won't execute.&lt;/p&gt;

&lt;p&gt;This is useful when later commands depend on earlier ones.&lt;/p&gt;

&lt;h3&gt;
  
  
  The &lt;code&gt;||&lt;/code&gt; Operator
&lt;/h3&gt;

&lt;p&gt;This operator runs the next command only if the previous command fails.&lt;/p&gt;

&lt;p&gt;Bash and Zsh:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; missing-folder &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Directory not found"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell 7+:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Location&lt;/span&gt; &lt;span class="n"&gt;missing&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;folder&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Output&lt;/span&gt; &lt;span class="s2"&gt;"Directory not found"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd missing-folder || echo Directory not found
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is especially useful for simple fallback behavior and error messages.&lt;/p&gt;

&lt;h3&gt;
  
  
  A Note About Older PowerShell Versions
&lt;/h3&gt;

&lt;p&gt;Native &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; and &lt;code&gt;||&lt;/code&gt; support was introduced in PowerShell 7.&lt;/p&gt;

&lt;p&gt;If you're using Windows PowerShell 5.1, these operators aren't available as command-chain operators.&lt;/p&gt;

&lt;p&gt;You can use conditional logic instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;Directory&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Location&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For native executables, &lt;code&gt;$LASTEXITCODE&lt;/code&gt; is often the better choice when you need to check the program's exit code.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Understanding Exit Codes
&lt;/h2&gt;

&lt;p&gt;How does a shell know whether a command succeeded?&lt;/p&gt;

&lt;p&gt;Most command-line programs return an exit code when they finish.&lt;/p&gt;

&lt;p&gt;Conventionally:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;0&lt;/code&gt; means success.&lt;/li&gt;
&lt;li&gt;A non-zero value means an error or another unsuccessful result.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Bash and Zsh
&lt;/h3&gt;

&lt;p&gt;Check the previous command's exit code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PowerShell
&lt;/h3&gt;

&lt;p&gt;PowerShell has two useful variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This indicates whether the previous command succeeded from PowerShell's perspective.&lt;/p&gt;

&lt;p&gt;For native executables, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$LASTEXITCODE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It contains the exit code returned by the most recently executed native program.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows CMD
&lt;/h3&gt;

&lt;p&gt;Use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo %ERRORLEVEL%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These values are important when building scripts and automated workflows.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Real-World Examples
&lt;/h2&gt;

&lt;p&gt;Let's combine everything we've learned.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example 1: Save a Directory Listing
&lt;/h3&gt;

&lt;p&gt;Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -la &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; directory-report.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Out&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="n"&gt;directory&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;report&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dir &amp;gt; directory-report.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example 2: Search for Errors in a Log File
&lt;/h3&gt;

&lt;p&gt;Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep -i &lt;span class="s2"&gt;"error"&lt;/span&gt; app.log &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; errors.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Pattern&lt;/span&gt; &lt;span class="s2"&gt;"error"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Out&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;findstr /i "error" app.log &amp;gt; errors.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example 3: Create a Project Structure
&lt;/h3&gt;

&lt;p&gt;Bash and Zsh:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir my-project &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; my-project &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; mkdir src docs tests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell 7+:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;Directory&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Location&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;Directory&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tests&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir my-project &amp;amp;&amp;amp; cd my-project &amp;amp;&amp;amp; mkdir src docs tests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example 4: Keep a Record of Command Output
&lt;/h3&gt;

&lt;p&gt;Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;some-command 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1 &lt;span class="o"&gt;|&lt;/span&gt; tee command.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;some&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="o"&gt;*&amp;gt;&amp;amp;&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Tee&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;FilePath&lt;/span&gt; &lt;span class="n"&gt;command&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These examples are useful when troubleshooting applications or keeping records of command execution.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Common Mistakes to Avoid
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Confusing &lt;code&gt;&amp;gt;&lt;/code&gt; with &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using &lt;code&gt;&amp;gt;&lt;/code&gt; accidentally can erase existing file contents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Assuming every shell behaves the same way&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PowerShell, CMD, Bash, and Zsh have different features and syntax.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Forgetting the order of redirection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Bash and CMD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;command&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; output.txt 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is not equivalent to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;command&lt;/span&gt; 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; output.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Redirections are processed from left to right.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Using &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; in Windows PowerShell 5.1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Remember that native &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; and &lt;code&gt;||&lt;/code&gt; support requires PowerShell 7 or later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Assuming a pipe always passes plain text&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PowerShell pipelines can pass structured objects, while traditional Unix pipelines generally pass byte streams.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. Practice Exercises
&lt;/h2&gt;

&lt;p&gt;Try these exercises in your preferred terminal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exercise 1:&lt;/strong&gt; List the files in your current directory and save the result to &lt;code&gt;files.txt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exercise 2:&lt;/strong&gt; Append a new line to that file without deleting its existing content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exercise 3:&lt;/strong&gt; Search a log file for the word &lt;code&gt;error&lt;/code&gt; and save matching results into another file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exercise 4:&lt;/strong&gt; Create a directory named &lt;code&gt;terminal-practice&lt;/code&gt;, enter it, and create three subdirectories: &lt;code&gt;src&lt;/code&gt;, &lt;code&gt;docs&lt;/code&gt;, and &lt;code&gt;tests&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exercise 5:&lt;/strong&gt; Run a command that intentionally fails and redirect its error output into a file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exercise 6:&lt;/strong&gt; Use a pipe to filter a directory listing by filename.&lt;/p&gt;

&lt;p&gt;Try implementing each exercise in Bash or Zsh, PowerShell, and CMD. Pay attention to the differences.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Reference
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Bash / Zsh&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;th&gt;CMD&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pipe&lt;/td&gt;
&lt;td&gt;`\&lt;/td&gt;
&lt;td&gt;`&lt;/td&gt;
&lt;td&gt;`\&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Overwrite output&lt;/td&gt;
&lt;td&gt;{% raw %}&lt;code&gt;&amp;gt;&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Append output&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Redirect errors&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Run sequentially&lt;/td&gt;
&lt;td&gt;&lt;code&gt;;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;;&lt;/code&gt; (7+ also)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;amp;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Run on success&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; (7+)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Run on failure&lt;/td&gt;
&lt;td&gt;`&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;`&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Display and save&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tee&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Tee-Object&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;External utility / PowerShell&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;You've now learned how to combine commands, redirect their output, handle errors, and build more efficient terminal workflows.&lt;/p&gt;

&lt;p&gt;In the next article, we'll explore something every developer eventually needs to understand:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Users, Permissions and Administrative Privileges.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We'll learn how file permissions work, how to execute commands with elevated privileges, and how Windows and Unix-like systems handle access control differently.&lt;/p&gt;

&lt;p&gt;See you in Article 05!&lt;/p&gt;

</description>
      <category>terminal</category>
      <category>linux</category>
      <category>windows</category>
      <category>programming</category>
    </item>
    <item>
      <title>Terminal Mastery-Searching, Reading and Managing Files from the Terminal</title>
      <dc:creator>Hamed Farazi</dc:creator>
      <pubDate>Sun, 15 Nov 2026 08:21:25 +0000</pubDate>
      <link>https://dev.to/hamedfarazi/terminal-mastery-searching-reading-and-managing-files-from-the-terminal-39p8</link>
      <guid>https://dev.to/hamedfarazi/terminal-mastery-searching-reading-and-managing-files-from-the-terminal-39p8</guid>
      <description>&lt;p&gt;03 of 10 — Terminal Mastery&lt;br&gt;
&lt;strong&gt;A practical guide to finding files, searching text, reading content, and filtering results on Windows, macOS, and Linux.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you're working on a large React application.&lt;/p&gt;

&lt;p&gt;Your project contains hundreds of components, thousands of lines of code, configuration files, and documentation.&lt;/p&gt;

&lt;p&gt;You remember using a function called &lt;code&gt;getUserData&lt;/code&gt;, but you can't remember which file contains it.&lt;/p&gt;

&lt;p&gt;What do you do?&lt;/p&gt;

&lt;p&gt;Open every file individually?&lt;/p&gt;

&lt;p&gt;Search through folders manually?&lt;/p&gt;

&lt;p&gt;There is a much better solution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You use your terminal.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The command line provides powerful tools for finding files, searching their contents, reading logs, and filtering large amounts of information.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore these tools across Windows PowerShell, macOS, and Linux.&lt;/p&gt;

&lt;p&gt;By the end, you'll know how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Find files by name and extension.&lt;/li&gt;
&lt;li&gt;Search for specific text inside files.&lt;/li&gt;
&lt;li&gt;Read files directly from the terminal.&lt;/li&gt;
&lt;li&gt;Inspect large log files efficiently.&lt;/li&gt;
&lt;li&gt;Display only the lines you need.&lt;/li&gt;
&lt;li&gt;Combine search operations.&lt;/li&gt;
&lt;li&gt;Search through real development projects.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's get started.&lt;/p&gt;


&lt;h2&gt;
  
  
  1. Finding Files and Directories
&lt;/h2&gt;

&lt;p&gt;The first skill we'll learn is finding files by their names.&lt;/p&gt;

&lt;p&gt;Imagine you have this project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my-project/
├── src/
│   ├── components/
│   │   ├── Header.jsx
│   │   └── Footer.jsx
│   ├── utils/
│   │   └── helpers.js
│   └── App.jsx
├── public/
│   └── logo.svg
├── package.json
└── README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You want to locate &lt;code&gt;helpers.js&lt;/code&gt;, but you don't remember its exact directory.&lt;/p&gt;

&lt;p&gt;Let's solve that.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux and macOS: The &lt;code&gt;find&lt;/code&gt; Command
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;find&lt;/code&gt; command searches for files and directories within a specified location.&lt;/p&gt;

&lt;p&gt;Basic syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find &lt;span class="o"&gt;[&lt;/span&gt;path&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;expression&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To search for a file named &lt;code&gt;helpers.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find . -name &lt;span class="s2"&gt;"helpers.js"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's understand this command:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;find&lt;/code&gt; starts the search.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.&lt;/code&gt; means the current directory.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-name&lt;/code&gt; specifies the filename pattern.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"helpers.js"&lt;/code&gt; is the name we're searching for.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Possible output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./src/utils/helpers.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Find All JavaScript Files
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find . -name &lt;span class="s2"&gt;"*.js"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This searches recursively for files ending in &lt;code&gt;.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To find both &lt;code&gt;.js&lt;/code&gt; and &lt;code&gt;.jsx&lt;/code&gt; files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find . -type f \&lt;span class="o"&gt;(&lt;/span&gt; -name &lt;span class="s2"&gt;"*.js"&lt;/span&gt; -o -name &lt;span class="s2"&gt;"*.jsx"&lt;/span&gt; \&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-type f&lt;/code&gt; restricts results to regular files.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-o&lt;/code&gt; means OR.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt; group expressions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Find Only Directories
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find . -type d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Find Files with a Specific Extension
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find . -type f -name &lt;span class="s2"&gt;"*.json"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is especially useful when working with configuration-heavy projects.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Finding Files in Windows PowerShell
&lt;/h2&gt;

&lt;p&gt;PowerShell provides its own filesystem search capabilities.&lt;/p&gt;

&lt;p&gt;The most useful starting point is &lt;code&gt;Get-ChildItem&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Search for a Specific Filename
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Filter&lt;/span&gt; &lt;span class="s2"&gt;"helpers.js"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break it down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Get-ChildItem&lt;/code&gt; retrieves filesystem items.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-Path .&lt;/code&gt; starts in the current directory.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-Filter&lt;/code&gt; specifies the filename.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-Recurse&lt;/code&gt; searches through subdirectories.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Find All JavaScript Files
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Filter&lt;/span&gt; &lt;span class="s2"&gt;"*.js"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-File&lt;/code&gt; option ensures that only files are returned.&lt;/p&gt;

&lt;h3&gt;
  
  
  Find All React Components
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Include&lt;/span&gt; &lt;span class="s2"&gt;"*.jsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"*.tsx"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is useful when exploring React or TypeScript projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Find Directories Only
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Directory&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Search by Filename Using Wildcards
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Where&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;like&lt;/span&gt; &lt;span class="s2"&gt;"*config*"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This finds files whose names contain &lt;code&gt;config&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vite.config.js
tsconfig.json
config.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell's &lt;code&gt;Where-Object&lt;/code&gt; allows you to filter objects based on conditions.&lt;/p&gt;

&lt;p&gt;We'll explore pipelines more deeply in Article 04.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Finding Files in Windows Command Prompt
&lt;/h2&gt;

&lt;p&gt;Command Prompt also supports recursive file searches.&lt;/p&gt;

&lt;p&gt;Use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;where /r . helpers.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This searches recursively from the current directory.&lt;/p&gt;

&lt;p&gt;To find all JavaScript files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;where /r . *.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;where&lt;/code&gt; command can search for matching files in directory trees.&lt;/p&gt;

&lt;p&gt;Don't confuse it with PowerShell's &lt;code&gt;Where-Object&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;They are different commands with different purposes.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Reading Files from the Terminal
&lt;/h2&gt;

&lt;p&gt;Finding a file is only half the job.&lt;/p&gt;

&lt;p&gt;Now you need to inspect its contents.&lt;/p&gt;

&lt;p&gt;Let's explore the most common ways to read files.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux and macOS: The &lt;code&gt;cat&lt;/code&gt; Command
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;cat&lt;/code&gt; displays file contents directly in the terminal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cat README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# My Project

This is a React application.

## Installation

npm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also display multiple files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cat file1.txt file2.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prints their contents one after another.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; &lt;code&gt;cat&lt;/code&gt; is useful for short files, but it can become inconvenient when reading very large files.&lt;/p&gt;

&lt;p&gt;That's where other commands come in.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows PowerShell: &lt;code&gt;Get-Content&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;PowerShell provides:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="no"&gt;README&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;md&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use its alias:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;gc&lt;/span&gt; &lt;span class="no"&gt;README&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;md&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For reading a file line by line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="no"&gt;README&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;md&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell returns the file's contents as objects representing lines of text.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows CMD: &lt;code&gt;type&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Command Prompt uses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays the contents of the specified file.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Reading Large Files Efficiently
&lt;/h2&gt;

&lt;p&gt;Imagine you're inspecting a server log containing 50,000 lines.&lt;/p&gt;

&lt;p&gt;Displaying the entire file isn't always practical.&lt;/p&gt;

&lt;p&gt;Instead, you can inspect only the beginning or end.&lt;/p&gt;

&lt;h3&gt;
  
  
  The &lt;code&gt;head&lt;/code&gt; Command
&lt;/h3&gt;

&lt;p&gt;On Linux and macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;head logfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By default, this displays the first 10 lines.&lt;/p&gt;

&lt;p&gt;To display the first 20 lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;head -n 20 logfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The &lt;code&gt;tail&lt;/code&gt; Command
&lt;/h3&gt;

&lt;p&gt;To display the last 10 lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tail logfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To display the last 20 lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tail -n 20 logfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Follow a Log File in Real Time
&lt;/h3&gt;

&lt;p&gt;One of the most useful terminal tricks is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tail -f application.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This continuously displays new lines as they are added to the file.&lt;/p&gt;

&lt;p&gt;It's especially useful when monitoring application logs or debugging a running server.&lt;/p&gt;

&lt;p&gt;Press &lt;code&gt;Ctrl + C&lt;/code&gt; to stop following the file.&lt;/p&gt;

&lt;h3&gt;
  
  
  PowerShell Alternatives
&lt;/h3&gt;

&lt;p&gt;Display the first 10 lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;TotalCount&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Display the last 10 lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Tail&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Follow a log file as it changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Wait&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the PowerShell equivalent of a common &lt;code&gt;tail -f&lt;/code&gt; workflow.&lt;/p&gt;

&lt;h3&gt;
  
  
  What About CMD?
&lt;/h3&gt;

&lt;p&gt;CMD doesn't provide direct equivalents of &lt;code&gt;head&lt;/code&gt; and &lt;code&gt;tail&lt;/code&gt; as built-in commands.&lt;/p&gt;

&lt;p&gt;You can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;more application.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This lets you view content page by page.&lt;/p&gt;

&lt;p&gt;For more advanced inspection, PowerShell is usually the better option on Windows.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Searching for Text Inside Files
&lt;/h2&gt;

&lt;p&gt;Now we reach one of the most powerful terminal skills.&lt;/p&gt;

&lt;p&gt;Suppose you want to find every occurrence of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;getUserData
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;inside your source code.&lt;/p&gt;

&lt;p&gt;Instead of opening every file, you can search recursively.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux and macOS: The &lt;code&gt;grep&lt;/code&gt; Command
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;grep&lt;/code&gt; searches text using patterns.&lt;/p&gt;

&lt;p&gt;Basic syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep &lt;span class="s2"&gt;"search-term"&lt;/span&gt; filename
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep &lt;span class="s2"&gt;"getUserData"&lt;/span&gt; app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays matching lines from &lt;code&gt;app.js&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Search Recursively
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep -R &lt;span class="s2"&gt;"getUserData"&lt;/span&gt; ./src
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-R&lt;/code&gt; option searches through directories recursively.&lt;/p&gt;

&lt;h3&gt;
  
  
  Display Line Numbers
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep -Rn &lt;span class="s2"&gt;"getUserData"&lt;/span&gt; ./src
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-n&lt;/code&gt; option includes line numbers.&lt;/p&gt;

&lt;p&gt;Example output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./src/services/user.js:15:const getUserData = () =&amp;gt; {};
./src/components/Profile.jsx:8:import { getUserData } from "../services/user";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you know exactly where the function appears.&lt;/p&gt;

&lt;h3&gt;
  
  
  Case-Insensitive Search
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep -Ri &lt;span class="s2"&gt;"getuserdata"&lt;/span&gt; ./src
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-i&lt;/code&gt; option ignores letter case.&lt;/p&gt;

&lt;h3&gt;
  
  
  Search Only Specific File Types
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep -Rn --include=&lt;span class="s2"&gt;"*.js"&lt;/span&gt; &lt;span class="s2"&gt;"getUserData"&lt;/span&gt; ./src
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This restricts the search to JavaScript files.&lt;/p&gt;

&lt;p&gt;You can also search multiple extensions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep -Rn --include=&lt;span class="s2"&gt;"*.js"&lt;/span&gt; --include=&lt;span class="s2"&gt;"*.jsx"&lt;/span&gt; &lt;span class="s2"&gt;"getUserData"&lt;/span&gt; ./src
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  7. Searching Text in Windows PowerShell
&lt;/h2&gt;

&lt;p&gt;PowerShell provides a powerful command called &lt;code&gt;Select-String&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It's similar to &lt;code&gt;grep&lt;/code&gt;, but it works with PowerShell's object-based pipeline.&lt;/p&gt;

&lt;h3&gt;
  
  
  Search Inside a File
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="s2"&gt;"app.js"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Pattern&lt;/span&gt; &lt;span class="s2"&gt;"getUserData"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Search Recursively
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;\&lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Pattern&lt;/span&gt; &lt;span class="s2"&gt;"getUserData"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This searches every file under &lt;code&gt;src&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Include Line Numbers
&lt;/h3&gt;

&lt;p&gt;PowerShell's &lt;code&gt;Select-String&lt;/code&gt; includes line information in its results.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src\services\user.js:15:const getUserData = () =&amp;gt; {};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Case-Insensitive Search
&lt;/h3&gt;

&lt;p&gt;By default, &lt;code&gt;Select-String&lt;/code&gt; searches case-insensitively.&lt;/p&gt;

&lt;p&gt;You can explicitly use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="s2"&gt;"app.js"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Pattern&lt;/span&gt; &lt;span class="s2"&gt;"getuserdata"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;CaseSensitive&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Search Only JavaScript Files
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;\&lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Filter&lt;/span&gt; &lt;span class="s2"&gt;"*.js"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Pattern&lt;/span&gt; &lt;span class="s2"&gt;"getUserData"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also search JSX files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;\&lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Include&lt;/span&gt; &lt;span class="s2"&gt;"*.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"*.jsx"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Pattern&lt;/span&gt; &lt;span class="s2"&gt;"getUserData"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  8. Searching Text in Windows CMD
&lt;/h2&gt;

&lt;p&gt;Command Prompt provides the &lt;code&gt;findstr&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;It can search for text inside files.&lt;/p&gt;

&lt;h3&gt;
  
  
  Search Inside a File
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;findstr "getUserData" app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Search Recursively
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;findstr /S "getUserData" src\*.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;/S&lt;/code&gt; option searches through subdirectories.&lt;/p&gt;

&lt;h3&gt;
  
  
  Include Line Numbers
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;findstr /N "getUserData" app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Case-Insensitive Search
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;findstr /I "getuserdata" app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Search Multiple Files
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;findstr "React" *.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;findstr&lt;/code&gt; is useful for simple text searches, although its pattern-matching behavior differs from &lt;code&gt;grep&lt;/code&gt; and PowerShell's &lt;code&gt;Select-String&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  9. Reading Specific Lines from a File
&lt;/h2&gt;

&lt;p&gt;Sometimes you don't need an entire file.&lt;/p&gt;

&lt;p&gt;You only need a particular section.&lt;/p&gt;

&lt;p&gt;For example, imagine a configuration file contains 500 lines, and you want to inspect lines 20 through 30.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux and macOS
&lt;/h3&gt;

&lt;p&gt;Combine &lt;code&gt;sed&lt;/code&gt; with a line range:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sed -n &lt;span class="s1"&gt;'20,30p'&lt;/span&gt; config.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's what the options mean:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-n&lt;/code&gt; disables automatic printing.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;20,30&lt;/code&gt; specifies the line range.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;p&lt;/code&gt; prints the selected lines.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can also use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sed -n &lt;span class="s1"&gt;'20p'&lt;/span&gt; config.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays only line 20.&lt;/p&gt;

&lt;h3&gt;
  
  
  PowerShell
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;Get-Content&lt;/code&gt; with &lt;code&gt;Select-Object&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Skip&lt;/span&gt; &lt;span class="mi"&gt;19&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;First&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why skip 19?&lt;/p&gt;

&lt;p&gt;Because PowerShell's &lt;code&gt;-Skip&lt;/code&gt; counts from zero, while humans usually count lines starting from one.&lt;/p&gt;

&lt;p&gt;This displays lines 20 through 30.&lt;/p&gt;

&lt;h3&gt;
  
  
  CMD
&lt;/h3&gt;

&lt;p&gt;You can combine &lt;code&gt;more&lt;/code&gt; with line-number skipping:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;more +19 config.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This starts displaying the file from approximately the twentieth line.&lt;/p&gt;

&lt;p&gt;For precise line-range selection, PowerShell or another dedicated text-processing tool is preferable.&lt;/p&gt;




&lt;h2&gt;
  
  
  10. Counting Lines, Words, and Characters
&lt;/h2&gt;

&lt;p&gt;Sometimes you want to understand the size of a file without opening it.&lt;/p&gt;

&lt;p&gt;Linux and macOS provide the &lt;code&gt;wc&lt;/code&gt; command.&lt;/p&gt;

&lt;h3&gt;
  
  
  Count Lines
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wc -l app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Count Words
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wc -w README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Count Bytes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wc -c app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Count Characters
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wc -m app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These commands are especially useful when analyzing logs, documentation, or large source files.&lt;/p&gt;

&lt;h3&gt;
  
  
  PowerShell
&lt;/h3&gt;

&lt;p&gt;Count lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;js&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Count&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Count characters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;js&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Raw&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Length&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-Raw&lt;/code&gt; parameter reads the file as one string instead of returning individual lines.&lt;/p&gt;

&lt;h3&gt;
  
  
  CMD
&lt;/h3&gt;

&lt;p&gt;You can count lines using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;find /C /V "" app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a common CMD technique for counting non-empty strings, though blank-line handling can make it less suitable as an exact general-purpose line counter.&lt;/p&gt;

&lt;p&gt;For reliable text analysis on Windows, PowerShell offers more flexibility.&lt;/p&gt;




&lt;h2&gt;
  
  
  11. Combining Search Operations
&lt;/h2&gt;

&lt;p&gt;Now let's combine what we've learned.&lt;/p&gt;

&lt;p&gt;Imagine you have a React project and want to find every occurrence of &lt;code&gt;useState&lt;/code&gt; inside JavaScript and JSX files.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux / macOS
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep -Rn \
  --include=&lt;span class="s2"&gt;"*.js"&lt;/span&gt; \
  --include=&lt;span class="s2"&gt;"*.jsx"&lt;/span&gt; \
  &lt;span class="s2"&gt;"useState"&lt;/span&gt; ./src
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This searches recursively and displays line numbers.&lt;/p&gt;

&lt;h3&gt;
  
  
  PowerShell
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;\&lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Where&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Extension&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;".js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;".jsx"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Pattern&lt;/span&gt; &lt;span class="s2"&gt;"useState"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This performs the same general task using PowerShell objects and pipelines.&lt;/p&gt;

&lt;h3&gt;
  
  
  CMD
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;findstr /S /N "useState" src\*.js src\*.jsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now imagine searching for a function across an entire project containing hundreds of files.&lt;/p&gt;

&lt;p&gt;A few commands can save you a lot of manual work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer tip:&lt;/strong&gt; In real projects, you may eventually want a faster search tool called &lt;code&gt;ripgrep&lt;/code&gt; (&lt;code&gt;rg&lt;/code&gt;). We'll introduce modern developer tools in Article 08.&lt;/p&gt;




&lt;h2&gt;
  
  
  12. A Real-World Debugging Exercise
&lt;/h2&gt;

&lt;p&gt;Let's apply these skills to a realistic situation.&lt;/p&gt;

&lt;p&gt;Imagine your Node.js application writes errors to a file called &lt;code&gt;server.log&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You want to find every line containing the word &lt;code&gt;ERROR&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Linux / macOS
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep -in &lt;span class="s2"&gt;"ERROR"&lt;/span&gt; server.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This searches without considering letter case and displays line numbers.&lt;/p&gt;

&lt;h3&gt;
  
  
  PowerShell
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Pattern&lt;/span&gt; &lt;span class="s2"&gt;"ERROR"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  CMD
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;findstr /I /N "ERROR" server.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now suppose you only want the latest 20 lines of the log.&lt;/p&gt;

&lt;p&gt;Linux / macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tail -n 20 server.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Tail&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if you want to monitor new log entries:&lt;/p&gt;

&lt;p&gt;Linux / macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tail -f server.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Wait&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a common debugging workflow when working with backend applications.&lt;/p&gt;




&lt;h2&gt;
  
  
  13. Common Mistakes to Avoid
&lt;/h2&gt;

&lt;p&gt;Here are some mistakes beginners frequently make.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Searching the wrong directory&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Always verify your current location before starting a search.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or in PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Location&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Forgetting recursive search&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A search inside the current directory doesn't necessarily include all nested directories unless you request recursion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Confusing &lt;code&gt;find&lt;/code&gt; and &lt;code&gt;grep&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On Unix-like systems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;find&lt;/code&gt; locates filesystem entries.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;grep&lt;/code&gt; searches text inside files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They solve different problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Printing enormous files&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Avoid displaying thousands of lines when you only need a small section.&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;head&lt;/code&gt;, &lt;code&gt;tail&lt;/code&gt;, &lt;code&gt;less&lt;/code&gt;, or PowerShell's &lt;code&gt;Select-Object&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Searching generated directories unnecessarily&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JavaScript projects often contain directories such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node_modules/
dist/
build/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Searching these directories can produce enormous amounts of irrelevant output.&lt;/p&gt;

&lt;p&gt;Exclude them when appropriate.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep -Rn \
  --exclude-dir=node_modules \
  --exclude-dir=dist \
  &lt;span class="s2"&gt;"useState"&lt;/span&gt; .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Assuming every search tool uses the same syntax&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;findstr&lt;/code&gt;, and &lt;code&gt;Select-String&lt;/code&gt; have different options and pattern-matching rules.&lt;/p&gt;

&lt;p&gt;Learn the tool you're actually using.&lt;/p&gt;




&lt;h2&gt;
  
  
  14. Practice Challenges
&lt;/h2&gt;

&lt;p&gt;Time to put your knowledge to work.&lt;/p&gt;

&lt;p&gt;Create a directory named &lt;code&gt;search-lab&lt;/code&gt; and add these files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;search-lab/
├── app.js
├── helpers.js
├── README.md
├── config.json
└── logs/
    └── server.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put the following content in &lt;code&gt;app.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getUserData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Alex"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getProducts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;getUserData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put this in &lt;code&gt;helpers.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;formatName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put this in &lt;code&gt;server.log&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INFO Server started
INFO Database connected
ERROR Database connection timeout
INFO Retrying connection
ERROR Authentication failed
INFO Server stopped
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now complete these challenges.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenge 1: Find Files
&lt;/h3&gt;

&lt;p&gt;Find all &lt;code&gt;.js&lt;/code&gt; files inside &lt;code&gt;search-lab&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenge 2: Search for a Function
&lt;/h3&gt;

&lt;p&gt;Find every occurrence of &lt;code&gt;getUserData&lt;/code&gt; and display the line numbers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenge 3: Search for Errors
&lt;/h3&gt;

&lt;p&gt;Find every line containing &lt;code&gt;ERROR&lt;/code&gt; inside &lt;code&gt;server.log&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenge 4: Inspect a File
&lt;/h3&gt;

&lt;p&gt;Display the first two lines of &lt;code&gt;server.log&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenge 5: Count Lines
&lt;/h3&gt;

&lt;p&gt;Count the number of lines in &lt;code&gt;helpers.js&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenge 6: Find Configuration Files
&lt;/h3&gt;

&lt;p&gt;Find every &lt;code&gt;.json&lt;/code&gt; file inside your project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenge 7: Combine Your Skills
&lt;/h3&gt;

&lt;p&gt;Search the entire project for the word &lt;code&gt;function&lt;/code&gt;, but exclude any generated or dependency directories if they exist.&lt;/p&gt;

&lt;p&gt;Try solving every challenge using your operating system's native shell.&lt;/p&gt;




&lt;h2&gt;
  
  
  Quick Command Reference
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Linux / macOS&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;th&gt;CMD&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Find files&lt;/td&gt;
&lt;td&gt;&lt;code&gt;find&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-ChildItem&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;where /r&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Read file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cat&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Content&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;type&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First lines&lt;/td&gt;
&lt;td&gt;&lt;code&gt;head&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Select-Object -First&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;more&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Last lines&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tail&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Content -Tail&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;more&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Follow logs&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tail -f&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Content -Wait&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Search text&lt;/td&gt;
&lt;td&gt;&lt;code&gt;grep&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Select-String&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;findstr&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Count lines&lt;/td&gt;
&lt;td&gt;&lt;code&gt;wc -l&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.Count&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;find /C /V ""&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Show line ranges&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Select-Object&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;more +N&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Remember that these are functional equivalents for common tasks, not identical implementations.&lt;/p&gt;




&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;You can now locate files, search through source code, inspect logs, and extract useful information without manually opening every file.&lt;/p&gt;

&lt;p&gt;But something even more powerful is waiting.&lt;/p&gt;

&lt;p&gt;So far, we've mostly executed individual commands.&lt;/p&gt;

&lt;p&gt;What happens when you want to combine several commands into one workflow?&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Find all JavaScript files.&lt;/li&gt;
&lt;li&gt;Search them for a specific function.&lt;/li&gt;
&lt;li&gt;Filter the results.&lt;/li&gt;
&lt;li&gt;Save the output into a separate file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where &lt;strong&gt;Pipes, Redirection, and Command Chaining&lt;/strong&gt; come in.&lt;/p&gt;

&lt;p&gt;In Article 04, we'll explore how commands communicate with each other and how to build powerful workflows from simple operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next Article: Pipes, Redirection and Command Chaining&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Searching through files is one of those skills that seems simple until you start working on large projects.&lt;/p&gt;

&lt;p&gt;Once you become comfortable with &lt;code&gt;find&lt;/code&gt;, &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;Select-String&lt;/code&gt;, and the other tools covered here, you'll spend much less time searching manually.&lt;/p&gt;

&lt;p&gt;The terminal isn't just a place to execute commands.&lt;/p&gt;

&lt;p&gt;It's a powerful environment for exploring, inspecting, and understanding your entire codebase.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learn to search efficiently, and you'll spend more time building and less time looking for things.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>terminal</category>
      <category>linux</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Terminal Mastery-Navigating the File System Like a Pro Master directories</title>
      <dc:creator>Hamed Farazi</dc:creator>
      <pubDate>Sun, 15 Nov 2026 08:14:07 +0000</pubDate>
      <link>https://dev.to/hamedfarazi/terminal-mastery-navigating-the-file-system-like-a-promaster-directories-2g8n</link>
      <guid>https://dev.to/hamedfarazi/terminal-mastery-navigating-the-file-system-like-a-promaster-directories-2g8n</guid>
      <description>&lt;p&gt;02 of 10 — Terminal Mastery&lt;br&gt;
&lt;strong&gt;A practical guide to managing files and directories using Windows PowerShell, macOS, and Linux terminals.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you're working on a React project.&lt;/p&gt;

&lt;p&gt;You need to create a new folder, move configuration files, rename directories, remove temporary files, and organize your project structure.&lt;/p&gt;

&lt;p&gt;You could do all of this using File Explorer or Finder.&lt;/p&gt;

&lt;p&gt;But what if you could accomplish the same tasks directly from your terminal?&lt;/p&gt;

&lt;p&gt;That's exactly what we're going to learn in this article.&lt;/p&gt;

&lt;p&gt;In the previous chapter, we explored what a terminal is, how shells work, and how to execute our first commands.&lt;/p&gt;

&lt;p&gt;Now it's time to develop one of the most important command-line skills: &lt;strong&gt;filesystem navigation and management.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By the end of this article, you'll know how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigate between directories.&lt;/li&gt;
&lt;li&gt;Understand absolute and relative paths.&lt;/li&gt;
&lt;li&gt;Create files and directories.&lt;/li&gt;
&lt;li&gt;Copy and move files.&lt;/li&gt;
&lt;li&gt;Rename files and folders.&lt;/li&gt;
&lt;li&gt;Delete files safely.&lt;/li&gt;
&lt;li&gt;Find and work with hidden files.&lt;/li&gt;
&lt;li&gt;Use wildcards to manage multiple files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We'll cover Windows PowerShell, macOS Zsh, and Linux Bash throughout the article.&lt;/p&gt;

&lt;p&gt;Let's get started.&lt;/p&gt;


&lt;h2&gt;
  
  
  1. Understanding the Filesystem
&lt;/h2&gt;

&lt;p&gt;Before executing commands, let's understand how your computer organizes files.&lt;/p&gt;

&lt;p&gt;A filesystem is the structure an operating system uses to store and organize data.&lt;/p&gt;

&lt;p&gt;Most filesystems are organized hierarchically.&lt;/p&gt;

&lt;p&gt;Think of it as a tree:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/
├── home/
│   └── developer/
│       ├── Documents/
│       ├── Downloads/
│       └── Projects/
│           ├── react-app/
│           └── node-api/
│
├── etc/
├── var/
└── usr/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a simplified example of a Linux filesystem.&lt;/p&gt;

&lt;p&gt;Directories can contain files and other directories. Those directories can contain even more directories.&lt;/p&gt;

&lt;p&gt;This creates a hierarchical structure.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows Filesystem
&lt;/h3&gt;

&lt;p&gt;Windows commonly uses drive letters to identify storage devices.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\
├── Users\
│   └── Developer\
│       ├── Documents\
│       ├── Downloads\
│       └── Projects\
│           └── react-app\
│
├── Program Files\
└── Windows\
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  macOS Filesystem
&lt;/h3&gt;

&lt;p&gt;macOS uses a Unix-style directory hierarchy.&lt;/p&gt;

&lt;p&gt;A typical user's home directory looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/
├── Applications/
├── System/
├── Library/
└── Users/
    └── developer/
        ├── Desktop/
        ├── Documents/
        ├── Downloads/
        └── Projects/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Linux Filesystem
&lt;/h3&gt;

&lt;p&gt;Linux also uses a Unix-style hierarchy.&lt;/p&gt;

&lt;p&gt;Some important directories include:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Directory&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Filesystem root&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/home&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Regular users' home directories&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/root&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Root user's home directory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;System configuration files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/var&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Variable data and logs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/tmp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Temporary files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/usr&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Userland applications and resources&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Understanding these structures makes navigating the terminal much easier.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Understanding Paths
&lt;/h2&gt;

&lt;p&gt;A path tells your operating system where a file or directory is located.&lt;/p&gt;

&lt;p&gt;There are two fundamental types of paths.&lt;/p&gt;

&lt;h3&gt;
  
  
  Absolute Paths
&lt;/h3&gt;

&lt;p&gt;An absolute path specifies a location from the filesystem's root or an equivalent starting point.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Windows:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\Developer\Documents\Projects
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;macOS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/Users/developer/Documents/Projects
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/developer/Documents/Projects
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An absolute path doesn't depend on your current working directory.&lt;/p&gt;

&lt;p&gt;You can reference the same location from almost anywhere.&lt;/p&gt;

&lt;h3&gt;
  
  
  Relative Paths
&lt;/h3&gt;

&lt;p&gt;A relative path describes a location based on your current working directory.&lt;/p&gt;

&lt;p&gt;Imagine your current location is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/developer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And you want to access:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/developer/Projects/react-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can simply use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Projects/react-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's a relative path.&lt;/p&gt;

&lt;p&gt;Relative paths are particularly useful when working inside software projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Three Special Path References
&lt;/h3&gt;

&lt;p&gt;There are three important references you should recognize.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Current directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Parent directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;..
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Home directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;~&lt;/code&gt; shortcut is commonly supported by Bash and Zsh. PowerShell also supports it as a home-directory shortcut.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ..
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Moves one directory up.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Moves to your home directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keeps you in the current directory.&lt;/p&gt;

&lt;p&gt;These references will appear frequently throughout your terminal journey.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Navigating Between Directories
&lt;/h2&gt;

&lt;p&gt;Let's start with the command you'll probably use more than any other navigation command.&lt;/p&gt;

&lt;h3&gt;
  
  
  The &lt;code&gt;cd&lt;/code&gt; Command
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;cd&lt;/code&gt; stands for Change Directory.&lt;/p&gt;

&lt;p&gt;It allows you to move from one directory to another.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Windows PowerShell:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="nc"&gt;Documents&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;macOS / Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; Documents
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command is the same across these environments.&lt;/p&gt;

&lt;p&gt;To move into a nested directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; Projects/react-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Windows, PowerShell also accepts forward slashes in paths.&lt;/p&gt;

&lt;p&gt;You can use Windows-style separators too:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="nc"&gt;Projects&lt;/span&gt;\&lt;span class="n"&gt;react&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Move One Directory Up
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;..&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ..
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, if you're currently inside:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/developer/Projects/react-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After executing &lt;code&gt;cd ..&lt;/code&gt;, you'll be in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/developer/Projects
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Move Two Directories Up
&lt;/h3&gt;

&lt;p&gt;You can combine parent-directory references:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ../..
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This moves two levels up.&lt;/p&gt;

&lt;h3&gt;
  
  
  Return to Your Home Directory
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;PowerShell:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;macOS / Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Return to the Previous Directory
&lt;/h3&gt;

&lt;p&gt;Bash and Zsh provide a useful shortcut:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This switches to your previous working directory.&lt;/p&gt;

&lt;p&gt;PowerShell also supports &lt;code&gt;cd -&lt;/code&gt; through its location stack and navigation behavior in common interactive usage, but for explicit directory-stack operations, use &lt;code&gt;Push-Location&lt;/code&gt; and &lt;code&gt;Pop-Location&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Check Your Current Location
&lt;/h3&gt;

&lt;p&gt;Whenever you're unsure where you are, use:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PowerShell:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Location&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;macOS / Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Knowing your current directory prevents many common mistakes.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Listing Files and Directories
&lt;/h2&gt;

&lt;p&gt;How do you know what's inside your current directory?&lt;/p&gt;

&lt;p&gt;You need a command that displays its contents.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows PowerShell
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Its common alias is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;ls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;dir&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  macOS / Linux
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To display detailed information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -l
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To include hidden files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To combine both:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -la
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A typical output might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;drwxr-xr-x  5 developer developer 4096 Nov 15 10:20 Projects
-rw-r--r--  1 developer developer  512 Nov 15 10:15 notes.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's understand some of this output:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;d&lt;/code&gt; indicates a directory.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-&lt;/code&gt; indicates a regular file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;r&lt;/code&gt; means read permission.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;w&lt;/code&gt; means write permission.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;x&lt;/code&gt; means execute permission.&lt;/li&gt;
&lt;li&gt;The number represents the link count.&lt;/li&gt;
&lt;li&gt;The owner and group identify file ownership.&lt;/li&gt;
&lt;li&gt;The size indicates the file size in bytes.&lt;/li&gt;
&lt;li&gt;The date indicates the last modification time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We'll explore permissions in Article 05.&lt;/p&gt;

&lt;h3&gt;
  
  
  Listing Files in Another Directory
&lt;/h3&gt;

&lt;p&gt;You don't need to navigate into a directory just to inspect it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PowerShell:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="nc"&gt;Documents&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;macOS / Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls Documents
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also provide an absolute path.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls /home/developer/Documents
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  5. Creating Directories
&lt;/h2&gt;

&lt;p&gt;Let's create our first directory.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;mkdir&lt;/code&gt; command stands for Make Directory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Windows PowerShell:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;macOS / Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir my-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both commands create a directory named &lt;code&gt;my-project&lt;/code&gt; in your current location.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Nested Directories
&lt;/h3&gt;

&lt;p&gt;What if you want to create several directories at once?&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Projects/
└── frontend/
    └── react-app/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On macOS and Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir -p Projects/frontend/react-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-p&lt;/code&gt; option creates missing parent directories as needed.&lt;/p&gt;

&lt;p&gt;In PowerShell, you can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;Directory&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Force&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="s2"&gt;"Projects/frontend/react-app"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use &lt;code&gt;mkdir&lt;/code&gt; with a nested path when the parent directory already exists.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Multiple Directories
&lt;/h3&gt;

&lt;p&gt;On macOS and Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir project-a project-b project-c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates three directories in your current location.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Creating Files
&lt;/h2&gt;

&lt;p&gt;Directories organize files. But how do you create files directly from the terminal?&lt;/p&gt;

&lt;p&gt;The answer depends on your shell.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows PowerShell
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;New-Item&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="s2"&gt;"index.html"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a JavaScript file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="s2"&gt;"app.js"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use the &lt;code&gt;ni&lt;/code&gt; alias:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;ni&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;File&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  macOS / Linux
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;touch&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;touch index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create another file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;touch app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can create multiple files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;touch index.html style.css app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; &lt;code&gt;touch&lt;/code&gt; creates an empty file if it doesn't exist. If the file already exists, it updates its access and modification timestamps rather than deleting its contents.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a File with Initial Content
&lt;/h3&gt;

&lt;p&gt;In PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="s2"&gt;"Hello, Terminal!"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="n"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Bash or Zsh:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello, Terminal!"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; hello.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;&amp;gt;&lt;/code&gt; operator redirects output into a file.&lt;/p&gt;

&lt;p&gt;If the file already exists, its previous contents are overwritten.&lt;/p&gt;

&lt;p&gt;We'll explore redirection in detail in Article 04.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. Copying Files and Directories
&lt;/h2&gt;

&lt;p&gt;Sometimes you need to duplicate files without removing the original.&lt;/p&gt;

&lt;p&gt;That's what copying is for.&lt;/p&gt;

&lt;h3&gt;
  
  
  Copying a File
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Windows PowerShell:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Copy&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;js&lt;/span&gt; &lt;span class="n"&gt;backup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;js&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;macOS / Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cp app.js backup.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a copy named &lt;code&gt;backup.js&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Copying a File into Another Directory
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;PowerShell:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Copy&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;js&lt;/span&gt; &lt;span class="nc"&gt;Documents&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;macOS / Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cp app.js Documents/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The original file remains in its original location.&lt;/p&gt;

&lt;h3&gt;
  
  
  Copying Directories
&lt;/h3&gt;

&lt;p&gt;For PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Copy&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;backup&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For macOS / Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cp -r project project-backup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The recursive option tells the command to include the directory's contents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Be careful:&lt;/strong&gt; Copying large directories can consume significant disk space. Always verify your destination before executing recursive copy commands.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. Moving and Renaming Files
&lt;/h2&gt;

&lt;p&gt;Moving and renaming are closely related operations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Moving a File
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;PowerShell:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Move&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;js&lt;/span&gt; &lt;span class="nc"&gt;Documents&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;macOS / Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mv app.js Documents/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This moves &lt;code&gt;app.js&lt;/code&gt; into the Documents directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Renaming a File
&lt;/h3&gt;

&lt;p&gt;You can also use the same commands to rename files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PowerShell:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Rename&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;js&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;js&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;macOS / Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mv app.js main.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The original file is now named &lt;code&gt;main.js&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Renaming a Directory
&lt;/h3&gt;

&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Rename&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS / Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mv old-project new-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Moving and Renaming at the Same Time
&lt;/h3&gt;

&lt;p&gt;You can move a file and give it a new name in one operation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mv app.js Documents/main.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Move&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;js&lt;/span&gt; &lt;span class="nc"&gt;Documents&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;js&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This moves the file into Documents and renames it to &lt;code&gt;main.js&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  9. Deleting Files and Directories
&lt;/h2&gt;

&lt;p&gt;Deletion is one area where you should be especially careful.&lt;/p&gt;

&lt;p&gt;Some terminal commands can permanently remove data without sending it to the Recycle Bin or Trash.&lt;/p&gt;

&lt;p&gt;Always double-check the target before executing a deletion command.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deleting a File
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Windows PowerShell:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Remove&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;macOS / Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rm old-file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Deleting an Empty Directory
&lt;/h3&gt;

&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Remove&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="n"&gt;empty&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;folder&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS / Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rmdir empty-folder
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Unix &lt;code&gt;rmdir&lt;/code&gt; command only removes empty directories.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deleting a Directory and Its Contents
&lt;/h3&gt;

&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Remove&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS / Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rm -r old-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The recursive option removes the directory and its contents.&lt;/p&gt;

&lt;h3&gt;
  
  
  A Critical Safety Warning
&lt;/h3&gt;

&lt;p&gt;You may encounter this command online:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rm -rf some-directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break it down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;rm&lt;/code&gt; removes files and directories.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-r&lt;/code&gt; recursively removes directory contents.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-f&lt;/code&gt; forces removal without interactive confirmation for many situations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This command can permanently destroy data.&lt;/p&gt;

&lt;p&gt;Never execute commands like this without understanding their target and consequences.&lt;/p&gt;

&lt;p&gt;Also, avoid copying destructive commands from unknown websites or tutorials.&lt;/p&gt;

&lt;p&gt;A useful habit is to inspect the target first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -la some-directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="n"&gt;some&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;directory&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then decide whether deletion is actually necessary.&lt;/p&gt;




&lt;h2&gt;
  
  
  10. Working with Hidden Files
&lt;/h2&gt;

&lt;p&gt;Not every file appears in a normal directory listing.&lt;/p&gt;

&lt;p&gt;Operating systems and applications often use hidden files to store configuration and metadata.&lt;/p&gt;

&lt;p&gt;For example, a typical JavaScript project might contain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my-project/
├── src/
├── public/
├── package.json
├── package-lock.json
├── .gitignore
├── .env
└── .editorconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Files beginning with a dot are commonly treated as hidden files on Unix-like systems.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;.gitignore&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.env&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.bashrc&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.zshrc&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.editorconfig&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Show Hidden Files on macOS / Linux
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -la
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Show Hidden Files in PowerShell
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Show Hidden Files in Windows CMD
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dir /a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An important distinction:&lt;/p&gt;

&lt;p&gt;On Unix-like systems, a leading dot is a naming convention for hidden files.&lt;/p&gt;

&lt;p&gt;On Windows, hidden files generally have a filesystem attribute.&lt;/p&gt;

&lt;p&gt;These are different mechanisms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer tip:&lt;/strong&gt; If you're working with React, Node.js, or Git, learning to inspect hidden files is essential. Many important configuration files begin with a dot.&lt;/p&gt;




&lt;h2&gt;
  
  
  11. Using Wildcards
&lt;/h2&gt;

&lt;p&gt;Wildcards allow you to match multiple files using patterns.&lt;/p&gt;

&lt;p&gt;They become incredibly useful when managing large directories.&lt;/p&gt;

&lt;p&gt;Two common wildcard characters are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;*&lt;/code&gt; matches zero or more characters.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;?&lt;/code&gt; matches one character in many common command-line tools.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example: List All JavaScript Files
&lt;/h3&gt;

&lt;p&gt;macOS / Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls *.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;js&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example: Copy All CSS Files
&lt;/h3&gt;

&lt;p&gt;macOS / Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cp *.css backup/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Copy&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;css&lt;/span&gt; &lt;span class="n"&gt;backup&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example: List Files Starting with "app"
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls app*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can match:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.js
app.css
application.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wildcard behavior depends on the shell and command being used. PowerShell also has its own wildcard handling, which differs from Bash filename expansion.&lt;/p&gt;

&lt;p&gt;Always test a pattern by listing its matches before using it in a destructive operation.&lt;/p&gt;




&lt;h2&gt;
  
  
  12. Practical Project: Build a Directory Structure
&lt;/h2&gt;

&lt;p&gt;Let's combine everything we've learned.&lt;/p&gt;

&lt;p&gt;Imagine you're starting a new frontend project.&lt;/p&gt;

&lt;p&gt;You want this structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terminal-practice/
├── src/
│   ├── components/
│   ├── pages/
│   └── styles/
│
├── public/
│   └── images/
│
├── docs/
│
├── index.html
├── app.js
└── README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's build it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create the Main Directory
&lt;/h3&gt;

&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt; &lt;span class="n"&gt;terminal&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;practice&lt;/span&gt;
&lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="n"&gt;terminal&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;practice&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS / Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir terminal-practice
&lt;span class="nb"&gt;cd&lt;/span&gt; terminal-practice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Create Nested Directories
&lt;/h3&gt;

&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;docs&lt;/span&gt;
&lt;span class="n"&gt;mkdir&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;components&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;images&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS / Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir -p src/components src/pages src/styles public/images docs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Create Files
&lt;/h3&gt;

&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;
&lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;js&lt;/span&gt;
&lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ItemType&lt;/span&gt; &lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="no"&gt;README&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;md&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS / Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;touch index.html app.js README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Verify the Structure
&lt;/h3&gt;

&lt;p&gt;PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Recurse&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS / Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find . -print
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should now have a directory structure similar to the one shown above.&lt;/p&gt;

&lt;p&gt;Congratulations! You've just created a small project structure entirely from the terminal.&lt;/p&gt;




&lt;h2&gt;
  
  
  13. Common Mistakes Beginners Should Avoid
&lt;/h2&gt;

&lt;p&gt;Here are some mistakes that can cause unnecessary frustration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Forgetting quotation marks around paths with spaces&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Incorrect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; My Projects
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Correct:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"My Projects"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Confusing absolute and relative paths&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A relative path depends on your current location. An absolute path doesn't.&lt;/p&gt;

&lt;p&gt;Check your location before executing commands.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Deleting files without checking the target&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Especially when using recursive deletion commands.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Assuming commands behave identically across shells&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PowerShell, CMD, Bash, and Zsh have different syntax and features.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Forgetting that filenames can be case-sensitive&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A filename that works on your Windows machine may behave differently on a Linux server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Running commands from the wrong directory&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A simple &lt;code&gt;pwd&lt;/code&gt; or &lt;code&gt;Get-Location&lt;/code&gt; can prevent mistakes.&lt;/p&gt;




&lt;h2&gt;
  
  
  14. Practice Challenges
&lt;/h2&gt;

&lt;p&gt;It's time to test your knowledge.&lt;/p&gt;

&lt;p&gt;Try completing these tasks without looking at the solutions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenge 1: Directory Navigation
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open your terminal.&lt;/li&gt;
&lt;li&gt;Navigate to your home directory.&lt;/li&gt;
&lt;li&gt;Create a folder named &lt;code&gt;terminal-lab&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Enter that directory.&lt;/li&gt;
&lt;li&gt;Display its current location.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Challenge 2: File Management
&lt;/h3&gt;

&lt;p&gt;Inside &lt;code&gt;terminal-lab&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create three files: &lt;code&gt;index.html&lt;/code&gt;, &lt;code&gt;style.css&lt;/code&gt;, and &lt;code&gt;app.js&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Create a directory named &lt;code&gt;backup&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Copy &lt;code&gt;app.js&lt;/code&gt; into &lt;code&gt;backup&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Rename the original &lt;code&gt;app.js&lt;/code&gt; to &lt;code&gt;main.js&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;List all files and directories.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Challenge 3: Nested Directories
&lt;/h3&gt;

&lt;p&gt;Create the following structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terminal-lab/
├── frontend/
│   ├── components/
│   └── pages/
│
├── backend/
│   ├── routes/
│   └── controllers/
│
└── docs/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use as few commands as possible.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenge 4: Hidden Files
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create a file named &lt;code&gt;.env&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;List the directory normally.&lt;/li&gt;
&lt;li&gt;List it again with hidden files included.&lt;/li&gt;
&lt;li&gt;Compare the results.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Challenge 5: Safe Cleanup
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create a directory called &lt;code&gt;temporary&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Create a file inside it.&lt;/li&gt;
&lt;li&gt;Inspect the directory contents.&lt;/li&gt;
&lt;li&gt;Remove the directory and its contents.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Remember to verify the target before deletion.&lt;/p&gt;




&lt;h2&gt;
  
  
  Quick Command Reference
&lt;/h2&gt;

&lt;p&gt;Here's a compact reference you can save for later.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operation&lt;/th&gt;
&lt;th&gt;PowerShell&lt;/th&gt;
&lt;th&gt;macOS / Linux&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Current location&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-Location&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pwd&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List files&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-ChildItem&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ls&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Show hidden files&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-ChildItem -Force&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ls -la&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Home directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd ~&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cd ~&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mkdir&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mkdir&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;New-Item&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;touch&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Copy file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Copy-Item&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cp&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Move file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Move-Item&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mv&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rename file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Rename-Item&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mv&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delete file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Remove-Item&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;rm&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remove directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Remove-Item -Recurse&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;rm -r&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List recursively&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Get-ChildItem -Recurse&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;find . -print&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Note: These are common equivalents, not perfectly interchangeable commands. Their options, defaults, and behaviors can differ.&lt;/p&gt;




&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;You've learned how to navigate directories, manage files, create project structures, and work with hidden files.&lt;/p&gt;

&lt;p&gt;But there's another important question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What if you have thousands of files and need to find one specific file or search for a particular piece of text?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's where searching and filtering become essential.&lt;/p&gt;

&lt;p&gt;In Article 03, we'll explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finding files by name.&lt;/li&gt;
&lt;li&gt;Searching inside files.&lt;/li&gt;
&lt;li&gt;Reading file contents.&lt;/li&gt;
&lt;li&gt;Filtering command output.&lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;find&lt;/code&gt;, &lt;code&gt;grep&lt;/code&gt;, and PowerShell's &lt;code&gt;Select-String&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Searching through real development projects.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Next Article: Searching, Reading and Managing Files from the Terminal&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;The filesystem is the foundation of almost everything you do in a development environment.&lt;/p&gt;

&lt;p&gt;Once you understand how paths, directories, and file operations work, the terminal becomes much less intimidating.&lt;/p&gt;

&lt;p&gt;You don't need to memorize every command today.&lt;/p&gt;

&lt;p&gt;Practice the basics, experiment in a safe directory, and gradually build confidence.&lt;/p&gt;

&lt;p&gt;Remember:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A developer who understands the filesystem can work efficiently on almost any operating system.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

&lt;p&gt;---nced Terminal Workflows and Troubleshooting&lt;/p&gt;

</description>
      <category>terminal</category>
      <category>beginners</category>
      <category>linux</category>
      <category>programming</category>
    </item>
    <item>
      <title>Terminal Mastery: Windows, macOS &amp; Linux</title>
      <dc:creator>Hamed Farazi</dc:creator>
      <pubDate>Sun, 15 Nov 2026 07:50:31 +0000</pubDate>
      <link>https://dev.to/hamedfarazi/terminal-mastery-windows-macos-linux-53di</link>
      <guid>https://dev.to/hamedfarazi/terminal-mastery-windows-macos-linux-53di</guid>
      <description>&lt;p&gt;Chapter 01/10 — Terminal Fundamentals: Your First Steps into the Command Line&lt;/p&gt;

&lt;h1&gt;
  
  
  Terminal Fundamentals: Your First Steps into the Command Line
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;A practical beginner's guide to Windows, macOS, and Linux&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Have you ever watched a developer open a black window, type a few commands, and suddenly create an entire project, install dependencies, or manage their system?&lt;/p&gt;

&lt;p&gt;That window is called a &lt;strong&gt;Terminal&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For many beginners, the command line looks intimidating. It seems like a place where you need to memorize hundreds of mysterious commands just to get something done.&lt;/p&gt;

&lt;p&gt;But here's the truth:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The terminal is simply another way to communicate with your computer.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of clicking buttons and navigating menus, you type instructions and let the operating system execute them.&lt;/p&gt;

&lt;p&gt;Whether you're using Windows, macOS, or Linux, learning the command line is one of the most valuable skills you can develop as a programmer.&lt;/p&gt;

&lt;p&gt;In this article, we'll start from absolute zero.&lt;/p&gt;

&lt;p&gt;By the end, you'll understand what a terminal is, how it differs from a shell, how to execute your first commands, and how to navigate the command-line environments of all three major operating systems.&lt;/p&gt;

&lt;p&gt;Let's get started.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. What Is a Terminal?
&lt;/h2&gt;

&lt;p&gt;A terminal is an application that provides a text-based interface for interacting with your computer.&lt;/p&gt;

&lt;p&gt;Traditionally, computers relied heavily on text-based interfaces. Users typed commands to perform operations instead of clicking graphical elements.&lt;/p&gt;

&lt;p&gt;Today, we have beautiful graphical interfaces, but the terminal is still an essential tool.&lt;/p&gt;

&lt;p&gt;For example, imagine you want to create a new folder.&lt;/p&gt;

&lt;p&gt;Using a graphical interface:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open File Explorer or Finder.&lt;/li&gt;
&lt;li&gt;Navigate to the desired location.&lt;/li&gt;
&lt;li&gt;Right-click.&lt;/li&gt;
&lt;li&gt;Select New Folder.&lt;/li&gt;
&lt;li&gt;Enter the folder name.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Using a terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir my-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it.&lt;/p&gt;

&lt;p&gt;One command creates the folder.&lt;/p&gt;

&lt;p&gt;The terminal becomes especially powerful when you need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Manage files and directories.&lt;/li&gt;
&lt;li&gt;Install software and dependencies.&lt;/li&gt;
&lt;li&gt;Run development servers.&lt;/li&gt;
&lt;li&gt;Work with Git and GitHub.&lt;/li&gt;
&lt;li&gt;Manage processes.&lt;/li&gt;
&lt;li&gt;Connect to remote servers.&lt;/li&gt;
&lt;li&gt;Automate repetitive tasks.&lt;/li&gt;
&lt;li&gt;Diagnose system problems.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For developers, the terminal isn't just an alternative interface. It's an essential part of the development workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Terminal vs. Shell vs. Command Line
&lt;/h2&gt;

&lt;p&gt;Before running commands, let's understand three terms that developers often use interchangeably.&lt;/p&gt;

&lt;p&gt;Although they're related, they aren't exactly the same.&lt;/p&gt;

&lt;h3&gt;
  
  
  Terminal
&lt;/h3&gt;

&lt;p&gt;A terminal is the application or interface where you type commands and see their output.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows Terminal&lt;/li&gt;
&lt;li&gt;macOS Terminal&lt;/li&gt;
&lt;li&gt;GNOME Terminal&lt;/li&gt;
&lt;li&gt;iTerm2&lt;/li&gt;
&lt;li&gt;Alacritty&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Shell
&lt;/h3&gt;

&lt;p&gt;A shell is the program that interprets your commands and communicates with the operating system.&lt;/p&gt;

&lt;p&gt;When you type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir my-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The shell interprets the command and executes the requested operation.&lt;/p&gt;

&lt;p&gt;Popular shells include:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Shell&lt;/th&gt;
&lt;th&gt;Common Environment&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Bash&lt;/td&gt;
&lt;td&gt;Linux&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Zsh&lt;/td&gt;
&lt;td&gt;macOS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PowerShell&lt;/td&gt;
&lt;td&gt;Windows, macOS, Linux&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fish&lt;/td&gt;
&lt;td&gt;Linux, macOS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CMD&lt;/td&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Command Line
&lt;/h3&gt;

&lt;p&gt;The command line refers to the text-based interface through which you interact with the shell.&lt;/p&gt;

&lt;p&gt;You'll often hear developers say:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open your terminal.&lt;/li&gt;
&lt;li&gt;Run this command in your shell.&lt;/li&gt;
&lt;li&gt;Execute this from the command line.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In everyday development conversations, these expressions are often used loosely.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Do They Work Together?
&lt;/h3&gt;

&lt;p&gt;Think of it this way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Terminal:&lt;/strong&gt; Where you type.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shell:&lt;/strong&gt; What understands your commands.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operating System:&lt;/strong&gt; What performs the requested operations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding this distinction will make the rest of this series much easier.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Getting Started on Windows
&lt;/h2&gt;

&lt;p&gt;Windows provides several command-line environments.&lt;/p&gt;

&lt;p&gt;The two most common options for modern Windows users are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows PowerShell&lt;/li&gt;
&lt;li&gt;Command Prompt (CMD)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Windows Terminal is a modern application that can host these environments in separate tabs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option A: Open Windows Terminal
&lt;/h3&gt;

&lt;p&gt;There are several ways to open it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Method 1: Start Menu&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Press the Windows key.&lt;/li&gt;
&lt;li&gt;Search for Windows Terminal.&lt;/li&gt;
&lt;li&gt;Open the application.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Method 2: Run Dialog&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Press:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Win + R
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then enter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Press Enter.&lt;/p&gt;

&lt;p&gt;Windows Terminal should open.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option B: Open PowerShell
&lt;/h3&gt;

&lt;p&gt;You can also search for PowerShell directly in the Start Menu.&lt;/p&gt;

&lt;p&gt;PowerShell is a powerful command-line shell with scripting capabilities and access to Windows system management features.&lt;/p&gt;

&lt;p&gt;Let's run our first command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Location&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays your current working directory.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Path
----
C:\Users\Developer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now try:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays files and directories in your current location.&lt;/p&gt;

&lt;p&gt;You can also use its shorter alias:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;ls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's right. PowerShell supports aliases for many common commands.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option C: Open Command Prompt
&lt;/h3&gt;

&lt;p&gt;Search for &lt;code&gt;cmd&lt;/code&gt; in the Start Menu.&lt;/p&gt;

&lt;p&gt;Then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays your current directory.&lt;/p&gt;

&lt;p&gt;To list files and folders:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember that CMD and PowerShell are different shells. They have different syntax and capabilities.&lt;/p&gt;

&lt;p&gt;We'll explore their differences throughout this series.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Getting Started on macOS
&lt;/h2&gt;

&lt;p&gt;macOS comes with a built-in terminal application.&lt;/p&gt;

&lt;p&gt;The default shell on modern macOS installations is Zsh.&lt;/p&gt;

&lt;h3&gt;
  
  
  Open Terminal
&lt;/h3&gt;

&lt;p&gt;There are two easy methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Method 1: Spotlight Search&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Press &lt;code&gt;Command + Space&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Type Terminal.&lt;/li&gt;
&lt;li&gt;Press Enter.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Method 2: Finder&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Navigate to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Applications → Utilities → Terminal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open Terminal.&lt;/p&gt;

&lt;p&gt;You should see a command prompt waiting for input.&lt;/p&gt;

&lt;p&gt;Let's execute our first command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;pwd&lt;/code&gt; stands for Print Working Directory.&lt;/p&gt;

&lt;p&gt;It displays your current location.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/Users/developer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now list the files and directories:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To display additional details, including hidden files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -la
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll explore these options in detail in the next articles.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Getting Started on Linux
&lt;/h2&gt;

&lt;p&gt;Linux distributions usually provide a terminal application, although the exact application depends on your desktop environment.&lt;/p&gt;

&lt;p&gt;Some popular terminal applications include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GNOME Terminal&lt;/li&gt;
&lt;li&gt;Konsole&lt;/li&gt;
&lt;li&gt;Xfce Terminal&lt;/li&gt;
&lt;li&gt;Alacritty&lt;/li&gt;
&lt;li&gt;Kitty&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Open Terminal
&lt;/h3&gt;

&lt;p&gt;On many Linux distributions, you can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ctrl + Alt + T
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This shortcut works on many popular desktop environments, although it may vary.&lt;/p&gt;

&lt;p&gt;Alternatively, search for Terminal in your applications menu.&lt;/p&gt;

&lt;p&gt;Once the terminal opens, let's run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;whoami
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;whoami&lt;/code&gt; command displays the username of the current user.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;developer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Congratulations! You've already executed your first Linux commands.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Understanding Command Structure
&lt;/h2&gt;

&lt;p&gt;Now that you've opened a terminal on each operating system, let's understand how commands are structured.&lt;/p&gt;

&lt;p&gt;A typical command can contain several parts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;command [options] [arguments]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break it down.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Command:&lt;/strong&gt; The program or operation you want to execute.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Options:&lt;/strong&gt; Additional settings that modify the command's behavior.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arguments:&lt;/strong&gt; The values or targets on which the command operates.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -la /home/developer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ls&lt;/code&gt; is the command.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-la&lt;/code&gt; contains options.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/home/developer&lt;/code&gt; is the argument.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Another example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir my-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;mkdir&lt;/code&gt; is the command.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;my-project&lt;/code&gt; is the argument.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not every command requires options or arguments.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command works without either.&lt;/p&gt;

&lt;h3&gt;
  
  
  Short and Long Options
&lt;/h3&gt;

&lt;p&gt;Many command-line tools support both short and long options.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls --all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both display hidden files on typical Unix-like systems.&lt;/p&gt;

&lt;p&gt;However, option names and syntax depend on the specific command and shell.&lt;/p&gt;

&lt;p&gt;Never assume every command supports the same options.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Your First Essential Commands
&lt;/h2&gt;

&lt;p&gt;Let's learn a few commands that you'll use frequently.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Print Your Current Location
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;macOS / Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PowerShell:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Location&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CMD:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. List Files and Directories
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;macOS / Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PowerShell:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CMD:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Clear the Terminal Screen
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;macOS / Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;clear
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PowerShell / CMD:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;cls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Display Your Username
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;macOS / Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;whoami
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PowerShell / CMD:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;whoami&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Display Command Help
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;PowerShell:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Help&lt;/span&gt; &lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ChildItem&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CMD:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;help
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Bash / Zsh:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls --help
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that &lt;code&gt;--help&lt;/code&gt; is not supported by every command.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;man&lt;/code&gt; command opens a manual page when documentation is available.&lt;/p&gt;

&lt;p&gt;These help systems are incredibly useful. Experienced developers don't memorize everything. They know how to find the information they need.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Understanding Paths
&lt;/h2&gt;

&lt;p&gt;A path describes the location of a file or directory.&lt;/p&gt;

&lt;p&gt;There are two important types of paths.&lt;/p&gt;

&lt;h3&gt;
  
  
  Absolute Path
&lt;/h3&gt;

&lt;p&gt;An absolute path specifies a complete location starting from the filesystem root or an equivalent system-specific root.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Windows:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\Developer\Documents
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;macOS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/Users/developer/Documents
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/developer/Documents
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Relative Path
&lt;/h3&gt;

&lt;p&gt;A relative path describes a location in relation to your current working directory.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;projects/my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your current location is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/developer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the relative path points to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/developer/projects/my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll frequently use relative paths when working with development projects.&lt;/p&gt;

&lt;p&gt;We'll explore navigation and filesystem operations in much greater detail in Article 02.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Important Terminal Concepts for Beginners
&lt;/h2&gt;

&lt;p&gt;Before moving on, there are a few concepts worth understanding.&lt;/p&gt;

&lt;h3&gt;
  
  
  Case Sensitivity
&lt;/h3&gt;

&lt;p&gt;Linux and macOS filesystems are commonly case-sensitive, although macOS can also use case-insensitive filesystem configurations.&lt;/p&gt;

&lt;p&gt;Windows filesystems are generally case-insensitive by default.&lt;/p&gt;

&lt;p&gt;For example, on a typical case-sensitive Linux filesystem:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Project.txt
project.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These can be two different files.&lt;/p&gt;

&lt;p&gt;Don't assume that filenames behave identically across operating systems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Spaces in File and Directory Names
&lt;/h3&gt;

&lt;p&gt;Consider this directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;My Projects
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you try:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; My Projects
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The shell may interpret this as multiple arguments.&lt;/p&gt;

&lt;p&gt;Instead, wrap the path in quotation marks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"My Projects"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works in PowerShell, CMD, Bash, and Zsh.&lt;/p&gt;

&lt;h3&gt;
  
  
  Command History
&lt;/h3&gt;

&lt;p&gt;Most interactive shells allow you to access previously executed commands.&lt;/p&gt;

&lt;p&gt;Press the Up Arrow key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;↑
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays your previous command.&lt;/p&gt;

&lt;p&gt;Press it again to navigate further back through your history.&lt;/p&gt;

&lt;p&gt;The Down Arrow key moves forward.&lt;/p&gt;

&lt;p&gt;This simple feature can save you a lot of time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tab Completion
&lt;/h3&gt;

&lt;p&gt;You don't always need to type the entire command or path.&lt;/p&gt;

&lt;p&gt;Start typing a filename or directory name and press:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Tab
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your shell may automatically complete the name.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; Doc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Press Tab, and the shell may complete it to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; Documents
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The exact behavior depends on your shell configuration and available completions.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Practice: Your First Terminal Exercise
&lt;/h2&gt;

&lt;p&gt;Theory is useful, but the best way to learn the terminal is to use it.&lt;/p&gt;

&lt;p&gt;Open your terminal and complete these exercises.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Task 1:&lt;/strong&gt; Display your current location.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Task 2:&lt;/strong&gt; Display the files and directories in your current location.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Task 3:&lt;/strong&gt; Display your current username.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Task 4:&lt;/strong&gt; Clear your terminal screen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Task 5:&lt;/strong&gt; Display the available help information for a command.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Task 6:&lt;/strong&gt; Use the Up Arrow key to execute a previously entered command.&lt;/p&gt;

&lt;p&gt;Try completing all six tasks without copying the commands directly from the article.&lt;/p&gt;

&lt;p&gt;The goal is to become comfortable with the environment.&lt;/p&gt;




&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;You've now learned the fundamentals of the command line and explored the basic differences between Windows, macOS, and Linux terminal environments.&lt;/p&gt;

&lt;p&gt;But knowing how to execute commands is only the beginning.&lt;/p&gt;

&lt;p&gt;In the next article, we'll explore one of the most important terminal skills: navigating and managing the filesystem.&lt;/p&gt;

&lt;p&gt;We'll learn how to move between directories, create files, rename folders, copy data, and delete files safely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next Article: Navigating the File System Like a Pro&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;The terminal might look complicated at first, but don't let that discourage you.&lt;/p&gt;

&lt;p&gt;You don't need to memorize hundreds of commands.&lt;/p&gt;

&lt;p&gt;Start with a few essential operations, understand what they do, and practice them regularly.&lt;/p&gt;

&lt;p&gt;Over time, the command line will become a natural part of your development workflow.&lt;/p&gt;

&lt;p&gt;Remember:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The goal isn't to memorize commands. It's to understand how to communicate with your computer.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>terminal</category>
      <category>beginners</category>
      <category>linux</category>
      <category>windows</category>
    </item>
  </channel>
</rss>
