<?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: Safal Bhattarai</title>
    <description>The latest articles on DEV Community by Safal Bhattarai (@coder-safal).</description>
    <link>https://dev.to/coder-safal</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%2F3112491%2Fbdc68e36-d277-4270-a3c5-c19903276f3f.jpg</url>
      <title>DEV Community: Safal Bhattarai</title>
      <link>https://dev.to/coder-safal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/coder-safal"/>
    <language>en</language>
    <item>
      <title>Linux curl Command: 5 Examples Every Developer Should Know</title>
      <dc:creator>Safal Bhattarai</dc:creator>
      <pubDate>Sat, 14 Nov 2026 14:02:51 +0000</pubDate>
      <link>https://dev.to/coder-safal/linux-curl-command-5-examples-every-developer-should-know-2ni0</link>
      <guid>https://dev.to/coder-safal/linux-curl-command-5-examples-every-developer-should-know-2ni0</guid>
      <description>&lt;p&gt;The &lt;code&gt;curl&lt;/code&gt; command transfers data to and from a server using protocols like HTTP and HTTPS. Developers use it to test APIs, check response headers, download files, and debug web requests right from the terminal.&lt;/p&gt;

&lt;p&gt;This is part 5 of my Linux networking series. If you missed the earlier posts, start with &lt;a href="https://dev.to/coder-safal/linux-dig-command-5-examples-every-developer-should-know-3bo9"&gt;Linux dig Command: 5 Examples Every Developer Should Know&lt;/a&gt;, then read the nslookup, ping, and traceroute posts.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Install curl
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;curl&lt;/code&gt; is already installed on many systems. If it's missing, install it on Debian/Ubuntu 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 apt update
sudo apt install curl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Make a Basic GET Request
&lt;/h2&gt;



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

&lt;/div&gt;



&lt;p&gt;This sends a GET request and prints the response body to the terminal. Since &lt;code&gt;google.com&lt;/code&gt; redirects, you'll see a short HTML page telling you the page has moved. The next examples show how to handle that.&lt;/p&gt;

&lt;p&gt;To hide the progress meter in scripts, add &lt;code&gt;-s&lt;/code&gt; (silent):&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://google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Check Response Headers and Follow Redirects
&lt;/h2&gt;

&lt;p&gt;Show only the response headers with &lt;code&gt;-I&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;curl -I https://google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is handy for checking the status code, content type, caching headers, and where a redirect points.&lt;/p&gt;

&lt;p&gt;Follow redirects automatically with &lt;code&gt;-L&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;curl -L https://google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Combine both to see the headers of the final page:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Download a File
&lt;/h2&gt;

&lt;p&gt;Save the output to a file name of your choice with &lt;code&gt;-o&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;curl -o page.html https://google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file using its original name from the URL with &lt;code&gt;-O&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;curl -O https://example.com/file.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Resume an interrupted download with &lt;code&gt;-C -&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;curl -C - -O https://example.com/file.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Send Data to an API (POST Request)
&lt;/h2&gt;

&lt;p&gt;Send JSON using a POST request:&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://httpbin.org/post \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"name": "Safal", "role": "developer"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-X POST&lt;/code&gt; sets the HTTP method.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-H&lt;/code&gt; adds a request header.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-d&lt;/code&gt; sets the request body.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Add an authorization header when an API needs a token:&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/data \
  -H &lt;span class="s2"&gt;"Authorization: Bearer YOUR_TOKEN"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;YOUR_TOKEN&lt;/code&gt; with a real token, and keep real tokens out of your shell history and public posts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: Debug with Verbose Output
&lt;/h2&gt;



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

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-v&lt;/code&gt; option shows the DNS lookup, the connection, the TLS handshake, and the full request and response headers. It's the best way to see what is really happening during a request.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: Measure How Long a Request Takes
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -o /dev/null -s -w &lt;span class="s2"&gt;"Total time: %{time_total}s\n"&lt;/span&gt; https://google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here &lt;code&gt;-o /dev/null&lt;/code&gt; throws away the body, &lt;code&gt;-s&lt;/code&gt; hides the progress meter, and &lt;code&gt;-w&lt;/code&gt; prints the timing you ask for. You can also use &lt;code&gt;%{http_code}&lt;/code&gt; to print the status code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Options
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-s&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Silent mode, no progress meter&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-I&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Show response headers only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-L&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Follow redirects&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;Save output to a file name you choose&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;Save output using the remote file name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-X&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Set the HTTP method&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-H&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Add a request header&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;Send data in the request body&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-v&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Verbose output for debugging&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;The &lt;code&gt;curl&lt;/code&gt; command is one of the most useful tools for developers and DevOps engineers. Used together with &lt;code&gt;dig&lt;/code&gt;, &lt;code&gt;nslookup&lt;/code&gt;, &lt;code&gt;ping&lt;/code&gt;, and &lt;code&gt;traceroute&lt;/code&gt;, you can follow a request from DNS lookup all the way to the HTTP response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next:&lt;/strong&gt; Linux &lt;code&gt;ss&lt;/code&gt; Command: Simple Examples.&lt;/p&gt;




&lt;h2&gt;
  
  
  About Me
&lt;/h2&gt;

&lt;p&gt;I'm &lt;strong&gt;Safal Bhattarai&lt;/strong&gt;, a Tech Lead, Full Stack Developer, and DevOps Engineer.&lt;/p&gt;

&lt;p&gt;🌐 &lt;a href="https://safal.me" rel="noopener noreferrer"&gt;Website&lt;/a&gt; · 💻 &lt;a href="https://github.com/" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>api</category>
      <category>networking</category>
    </item>
    <item>
      <title>Linux Folder Structure Explained: /home, /root, and /tmp</title>
      <dc:creator>Safal Bhattarai</dc:creator>
      <pubDate>Mon, 09 Nov 2026 06:55:56 +0000</pubDate>
      <link>https://dev.to/coder-safal/linux-folder-structure-explained-home-root-and-tmp-1i6g</link>
      <guid>https://dev.to/coder-safal/linux-folder-structure-explained-home-root-and-tmp-1i6g</guid>
      <description>&lt;p&gt;In &lt;a href="https://dev.to/coder-safal"&gt;Part 1&lt;/a&gt; we looked at the root directory (&lt;code&gt;/&lt;/code&gt;) and &lt;code&gt;/etc&lt;/code&gt;. In this part we cover three places you will use every day: &lt;code&gt;/home&lt;/code&gt;, &lt;code&gt;/root&lt;/code&gt;, and &lt;code&gt;/tmp&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  /home: where regular users live
&lt;/h2&gt;

&lt;p&gt;Every regular user gets a personal folder inside &lt;code&gt;/home&lt;/code&gt;. This is where your documents, downloads, projects, and personal settings are stored.&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;ls&lt;/span&gt; /home
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





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

&lt;/div&gt;



&lt;p&gt;Your own folder is &lt;code&gt;/home/&amp;lt;username&amp;gt;&lt;/code&gt;. You can jump to it from anywhere 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;cd&lt;/span&gt; ~
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;~&lt;/code&gt; symbol is a shortcut for your home directory. You can also print 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="nv"&gt;$HOME&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Typical contents
&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;ls&lt;/span&gt; ~
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Desktop  Documents  Downloads
Music    Pictures   Videos
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Hidden files (dotfiles)
&lt;/h3&gt;

&lt;p&gt;Files and folders that start with a dot are hidden. Programs store your personal settings in them. Use &lt;code&gt;-a&lt;/code&gt; to see them:&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;ls&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; ~
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.  ..  .bashrc  .profile  .ssh
.config  .local  .cache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dotfile&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;.bashrc&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Bash settings and aliases&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.profile&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Login shell settings&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.ssh/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;SSH keys and known hosts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.config/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Settings for many apps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.cache/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Cached data, safe to clear&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Check how much space you use
&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;du&lt;/span&gt; &lt;span class="nt"&gt;-sh&lt;/span&gt; ~
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;4.2G    /home/safal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Permissions
&lt;/h3&gt;

&lt;p&gt;Home folders are private to each user by default:&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;ls&lt;/span&gt; &lt;span class="nt"&gt;-ld&lt;/span&gt; ~
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;drwxr-x--- 15 safal safal 4096 Nov 2 10:15 /home/safal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On many newer distributions, other users cannot read your home folder, which is good for privacy.&lt;/p&gt;

&lt;h2&gt;
  
  
  /root: the home of the root user
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;/root&lt;/code&gt; is the home directory of the &lt;strong&gt;root&lt;/strong&gt; (administrator) user. It is not inside &lt;code&gt;/home&lt;/code&gt;, so it stays available even if &lt;code&gt;/home&lt;/code&gt; is on a separate disk that fails to mount.&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;ls&lt;/span&gt; &lt;span class="nt"&gt;-ld&lt;/span&gt; /root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;drwx------ 5 root root 4096 Nov 2 09:40 /root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only root can enter it. To look inside, use &lt;code&gt;sudo&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;sudo ls&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do not confuse these three:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Path&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;Root of the whole filesystem&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;Home folder of the root user&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;The administrator account&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  /tmp: temporary files
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;/tmp&lt;/code&gt; is a shared place for short-lived files. Programs use it for scratch data, and any user can write to 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;ls&lt;/span&gt; &lt;span class="nt"&gt;-ld&lt;/span&gt; /tmp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;drwxrwxrwt 18 root root 4096 Nov 2 10:20 /tmp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the &lt;code&gt;t&lt;/code&gt; at the end of the permissions. This is the &lt;strong&gt;sticky bit&lt;/strong&gt;. It means everyone can create files in &lt;code&gt;/tmp&lt;/code&gt;, but you can only delete or rename your own files.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a safe temporary file
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;mktemp&lt;/code&gt; instead of inventing a file name, so two programs never clash:&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;mktemp&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/tmp/tmp.Xk3j9fA2bQ
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a temporary folder:&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;mktemp&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Files may disappear
&lt;/h3&gt;

&lt;p&gt;Many systems clear &lt;code&gt;/tmp&lt;/code&gt; on reboot, and some also delete old files automatically. Never store anything important there.&lt;/p&gt;

&lt;p&gt;If you need temporary files that survive a reboot, look at &lt;code&gt;/var/tmp&lt;/code&gt;, which we will cover in the &lt;code&gt;/var&lt;/code&gt; part.&lt;/p&gt;

&lt;h3&gt;
  
  
  Security tip
&lt;/h3&gt;

&lt;p&gt;Because &lt;code&gt;/tmp&lt;/code&gt; is writable by everyone, avoid putting passwords, keys, or private data there. Also avoid predictable file names in scripts, and prefer &lt;code&gt;mktemp&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick comparison
&lt;/h2&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;Owner&lt;/th&gt;
&lt;th&gt;Survives reboot?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/home/user&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;That user&lt;/td&gt;
&lt;td&gt;Yes&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 only&lt;/td&gt;
&lt;td&gt;Yes&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;Everyone&lt;/td&gt;
&lt;td&gt;Often no&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/home/&amp;lt;user&amp;gt;&lt;/code&gt; is your personal space, with hidden dotfiles for settings.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/root&lt;/code&gt; is the private home folder of the administrator.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/tmp&lt;/code&gt; is shared and temporary, so never keep important data there.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Next in the series:&lt;/strong&gt; Part 3, &lt;code&gt;/var&lt;/code&gt; (logs, cache, and spool).&lt;/p&gt;

&lt;p&gt;Found a mistake or have a tip? Leave a comment below.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>beginners</category>
      <category>devops</category>
      <category>sysadmin</category>
    </item>
    <item>
      <title>Linux traceroute Command: 5 Examples Every Developer Should Know</title>
      <dc:creator>Safal Bhattarai</dc:creator>
      <pubDate>Mon, 09 Nov 2026 06:55:19 +0000</pubDate>
      <link>https://dev.to/coder-safal/linux-traceroute-command-5-examples-every-developer-should-know-23gd</link>
      <guid>https://dev.to/coder-safal/linux-traceroute-command-5-examples-every-developer-should-know-23gd</guid>
      <description>&lt;p&gt;The &lt;code&gt;traceroute&lt;/code&gt; command shows the path your network traffic takes to reach a destination. It lists every router (hop) along the way and how long each one takes to respond, which helps you find where a connection slows down or stops working.&lt;/p&gt;

&lt;p&gt;This is part 4 of my Linux networking series. If you missed the earlier posts, start with &lt;a href="https://dev.to/coder-safal/linux-dig-command-5-examples-every-developer-should-know-3bo9"&gt;Linux dig Command: 5 Examples Every Developer Should Know&lt;/a&gt;, then read the nslookup and ping posts.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Install traceroute
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;traceroute&lt;/code&gt; is often not installed by default. On Debian/Ubuntu:&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;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;traceroute
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Trace the Route to a Domain
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;traceroute google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output looks like this (addresses and times will differ on your network):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;traceroute to google.com (142.250.x.x), 30 hops max, 60 byte packets
 1  _gateway (192.168.1.1)  1.2 ms  1.1 ms  1.0 ms
 2  10.20.0.1  8.4 ms  8.1 ms  8.3 ms
 3  * * *
 4  ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Each numbered line is one hop, meaning one router on the path.&lt;/li&gt;
&lt;li&gt;The three times are the round-trip times for three probe packets sent to that hop.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;* * *&lt;/code&gt; means that hop did not reply within the timeout. It is common, because many routers are set to ignore these probes, and it does not always mean a problem.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Skip DNS Lookups with -n
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;traceroute &lt;span class="nt"&gt;-n&lt;/span&gt; google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By default, &lt;code&gt;traceroute&lt;/code&gt; tries to resolve each hop's IP address to a hostname, which can slow things down. The &lt;code&gt;-n&lt;/code&gt; option shows IP addresses only, so the trace runs faster and the output is easier to copy into a bug report.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Control Hops, Timeout, and Probes
&lt;/h2&gt;

&lt;p&gt;Limit the maximum number of hops (the default is 30):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;traceroute &lt;span class="nt"&gt;-m&lt;/span&gt; 15 google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wait only 2 seconds for each reply (the default is 5):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;traceroute &lt;span class="nt"&gt;-w&lt;/span&gt; 2 google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Send 1 probe per hop instead of 3 for a shorter, faster trace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;traceroute &lt;span class="nt"&gt;-q&lt;/span&gt; 1 google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can combine them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;traceroute &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nt"&gt;-m&lt;/span&gt; 15 &lt;span class="nt"&gt;-w&lt;/span&gt; 2 &lt;span class="nt"&gt;-q&lt;/span&gt; 1 google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Use ICMP or TCP Instead of UDP
&lt;/h2&gt;

&lt;p&gt;By default, &lt;code&gt;traceroute&lt;/code&gt; on Linux sends UDP packets. Some firewalls block these, so you may see many &lt;code&gt;* * *&lt;/code&gt; lines. Try another method:&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;sudo &lt;/span&gt;traceroute &lt;span class="nt"&gt;-I&lt;/span&gt; google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;-I&lt;/code&gt; uses ICMP echo requests, the same kind of packet that &lt;code&gt;ping&lt;/code&gt; sends.&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;sudo &lt;/span&gt;traceroute &lt;span class="nt"&gt;-T&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 443 google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;-T&lt;/code&gt; uses TCP, and &lt;code&gt;-p 443&lt;/code&gt; sets the destination port. Since HTTPS traffic is rarely blocked, a TCP trace to port 443 often gets further than the default.&lt;/p&gt;

&lt;p&gt;Both options need &lt;code&gt;sudo&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: Choose IPv4 or IPv6
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;traceroute &lt;span class="nt"&gt;-4&lt;/span&gt; google.com
traceroute &lt;span class="nt"&gt;-6&lt;/span&gt; google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Bonus: Try tracepath
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;tracepath&lt;/code&gt; is a similar tool that works without root privileges and is often already installed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tracepath google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How to Read the Results
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What you see&lt;/th&gt;
&lt;th&gt;What it likely means&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Latency jumps at one hop and stays high afterward&lt;/td&gt;
&lt;td&gt;The problem starts at that hop or the link after it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;One hop with high latency, then normal again&lt;/td&gt;
&lt;td&gt;That router is slow to answer probes, but traffic is probably fine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;* * *&lt;/code&gt; on a hop, but later hops reply&lt;/td&gt;
&lt;td&gt;That router ignores probes, which is usually harmless&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;* * *&lt;/code&gt; on every hop from some point onward&lt;/td&gt;
&lt;td&gt;Traffic is blocked or lost there, or a firewall drops the probes&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;The &lt;code&gt;traceroute&lt;/code&gt; command shows where your traffic goes and where it slows down. Use &lt;code&gt;ping&lt;/code&gt; to check that a host is reachable, &lt;code&gt;dig&lt;/code&gt; or &lt;code&gt;nslookup&lt;/code&gt; to check&lt;/p&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>networking</category>
      <category>sysadmin</category>
    </item>
    <item>
      <title>Linux Folder Structure Explained: The Root Directory (/) and /etc</title>
      <dc:creator>Safal Bhattarai</dc:creator>
      <pubDate>Mon, 02 Nov 2026 16:17:01 +0000</pubDate>
      <link>https://dev.to/coder-safal/linux-folder-structure-explained-the-root-directory-and-etc-155n</link>
      <guid>https://dev.to/coder-safal/linux-folder-structure-explained-the-root-directory-and-etc-155n</guid>
      <description>&lt;p&gt;If you are new to Linux, the first thing that feels strange is the folder layout. There is no &lt;code&gt;C:\&lt;/code&gt; drive. Everything starts from a single root directory: &lt;code&gt;/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This is &lt;strong&gt;Part 1&lt;/strong&gt; of a series where I walk through the Linux filesystem one directory at a time. In this post we cover the root directory and &lt;code&gt;/etc&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Filesystem Hierarchy Standard (FHS)
&lt;/h2&gt;

&lt;p&gt;Most Linux distributions follow the &lt;strong&gt;Filesystem Hierarchy Standard (FHS)&lt;/strong&gt;, a convention that defines which kind of file lives where. Once you learn it, every Linux server feels familiar.&lt;/p&gt;

&lt;h2&gt;
  
  
  See it yourself
&lt;/h2&gt;



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

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bin   boot  dev   etc   home  lib   media
mnt   opt   proc  root  run   sbin  srv
sys   tmp   usr   var
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your output may differ slightly depending on the distribution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick map of &lt;code&gt;/&lt;/code&gt;
&lt;/h2&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;/bin&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Essential user commands (&lt;code&gt;ls&lt;/code&gt;, &lt;code&gt;cp&lt;/code&gt;, &lt;code&gt;cat&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/sbin&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;System administration commands&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-wide configuration files&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;Personal folders for regular users&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;Home folder of the root user&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: logs, caches, mail&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;Installed programs and libraries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/dev&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Device files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/proc&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Virtual files with process and kernel information&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/boot&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Bootloader and kernel files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/opt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Optional third-party software&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;On many modern distributions, &lt;code&gt;/bin&lt;/code&gt;, &lt;code&gt;/sbin&lt;/code&gt;, and &lt;code&gt;/lib&lt;/code&gt; are symbolic links to the matching folders inside &lt;code&gt;/usr&lt;/code&gt;. You can check 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;ls&lt;/span&gt; &lt;span class="nt"&gt;-ld&lt;/span&gt; /bin /sbin /lib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will cover each of these in later parts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deep dive: &lt;code&gt;/etc&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;/etc&lt;/code&gt; holds &lt;strong&gt;system-wide configuration files&lt;/strong&gt;. Most of them are plain text, so you can read them with &lt;code&gt;cat&lt;/code&gt; or &lt;code&gt;less&lt;/code&gt; and edit them with a text editor.&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;ls&lt;/span&gt; /etc | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Important files in &lt;code&gt;/etc&lt;/code&gt;
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;File&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc/passwd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;List of user accounts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc/group&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;List of groups&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc/hosts&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Local hostname to IP mapping&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc/resolv.conf&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;DNS resolver settings&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc/fstab&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Filesystems mounted at boot&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc/hostname&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The name of the machine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;SSH server settings&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc/os-release&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Distribution name and version&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Example 1: Read the hosts file
&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;cat&lt;/span&gt; /etc/hosts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;127.0.0.1   localhost
127.0.1.1   my-machine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can map a name to an IP here, which is handy for local testing:&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;"192.168.1.50 myserver.local"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /etc/hosts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example 2: Check your Linux distribution
&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;cat&lt;/span&gt; /etc/os-release
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example 3: See user accounts
&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;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;: &lt;span class="nt"&gt;-f1&lt;/span&gt; /etc/passwd | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;root
daemon
bin
sys
sync
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each line in &lt;code&gt;/etc/passwd&lt;/code&gt; has fields separated by colons: username, password placeholder, user ID, group ID, description, home directory, and shell. Despite the name, real password hashes are stored in &lt;code&gt;/etc/shadow&lt;/code&gt;, which only root can read.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example 4: Check DNS settings
&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;cat&lt;/span&gt; /etc/resolv.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This shows which DNS servers your system uses. It connects nicely to the &lt;code&gt;dig&lt;/code&gt; and &lt;code&gt;nslookup&lt;/code&gt; posts in my Linux Networking Commands series.&lt;/p&gt;

&lt;h2&gt;
  
  
  Good practice when editing &lt;code&gt;/etc&lt;/code&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Back up first: &lt;code&gt;sudo cp /etc/hosts /etc/hosts.bak&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;sudo&lt;/code&gt; only when you really need it.&lt;/li&gt;
&lt;li&gt;Validate the config when the tool supports it, for example &lt;code&gt;sudo sshd -t&lt;/code&gt; for SSH.&lt;/li&gt;
&lt;li&gt;Never delete files in &lt;code&gt;/etc&lt;/code&gt; unless you know exactly what they do.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/&lt;/code&gt; is the top of the whole directory tree.&lt;/li&gt;
&lt;li&gt;Each top-level directory has a specific purpose defined by the FHS.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/etc&lt;/code&gt; stores system configuration, mostly as editable text files.&lt;/li&gt;
&lt;li&gt;Always back up before you change anything.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Next in the series:&lt;/strong&gt; Part 2, &lt;code&gt;/home&lt;/code&gt;, &lt;code&gt;/root&lt;/code&gt;, and &lt;code&gt;/tmp&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Did I miss anything or get something wrong? Leave a comment below.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>beginners</category>
      <category>devops</category>
      <category>sysadmin</category>
    </item>
    <item>
      <title>Linux ping Command: 5 Examples Every Developer Should Know</title>
      <dc:creator>Safal Bhattarai</dc:creator>
      <pubDate>Mon, 02 Nov 2026 16:13:13 +0000</pubDate>
      <link>https://dev.to/coder-safal/linux-ping-command-5-examples-every-developer-should-know-39nd</link>
      <guid>https://dev.to/coder-safal/linux-ping-command-5-examples-every-developer-should-know-39nd</guid>
      <description>&lt;p&gt;The &lt;code&gt;ping&lt;/code&gt; command is the quickest way to check whether another machine is reachable over the network. It sends small ICMP echo requests to a host and measures how long the replies take, which makes it a first step for troubleshooting connectivity, latency, and packet loss on Linux.&lt;/p&gt;

&lt;p&gt;This is part 3 of my Linux networking series. If you missed the earlier posts, start with &lt;a href="https://dev.to/coder-safal/linux-dig-command-5-examples-every-developer-should-know-3bo9"&gt;Linux dig Command: 5 Examples Every Developer Should Know&lt;/a&gt;, then read the nslookup post.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Install ping
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ping&lt;/code&gt; is installed by default on most systems. If it's missing, install it on Debian/Ubuntu 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;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;iputils-ping
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Ping a Domain or IP Address
&lt;/h2&gt;



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

&lt;/div&gt;



&lt;p&gt;On Linux, &lt;code&gt;ping&lt;/code&gt; keeps running until you stop it with &lt;code&gt;Ctrl + C&lt;/code&gt;. Each line of output 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;64 bytes from ... icmp_seq=1 ttl=117 time=14.2 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;icmp_seq&lt;/code&gt; is the packet number.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ttl&lt;/code&gt; is the time to live, which limits how many network hops a packet can make.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;time&lt;/code&gt; is the round-trip time in milliseconds. Lower is better.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you stop it, &lt;code&gt;ping&lt;/code&gt; prints a summary with the packets sent and received, the percentage of packet loss, and the minimum, average, and maximum round-trip times.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Send a Fixed Number of Packets
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ping &lt;span class="nt"&gt;-c&lt;/span&gt; 4 google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-c&lt;/code&gt; option stops &lt;code&gt;ping&lt;/code&gt; after the given number of packets. This is useful in scripts and for quick checks, because you don't need to press &lt;code&gt;Ctrl + C&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For a short summary only, add &lt;code&gt;-q&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;ping &lt;span class="nt"&gt;-c&lt;/span&gt; 4 &lt;span class="nt"&gt;-q&lt;/span&gt; google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Change the Interval and Timeout
&lt;/h2&gt;

&lt;p&gt;Wait 2 seconds between packets with &lt;code&gt;-i&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;ping &lt;span class="nt"&gt;-i&lt;/span&gt; 2 google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set how long to wait for each reply with &lt;code&gt;-W&lt;/code&gt; (in seconds):&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;span class="nt"&gt;-c&lt;/span&gt; 4 &lt;span class="nt"&gt;-W&lt;/span&gt; 2 google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Intervals shorter than 0.2 seconds require root privileges, so most of the time the default of 1 second is fine.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Tell DNS Problems from Network Problems
&lt;/h2&gt;

&lt;p&gt;Ping a domain name and an IP address separately:&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;span class="nt"&gt;-c&lt;/span&gt; 4 google.com
ping &lt;span class="nt"&gt;-c&lt;/span&gt; 4 8.8.8.8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Domain works&lt;/th&gt;
&lt;th&gt;IP works&lt;/th&gt;
&lt;th&gt;What it likely means&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Everything is fine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;DNS problem (check &lt;code&gt;dig&lt;/code&gt; or &lt;code&gt;nslookup&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Network or firewall problem&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If the IP address responds but the domain doesn't, the network is fine and the problem is name resolution. That's where the &lt;code&gt;dig&lt;/code&gt; and &lt;code&gt;nslookup&lt;/code&gt; commands from earlier in the series come in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: Choose IPv4 or IPv6
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ping &lt;span class="nt"&gt;-4&lt;/span&gt; google.com
ping &lt;span class="nt"&gt;-6&lt;/span&gt; google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Bonus: Change the Packet Size
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ping &lt;span class="nt"&gt;-c&lt;/span&gt; 4 &lt;span class="nt"&gt;-s&lt;/span&gt; 1000 google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-s&lt;/code&gt; option sets the data size in bytes (the default is 56). Larger packets can help you spot problems that only appear with bigger payloads.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Some servers and firewalls block ICMP, so a failed &lt;code&gt;ping&lt;/code&gt; doesn't always mean the host is down.&lt;/li&gt;
&lt;li&gt;High or uneven &lt;code&gt;time&lt;/code&gt; values point to network congestion or a poor connection.&lt;/li&gt;
&lt;li&gt;Any packet loss above 0% is worth investigating.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;ping&lt;/code&gt; command is simple, but it answers the first question in any network problem: can I reach this host? Combine it with &lt;code&gt;dig&lt;/code&gt; and &lt;code&gt;nslookup&lt;/code&gt; and you can quickly tell whether the issue is DNS or the network itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next:&lt;/strong&gt; Linux &lt;code&gt;traceroute&lt;/code&gt; Command: Simple Examples.&lt;/p&gt;




&lt;h2&gt;
  
  
  About Me
&lt;/h2&gt;

&lt;p&gt;I'm &lt;strong&gt;Safal Bhattarai&lt;/strong&gt;, a Tech Lead, Full Stack Developer, and DevOps Engineer.&lt;/p&gt;

&lt;p&gt;🌐 &lt;a href="https://safal.me" rel="noopener noreferrer"&gt;Website&lt;/a&gt; · 💻 &lt;a href="https://github.com/" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>networking</category>
      <category>sysadmin</category>
    </item>
    <item>
      <title>How to Expose localhost to the Internet with Free HTTPS (Cloudflare Tunnel, No Port Forwarding)</title>
      <dc:creator>Safal Bhattarai</dc:creator>
      <pubDate>Mon, 02 Nov 2026 09:33:04 +0000</pubDate>
      <link>https://dev.to/coder-safal/how-to-expose-localhost-to-the-internet-with-free-https-cloudflare-tunnel-no-port-forwarding-e6o</link>
      <guid>https://dev.to/coder-safal/how-to-expose-localhost-to-the-internet-with-free-https-cloudflare-tunnel-no-port-forwarding-e6o</guid>
      <description>&lt;p&gt;Most home and mobile ISPs put you behind &lt;strong&gt;NAT or CGNAT&lt;/strong&gt;. Your laptop only has a private address like &lt;code&gt;192.168.x.x&lt;/code&gt;, so nobody on the internet can reach your local server, and router port forwarding usually doesn't help.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloudflare Tunnel&lt;/strong&gt; solves this the other way around. Instead of the internet connecting &lt;em&gt;in&lt;/em&gt; to your laptop, a small program called &lt;code&gt;cloudflared&lt;/code&gt; on your laptop connects &lt;em&gt;out&lt;/em&gt; to Cloudflare. Cloudflare then forwards visitors from your public domain through that connection to your local app.&lt;/p&gt;

&lt;p&gt;What you get:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A permanent URL like &lt;code&gt;https://app.yourdomain.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Free HTTPS, with no certificate setup&lt;/li&gt;
&lt;li&gt;No open ports and no public IP needed&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Visitor
  → app.yourdomain.com
  → Cloudflare
  → tunnel
  → cloudflared (your laptop)
  → localhost:3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What you need
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A free Cloudflare account&lt;/li&gt;
&lt;li&gt;A domain added to Cloudflare with status &lt;strong&gt;Active&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;An app running locally, for example on &lt;code&gt;http://localhost:3000&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 0: Add your domain to Cloudflare
&lt;/h2&gt;

&lt;p&gt;Cloudflare can only create a tunnel for a domain it manages DNS for. If you bought your domain elsewhere:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In the Cloudflare dashboard, click &lt;strong&gt;Add a domain&lt;/strong&gt; and choose the free plan.&lt;/li&gt;
&lt;li&gt;Cloudflare shows you two nameservers.&lt;/li&gt;
&lt;li&gt;At your registrar (where you bought the domain), replace the existing nameservers with those two.&lt;/li&gt;
&lt;li&gt;Wait until the domain shows &lt;strong&gt;Active&lt;/strong&gt;. This can take a few minutes to a few hours.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 1: Install cloudflared
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;cloudflared&lt;/code&gt; is the program that runs on your laptop and keeps the outbound connection to Cloudflare alive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ubuntu / Debian:&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;sudo mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nt"&gt;--mode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0755 /usr/share/keyrings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creates the folder where trusted package signing keys are stored.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://pkg.cloudflare.com/cloudflare-main.gpg &lt;span class="se"&gt;\&lt;/span&gt;
  | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /usr/share/keyrings/cloudflare-main.gpg &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Downloads Cloudflare's signing key so your system can verify the package really comes from Cloudflare.&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;"deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="s2"&gt;
https://pkg.cloudflare.com/cloudflared any main"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /etc/apt/sources.list.d/cloudflared.list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adds Cloudflare's package repository to &lt;code&gt;apt&lt;/code&gt;, so &lt;code&gt;apt&lt;/code&gt; knows where to download &lt;code&gt;cloudflared&lt;/code&gt; from.&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;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;cloudflared
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Refreshes the package list (so it sees the new repository) and installs &lt;code&gt;cloudflared&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;cloudflared &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Confirms the install worked and prints the version.&lt;/p&gt;

&lt;p&gt;On macOS use &lt;code&gt;brew install cloudflared&lt;/code&gt;. On Windows 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;winget&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Cloudflare.cloudflared&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Log in to Cloudflare
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloudflared tunnel login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; This links your laptop to your Cloudflare account and chooses which domain the tunnel may use. A browser page opens. Select your domain and click &lt;strong&gt;Authorize&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When it succeeds, it saves a certificate file called &lt;code&gt;cert.pem&lt;/code&gt; in &lt;code&gt;~/.cloudflared/&lt;/code&gt;. The next command needs this file to prove you're allowed to create tunnels.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Don't press &lt;code&gt;Ctrl+C&lt;/code&gt; while the terminal is waiting. If you cancel, &lt;code&gt;cert.pem&lt;/code&gt; is never saved and the next step fails with &lt;code&gt;Cannot determine default origin certificate path&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Check that it exists:&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;ls&lt;/span&gt; ~/.cloudflared/cert.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Confirms the login finished before you continue.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Create the tunnel
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloudflared tunnel create my-laptop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; This registers a new tunnel named &lt;code&gt;my-laptop&lt;/code&gt; with Cloudflare. It prints a &lt;strong&gt;tunnel ID&lt;/strong&gt; (a long UUID) and saves a credentials file at &lt;code&gt;~/.cloudflared/&amp;lt;TUNNEL_ID&amp;gt;.json&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That JSON file is the tunnel's secret key. It's what lets your laptop prove it owns this tunnel, so keep it private and never commit it to Git.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Point a hostname at the tunnel
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloudflared tunnel route dns my-laptop &lt;span class="se"&gt;\&lt;/span&gt;
  app.yourdomain.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; A tunnel by itself has no public address. This command creates a DNS record in Cloudflare so that &lt;code&gt;app.yourdomain.com&lt;/code&gt; points to your tunnel. Replace &lt;code&gt;app.yourdomain.com&lt;/code&gt; with the real hostname you want, such as &lt;code&gt;api.example.com&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Create the config file
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;~/.cloudflared/config.yml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;tunnel&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;TUNNEL_ID&amp;gt;&lt;/span&gt;
&lt;span class="na"&gt;credentials-file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/home/YOURUSER/.cloudflared/&amp;lt;TUNNEL_ID&amp;gt;.json&lt;/span&gt;

&lt;span class="na"&gt;ingress&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;hostname&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;app.yourdomain.com&lt;/span&gt;
    &lt;span class="na"&gt;service&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http://localhost:3000&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;service&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http_status:404&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why each line matters:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;tunnel&lt;/code&gt; tells &lt;code&gt;cloudflared&lt;/code&gt; which tunnel to run (use the ID from Step 3).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;credentials-file&lt;/code&gt; is the path to the secret JSON from Step 3.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ingress&lt;/code&gt; is the routing table. It says "requests for this hostname go to this local service."&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;hostname: app.yourdomain.com&lt;/code&gt; matches the DNS record from Step 4.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;service: http://localhost:3000&lt;/code&gt; is your local app. Change the port to match yours.&lt;/li&gt;
&lt;li&gt;The last rule, &lt;code&gt;http_status:404&lt;/code&gt;, is a required catch-all that answers any request that matches no hostname.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 6: Run the tunnel
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloudflared tunnel run my-laptop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; This starts the tunnel. &lt;code&gt;cloudflared&lt;/code&gt; opens an outbound connection to Cloudflare and begins forwarding traffic to your local app.&lt;/p&gt;

&lt;p&gt;Now open &lt;code&gt;https://app.yourdomain.com&lt;/code&gt;. You should see your local app, served over HTTPS automatically. Cloudflare handles the certificate for you.&lt;/p&gt;

&lt;p&gt;If you stop this command (&lt;code&gt;Ctrl+C&lt;/code&gt;), the site goes offline. The next step fixes that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 7: Run it automatically on boot
&lt;/h2&gt;

&lt;p&gt;So you don't have to keep a terminal open, install it as a system service.&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;sudo mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /etc/cloudflared
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Creates the system-wide config folder that the service reads from.&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;sudo cp&lt;/span&gt; ~/.cloudflared/config.yml &lt;span class="se"&gt;\&lt;/span&gt;
  /etc/cloudflared/config.yml

&lt;span class="nb"&gt;sudo cp&lt;/span&gt; ~/.cloudflared/&amp;lt;TUNNEL_ID&amp;gt;.json &lt;span class="se"&gt;\&lt;/span&gt;
  /etc/cloudflared/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; The service runs as root, not as your user, so it can't read files in your home folder. These commands copy the config and credentials to where it can.&lt;/p&gt;

&lt;p&gt;Then edit &lt;code&gt;/etc/cloudflared/config.yml&lt;/code&gt; and change the credentials path to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;credentials-file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/etc/cloudflared/&amp;lt;TUNNEL_ID&amp;gt;.json&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; The file moved, so the path must match its new location.&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;sudo &lt;/span&gt;cloudflared service &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Registers &lt;code&gt;cloudflared&lt;/code&gt; as a systemd service.&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;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; &lt;span class="nt"&gt;--now&lt;/span&gt; cloudflared
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; &lt;code&gt;enable&lt;/code&gt; makes it start at every boot, and &lt;code&gt;--now&lt;/code&gt; starts it immediately.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemctl status cloudflared
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Shows whether the service is running. You want to see &lt;code&gt;active (running)&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optional: expose more than one app
&lt;/h2&gt;

&lt;p&gt;Add more entries under &lt;code&gt;ingress&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;ingress&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;hostname&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;app.yourdomain.com&lt;/span&gt;
    &lt;span class="na"&gt;service&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http://localhost:3000&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;hostname&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;api.yourdomain.com&lt;/span&gt;
    &lt;span class="na"&gt;service&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http://localhost:8000&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;hostname&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ssh.yourdomain.com&lt;/span&gt;
    &lt;span class="na"&gt;service&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ssh://localhost:22&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;service&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http_status:404&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For each new hostname, run the DNS command from Step 4:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloudflared tunnel route dns my-laptop &lt;span class="se"&gt;\&lt;/span&gt;
  api.yourdomain.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Each hostname needs its own DNS record pointing at the tunnel. Restart the service afterwards:&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;sudo &lt;/span&gt;systemctl restart cloudflared
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  SSH through the tunnel
&lt;/h3&gt;

&lt;p&gt;On the machine you're connecting &lt;em&gt;from&lt;/em&gt;, install &lt;code&gt;cloudflared&lt;/code&gt; and add this to &lt;code&gt;~/.ssh/config&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ssh"&gt;&lt;code&gt;&lt;span class="k"&gt;Host&lt;/span&gt; ssh.yourdomain.com
  &lt;span class="k"&gt;ProxyCommand&lt;/span&gt; cloudflared access ssh &lt;span class="err"&gt;\&lt;/span&gt;
    &lt;span class="err"&gt;--&lt;/span&gt;&lt;span class="k"&gt;hostname&lt;/span&gt; %h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; SSH isn't a web protocol, so it needs &lt;code&gt;cloudflared&lt;/code&gt; on the client side to wrap the connection. Then connect normally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh youruser@ssh.yourdomain.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: in &lt;code&gt;~/.ssh/config&lt;/code&gt;, a backslash does not continue a line. If your SSH version rejects the split &lt;code&gt;ProxyCommand&lt;/code&gt; above, put it back on one line: &lt;code&gt;ProxyCommand cloudflared access ssh --hostname %h&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Prefer a UI? Dashboard method
&lt;/h2&gt;

&lt;p&gt;If you don't want to edit YAML:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the Cloudflare &lt;strong&gt;Zero Trust&lt;/strong&gt; dashboard.&lt;/li&gt;
&lt;li&gt;Go to &lt;strong&gt;Networks → Tunnels → Create a tunnel&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Copy the install command it shows and run it on your laptop. This installs the tunnel as a service using a token.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Public Hostname&lt;/strong&gt; tab, add &lt;code&gt;app.yourdomain.com&lt;/code&gt; and set the service to &lt;code&gt;http://localhost:3000&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Menu names change sometimes, but the flow stays the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;Cannot determine default origin certificate path&lt;/code&gt; or &lt;code&gt;Error locating origin cert&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
There's no &lt;code&gt;cert.pem&lt;/code&gt;. The login in Step 2 didn't finish, usually because of &lt;code&gt;Ctrl+C&lt;/code&gt;, or no domain was authorized. Run &lt;code&gt;cloudflared tunnel login&lt;/code&gt; again, select your domain, click &lt;strong&gt;Authorize&lt;/strong&gt;, and wait for the success message.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The authorize page shows no domains&lt;/strong&gt;&lt;br&gt;
Your domain isn't added to Cloudflare yet, it's still &lt;strong&gt;Pending&lt;/strong&gt;, or you're logged into a different Cloudflare account.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;502 Bad Gateway or error 1033&lt;/strong&gt;&lt;br&gt;
Your local app isn't running, the port in &lt;code&gt;service:&lt;/code&gt; is wrong, or the tunnel isn't running. Check &lt;code&gt;systemctl status cloudflared&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The site doesn't load but the tunnel is running&lt;/strong&gt;&lt;br&gt;
Check the YAML indentation, make sure the catch-all rule is last, and make sure the hostname in &lt;code&gt;config.yml&lt;/code&gt; matches the DNS record exactly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Useful commands&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;cloudflared tunnel list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lists all your tunnels.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloudflared tunnel info my-laptop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shows whether the tunnel has active connections.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloudflared tunnel ingress validate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Checks your &lt;code&gt;config.yml&lt;/code&gt; for mistakes.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Streams live logs from the service, which is the best place to see why something fails.&lt;/p&gt;

&lt;h2&gt;
  
  
  Security tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Don't expose SSH or admin panels openly. Put them behind &lt;strong&gt;Cloudflare Access&lt;/strong&gt; so a login is required first.&lt;/li&gt;
&lt;li&gt;Keep &lt;code&gt;cert.pem&lt;/code&gt;, the tunnel credentials JSON and any tokens out of Git and out of screenshots.&lt;/li&gt;
&lt;li&gt;Add authentication to your own API. A public URL means anyone on the internet can reach it.&lt;/li&gt;
&lt;li&gt;Disable sleep on the laptop and run your app as a service so it restarts after a reboot.&lt;/li&gt;
&lt;li&gt;Cloudflare's terms are aimed at web traffic, so avoid pushing large video or file transfers through the tunnel.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;With your own domain, Cloudflare Tunnel gives you a permanent HTTPS URL for a laptop server without opening a single port or needing a public IP. The key ideas are: log in once, create a tunnel, point a hostname at it, describe the routing in &lt;code&gt;config.yml&lt;/code&gt;, and run it as a service.&lt;/p&gt;

&lt;p&gt;What are you hosting from your laptop? Let me know in the comments.&lt;/p&gt;

</description>
      <category>cloudflare</category>
      <category>devops</category>
      <category>networking</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Linux nslookup Command: 5 Examples Every Developer Should Know</title>
      <dc:creator>Safal Bhattarai</dc:creator>
      <pubDate>Mon, 02 Nov 2026 05:02:27 +0000</pubDate>
      <link>https://dev.to/coder-safal/linux-nslookup-command-5-examples-every-developer-should-know-52mc</link>
      <guid>https://dev.to/coder-safal/linux-nslookup-command-5-examples-every-developer-should-know-52mc</guid>
      <description>&lt;p&gt;The &lt;code&gt;nslookup&lt;/code&gt; (Name Server Lookup) command is a simple tool for querying DNS servers on Linux. It is a quick way to check what a domain resolves to, inspect DNS records, and troubleshoot name resolution problems.&lt;/p&gt;

&lt;p&gt;If you read my previous post, &lt;a href="https://dev.to/coder-safal/linux-dig-command-5-examples-every-developer-should-know-3bo9"&gt;Linux dig Command: 5 Examples Every Developer Should Know&lt;/a&gt;, you'll notice &lt;code&gt;nslookup&lt;/code&gt; does similar work with a shorter, friendlier output.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Install nslookup
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;nslookup&lt;/code&gt; ships in the same package as &lt;code&gt;dig&lt;/code&gt;. On Debian/Ubuntu:&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;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;dnsutils
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Find a Domain's IP Address
&lt;/h2&gt;



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

&lt;/div&gt;



&lt;p&gt;The output shows the DNS server that answered your query, followed by the IP addresses for the domain.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If you see &lt;code&gt;Non-authoritative answer&lt;/code&gt;, it means the response came from a cache (such as your ISP's or a public resolver) rather than directly from the domain's own name servers. This is normal.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  3. Check Specific DNS Records
&lt;/h2&gt;

&lt;p&gt;Use the &lt;code&gt;-type&lt;/code&gt; option to choose a record type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nslookup &lt;span class="nt"&gt;-type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;A google.com
nslookup &lt;span class="nt"&gt;-type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;AAAA google.com
nslookup &lt;span class="nt"&gt;-type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;MX google.com
nslookup &lt;span class="nt"&gt;-type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;NS google.com
nslookup &lt;span class="nt"&gt;-type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;TXT google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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;&lt;code&gt;A&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;IPv4 address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;AAAA&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;IPv6 address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;MX&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Mail servers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;NS&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Name servers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;TXT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Text records (SPF, domain verification, etc.)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  4. Query a Specific DNS Server
&lt;/h2&gt;

&lt;p&gt;Add the DNS server address at the end of the command:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This asks Google's public DNS resolver instead of your system default. It's useful for checking whether a problem is caused by your local resolver or by the domain's DNS records.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Reverse DNS Lookup
&lt;/h2&gt;

&lt;p&gt;Give &lt;code&gt;nslookup&lt;/code&gt; an IP address to find the hostname linked to it:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Reverse lookups are handy when checking server logs or confirming that an IP address maps back to the expected hostname.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: Interactive Mode
&lt;/h2&gt;

&lt;p&gt;Run &lt;code&gt;nslookup&lt;/code&gt; with no arguments to enter interactive mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nslookup
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;set type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;MX
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; google.com
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; server 1.1.1.1
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; google.com
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This lets you run several queries in a row and change the record type or DNS server between them.&lt;/p&gt;

&lt;h2&gt;
  
  
  dig vs nslookup
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;code&gt;dig&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;&lt;code&gt;nslookup&lt;/code&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Output&lt;/td&gt;
&lt;td&gt;Detailed, script-friendly&lt;/td&gt;
&lt;td&gt;Short and simple&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Trace resolution&lt;/td&gt;
&lt;td&gt;Yes (&lt;code&gt;+trace&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best for&lt;/td&gt;
&lt;td&gt;In-depth DNS debugging&lt;/td&gt;
&lt;td&gt;Quick lookups&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;The &lt;code&gt;nslookup&lt;/code&gt; command is a fast way to check DNS records and confirm how a domain resolves. Use it for quick checks, and reach for &lt;code&gt;dig&lt;/code&gt; when you need more detail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next:&lt;/strong&gt; Linux &lt;code&gt;ping&lt;/code&gt; Command: Simple Examples.&lt;/p&gt;




&lt;h2&gt;
  
  
  About Me
&lt;/h2&gt;

&lt;p&gt;I'm &lt;strong&gt;Safal Bhattarai&lt;/strong&gt;, a Tech Lead, Full Stack Developer, and DevOps Engineer.&lt;/p&gt;

&lt;p&gt;🌐 &lt;a href="https://safal.me" rel="noopener noreferrer"&gt;Website&lt;/a&gt; · 💻 &lt;a href="https://github.com/" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>dns</category>
      <category>networking</category>
    </item>
    <item>
      <title>Deploy Node.js &amp; Express APIs to Cloudflare Workers: A Practical Command Cheat Sheet</title>
      <dc:creator>Safal Bhattarai</dc:creator>
      <pubDate>Thu, 29 Oct 2026 10:39:31 +0000</pubDate>
      <link>https://dev.to/coder-safal/deploy-nodejs-express-apis-to-cloudflare-workers-a-practical-command-cheat-sheet-1epm</link>
      <guid>https://dev.to/coder-safal/deploy-nodejs-express-apis-to-cloudflare-workers-a-practical-command-cheat-sheet-1epm</guid>
      <description>&lt;p&gt;A quick reference for deploying a Node.js / Express API to Cloudflare Workers. Each section has a short note on what it does, then the commands.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Commands marked &lt;strong&gt;LIVE&lt;/strong&gt; change the real running service. Everything else is safe to run.&lt;/p&gt;

&lt;p&gt;Replace &lt;code&gt;my-worker&lt;/code&gt;, &lt;code&gt;my-account&lt;/code&gt;, and &lt;code&gt;example.com&lt;/code&gt; with your own values.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;Install dependencies and log in to Cloudflare. Login only connects the CLI to your account. It does not deploy anything.&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;span class="nt"&gt;--version&lt;/span&gt;
pnpm &lt;span class="nt"&gt;--version&lt;/span&gt;
pnpm &lt;span class="nb"&gt;install
&lt;/span&gt;pnpm add &lt;span class="nt"&gt;-D&lt;/span&gt; wrangler               &lt;span class="c"&gt;# if the project doesn't have it yet&lt;/span&gt;
pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler login
pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler &lt;span class="nb"&gt;whoami&lt;/span&gt;          &lt;span class="c"&gt;# confirm the right account&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Minimal Express Worker
&lt;/h2&gt;

&lt;p&gt;The smallest working example. &lt;code&gt;wrangler.jsonc&lt;/code&gt; tells Cloudflare where your code is, and &lt;code&gt;src/index.ts&lt;/code&gt; wraps Express so Workers can run it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;wrangler.jsonc&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json-doc"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"my-worker"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"main"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"src/index.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"compatibility_date"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-10-29"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"compatibility_flags"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"nodejs_compat"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;src/index.ts&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;httpServerHandler&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cloudflare:node&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;express&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="na"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1mb&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;

&lt;span class="nx"&gt;app&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/health&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;res&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="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ok&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;httpServerHandler&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The port is only an internal routing detail, not a public port.&lt;/p&gt;

&lt;h2&gt;
  
  
  Local run + check
&lt;/h2&gt;

&lt;p&gt;Run the Worker on your machine and check that it builds. A dry run proves bundling works, but not that login, database or uploads work.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler types
pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler dev
pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;tsc &lt;span class="nt"&gt;--noEmit&lt;/span&gt;
pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler deploy &lt;span class="nt"&gt;--dry-run&lt;/span&gt;   &lt;span class="c"&gt;# bundle check only&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Deploy (LIVE)
&lt;/h2&gt;

&lt;p&gt;Publishes your Worker. Wrangler prints the public URL when it finishes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Secrets (LIVE)
&lt;/h2&gt;

&lt;p&gt;Secrets (database URL, API keys) are stored in Cloudflare, not in your code. Editing a local file does not change the live Worker. Set the secret, then redeploy if needed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler secret put MONGODB_URI
pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler secret list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For local development, put values in &lt;code&gt;.dev.vars&lt;/code&gt; and keep it out of git:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MONGODB_URI=&amp;lt;your-connection-string&amp;gt;
JWT_SECRET=&amp;lt;your-signing-secret&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Never put secrets in &lt;code&gt;NEXT_PUBLIC_*&lt;/code&gt; variables. They are exposed to the browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verify
&lt;/h2&gt;

&lt;p&gt;After deploying, test the live URL. &lt;code&gt;health&lt;/code&gt; means the app is up. A &lt;code&gt;ready&lt;/code&gt; endpoint (if you build one) can also check the database. The CORS test shows whether your frontend origin is allowed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;--fail-with-body&lt;/span&gt; https://my-worker.my-account.workers.dev/health

&lt;span class="c"&gt;# CORS preflight (try an allowed AND a disallowed origin)&lt;/span&gt;
curl &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="nt"&gt;-X&lt;/span&gt; OPTIONS https://my-worker.my-account.workers.dev/api/upload &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s1"&gt;'Origin: http://localhost:3000'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s1"&gt;'Access-Control-Request-Method: POST'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s1"&gt;'Access-Control-Request-Headers: authorization,content-type'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Database note
&lt;/h2&gt;

&lt;p&gt;Workers can't hold a TCP connection across requests like a normal server.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MongoDB: use the native driver or Mongoose 9+, and keep the connection inside a Durable Object.&lt;/li&gt;
&lt;li&gt;SQL: use D1, or Hyperdrive for Postgres/MySQL.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;localhost&lt;/code&gt; in your database URL means Cloudflare's servers, not your laptop. Use a cloud URL.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Logs / history
&lt;/h2&gt;

&lt;p&gt;See live errors and past deployments. Redact tokens and cookies before sharing logs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler &lt;span class="nb"&gt;tail
&lt;/span&gt;pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler deployments list
pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler versions list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Rollback (LIVE)
&lt;/h2&gt;

&lt;p&gt;Goes back to an older Worker version. It does not undo database writes or uploaded files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler rollback VERSION_ID &lt;span class="nt"&gt;--message&lt;/span&gt; &lt;span class="s2"&gt;"Restore known-good version"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Staging (needs &lt;code&gt;env.staging&lt;/code&gt; in wrangler.jsonc first)
&lt;/h2&gt;

&lt;p&gt;A separate Worker for testing. Use separate secrets and a separate database, or staging can write to production data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler dev &lt;span class="nt"&gt;--env&lt;/span&gt; staging
pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler deploy &lt;span class="nt"&gt;--env&lt;/span&gt; staging   &lt;span class="c"&gt;# LIVE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CORS and cookies
&lt;/h2&gt;

&lt;p&gt;CORS decides which browser origins may call your API. Origins include scheme and port, with no path and no trailing slash.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CORS_ORIGIN=http://localhost:3000,https://app.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;With cookies, return the exact origin plus &lt;code&gt;Access-Control-Allow-Credentials: true&lt;/code&gt;. Never use &lt;code&gt;*&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Local frontend calling a &lt;code&gt;workers.dev&lt;/code&gt; API is cross-site, so cookies need &lt;code&gt;Secure&lt;/code&gt; + &lt;code&gt;SameSite=None&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Browsers can still block third-party cookies even when CORS is correct. Check the Network and Application tabs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frontend still calling localhost?
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;NEXT_PUBLIC_*&lt;/code&gt; values are baked into the frontend at build time. Change the file, then restart the dev server (or rebuild for production).&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;# .env.local&lt;/span&gt;
&lt;span class="nv"&gt;NEXT_PUBLIC_API_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://my-worker.my-account.workers.dev

&lt;span class="c"&gt;# then restart&lt;/span&gt;
pnpm dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Domain Name
&lt;/h2&gt;

&lt;p&gt;Your Worker gets a free &lt;code&gt;workers.dev&lt;/code&gt; address automatically. You can also add your own domain, or use both at once.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option 1: workers.dev (no DNS needed)
&lt;/h3&gt;

&lt;p&gt;Works right after deploy. No A record and no DNS change.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://&amp;lt;worker-name&amp;gt;.&amp;lt;account-subdomain&amp;gt;.workers.dev
https://my-worker.my-account.workers.dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Option 2: Custom domain (e.g. api.example.com)
&lt;/h3&gt;

&lt;p&gt;Gives you a professional address with automatic HTTPS. The domain must be managed by Cloudflare DNS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Add the domain to Cloudflare&lt;/strong&gt; (Dashboard &amp;gt; Add a site), then copy the 2 nameservers it gives you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Copy old DNS records first&lt;/strong&gt; (A, AAAA, MX, TXT, CNAME) into Cloudflare so email and website don't break.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Change nameservers at your registrar&lt;/strong&gt; to the ones Cloudflare shows you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Check the zone is active&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;dig NS example.com +short
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5: Attach the hostname to the Worker&lt;/strong&gt; in &lt;code&gt;wrangler.jsonc&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json-doc"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"my-worker"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"main"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"src/index.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"routes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"pattern"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"api.example.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"custom_domain"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&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;pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler deploy      &lt;span class="c"&gt;# LIVE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Or Dashboard &amp;gt; Worker &amp;gt; Settings &amp;gt; Domains &amp;amp; Routes &amp;gt; Add &amp;gt; Custom Domain.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Verify&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;dig api.example.com +short
curl &lt;span class="nt"&gt;-I&lt;/span&gt; https://api.example.com/health
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Option 3: DNS stays at another provider
&lt;/h3&gt;

&lt;p&gt;Custom Domains need the zone on Cloudflare. If DNS stays elsewhere, move the zone or keep using workers.dev.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use BOTH together (workers.dev + custom domain)
&lt;/h3&gt;

&lt;p&gt;Both URLs point to the same Worker at the same time. Good for testing on workers.dev while production uses your domain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json-doc"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"my-worker"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"main"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"src/index.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"workers_dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"routes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"pattern"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"api.example.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"custom_domain"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&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;pnpm &lt;span class="nb"&gt;exec &lt;/span&gt;wrangler deploy      &lt;span class="c"&gt;# LIVE&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;# test both&lt;/span&gt;
curl &lt;span class="nt"&gt;-I&lt;/span&gt; https://my-worker.my-account.workers.dev/health
curl &lt;span class="nt"&gt;-I&lt;/span&gt; https://api.example.com/health
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you use Google login, add BOTH callback URLs in Google Cloud Console:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  https://my-worker.my-account.workers.dev/auth/google/callback
  https://api.example.com/auth/google/callback
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Your app uses one callback URL at a time. Set it to your main one (usually the custom domain).&lt;/li&gt;
&lt;li&gt;Cookies are host-only, so a login on one hostname does not work on the other.&lt;/li&gt;
&lt;li&gt;To turn workers.dev off later: set &lt;code&gt;"workers_dev": false&lt;/code&gt; and deploy.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  After the domain changes, update everything that uses the URL
&lt;/h3&gt;

&lt;p&gt;The domain alone does nothing for your app settings. CORS, cookies, OAuth and frontends all need the new URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BACKEND_URL=https://api.example.com
CORS_ORIGIN=https://example.com,https://admin.example.com
GOOGLE_CALLBACK_URL=https://api.example.com/auth/google/callback
COOKIE_DOMAIN=            # leave empty = host-only cookie
COOKIE_SAME_SITE=lax      # ok when frontend and API share the same site
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# frontend .env.local, then rebuild
NEXT_PUBLIC_API_URL=https://api.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add the new callback URL in Google Cloud Console (OAuth client &amp;gt; Authorized redirect URIs).&lt;/li&gt;
&lt;li&gt;Redeploy: &lt;code&gt;pnpm exec wrangler deploy&lt;/code&gt; (LIVE).&lt;/li&gt;
&lt;li&gt;Rebuild frontends (&lt;code&gt;NEXT_PUBLIC_*&lt;/code&gt; is baked in at build time).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Domain troubleshooting
&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;Check&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;404 on new domain&lt;/td&gt;
&lt;td&gt;Custom domain not attached; check Domains &amp;amp; Routes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSL error right after setup&lt;/td&gt;
&lt;td&gt;Wait a few minutes for the certificate; retry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Site/email broke after nameserver change&lt;/td&gt;
&lt;td&gt;Missing copied DNS records (A, MX, TXT)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;redirect_uri_mismatch&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;New callback not added in Google Console&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CORS error on new domain&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;CORS_ORIGIN&lt;/code&gt; still has old origin; redeploy&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Common errors
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Error&lt;/th&gt;
&lt;th&gt;Likely cause&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare 1101&lt;/td&gt;
&lt;td&gt;Unhandled exception; read &lt;code&gt;wrangler tail&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare 1102&lt;/td&gt;
&lt;td&gt;CPU or memory limit exceeded&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;__dirname is not defined&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Package expects local files; bundle assets or replace it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;[unenv] ... not implemented&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Node API not supported in Workers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ECONNREFUSED 127.0.0.1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A localhost database URL was deployed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Disallowed operation in global scope&lt;/td&gt;
&lt;td&gt;I/O, timers or randomness at import time; move into a request&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Limits to know
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Resource&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;Memory per isolate&lt;/td&gt;
&lt;td&gt;128 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Free plan CPU per request&lt;/td&gt;
&lt;td&gt;10 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Paid plan CPU per request&lt;/td&gt;
&lt;td&gt;30 s default, up to 5 min&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Simultaneous outgoing connections&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Limits change, so check the &lt;a href="https://developers.cloudflare.com/workers/platform/limits/" rel="noopener noreferrer"&gt;current Cloudflare limits&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  CI deploys
&lt;/h2&gt;

&lt;p&gt;For automated deploys (GitHub Actions etc.), use an API token instead of &lt;code&gt;wrangler login&lt;/code&gt;. Store these in your CI's protected secrets, never in git.&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;CLOUDFLARE_API_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&amp;lt;token&amp;gt;
&lt;span class="nv"&gt;CLOUDFLARE_ACCOUNT_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&amp;lt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developers.cloudflare.com/workers/tutorials/deploy-an-express-app/" rel="noopener noreferrer"&gt;Express on Workers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developers.cloudflare.com/workers/runtime-apis/nodejs/" rel="noopener noreferrer"&gt;Node.js compatibility&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developers.cloudflare.com/workers/wrangler/configuration/" rel="noopener noreferrer"&gt;Wrangler configuration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developers.cloudflare.com/workers/configuration/routing/custom-domains/" rel="noopener noreferrer"&gt;Custom domains&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developers.cloudflare.com/workers/versions-and-deployments/rollbacks/" rel="noopener noreferrer"&gt;Rollbacks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cloudflare</category>
      <category>node</category>
      <category>webdev</category>
      <category>devops</category>
    </item>
    <item>
      <title>Linux dig Command: Simple DNS Lookup Examples</title>
      <dc:creator>Safal Bhattarai</dc:creator>
      <pubDate>Tue, 27 Oct 2026 15:44:54 +0000</pubDate>
      <link>https://dev.to/coder-safal/linux-dig-command-5-examples-every-developer-should-know-3bo9</link>
      <guid>https://dev.to/coder-safal/linux-dig-command-5-examples-every-developer-should-know-3bo9</guid>
      <description>&lt;p&gt;The &lt;code&gt;dig&lt;/code&gt; (Domain Information Groper) command helps developers check DNS records and troubleshoot domain resolution on Linux. It is one of the first tools to reach for when a domain isn't behaving the way you expect.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Install dig
&lt;/h2&gt;

&lt;p&gt;On Debian/Ubuntu-based systems, &lt;code&gt;dig&lt;/code&gt; ships in the &lt;code&gt;dnsutils&lt;/code&gt; package:&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;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;dnsutils
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Find a Domain's IP Address
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig safal.me +short
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;+short&lt;/code&gt; flag trims the output down to just the IP addresses found in the DNS response.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Check DNS Records
&lt;/h2&gt;

&lt;p&gt;Pass a record type after the domain name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig safal.me A
dig safal.me AAAA
dig safal.me MX
dig safal.me NS
dig safal.me TXT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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;&lt;code&gt;A&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;IPv4 address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;AAAA&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;IPv6 address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;MX&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Mail servers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;NS&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Name servers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;TXT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Text records (SPF, domain verification, etc.)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  4. Query a Specific DNS Server
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig @8.8.8.8 safal.me
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sends the query to Google's public DNS resolver instead of your system default, which is handy for checking whether a problem is local to your resolver.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Trace DNS Resolution
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig safal.me +trace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This shows the delegation process step by step, from the root servers down to the domain's authoritative name servers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;dig&lt;/code&gt; command is a useful tool for developers and DevOps engineers troubleshooting DNS issues. Once you know these few flags, most DNS debugging becomes quick and predictable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next:&lt;/strong&gt; Linux &lt;code&gt;nslookup&lt;/code&gt; Command: Simple Examples.&lt;/p&gt;




&lt;h2&gt;
  
  
  About Me
&lt;/h2&gt;

&lt;p&gt;I'm &lt;strong&gt;Safal Bhattarai&lt;/strong&gt;, a Tech Lead, Full Stack Developer, and DevOps Engineer.&lt;/p&gt;

&lt;p&gt;🌐 &lt;a href="https://safal.me" rel="noopener noreferrer"&gt;Website&lt;/a&gt; &lt;a href="https://github.com/Coder-safal" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>dns</category>
      <category>networking</category>
    </item>
  </channel>
</rss>
