<?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: Carlos Leonel Ramirez</title>
    <description>The latest articles on DEV Community by Carlos Leonel Ramirez (@carloslramirez).</description>
    <link>https://dev.to/carloslramirez</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1217206%2Fe5eebbca-4ce7-45ec-9e65-8354474b8c67.jpeg</url>
      <title>DEV Community: Carlos Leonel Ramirez</title>
      <link>https://dev.to/carloslramirez</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/carloslramirez"/>
    <language>en</language>
    <item>
      <title>My Linux Upskill Challenge: Day 9</title>
      <dc:creator>Carlos Leonel Ramirez</dc:creator>
      <pubDate>Fri, 06 Jun 2025 18:11:56 +0000</pubDate>
      <link>https://dev.to/carloslramirez/my-linux-upskill-challenge-day-9-3a47</link>
      <guid>https://dev.to/carloslramirez/my-linux-upskill-challenge-day-9-3a47</guid>
      <description>&lt;p&gt;This lesson is about an introduction to networking controls, including securing ports and basic firewall configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checking Open Ports
&lt;/h2&gt;

&lt;p&gt;To check which ports are open on the server, we can use the following tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ss&lt;/code&gt; — stands for &lt;strong&gt;socket status&lt;/strong&gt; , a modern replacement for the old &lt;code&gt;netstat&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;nmap&lt;/code&gt; — a powerful &lt;strong&gt;port scanner&lt;/strong&gt; , not usually installed by default.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To show which ports are open and on which interfaces:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Current output on my Ubuntu server, I only have ports 22(&lt;code&gt;ssh&lt;/code&gt;) and 80 (&lt;code&gt;http&lt;/code&gt;) open.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Another tool that we can use to check open ports is &lt;code&gt;nmap&lt;/code&gt;, this tool is more intended to scan port on a remote machine, but we can use it to scan our own server (&lt;code&gt;localhost&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;nmap&lt;/code&gt; can scan more than 1,000 ports to see if they’re open. But heads up — firewalls might see this as suspicious behavior and block your IP. So use it carefully, especially in your own network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;nmap&lt;/code&gt;was not present by default on my ubuntu machine, so I installed using &lt;code&gt;sudo apt install nmap&lt;/code&gt;, then I run:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The results showed with the &lt;code&gt;localhost&lt;/code&gt; (&lt;code&gt;127.0.0.1&lt;/code&gt;) IP could be incomplete, because this shows you only the service that are bounded to you local interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you want to be sure of what is really exposed, you should use the actual IP interface on the network card and use &lt;code&gt;nmap&lt;/code&gt;with that.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To find you the IP address of your network card use:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;And scan again with your actual IP address, In my case the result turned out to be the same, but on real world scenario could differ&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Linux firewall
&lt;/h2&gt;

&lt;p&gt;Linux has a built-in firewall directly on its kernel called &lt;strong&gt;Netfilter&lt;/strong&gt; , don’t think it as a tool or a command, instead is something included on its core, as a backend system.&lt;/p&gt;

&lt;p&gt;There are different ways to “interact” or configure &lt;strong&gt;Netfilter&lt;/strong&gt; , one of older and most-used is &lt;strong&gt;iptables&lt;/strong&gt; , is still used but now it’s considered legacy.&lt;/p&gt;

&lt;p&gt;A more modern alternative is &lt;strong&gt;nftables&lt;/strong&gt; , that was introduced in Linux 3.13+&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;iptables&lt;/strong&gt; and &lt;strong&gt;nftables&lt;/strong&gt; can’t be used at the same time unless you very sure what you’re doing because they may conflict.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;To view the &lt;strong&gt;iptables&lt;/strong&gt; current rules use this command:&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🔎 iptables output explained
&lt;/h3&gt;

&lt;p&gt;Let’s break this output down. When you run &lt;code&gt;sudo iptables -L&lt;/code&gt;, you’re asking &lt;strong&gt;iptables&lt;/strong&gt; to &lt;strong&gt;list the current rules&lt;/strong&gt; in the &lt;strong&gt;filter table&lt;/strong&gt; , which is the default table used for firewall rules.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Chain INPUT (policy ACCEPT)
target prot opt source destination
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  🔹 Chain: &lt;code&gt;INPUT&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Handles &lt;strong&gt;incoming traffic to your system&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Example: SSH requests, web traffic to a server on port 80/443, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Policy: ACCEPT&lt;/strong&gt; → If no rules match, allow the packet by default.&lt;/li&gt;
&lt;/ul&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Chain FORWARD (policy ACCEPT)
target prot opt source destination
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  🔹 Chain: &lt;code&gt;FORWARD&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Handles &lt;strong&gt;traffic that’s passing through your system&lt;/strong&gt; , not destined for it.&lt;/li&gt;
&lt;li&gt;Example: If your Linux box is acting as a &lt;strong&gt;router&lt;/strong&gt; or &lt;strong&gt;gateway&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Policy: ACCEPT&lt;/strong&gt; → Forward everything by default.&lt;/li&gt;
&lt;/ul&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Chain OUTPUT (policy ACCEPT)
target prot opt source destination
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  🔹 Chain: &lt;code&gt;OUTPUT&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Handles &lt;strong&gt;outgoing traffic&lt;/strong&gt; generated by your system.&lt;/li&gt;
&lt;li&gt;Example: You using &lt;code&gt;curl&lt;/code&gt; or &lt;code&gt;apt&lt;/code&gt; to reach external servers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Policy: ACCEPT&lt;/strong&gt; → Allow all outgoing traffic by default.&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  Output Summary
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Currently I have &lt;strong&gt;no firewall rules&lt;/strong&gt; set in &lt;code&gt;iptables&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;default policy is “ACCEPT”&lt;/strong&gt; , so &lt;strong&gt;everything is allowed&lt;/strong&gt; :

&lt;ul&gt;
&lt;li&gt;Any service can receive inbound traffic (&lt;code&gt;INPUT&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Forwarding traffic is allowed (&lt;code&gt;FORWARD&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Your system can initiate outbound connections (&lt;code&gt;OUTPUT&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;In addition to the default filter table (used for basic firewall rules), &lt;strong&gt;iptables&lt;/strong&gt; supports several other &lt;strong&gt;tables&lt;/strong&gt; — each with a specific purpose, some examples are: &lt;strong&gt;nat&lt;/strong&gt; , &lt;strong&gt;mangle&lt;/strong&gt; , &lt;strong&gt;raw&lt;/strong&gt; , &lt;strong&gt;security&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Uncomplicated Firewall (UFW)
&lt;/h3&gt;

&lt;p&gt;UFW it’s a &lt;strong&gt;frontend&lt;/strong&gt; that helps us to configure the firewall rules on a more easy way, it’s present mostly on Ubuntu/Debian systems.&lt;/p&gt;

&lt;p&gt;Under the hood, it manages the &lt;strong&gt;iptables&lt;/strong&gt; configuration (or &lt;strong&gt;nftables&lt;/strong&gt; in newer systems.)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ufw&lt;/code&gt;is available by default in all Ubuntu installations after 8.04 LST, but if you need to install it, use:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To check the current status of &lt;strong&gt;UFW&lt;/strong&gt; run&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In my case it was disabled by default&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;❯ sudo ufw status verbose
Status: inactive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To allow SSH but deny HTTP we would type&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then enable &lt;strong&gt;UFW&lt;/strong&gt; with this:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;TIP&lt;/p&gt;

&lt;p&gt;Be sure to ALLOW ssh, of you will loose contact with your remote server&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;After enabling UFW, if you run &lt;code&gt;iptables -L&lt;/code&gt; again, you’ll see UFW-created rules like:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Chain ufw-user-input (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
DROP tcp -- anywhere anywhere tcp dpt:http
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To re-allow HTTP traffic:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ufw allow http
sudo ufw enable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Changing default ssh port
&lt;/h2&gt;

&lt;p&gt;ometimes it’s a good idea to change the default SSH port (22) to something else like &lt;code&gt;2222&lt;/code&gt;. This can be done by editing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/etc/ssh/sshd_config

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is called “security through obscurity.” It’s not a strong defense by itself, but can help avoid automated scans.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusions
&lt;/h2&gt;

&lt;p&gt;This lesson covered the basics of checking open ports and using firewalls to secure Linux servers. It focused on practical tools (&lt;code&gt;ss&lt;/code&gt;, &lt;code&gt;nmap&lt;/code&gt;, &lt;code&gt;iptables&lt;/code&gt;, &lt;code&gt;ufw&lt;/code&gt;) and basic firewall configurations.&lt;/p&gt;

&lt;p&gt;This is not an in-depth guide — for more advanced usage, consult the official documentation or community tutorials.&lt;/p&gt;




&lt;p&gt;➡️ &lt;a href="https://dev.to/carloslramirez/my-linux-upskill-challenge-day-8-e3b"&gt;Previos Lesson: Day 8&lt;/a&gt;  &lt;/p&gt;

</description>
      <category>linux</category>
    </item>
    <item>
      <title>My Linux Upskill Challenge: Day 8</title>
      <dc:creator>Carlos Leonel Ramirez</dc:creator>
      <pubDate>Thu, 05 Jun 2025 17:30:36 +0000</pubDate>
      <link>https://dev.to/carloslramirez/my-linux-upskill-challenge-day-8-e3b</link>
      <guid>https://dev.to/carloslramirez/my-linux-upskill-challenge-day-8-e3b</guid>
      <description>&lt;p&gt;&lt;em&gt;Following the &lt;a href="https://linuxupskillchallenge.org/08/" rel="noopener noreferrer"&gt;Linux Upskill Challenge: Day 8&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is my notes for the Day 8 Lesson - Text Analysis Tools&lt;/p&gt;




&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This lesson covers the most important Linux commands for viewing, exploring, and manipulating text files. These small but powerful tools are incredibly useful when you need to explore and analyze large text files created by applications, user logs, and other system files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sample Log File Setup
&lt;/h2&gt;

&lt;p&gt;For this practice session, I asked ChatGPT to generate an Apache access log sample file with different sources and scenarios to test various combinations and common sysadmin use cases. In real-world scenarios, you’d work with actual access log files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;File location:&lt;/strong&gt; &lt;code&gt;/var/log/apache2/sample_access.log&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;192.168.1.10 - - [05/Jun/2025:18:01:01 -0600] "GET / HTTP/1.1" 200 720 "-" "curl/8.4.0"
10.0.0.2 - - [05/Jun/2025:18:01:03 -0600] "GET /index.html HTTP/1.1" 200 1024 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/120.0.0.0"
172.16.5.5 - - [05/Jun/2025:18:01:04 -0600] "POST /login HTTP/1.1" 302 512 "http://myserver.com" "Mozilla/5.0 (Linux; Android 11; SM-G973U) Chrome/122.0.0.0 Mobile"
192.168.1.15 - - [05/Jun/2025:18:01:07 -0600] "GET /api/data HTTP/1.1" 200 2048 "-" "PostmanRuntime/7.30.0"
203.0.113.12 - - [05/Jun/2025:18:01:10 -0600] "GET /docs/index.html HTTP/1.1" 200 1560 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0"
192.168.1.10 - - [05/Jun/2025:18:01:14 -0600] "GET / HTTP/1.1" 200 720 "-" "curl/8.4.0"
192.168.1.15 - - [05/Jun/2025:18:01:16 -0600] "GET /favicon.ico HTTP/1.1" 404 230 "-" "PostmanRuntime/7.30.0"
10.0.0.2 - - [05/Jun/2025:18:01:20 -0600] "GET /dashboard HTTP/1.1" 200 1800 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Edge/115.0.0.0"
198.51.100.99 - - [05/Jun/2025:18:01:25 -0600] "GET /admin HTTP/1.1" 403 890 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_6_1) Safari/537.36"
10.10.10.1 - - [05/Jun/2025:18:01:28 -0600] "POST /upload HTTP/1.1" 500 10240 "-" "curl/8.3.0"
172.16.5.5 - - [05/Jun/2025:18:01:31 -0600] "GET /api/stats HTTP/1.1" 200 4096 "-" "Mozilla/5.0 (Linux; Android 11) Chrome/123.0.0.0 Mobile"
203.0.113.12 - - [05/Jun/2025:18:01:33 -0600] "GET /dashboard HTTP/1.1" 200 1800 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64) Firefox/121.0"
192.168.1.10 - - [05/Jun/2025:18:01:36 -0600] "GET /secret HTTP/1.1" 401 720 "-" "curl/8.4.0"
198.51.100.99 - - [05/Jun/2025:18:01:40 -0600] "GET /admin HTTP/1.1" 403 890 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_6_1) Safari/537.36"
10.10.10.1 - - [05/Jun/2025:18:01:45 -0600] "GET /static/image.png HTTP/1.1" 200 2048 "-" "Wget/1.21"
10.10.10.2 - - [05/Jun/2025:18:01:48 -0600] "GET /static/image.png HTTP/1.1" 200 2048 "-" "Wget/1.21"
192.168.1.15 - - [05/Jun/2025:18:01:50 -0600] "GET /login HTTP/1.1" 200 1024 "-" "Mozilla/5.0 (Windows NT 11.0; Win64; x64) Chrome/130.0.0.0"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Core Text Analysis Tools
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;cat&lt;/code&gt; - Display File Contents
&lt;/h3&gt;

&lt;p&gt;Dumps the complete content of a file to the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat /var/log/apache2/sample_access.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; Small files or when you need to see the entire content at once.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;less&lt;/code&gt; - Interactive File Viewer
&lt;/h3&gt;

&lt;p&gt;Opens a text file for interactive navigation with keyboard controls:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;less /var/log/apache2/sample_access.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Navigation shortcuts:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arrow keys or &lt;code&gt;j&lt;/code&gt;/&lt;code&gt;k&lt;/code&gt;: Move up/down line by line&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gg&lt;/code&gt;: Jump to the beginning of the file&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;G&lt;/code&gt;: Jump to the end of the file&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/pattern&lt;/code&gt;: Search for text patterns&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;n&lt;/code&gt;/&lt;code&gt;N&lt;/code&gt;: Jump to next/previous search result&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;q&lt;/code&gt;: Quit&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; Large files where you need to browse through content interactively.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;tail&lt;/code&gt; - View File Endings
&lt;/h3&gt;

&lt;p&gt;Displays the last part of a file (default: last 10 lines):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Basic usage - last 10 lines
tail /var/log/apache2/sample_access.log

# Specify number of lines
tail -n 5 /var/log/apache2/sample_access.log

# Follow file in real-time (great for monitoring logs)
tail -f /var/log/apache2/sample_access.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; Use &lt;code&gt;Ctrl+C&lt;/code&gt; to exit the &lt;code&gt;-f&lt;/code&gt; (follow) mode.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; Monitoring active log files or checking the most recent entries.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;head&lt;/code&gt; - View File Beginnings
&lt;/h3&gt;

&lt;p&gt;Similar to &lt;code&gt;tail&lt;/code&gt;, but shows the first lines of a file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# First 10 lines (default)
head /var/log/apache2/sample_access.log

# First 5 lines
head -n 5 /var/log/apache2/sample_access.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Pattern Matching and Filtering
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;grep&lt;/code&gt; - Search Text Patterns
&lt;/h3&gt;

&lt;p&gt;Filters lines containing specific text patterns (supports regular expressions):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Basic search
grep "Mozilla" /var/log/apache2/sample_access.log

# Case-insensitive search
grep -i "curl" /var/log/apache2/sample_access.log

# Search for specific requests
grep "favicon.ico" /var/log/apache2/sample_access.log

# Exclude lines matching a pattern
grep -v "Chrome" /var/log/apache2/sample_access.log

# Show line numbers
grep -n "404" /var/log/apache2/sample_access.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  The Power of Pipes (&lt;code&gt;|&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;The pipe symbol &lt;code&gt;|&lt;/code&gt; is fundamental to Unix philosophy - it lets you chain commands by passing the output of one command as input to another.&lt;/p&gt;

&lt;h3&gt;
  
  
  Basic Pipe Examples
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# View IP addresses and scroll through them
cut -d" " -f1 /var/log/apache2/sample_access.log | less

# Filter for Chrome browsers, then show only macOS users
grep "Mozilla" /var/log/apache2/sample_access.log | grep "Macintosh"

# Exclude Chrome traffic from Mozilla browsers
grep "Mozilla" /var/log/apache2/sample_access.log | grep -v "Chrome"

# Find Apache processes (system administration example)
ps aux | grep apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Data Extraction and Manipulation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;cut&lt;/code&gt; - Extract Columns/Fields
&lt;/h3&gt;

&lt;p&gt;Extracts specific sections from delimited text:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Extract first field (space-delimited)
cut -d" " -f1 /var/log/apache2/sample_access.log

# Extract multiple fields
cut -d: -f1,3,5 /etc/passwd

# Extract field ranges
cut -d: -f1-3 /etc/passwd # Fields 1 through 3
cut -d: -f4- /etc/passwd # Field 4 to end

# Extract by character position
cut -c1-10 myfile.txt # First 10 characters
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example with &lt;code&gt;/etc/passwd&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Show usernames only
tail /etc/passwd | cut -d: -f1

# Show username, UID, and home directory
cut -d: -f1,3,6 /etc/passwd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;sort&lt;/code&gt; - Arrange Lines
&lt;/h3&gt;

&lt;p&gt;Orders lines alphabetically or numerically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Basic alphabetical sort
sort names.txt

# Numeric sort in reverse order
sort -nr numbers.txt

# Sort by specific column (space-delimited)
sort -k2 file.txt

# Sort CSV by third column numerically
sort -t ',' -k3 -n data.csv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;uniq&lt;/code&gt; - Remove Duplicates
&lt;/h3&gt;

&lt;p&gt;Removes consecutive duplicate lines (usually used with &lt;code&gt;sort&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Remove duplicates
sort file.txt | uniq

# Count occurrences of each line
sort file.txt | uniq -c

# Show only duplicated lines
sort file.txt | uniq -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Advanced Text Processing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;awk&lt;/code&gt; - Pattern Scanning and Data Extraction
&lt;/h3&gt;

&lt;p&gt;Powerful tool for processing structured text data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Print specific columns (fields)
awk '{print $1}' /var/log/apache2/sample_access.log # IP addresses
awk '{print $4, $5}' /var/log/apache2/sample_access.log # Date and time

# Filter by conditions
awk '$9 == 404' /var/log/apache2/sample_access.log # 404 errors only
awk '$NF &amp;gt; 1000' /var/log/apache2/sample_access.log # Large responses

# Custom formatting
awk '{print "IP: " $1 ", Status: " $9}' /var/log/apache2/sample_access.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;sed&lt;/code&gt; - Stream Editor
&lt;/h3&gt;

&lt;p&gt;Search, replace, and edit text on-the-fly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Replace text (first occurrence per line)
sed 's/curl/CURL/' /var/log/apache2/sample_access.log

# Replace all occurrences
sed 's/curl/CURL/g' /var/log/apache2/sample_access.log

# Delete lines containing specific text
sed '/curl/d' /var/log/apache2/sample_access.log

# Show only matching lines
sed -n '/Mozilla/p' /var/log/apache2/sample_access.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; Use &lt;code&gt;sed -i&lt;/code&gt; (in-place editing) carefully - it modifies the original file!&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Output Redirection
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Save Output to Files (&lt;code&gt;&amp;gt;&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Redirect command output to files instead of the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Create/overwrite file
ls -ltr &amp;gt; listing.txt

# Append to file
echo "New entry" &amp;gt;&amp;gt; listing.txt

# Redirect errors to file
command 2&amp;gt; errors.log

# Redirect both output and errors
command &amp;gt; output.log 2&amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Practical Log Analysis One-Liners
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔍 Top Visitor IPs
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cut -d' ' -f1 /var/log/apache2/sample_access.log | sort | uniq -c | sort -nr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  📂 Request Methods Analysis
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cut -d'"' -f2 /var/log/apache2/sample_access.log | cut -d' ' -f1 | sort | uniq -c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🧑‍💻 User-Agent Analysis
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cut -d'"' -f6 /var/log/apache2/sample_access.log | sort | uniq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  📊 HTTP Status Code Breakdown
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cut -d'"' -f3 /var/log/apache2/sample_access.log | cut -d' ' -f2 | sort | uniq -c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🔐 Find Failed Access Attempts
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grep -E ' (401|403) ' /var/log/apache2/sample_access.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🌐 Filter by Browser Type
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grep -i "chrome" /var/log/apache2/sample_access.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  📄 Most Requested Paths
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cut -d'"' -f2 /var/log/apache2/sample_access.log | cut -d' ' -f2 | sort | uniq -c | sort -nr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🔍 Find 404 Error Paths
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grep ' 404 ' /var/log/apache2/sample_access.log | cut -d'"' -f2 | cut -d' ' -f2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ⏰ Traffic by Hour
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cut -d'[' -f2 /var/log/apache2/sample_access.log | cut -d':' -f2 | sort | uniq -c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Advanced Analysis Examples
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Most Active IPs with Request Count
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cut -d' ' -f1 /var/log/apache2/sample_access.log | sort | uniq -c | sort -nr | head -10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Browsers Causing Most Server Errors
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grep " 5[0-9][0-9] " /var/log/apache2/sample_access.log | cut -d'"' -f6 | sort | uniq -c | sort -nr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Traffic Analysis by Time Period
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cut -d'[' -f2 /var/log/apache2/sample_access.log | cut -d']' -f1 | cut -d':' -f1-2 | sort | uniq -c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Large Response Analysis
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;awk '$NF &amp;gt; 2000 {print $1, $NF, $7}' /var/log/apache2/sample_access.log | sort -k2 -nr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;p&gt;These text processing tools become incredibly powerful when combined. The Unix philosophy of “do one thing well” means you can chain simple commands to perform complex analysis tasks. Practice chaining these commands with pipes to build your own custom analysis workflows.&lt;/p&gt;

&lt;p&gt;Remember: always test your commands on sample data before running them on important production logs!&lt;/p&gt;

&lt;h2&gt;
  
  
  External Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=nLa6jAbULe8&amp;amp;t=97s" rel="noopener noreferrer"&gt;Text processing commands&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.ostechnix.com/the-grep-command-tutorial-with-examples-for-beginners/" rel="noopener noreferrer"&gt;OSTechNix grep tutorial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=NTfOnGZUZDk" rel="noopener noreferrer"&gt;Where GREP came from&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://edoras.sdsu.edu/doc/sed-oneliners.html" rel="noopener noreferrer"&gt;SED onliners&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://regexr.com/" rel="noopener noreferrer"&gt;RegExr - a tool to learn, build and test Regular Expressions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://explainshell.com/" rel="noopener noreferrer"&gt;explainshell.com - write down a command-line to see the help text that matches each argument&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Related Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Previous Lesson: &lt;a href="//../Linux/20250527T0715-my-linux-upskill-challenge-day-7"&gt;My Linux Upskill Challenge: Day 7&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Next Lesson: &lt;a href="//../Linux/20250606T1811-my-linux-upskill-challenge-day-9"&gt;My Linux Upskill Challenge: Day 9&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Nota diaria:&lt;/strong&gt; &lt;a href="//../2025-06-05"&gt;2025-06-05&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linux</category>
    </item>
    <item>
      <title>My Linux Upskill Challenge: Day 7</title>
      <dc:creator>Carlos Leonel Ramirez</dc:creator>
      <pubDate>Tue, 27 May 2025 07:15:30 +0000</pubDate>
      <link>https://dev.to/carloslramirez/my-linux-upskill-challenge-day-7-99i</link>
      <guid>https://dev.to/carloslramirez/my-linux-upskill-challenge-day-7-99i</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This is my journal note following the &lt;a href="https://linuxupskillchallenge.org/07/" rel="noopener noreferrer"&gt;Linux Upskill Challenge: Day 7&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Before we Begin
&lt;/h2&gt;

&lt;p&gt;In this lesson, we explore how &lt;strong&gt;services work in Linux&lt;/strong&gt;, how they're configured, and where to find their logs. The example used is installing and experimenting with the &lt;strong&gt;Apache2 web server&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Apache2 on Ubuntu
&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;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;apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How to verify Apache is running
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Open your browser and go to &lt;code&gt;http://&amp;lt;server-ip&amp;gt;&lt;/code&gt; or use &lt;code&gt;curl&lt;/code&gt; in the server terminal:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;[!Note]&lt;br&gt;
If you'r using an cloud hosted virtual machine, you will probably need to do extra steps in order to allow incoming request to you server on the port 80, perhaps this guides will help you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-security-groups.html" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/answers/questions/1190066/how-can-i-open-a-port-in-azure-so-that-a-constant" rel="noopener noreferrer"&gt;Azure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/firewall/docs/using-firewalls#listing-rules-vm" rel="noopener noreferrer"&gt;GCP&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.oracle.com/en-us/iaas/developer-tutorials/tutorials/apache-on-oracle-linux/01-summary.htm#add-ingress-rules" rel="noopener noreferrer"&gt;Oracle Cloud Infrastructure&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Understanding Services in Linux
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a service in Linux?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A service is a background process (also called a &lt;em&gt;daemon&lt;/em&gt;) that is managed by the system to start, stop, or restart as needed.&lt;/li&gt;
&lt;li&gt;In our case &lt;strong&gt;apache2&lt;/strong&gt; applications is running as a "service" inside Linux.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How are services managed?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;On modern systems like Ubuntu, services are managed using &lt;code&gt;systemd&lt;/code&gt; via the &lt;code&gt;systemctl&lt;/code&gt; command.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Process,  Daemons, Services,  and Units
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Process
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;process&lt;/strong&gt; is a running instance of a program.
&lt;/li&gt;
&lt;li&gt;For example, if you have a Bash script in your &lt;code&gt;home&lt;/code&gt; folder, that's just a file — it does nothing until you execute it.&lt;/li&gt;
&lt;li&gt;When you run the script, a &lt;strong&gt;process is created&lt;/strong&gt; (with a Process ID or &lt;strong&gt;PID&lt;/strong&gt;) and it starts using system resources. So a process is the live, running version of a program.&lt;/li&gt;
&lt;li&gt;You can even run the same program (or script) multiple times — each execution creates a &lt;strong&gt;new, separate process&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Every process has its own Process ID (PID).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Daemon
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;daemon&lt;/strong&gt; is a process that runs in the background and typically does &lt;strong&gt;not&lt;/strong&gt; interact directly with the user.&lt;/li&gt;
&lt;li&gt;Daemons usually &lt;strong&gt;start when the system boots&lt;/strong&gt; and continue running “silently” in the background. They often handle essential tasks like &lt;strong&gt;logging&lt;/strong&gt;, &lt;strong&gt;printing&lt;/strong&gt;, &lt;strong&gt;networking&lt;/strong&gt;, or system services like &lt;strong&gt;SSH&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;There’s a naming convention where many daemons end with the letter &lt;strong&gt;d&lt;/strong&gt;, such as &lt;code&gt;sshd&lt;/code&gt;, &lt;code&gt;systemd&lt;/code&gt;, or &lt;code&gt;httpd&lt;/code&gt;. However, this is &lt;strong&gt;not a strict rule&lt;/strong&gt; — some daemons like &lt;code&gt;cron&lt;/code&gt;, &lt;code&gt;cups&lt;/code&gt;, or &lt;code&gt;rsyslog&lt;/code&gt; don’t follow this pattern.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Service
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;When a daemon is &lt;strong&gt;managed by the system’s init system&lt;/strong&gt; (like &lt;code&gt;systemd&lt;/code&gt;), it’s typically referred to as a &lt;strong&gt;service&lt;/strong&gt;. This means it has an associated &lt;strong&gt;unit file&lt;/strong&gt; that defines how to start, stop, and monitor it.&lt;/li&gt;
&lt;li&gt;Examples of daemons that run as managed services include: &lt;code&gt;httpd&lt;/code&gt; (Apache), &lt;code&gt;nginx&lt;/code&gt; (Nginx), and &lt;code&gt;docker&lt;/code&gt; (Docker).&lt;/li&gt;
&lt;li&gt;To understand the difference, think of it this way: &lt;strong&gt;not every daemon is a service&lt;/strong&gt; — meaning there can be background daemons that are &lt;strong&gt;not managed by the init system&lt;/strong&gt; (like &lt;code&gt;systemd&lt;/code&gt;). These may be started manually or by other programs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Unit
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;systemd&lt;/code&gt; manages &lt;strong&gt;units&lt;/strong&gt; — a unit is a representation of a resource that needs to be controlled.&lt;/li&gt;
&lt;li&gt;Simply put, a unit is something that &lt;code&gt;systemd&lt;/code&gt; organizes and keeps track of.&lt;/li&gt;
&lt;li&gt;There are different types of &lt;strong&gt;units&lt;/strong&gt; depending on the resource they describe or represent.&lt;/li&gt;
&lt;li&gt;One of the most common unit types is the &lt;strong&gt;service unit&lt;/strong&gt; (&lt;code&gt;.service&lt;/code&gt;), which defines how to manage a service or application. It includes instructions on how to start or stop the service, when it should be started automatically, and any dependencies or ordering with other software.&lt;/li&gt;
&lt;li&gt;Other unit types include: &lt;code&gt;.socket&lt;/code&gt;, &lt;code&gt;.mount&lt;/code&gt;, &lt;code&gt;.automount&lt;/code&gt;, &lt;code&gt;.swap&lt;/code&gt;, &lt;code&gt;.target&lt;/code&gt;, &lt;code&gt;.path&lt;/code&gt;, &lt;code&gt;.timer&lt;/code&gt;, &lt;code&gt;.snapshot&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;For example, a &lt;code&gt;.service&lt;/code&gt; unit describes how to manage a system service like &lt;code&gt;apache2&lt;/code&gt;, while a &lt;code&gt;.mount&lt;/code&gt; unit tells &lt;code&gt;systemd&lt;/code&gt; how to handle mounting a filesystem.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Units are defined using configuration files called &lt;strong&gt;unit files&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What is  systemd ?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;systemd&lt;/code&gt; it's the core &lt;strong&gt;init system&lt;/strong&gt; used in most modern Linux distributions (like Ubuntu, Debian, Fedora, RHEL, etc.).&lt;/li&gt;
&lt;li&gt;It's the background process that manages all the services and other processes that are running on your system.&lt;/li&gt;
&lt;li&gt;It's like the 🧠 brain, or🗼 Control Tower of everything that is running on Linux&lt;/li&gt;
&lt;li&gt;It is the &lt;strong&gt;first process (PID 1)&lt;/strong&gt; that runs after the Linux kernel finishes booting.&lt;/li&gt;
&lt;li&gt;Its job is to &lt;strong&gt;initialize the system&lt;/strong&gt;, &lt;strong&gt;start all necessary services&lt;/strong&gt;, and &lt;strong&gt;manage them&lt;/strong&gt; during runtime.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Other Linux distribution (specialy oldest) could have a different &lt;strong&gt;init systems&lt;/strong&gt;, like OpenRC, Upstart, etc..&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The command &lt;code&gt;systemctl&lt;/code&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;systemctl&lt;/code&gt;is the command line tool to interact with &lt;code&gt;systemd&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;You use &lt;code&gt;systemctl&lt;/code&gt;to start/stop/enable/disable services, among other things.&lt;/li&gt;
&lt;li&gt;So &lt;code&gt;systemctl&lt;/code&gt;is the user-facing CLI tool to manage &lt;strong&gt;systemd&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Start and  Stop services
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You can use this commands to start and stop the Apache2 &lt;strong&gt;service&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ul&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 start apache2
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl stop apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Restart and Reload services
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To restart a running service, you can use the &lt;code&gt;restart&lt;/code&gt; command:
&lt;/li&gt;
&lt;/ul&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 apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You can also reload a service with the &lt;code&gt;reload&lt;/code&gt; command, this means that the application will be able to reload its configuration files (without restarting):
&lt;/li&gt;
&lt;/ul&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 reload apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Check status
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In case you want to check the status you should use:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You should observe sometime like this if the service is running OK
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;● apache2.service - The Apache HTTP Server
     Loaded: loaded &lt;span class="o"&gt;(&lt;/span&gt;/usr/lib/systemd/system/apache2.service&lt;span class="p"&gt;;&lt;/span&gt; enabled&lt;span class="p"&gt;;&lt;/span&gt; preset: enabled&lt;span class="o"&gt;)&lt;/span&gt;
     Active: active &lt;span class="o"&gt;(&lt;/span&gt;running&lt;span class="o"&gt;)&lt;/span&gt; since Tue 2025-05-27 21:55:51 CST&lt;span class="p"&gt;;&lt;/span&gt; 12h ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 6291 &lt;span class="nv"&gt;ExecStart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/sbin/apachectl start &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;code&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;exited, &lt;span class="nv"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0/SUCCESS&lt;span class="o"&gt;)&lt;/span&gt;
   Main PID: 6294 &lt;span class="o"&gt;(&lt;/span&gt;apache2&lt;span class="o"&gt;)&lt;/span&gt;
      Tasks: 55 &lt;span class="o"&gt;(&lt;/span&gt;limit: 4549&lt;span class="o"&gt;)&lt;/span&gt;
     Memory: 5.6M &lt;span class="o"&gt;(&lt;/span&gt;peak: 6.3M&lt;span class="o"&gt;)&lt;/span&gt;
        CPU: 2.565s
     CGroup: /system.slice/apache2.service
             ├─6294 /usr/sbin/apache2 &lt;span class="nt"&gt;-k&lt;/span&gt; start
             ├─6296 /usr/sbin/apache2 &lt;span class="nt"&gt;-k&lt;/span&gt; start
             └─6297 /usr/sbin/apache2 &lt;span class="nt"&gt;-k&lt;/span&gt; start

May 27 21:55:51 ubuntu systemd[1]: Starting apache2.service - The Apache HTTP Server...
May 27 21:55:51 ubuntu apachectl[6293]: AH00558: apache2: Could not reliably determine the server&lt;span class="s1"&gt;'s fully qualified domain name, &amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Enabling and Disabling Services
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To enable a service to start automatically on boot, use the &lt;code&gt;enable&lt;/code&gt; command:
&lt;/li&gt;
&lt;/ul&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;apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To disable a service for automatic start, you can use:
&lt;/li&gt;
&lt;/ul&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 disable apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To see a list of all of the active units that &lt;code&gt;systemd&lt;/code&gt; knows about, we can use the &lt;code&gt;list-units&lt;/code&gt; command:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  Service configuration Files
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;As must of the services  in Linux &lt;strong&gt;Apache2&lt;/strong&gt; configurations files are located in the usual place: &lt;code&gt;/etc/&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Specifically, the main configuration file for &lt;strong&gt;Apache&lt;/strong&gt; is here:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/etc/apache2/apache2.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can open it using &lt;code&gt;less&lt;/code&gt;, but you could also use &lt;code&gt;vim&lt;/code&gt; to explore or edit it.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;less /etc/apache2/apache2.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Inside that file, you will found this line:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IncludeOptional conf-enabled/*.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;That tells Apache to also load all &lt;code&gt;.conf&lt;/code&gt; files inside the &lt;code&gt;conf-enabled/&lt;/code&gt; folder when it starts.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;So it’s like &lt;strong&gt;modular&lt;/strong&gt; config — instead of editing a single big file, you can drop in specific &lt;code&gt;.conf&lt;/code&gt; files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This pattern (many small config files + include directives) seems pretty common in Linux tools.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Another important configuration files in Apache2 includes&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/etc/apache2/sites-available/
/etc/apache2/sites-enabled/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/etc/apache2/sites-available/&lt;/code&gt;: this directory contains configuration files for &lt;strong&gt;all available virtual hosts&lt;/strong&gt;, that are available but not enables&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/etc/apache2/sites-enabled/&lt;/code&gt;: - This contains &lt;strong&gt;symbolic links&lt;/strong&gt; (symlinks) to the &lt;code&gt;.conf&lt;/code&gt; files in &lt;code&gt;sites-available/&lt;/code&gt;. If a site is linked here, &lt;strong&gt;it is active.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;This lesson isn’t about setting up Apache2 web server or deploying a web page, so I didn’t dive into the details, only a very basic guide  here&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Service logs
&lt;/h2&gt;

&lt;p&gt;Services saves their logs in &lt;code&gt;var/logs&lt;/code&gt;, as expected, &lt;strong&gt;Apache&lt;/strong&gt; keeps its logs under &lt;code&gt;/var/log/apache2/&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /var/log/apache2
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;I checked the &lt;code&gt;access.log&lt;/code&gt; file — I could actually see the request I made when I visited the test page in the browser.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;less access.log
&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;192.168.64.1 - - &lt;span class="o"&gt;[&lt;/span&gt;27/May/2025:21:55:55 &lt;span class="nt"&gt;-0600&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="s2"&gt;"GET / HTTP/1.1"&lt;/span&gt; 200 3459 &lt;span class="s2"&gt;"-"&lt;/span&gt; &lt;span class="s2"&gt;"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36"&lt;/span&gt;
192.168.64.1 - - &lt;span class="o"&gt;[&lt;/span&gt;27/May/2025:22:17:44 &lt;span class="nt"&gt;-0600&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="s2"&gt;"GET /sample HTTP/1.1"&lt;/span&gt; 404 491 &lt;span class="s2"&gt;"-"&lt;/span&gt; &lt;span class="s2"&gt;"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36"&lt;/span&gt;
192.168.64.1 - - &lt;span class="o"&gt;[&lt;/span&gt;28/May/2025:08:27:29 &lt;span class="nt"&gt;-0600&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="s2"&gt;"GET / HTTP/1.1"&lt;/span&gt; 200 689 &lt;span class="s2"&gt;"-"&lt;/span&gt; &lt;span class="s2"&gt;"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36"&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;I also looked at &lt;code&gt;error.log&lt;/code&gt; — luckily, it was empty (which is a good sign 😅).
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Appendix: Apache2 very basic setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In Apache2, the default webpage files are located in &lt;code&gt;/var/www/html&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;This is defined in the configuration file &lt;code&gt;/etc/apache2/sites-enabled/000-default.conf&lt;/code&gt;, specifically in the parameter &lt;code&gt;_DocumentRoot_&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;To modify the default web page to custom simple page, you need to edit the &lt;code&gt;var/www/html/index.html&lt;/code&gt;, using &lt;code&gt;vim&lt;/code&gt;of course!&lt;/li&gt;
&lt;li&gt;Delete everything on the current file and subtitute with this:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Welcome to My Apache Server&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Arial&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#f3f3f3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;padding-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#2c3e50&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#555&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;🚀 It works!&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is the new default page served by Apache.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;You can edit this page at &lt;span class="nt"&gt;&amp;lt;code&amp;gt;&lt;/span&gt;/var/www/html/index.html&lt;span class="nt"&gt;&amp;lt;/code&amp;gt;&lt;/span&gt;.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You will see this simple web page on your browser in &lt;code&gt;http://&amp;lt;server-ip&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpxqz65mh79d6y1tp64ke.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpxqz65mh79d6y1tp64ke.png" width="769" height="419"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;systemd&lt;/code&gt; is the program responsible for &lt;strong&gt;managing and coordinating&lt;/strong&gt; other programs that run in the background on a Linux system — known as &lt;strong&gt;services&lt;/strong&gt; or &lt;strong&gt;daemons&lt;/strong&gt;. But it goes beyond just services: it also manages &lt;strong&gt;devices&lt;/strong&gt;, &lt;strong&gt;mount points&lt;/strong&gt;, &lt;strong&gt;sockets&lt;/strong&gt;, &lt;strong&gt;timers&lt;/strong&gt;, and other essential components. &lt;/li&gt;
&lt;li&gt;Think of it as the &lt;strong&gt;modern orchestrator&lt;/strong&gt; of the system’s startup process and overall state.&lt;/li&gt;
&lt;li&gt;Every sevice has their own configuration files and service logs that are stores in &lt;code&gt;/etc&lt;/code&gt; and &lt;code&gt;/var/logs&lt;/code&gt; respectively&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Additional Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units" rel="noopener noreferrer"&gt;Using &lt;em&gt;systemctl&lt;/em&gt; to manage services&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ubuntu.com/server/docs/how-to-install-apache2" rel="noopener noreferrer"&gt;HTTPD - Apache2 Web Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/deploying_web_servers_and_reverse_proxies/setting-apache-http-server_deploying-web-servers-and-reverse-proxies#doc-wrapper" rel="noopener noreferrer"&gt;The Apache HTTP Server&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>linux</category>
    </item>
    <item>
      <title>My Linux Upskill Challenge: Day 6</title>
      <dc:creator>Carlos Leonel Ramirez</dc:creator>
      <pubDate>Mon, 26 May 2025 12:14:57 +0000</pubDate>
      <link>https://dev.to/carloslramirez/my-linux-upskill-challenge-day-6-1803</link>
      <guid>https://dev.to/carloslramirez/my-linux-upskill-challenge-day-6-1803</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This is my journal note following the &lt;a href="https://linuxupskillchallenge.org/06/" rel="noopener noreferrer"&gt;Linux Upskill Challenge: Day 6&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Editing Text Files with &lt;code&gt;Vi&lt;/code&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Part of being a Linux system administrator is being &lt;strong&gt;skilled at editing text files&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;nano&lt;/code&gt; and &lt;code&gt;pico&lt;/code&gt; are for beginners! (noobs 🙂)…&lt;/li&gt;
&lt;li&gt;Grown-ups usually use &lt;code&gt;vi&lt;/code&gt;❗ — a text editor developed in the 70s by Bill Joy.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Vim&lt;/code&gt; is the modern version (it’s been around for 20+ years), and it’s the &lt;strong&gt;de facto&lt;/strong&gt; text editor on servers. Knowing how to use it — or at least how to exit it — is a must for any sysadmin.&lt;/li&gt;
&lt;li&gt;Vim stands for &lt;a href="https://vimhelp.org/intro.txt.html#Vi" rel="noopener noreferrer"&gt;Vi&lt;/a&gt; IMproved.&lt;/li&gt;
&lt;li&gt;In 2014, &lt;strong&gt;NeoVim&lt;/strong&gt; appeared — a fork of Vim that is more customizable and backed by a large community of users (also, kind of a hype!).&lt;/li&gt;
&lt;li&gt;Having said that, the words &lt;code&gt;Vi&lt;/code&gt; and &lt;code&gt;Vim&lt;/code&gt; are used interchangeably in this document, but the difference between each has already been clarified.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Vim 101
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Check the version of &lt;code&gt;vi&lt;/code&gt;installed
&lt;/h3&gt;

&lt;p&gt;You normally run &lt;code&gt;vi&lt;/code&gt;command, however probably what you have installed is &lt;code&gt;vim&lt;/code&gt;, to check the version run:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;You should obtain something 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;carlos@ubuntu:~$ vi --version
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Apr 01 2025 20:12:31)
Included patches: 1-16, 647, 678, 697
Modified by team+vim@tracker.debian.org
Compiled by team+vim@tracker.debian.org
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Normally &lt;code&gt;vim&lt;/code&gt;is installed by default on every modern Linux distribution, in case you need to installed it you can use in Ubuntu using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install vim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For non-Debian based Linux distribution you will need to use another packet manager.&lt;/p&gt;




&lt;h3&gt;
  
  
  Vi modes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;There are two “modes” when working with Vim:

&lt;ul&gt;
&lt;li&gt;“normal mode”&lt;/li&gt;
&lt;li&gt;“insert mode”&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Sometimes, it’s very hard to know which mode you’re currently in, because there’s very little — or no — information on screen that could give you a clue.&lt;/li&gt;

&lt;li&gt;When in doubt, just remember this:&lt;/li&gt;

&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;TIP&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“Press ESC twice or more to return to normal mode”&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;The “normal mode”, also called “command mode”, is used to enter commands.&lt;/li&gt;
&lt;li&gt;The “insert mode” is used for writing text.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Open and exit without saving
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Make a copy of an existing text file to your &lt;code&gt;home&lt;/code&gt;, so you can edit it. Open it with Vim:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd
pwd
cp -v /etc/services testfile
vim testfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You will see the content of the file open in the editor. However, there is no “on-screen menu” like what you’re used to with &lt;code&gt;nano&lt;/code&gt;. &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyeucui143psdoomu7izd.png" width="800" height="653"&gt;
&lt;/li&gt;
&lt;li&gt;By default, Vim opens the file in “normal mode”, so if you enter a key, it will be interpreted as a &lt;strong&gt;command&lt;/strong&gt; , not as a character you want to insert.&lt;/li&gt;
&lt;li&gt;The next key you press in “normal mode” will determine the behavior of Vim.&lt;/li&gt;
&lt;li&gt;To be 100% sure you’re in normal mode, press &lt;code&gt;ESC&lt;/code&gt; twice.&lt;/li&gt;
&lt;li&gt;To exit the file without saving any changes, while in “normal mode”, type &lt;code&gt;:q!&lt;/code&gt; and press Enter.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flfj7o663rh7q44fk2oua.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flfj7o663rh7q44fk2oua.png" width="733" height="105"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Believe me! This will be a vital skill when you’re taking your first steps.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faj1pwge4ki4pzt3nikgt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faj1pwge4ki4pzt3nikgt.jpg" alt="Vim Joke|450" width="800" height="540"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Navigating in the file
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You can navigate in the file using the keys: &lt;code&gt;h&lt;/code&gt;, &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;, and &lt;code&gt;l&lt;/code&gt;. This is the traditional method since &lt;code&gt;vi&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The arrow keys may work as well; however, it’s important to get familiar with the traditional keys, because you may encounter systems where the arrow keys don’t work.

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;h&lt;/code&gt; → moves cursor &lt;strong&gt;left&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;j&lt;/code&gt; → moves cursor &lt;strong&gt;down&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;k&lt;/code&gt; → moves cursor &lt;strong&gt;up&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;l&lt;/code&gt; → moves cursor &lt;strong&gt;right&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Other useful commands in “normal mode” to navigate through the file:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;G&lt;/code&gt; — moves to the bottom of the file&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gg&lt;/code&gt; — moves to the top of the file&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h3&gt;
  
  
  Delete a single character or word
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Navigate througt the file and press &lt;code&gt;x&lt;/code&gt; to delete the character under the cursos.&lt;/li&gt;
&lt;li&gt;Press &lt;code&gt;X&lt;/code&gt; to delete the character before cursor&lt;/li&gt;
&lt;li&gt;To delete the whole word use &lt;code&gt;dw&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Delete a line
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To delete a single line, put the cursor in the line you want to delete an press &lt;code&gt;dd&lt;/code&gt; in normal mode.
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;






&lt;h3&gt;
  
  
  Delete multiple lines in one stroke
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;I moved down a few lines in the file and pressed &lt;code&gt;3&lt;/code&gt;, then &lt;code&gt;3&lt;/code&gt; again, then &lt;code&gt;d&lt;/code&gt;, and &lt;code&gt;d&lt;/code&gt; again — and 33 lines were deleted all at once 🙀&lt;/li&gt;
&lt;li&gt;To delete multiple lines at once in “normal mode”, use:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;num-of-lines&amp;gt;dd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Where &lt;code&gt;&amp;lt;num-of-lines&amp;gt;&lt;/code&gt; is the number of lines you want to delete.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Undo the last change (undo)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Fortunately, I was able to undo the deletion by entering the following command in “normal mode”. This command will undo the last change:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;






&lt;h3&gt;
  
  
  Finding things
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To search for the word “sun”, type &lt;code&gt;/sun&lt;/code&gt; in “normal mode” and Vim will find the first instance in the file.&lt;/li&gt;
&lt;li&gt;Hit &lt;code&gt;Enter&lt;/code&gt;, then press &lt;code&gt;n&lt;/code&gt; repeatedly to go through all the occurrences.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Cut and Paste
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To &lt;strong&gt;cut&lt;/strong&gt; a line, place the cursor anywhere on the line and press &lt;code&gt;dd&lt;/code&gt; (in &lt;em&gt;normal mode&lt;/em&gt;). This deletes the entire line and stores it in Vim’s clipboard (called the “&lt;em&gt;unnamed register&lt;/em&gt;”).&lt;/li&gt;
&lt;li&gt;To &lt;strong&gt;paste&lt;/strong&gt; , press &lt;code&gt;P&lt;/code&gt; (uppercase). The cut line will be inserted &lt;strong&gt;above&lt;/strong&gt; the current line — everything below will move down.&lt;/li&gt;
&lt;li&gt;To cut multiple lines at once, enter &lt;code&gt;&amp;lt;number-of-lines&amp;gt;dd&lt;/code&gt; in &lt;em&gt;normal mode&lt;/em&gt;. For example, &lt;code&gt;5dd&lt;/code&gt; will delete 5 lines starting from the current one, and store them in Vim’s clipboard.&lt;/li&gt;
&lt;li&gt;To &lt;strong&gt;paste&lt;/strong&gt; all those lines, do the same as before: press &lt;code&gt;P&lt;/code&gt; (uppercase), and all the lines will be inserted &lt;strong&gt;above&lt;/strong&gt; the current line — everything else will shift downward.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pasting&lt;/strong&gt; with &lt;code&gt;p&lt;/code&gt; (undercasse) also works, the difference is the text will be pasted &lt;strong&gt;below&lt;/strong&gt; the current line, meaning that everything else will shift upwards.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Inserting Text
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You can place the cursor anywhere in the file and press &lt;code&gt;i&lt;/code&gt; in Normal mode. This will allow you to insert any text you want.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Finally, it’s behaving like a normal text editor!!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;This puts you in “Insert Mode”, and you’ll notice an &lt;code&gt;-- INSERT --&lt;/code&gt; message in the status bar of &lt;code&gt;Vim&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqbfsfn7enriwauvdkpao.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqbfsfn7enriwauvdkpao.png" width="800" height="83"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To return to Normal mode, just press &lt;code&gt;ESC&lt;/code&gt; twice.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Copy (Yank) and Paste
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;There is a third mode in Vim, called “Visual Mode”, which lets you move the cursor while selecting text.&lt;/li&gt;
&lt;li&gt;To enter Visual Mode, press &lt;code&gt;v&lt;/code&gt;, then move the cursor to select the desired text. Press &lt;code&gt;y&lt;/code&gt; to copy the selection to the clipboard.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;P&lt;/code&gt; to paste &lt;strong&gt;before&lt;/strong&gt; the cursor or &lt;code&gt;p&lt;/code&gt; to paste &lt;strong&gt;after&lt;/strong&gt; the cursor.&lt;/li&gt;
&lt;li&gt;To yank (copy) the current line, use &lt;code&gt;yy&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;To yank 3 lines, use &lt;code&gt;3yy&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;To yank the word under the cursor, use &lt;code&gt;yaw&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;“Yank” is the term in Vim for “Copy”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Saving Changes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Once you’re done and want to save your changes without exiting, you “write” the file using this command in Normal mode:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you want to save &lt;strong&gt;and&lt;/strong&gt; exit Vim:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Next Steps
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;There’s a built-in interactive tutorial to help you learn Vim basics, called &lt;code&gt;vimtutor&lt;/code&gt;. To try it, just run:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It typically takes about 30 minutes to complete.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It’s recommended to do it regularly over a couple of weeks to build solid Vim skills.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Also, it’s a good idea to start using &lt;code&gt;vim&lt;/code&gt; (or &lt;code&gt;vi&lt;/code&gt;) every time you need to edit a file from now on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Everything described here also works with NeoVim, so I’ll start using it and exploring it. There’s also a built-in tutorial in NeoVim called &lt;code&gt;:Tutor&lt;/code&gt; — I’ll try it when I get the chance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I currently use Obsidian to edit my notes, but I might explore NeoVim as an alternative note editor. Although… I’ve seen that many who go down that path never come back the same. Hopefully, I won’t regret it 🙂&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Related Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Previous Lesson: &lt;a href="//../Linux/20250521T1822-linux-upskill-day-5"&gt;Linux Upskill Challenge: Day 5&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Next Lesson: &lt;a href="//../Linux/20250527T0715-my-linux-upskill-challenge-day-7"&gt;My Linux Upskill Challenge: Day 7&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  External Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.linux.com/news/sysadmin-sysadmin-getting-more-out-vim" rel="noopener noreferrer"&gt;Getting more out of Vim&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys/" rel="noopener noreferrer"&gt;Here is why &lt;code&gt;vim&lt;/code&gt; uses the &lt;em&gt;hjkl&lt;/em&gt; keys as arrow keys&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html" rel="noopener noreferrer"&gt;Graphical vi-vim Cheat Sheet and Tutorial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.youtube.com/watch?v=71YTkxUNwmg" rel="noopener noreferrer"&gt;Vi - Vim Tutorial&lt;/a&gt; (video)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://linuxize.com/post/how-to-copy-cut-paste-in-vim/" rel="noopener noreferrer"&gt;How to Copy, Cut and Paste in Vim / Vi&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>linux</category>
      <category>learninpublic</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>My Linux Upskill Challenge Journey: Day 1</title>
      <dc:creator>Carlos Leonel Ramirez</dc:creator>
      <pubDate>Thu, 22 May 2025 19:10:33 +0000</pubDate>
      <link>https://dev.to/carloslramirez/my-linux-upskill-challenge-day-1-36no</link>
      <guid>https://dev.to/carloslramirez/my-linux-upskill-challenge-day-1-36no</guid>
      <description>&lt;p&gt;Originally published on my Digital Garden &lt;a href="https://carloslramirez.com/notes/Linux/20250429T1854-linux-upskill-day-1" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I’ve started following the &lt;a href="https://linuxupskillchallenge.org/" rel="noopener noreferrer"&gt;Linux Upskill Challenge&lt;/a&gt; to sharpen my Linux knowledge and hands-on skills. It’s a series of 21 lessons designed to be completed daily, but I’ll be going through them at my own pace. I’ll share my journey and notes here as I move forward.&lt;/p&gt;




&lt;h2&gt;
  
  
  Day 1 - Get to know your server
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;URL&lt;/strong&gt;: &lt;a href="https://linuxupskillchallenge.org/01/" rel="noopener noreferrer"&gt;https://linuxupskillchallenge.org/01/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Previous Lesson:&lt;/strong&gt; [[20250429T1854-linux-upskill-day-0|My Linux Upskill Challenge: Day 0]]&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  General Information
&lt;/h3&gt;

&lt;p&gt;I connected to my Linux server in the cloud and ran the following commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;lsb_release -a&lt;/code&gt;: Shows which Linux distribution and version is installed.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cat /etc/os-release&lt;/code&gt;: Another way to check the distro—just look at the contents of this file.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;uname -a&lt;/code&gt;: Prints system information like kernel version and hardware platform.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;uptime&lt;/code&gt;: Displays how long the server has been running since the last restart or shutdown.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cat /proc/uptime&lt;/code&gt;: Another way to check system uptime.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;whoami&lt;/code&gt;: Shows the current user.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;who&lt;/code&gt;: Lists all logged-in users.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;w&lt;/code&gt;: Shows what logged-in users are doing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Hardware Information
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;lshw&lt;/code&gt;: Displays detailed hardware info.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lscpu&lt;/code&gt;: Shows CPU information.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lscpu | grep Hypervisor&lt;/code&gt;: Shows which hypervisor your VM is using—my EC2 instance uses Xen.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lsblk&lt;/code&gt;: Lists storage devices and their partitions. This command led me to start reading about the [[20250429T1748 snap package manager]].
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lspci&lt;/code&gt;: Lists all PCI devices. These are emulated by the Xen hypervisor, and some are quite outdated.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lsusb&lt;/code&gt;: Lists USB devices—my EC2 instance shows none, as expected.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Measuring Memory and CPU Usage
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;free -h&lt;/code&gt;: Displays memory usage in a human-readable format.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;vmstat&lt;/code&gt;: Gives a snapshot of system performance (CPU, memory, I/O, etc.). Use &lt;code&gt;vmstat 1&lt;/code&gt; for continuous output.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;top&lt;/code&gt;: Real-time summary of system resource usage.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;htop&lt;/code&gt;: A more interactive, colorful version of &lt;code&gt;top&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Measuring Disk Usage
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;df -h&lt;/code&gt;: Shows disk space usage in human-readable format.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;du -h&lt;/code&gt;: Shows the size of directories and subdirectories (including hidden ones).
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sudo du -h --max-depth=1 /&lt;/code&gt;: Useful for checking the largest folders under &lt;code&gt;/&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Measuring Network Usage
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ifconfig&lt;/code&gt;: Lists network interfaces and IPs (deprecated, but pre-installed). My EC2 instance shows two: &lt;code&gt;enX0&lt;/code&gt; and &lt;code&gt;lo&lt;/code&gt; (loopback).
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ip address&lt;/code&gt;: The modern replacement for &lt;code&gt;ifconfig&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;netstat -i&lt;/code&gt;: Displays interface statistics. It’s deprecated in Ubuntu 24.04.2 LTS and not available by default. I installed it using:
&lt;/li&gt;
&lt;/ul&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 &lt;span class="nb"&gt;install &lt;/span&gt;net-tools &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ifstat&lt;/code&gt;: Live bandwidth usage per interface. Not installed by default—installed with:
&lt;/li&gt;
&lt;/ul&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 &lt;span class="nb"&gt;install &lt;/span&gt;ifstat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;nload&lt;/code&gt;: A real-time visual network monitor.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sudo iftop -i enX0&lt;/code&gt;: Shows live connections, traffic direction, and throughput (like &lt;code&gt;top&lt;/code&gt;, but for the network).&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Extra: Modern Replacements for &lt;code&gt;netstat&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;&lt;strong&gt;Old &lt;code&gt;netstat&lt;/code&gt; Command&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Modern Alternative&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Purpose&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;netstat -i&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ip -s link&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Interface stats&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;netstat -tuln&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ss -tuln&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Listening ports (TCP/UDP)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;netstat -rn&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ip route show&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Routing table&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;netstat -a&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ss -a&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;All sockets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;netstat -plnt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ss -plnt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Listening TCP ports + PID&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>linux</category>
      <category>beginners</category>
      <category>devops</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>My Linux Upskill Challenge Journey: Day 0</title>
      <dc:creator>Carlos Leonel Ramirez</dc:creator>
      <pubDate>Thu, 22 May 2025 18:52:14 +0000</pubDate>
      <link>https://dev.to/carloslramirez/my-linux-upskill-challenge-journey-day-0-m26</link>
      <guid>https://dev.to/carloslramirez/my-linux-upskill-challenge-journey-day-0-m26</guid>
      <description>&lt;p&gt;This content was originally published as part of my Digital Garden that you can find &lt;a href="https://carloslramirez.com/notes/Linux/20250429T1854-linux-upskill-day-0" rel="noopener noreferrer"&gt;here&lt;/a&gt;: &lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I’ve started following the &lt;a href="https://linuxupskillchallenge.org/" rel="noopener noreferrer"&gt;Linux Upskill Challenge&lt;/a&gt; to sharpen my Linux knowledge and hands-on skills. It’s a series of 21 lessons designed to be completed daily, but I’ll be going through them at my own pace. I’ll share my journey and notes here as I move forward.&lt;/p&gt;




&lt;h2&gt;
  
  
  Day 0 - Get Your Own Server
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;URL:&lt;/strong&gt; &lt;a href="https://linuxupskillchallenge.org/00/" rel="noopener noreferrer"&gt;https://linuxupskillchallenge.org/00/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I created an EC2 instance in an AWS account] I already had with this specs:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Instance type: t2.micro  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;ul&gt;
&lt;li&gt;OS: Ubuntu 24.04.2 LTS
&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;ul&gt;
&lt;li&gt;Region: us-east-1
&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;ul&gt;
&lt;li&gt;SSH key: &lt;code&gt;linux.pem&lt;/code&gt; (AWS instances don’t use passwords for authentication)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Issue:&lt;/strong&gt; When I created the key pair, I named it &lt;code&gt;linux&lt;/code&gt;, but when it was downloaded to my computer, the file was called &lt;code&gt;"EC2 Instance Key.pem"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; I had to rename the key file from &lt;code&gt;"EC2 Instance Key.pem"&lt;/code&gt; to &lt;code&gt;linux.pem&lt;/code&gt; using:&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;mv&lt;/span&gt; &lt;span class="s2"&gt;"EC2 Instance Key.pem"&lt;/span&gt; linux.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything worked fine. Actually, the server doesn’t care about the file name—it only cares about the contents.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I connected to the EC2 instance using the &lt;code&gt;ubuntu&lt;/code&gt; user and the public DNS. But first, I had to set the correct permissions on the key file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;400 linux.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Then I used the following command to connect via SSH:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -i linux.pem ubuntu@&amp;lt;PUBLIC DNS&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;After logging in, I ran both &lt;code&gt;sudo apt update&lt;/code&gt; and &lt;code&gt;sudo apt upgrade&lt;/code&gt; to upgrade all pre-installed packages.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;[!NOTE]&lt;br&gt;&lt;br&gt;
The public IP and DNS of the server change every time you stop and restart the instance.&lt;/p&gt;

&lt;p&gt;[!NOTE]&lt;br&gt;&lt;br&gt;
I need to remember to turn off the server when I’m not using it to avoid being charged!&lt;br&gt;&lt;br&gt;
I used &lt;code&gt;sudo shutdown now&lt;/code&gt;. This stops AWS from charging me for compute time, but storage (EBS volume) and the public IP (if static) may still incur charges.&lt;/p&gt;
&lt;/blockquote&gt;




</description>
      <category>linux</category>
      <category>beginners</category>
      <category>devjournal</category>
      <category>devops</category>
    </item>
    <item>
      <title>Linux Upskill Challenge: Day 5 - More or less…</title>
      <dc:creator>Carlos Leonel Ramirez</dc:creator>
      <pubDate>Thu, 22 May 2025 00:22:52 +0000</pubDate>
      <link>https://dev.to/carloslramirez/linux-upskill-challenge-day-5-more-or-less-281l</link>
      <guid>https://dev.to/carloslramirez/linux-upskill-challenge-day-5-more-or-less-281l</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This is my journal note following the &lt;a href="https://linuxupskillchallenge.org/05/" rel="noopener noreferrer"&gt;Linux Upskill Challenge: Day 5&lt;/a&gt;.&lt;/p&gt;




&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;more&lt;/code&gt; and &lt;code&gt;less&lt;/code&gt; command&lt;/li&gt;
&lt;li&gt;How Tabs completion works in Linux, what happe when there is ambiguity?&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;history&lt;/code&gt; command&lt;/li&gt;
&lt;li&gt;repeat a command with &lt;code&gt;!&amp;lt;line number&amp;gt;&lt;/code&gt; and how the command get at the begining of the queue, but the previous number get lost.&lt;/li&gt;
&lt;li&gt;repeat a command - use of &lt;code&gt;ctrl+r&lt;/code&gt; to search for any part of a previous command&lt;/li&gt;
&lt;li&gt;hidde files are also called dot files because they start with a dot(.), you list them with &lt;code&gt;ls -la&lt;/code&gt; or &lt;code&gt;ls -ltra&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The most common use of a “dot file” is to keep personal settings in the home directory&lt;/li&gt;
&lt;li&gt;the use of &lt;code&gt;less&lt;/code&gt; to look the contents of &lt;code&gt;.bashrc&lt;/code&gt;, &lt;code&gt;.bash_history&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;the use of &lt;code&gt;nano&lt;/code&gt; to create a file with the summary of the last 4 lessons&lt;/li&gt;
&lt;li&gt;Changing the &lt;code&gt;bash&lt;/code&gt; terminal to &lt;code&gt;zsh&lt;/code&gt;, &lt;code&gt;fish&lt;/code&gt; and &lt;code&gt;oh-my-zsh&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Terminal multiplexers: &lt;strong&gt;screen&lt;/strong&gt; and &lt;strong&gt;tmux&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;some simple examples of how to customize your tmux&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📄 &lt;code&gt;more&lt;/code&gt; and &lt;code&gt;less&lt;/code&gt; commands
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;more&lt;/code&gt; is a command that lets you view text files &lt;strong&gt;one page at a time&lt;/strong&gt;. You press space to go to the next page. When you get to the end of the file, you cannot go back.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;less&lt;/code&gt; is similar but &lt;strong&gt;more powerful&lt;/strong&gt; — you can scroll &lt;strong&gt;up and down&lt;/strong&gt; with the arrow keys and search inside the file with &lt;code&gt;/&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Example of use:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  more / etc/services
  less /etc/services
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;I experimented with these two commands that allow you to view the content of text files. Certainly, they work in different ways. I think the winner is less, which is more flexible, but I think there should be situations where more does the work.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧠 Tab Completion in Linux
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Tab completion lets you press &lt;code&gt;Tab&lt;/code&gt; to &lt;strong&gt;auto-complete commands, file names, or paths&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;This is a feature provided by the shell: &lt;strong&gt;bash&lt;/strong&gt; , &lt;strong&gt;zsh&lt;/strong&gt; , and &lt;strong&gt;fish&lt;/strong&gt; all supports Tab completion.&lt;/li&gt;
&lt;li&gt;If there’s ambiguity (multiple matches), pressing &lt;code&gt;Tab&lt;/code&gt; twice shows a list of possibilities.&lt;/li&gt;
&lt;li&gt;Works with commands, paths, directories, users, etc.&lt;/li&gt;
&lt;li&gt;Saves time and avoids typing errors.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;I’m not good at memorizing commands, so this is definitely very useful when you’re working in the command line.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  ⏳ The &lt;code&gt;history&lt;/code&gt; Command
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;history&lt;/code&gt; command shows a &lt;strong&gt;list of previously run commands&lt;/strong&gt; with line numbers.
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;history&lt;/code&gt; is a built-in shell command.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;this only works well in bash shell&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Here’s a clever trick to navigate the history output:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;history | less
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This uses a &lt;strong&gt;pipe&lt;/strong&gt; (|) to pass the output of &lt;code&gt;history&lt;/code&gt; as input to the &lt;code&gt;less&lt;/code&gt; command.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;It’s a great example of the &lt;a href="https://en.wikipedia.org/wiki/Unix_philosophy" rel="noopener noreferrer"&gt;UNIX philosophy&lt;/a&gt;: &lt;em&gt;“using small tools that work together by chaining them”&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🔁 Repeating Commands
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You can repeat a command from history using &lt;code&gt;!&amp;lt;line-number&amp;gt;&lt;/code&gt;, for example:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;When you re-run a command with &lt;code&gt;!number&lt;/code&gt;, it moves to the &lt;strong&gt;end of the history queue&lt;/strong&gt; with a new number, and the &lt;strong&gt;original number is overwritten&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;You can also rerun the last command with:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Let said you submit a command that requieres to &lt;code&gt;sudo&lt;/code&gt; but you forgot, instead of submit the command again preceding &lt;code&gt;sudo&lt;/code&gt; you can use &lt;code&gt;sudo !!&lt;/code&gt;, like this example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;less /etc/shadow
/etc/shadow: Permission denied
sudo !!
sudo less /etc/shadow
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🔍 Search Command History with &lt;code&gt;Ctrl + r&lt;/code&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Press &lt;code&gt;Ctrl + r&lt;/code&gt; to start a &lt;strong&gt;reverse search&lt;/strong&gt; through your history.&lt;/li&gt;
&lt;li&gt;Start typing part of a command, and it will autocomplete the most recent match.&lt;/li&gt;
&lt;li&gt;Press &lt;code&gt;Ctrl + r&lt;/code&gt; again to go further back, or &lt;code&gt;Enter&lt;/code&gt; to run it.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🕵️ Hidden Files (Dot Files)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Hidden files in Linux start with a dot (&lt;code&gt;.&lt;/code&gt;), so they’re often called &lt;strong&gt;dot files&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;You list them with:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Or:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Common dot files include &lt;code&gt;.bashrc&lt;/code&gt;, &lt;code&gt;.bash_profile&lt;/code&gt;, &lt;code&gt;.bash_history&lt;/code&gt;,&lt;code&gt;.ssh/&lt;/code&gt;, etc.&lt;/li&gt;
&lt;li&gt;These files store &lt;strong&gt;personal configurations&lt;/strong&gt; in your home directory.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📂 Exploring Dot Files
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;I used &lt;code&gt;less&lt;/code&gt; to read the contents of dot files:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;less ~/.bashrc
less ~/.bash_history
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  ✏️ Editing with &lt;code&gt;nano&lt;/code&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;nano&lt;/code&gt; is one of the most widely used text editors in Linux because of its ease of use&lt;/li&gt;
&lt;li&gt;I used &lt;code&gt;nano&lt;/code&gt; to create a new file with a summary of the first 4 lessons.&lt;/li&gt;
&lt;li&gt;Example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nano lessons_summary.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F99h5ejihsbabyv537xn2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F99h5ejihsbabyv537xn2.png" alt="nano|450" width="800" height="688"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I was already familiar with the basic functions of nano, but I will have to delve into more advanced functions later.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🐚 Switching Shells: &lt;code&gt;bash&lt;/code&gt;, &lt;code&gt;zsh&lt;/code&gt;, &lt;code&gt;fish&lt;/code&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Linux supports multiple shell programs beyond just &lt;code&gt;bash&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I tried out:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I wrote this as a separate note to describe the process to install and change the shell&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧩 Terminal Multiplexers: &lt;code&gt;screen&lt;/code&gt; and &lt;code&gt;tmux&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;terminal multiplexer&lt;/strong&gt; is a command-line tool that lets you run and manage &lt;strong&gt;multiple terminal sessions&lt;/strong&gt; within a single terminal window or SSH connection, and keep them running even if you disconnect.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;screen&lt;/code&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;screen&lt;/code&gt; is a tool that let you have multiple shell sessions on a server, and let them “in the background”, while you work in another thing.&lt;/li&gt;
&lt;li&gt;You can even logout for your server, and get back when you left on a session.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;I confess it was hard to get it the first time, but after watching a YouTube video and asking ChatGPT, I kind of got it. I’ll put the references at the end of the note.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;tmux&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="//../Linux/20250523T0650-tmux-basic-guide"&gt;20250523T0650-tmux-basic-guide&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linux</category>
    </item>
    <item>
      <title>What a Shell is?</title>
      <dc:creator>Carlos Leonel Ramirez</dc:creator>
      <pubDate>Fri, 16 May 2025 23:08:17 +0000</pubDate>
      <link>https://dev.to/carloslramirez/what-a-shell-is-52m1</link>
      <guid>https://dev.to/carloslramirez/what-a-shell-is-52m1</guid>
      <description>&lt;h2&gt;
  
  
  So what actually the Shell is?
&lt;/h2&gt;

&lt;p&gt;The Shell is the “program” that &lt;strong&gt;runs on the server side&lt;/strong&gt; that provides the command-line interface between the user and the operating system.&lt;/p&gt;

&lt;p&gt;It’s the program that reads, interprets and run the commands that you type when you connect to a server.&lt;/p&gt;

&lt;p&gt;The shell interprets the commands you enter and some of them are “executed” by the shell itself, and others are passed to the operating system to be executed by a program.&lt;/p&gt;

&lt;p&gt;Different shells exist — some are mostly historical, while others are still widely used today. The most common ones are &lt;strong&gt;bash&lt;/strong&gt; and &lt;strong&gt;zsh&lt;/strong&gt;. &lt;strong&gt;zsh&lt;/strong&gt; is especially popular among power users and developers 😉&lt;/p&gt;

&lt;p&gt;On Linux, every user can choose which shell they want to use as their default login shell.&lt;/p&gt;

&lt;h3&gt;
  
  
  🧠 Why are there different shells?
&lt;/h3&gt;

&lt;p&gt;Because over time, developers built &lt;strong&gt;new shells with more features&lt;/strong&gt; , better scripting, customization, performance, or user experience — just like how web browsers or text editors evolved.&lt;/p&gt;

&lt;p&gt;Each shell aims to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Improve on limitations of older shells&lt;/li&gt;
&lt;li&gt;Add scripting capabilities&lt;/li&gt;
&lt;li&gt;Provide better interactivity (autocomplete, colors, plugins, etc.)&lt;/li&gt;
&lt;li&gt;Cater to specific use cases (like scripting vs. interactive use)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Related notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="//../Linux/20250516T1849-list-of-shells"&gt;List of the most commonly used shells&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="//../Linux/20250526T1834-history-of-shells"&gt;History of Shells&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="//../Linux/20250521T2100-how-to-change-your-shell-in-linux"&gt;How to change your shell in Linux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="//../Linux/20250516T1834-what-happens-when-you-connect-to-a-server-via-ssh-and-run-a-command"&gt;What Happens When You Connect to a Server via SSH and Run a Command?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>linux</category>
      <category>beginners</category>
    </item>
    <item>
      <title>My Linux Upskill Challenge Journal: Day 4 - Installing software, exploring the file structure</title>
      <dc:creator>Carlos Leonel Ramirez</dc:creator>
      <pubDate>Thu, 08 May 2025 13:14:29 +0000</pubDate>
      <link>https://dev.to/carloslramirez/linux-upskill-challenge-day-4-installing-software-exploring-the-file-structure-3bj1</link>
      <guid>https://dev.to/carloslramirez/linux-upskill-challenge-day-4-installing-software-exploring-the-file-structure-3bj1</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This is the Day 4 Journal on my &lt;a href="https://linuxupskillchallenge.org/" rel="noopener noreferrer"&gt;Linux Upskill Challenge&lt;/a&gt; , yes, this is the lesson when you get in deep with the Linux File System, I also learned about how to install packages in Ubuntu Linux with APT.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;Installing packages in Ubuntu Linux&lt;/li&gt;
&lt;li&gt;Linux File System&lt;/li&gt;
&lt;li&gt;Questions I asked myself 🤔&lt;/li&gt;
&lt;li&gt;Related Notes&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Installing packages in Ubuntu Linux
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Think of packages like programs or applications (apps) that you install on your phone.&lt;/li&gt;
&lt;li&gt;Like the “App Store” or the “Market” on your phone, in Linux we call them &lt;strong&gt;Package Managers&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;One of the most popular (if not the most used) package managers in Ubuntu (and other Linux distributions based on Debian) is &lt;strong&gt;apt&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;APT stands for “Advanced Package Tool” and is used to install, update, and manage software packages.&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;If you know a keyword or part of the description of a package, you can search for it using the &lt;code&gt;apt search&lt;/code&gt; command. For example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apt search "midnight commander"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This will display a list of packages matching the search term along with a brief description of each:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mc/noble-updates,now 3:4.8.30-1ubuntu0.1 arm64 [installed]
  Midnight Commander - a powerful file manager
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Here we can see &lt;code&gt;mc&lt;/code&gt; is the &lt;strong&gt;package name&lt;/strong&gt; for the &lt;a href="https://midnight-commander.org/" rel="noopener noreferrer"&gt;Midnight Commander&lt;/a&gt; package (application).&lt;/li&gt;
&lt;li&gt;To install the package with &lt;strong&gt;apt&lt;/strong&gt; you need to use &lt;code&gt;sudo&lt;/code&gt;, unless you’re already logged in as &lt;code&gt;root&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install mc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;ul&gt;
&lt;li&gt;Package managers like &lt;strong&gt;apt&lt;/strong&gt; make it easy to handle dependencies and ensure your system stays up-to-date.&lt;/li&gt;
&lt;li&gt;There are other package managers available for Debian-based Linux distributions.&lt;/li&gt;
&lt;li&gt;For Red Hat-based Linux distributions, the equivalent of &lt;code&gt;apt&lt;/code&gt; is &lt;code&gt;yum&lt;/code&gt;. (but that’s a completely different story! 🙂)&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Now that we’ve installed Midnight Commander, we can use its retro interface to easily navigate the Linux file system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5d5s8rho7hhfxdk0nsgb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5d5s8rho7hhfxdk0nsgb.png" width="800" height="707"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Linux File System
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The Linux operating system has a standard file system structure. At first, it might seem a bit intimidating—especially if you’re only familiar with Windows, where you have the C: drive, D: drive, and various folders within each. &lt;strong&gt;With Linux, it’s a totally different beast.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The Filesystem Hierarchy Standard (FHS) defines the structure of file systems on Linux and other UNIX-like operating systems. However, Linux file systems also contain some directories that aren’t yet defined by the standard.&lt;/li&gt;
&lt;li&gt;If you want to read the official manual of the file system hierarchy, type &lt;code&gt;man hier&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/&lt;/code&gt; ⇒ (La Raiz 🫚) The Root Directory
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Everything on your Linux system is located under the &lt;code&gt;/&lt;/code&gt; directory, also called the &lt;em&gt;root&lt;/em&gt; directory. (Don’t confuse it with the &lt;code&gt;/root&lt;/code&gt; directory.)&lt;/li&gt;
&lt;li&gt;In Linux you don’t have drive letters like C: or D:. &lt;strong&gt;Everything&lt;/strong&gt; is under &lt;code&gt;/&lt;/code&gt;, even if you have different physical drives and partitions— all of them will be under &lt;code&gt;/&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/boot&lt;/code&gt; ⇒ 🥾 Boot files
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Contains all the files needed to boot the system, including the currently installed Linux kernels and their supporting files.&lt;/li&gt;
&lt;li&gt;The GRUB bootloader’s files are stored here as well.&lt;/li&gt;
&lt;li&gt;It is better not to mess with this directory!&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/etc&lt;/code&gt; ⇒ ⚙️ Configuration Files
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Key configuration files are stored here, and in subdirectories inside.&lt;/li&gt;
&lt;li&gt;Most of the files here are simple text files.&lt;/li&gt;
&lt;li&gt;Some interesting files under &lt;code&gt;/etc&lt;/code&gt;:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/etc/passwd&lt;/code&gt;: contains basic information about each user account (like username, UID, default shell, etc.). Passwords are stored in another file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt;: this is the configuration file for the SSH daemon (&lt;code&gt;sshd&lt;/code&gt;), which acts as the &lt;em&gt;server&lt;/em&gt; for the SSH connection. (The &lt;em&gt;client&lt;/em&gt; is on your computer! 💻)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/home&lt;/code&gt;⇒ 🏠 User Home Folders
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Each user in the system will have a folder inside &lt;code&gt;/home&lt;/code&gt; (for example &lt;code&gt;/home/carlos&lt;/code&gt;, &lt;code&gt;/home/ubuntu&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Inside each folder we have user data files, user-specific configuration files, and folders. Many of them are hidden (use &lt;code&gt;ls -la&lt;/code&gt; to list them).&lt;/li&gt;
&lt;li&gt;Each user can only write in their own home folder.&lt;/li&gt;
&lt;li&gt;Example files and folders found in a home folder: &lt;code&gt;.bashrc&lt;/code&gt;, &lt;code&gt;.profile&lt;/code&gt;, &lt;code&gt;.ssh/&lt;/code&gt;, &lt;code&gt;.config&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/root&lt;/code&gt;⇒ ⛪ The root home directory
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Instead of being inside &lt;code&gt;/home&lt;/code&gt;, the root user has their own home directory in &lt;code&gt;/root&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/bin&lt;/code&gt; ⇒ Essential binaries 🧱
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;/bin&lt;/code&gt; directory contains all the essential &lt;strong&gt;system binaries&lt;/strong&gt; that Linux needs to function — even when it boots into a special recovery state called &lt;strong&gt;single-user mode&lt;/strong&gt; (you can think of it like Safe Mode in Windows).&lt;/li&gt;
&lt;li&gt;It contains important core command-line tools that must be available even if no other filesystems are mounted yet — such as &lt;code&gt;ls&lt;/code&gt;, &lt;code&gt;cp&lt;/code&gt;, &lt;code&gt;mv&lt;/code&gt;, and the &lt;code&gt;bash&lt;/code&gt; shell.&lt;/li&gt;
&lt;li&gt;It traditionally has two sibling directories: &lt;code&gt;/sbin&lt;/code&gt; (for essential system binaries for administrators) and &lt;code&gt;/usr/bin&lt;/code&gt; (for general user binaries that are not critical for boot).&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/sbin&lt;/code&gt;⇒ System administration binaries 💾
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;/sbin&lt;/code&gt; directory contains &lt;strong&gt;essential system administration binaries&lt;/strong&gt; used for system booting, repairing, or managing services — like &lt;code&gt;fsck&lt;/code&gt;, &lt;code&gt;reboot&lt;/code&gt;, and &lt;code&gt;ifconfig&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;These tools are generally intended for &lt;strong&gt;the root user or administrators&lt;/strong&gt; , and may not be in a regular user’s &lt;code&gt;$PATH&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/usr&lt;/code&gt; ⇒ 🧰 user-space programs and tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It contains applications and files used by users, as opposed to the system itself.&lt;/li&gt;
&lt;li&gt;These files and folders are meant to be read-only for regular users, unless you’re installing something manually into &lt;code&gt;/usr/local&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;These files are installed and managed by the package manager (apt, dnf, yum, etc.).&lt;/li&gt;
&lt;li&gt;In some distros (especially immutable or container-focused ones like Fedora Silverblue, Alpine, or embedded systems), &lt;code&gt;/usr&lt;/code&gt; is even mounted read-only at the filesystem level to improve security and stability.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/usr/bin&lt;/code&gt;, &lt;code&gt;/usr/lib&lt;/code&gt;, &lt;code&gt;/usr/share&lt;/code&gt;, and &lt;code&gt;/usr/local&lt;/code&gt; are examples of directories inside &lt;code&gt;/usr&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/usr/bin&lt;/code&gt; ⇒ 🛠️ main executables for users and apps
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;/usr/bin&lt;/code&gt; directory contains &lt;strong&gt;most user-level commands and applications&lt;/strong&gt; that are not essential for booting or single-user mode.&lt;/li&gt;
&lt;li&gt;It’s often much larger than &lt;code&gt;/bin&lt;/code&gt; and includes tools like &lt;code&gt;git&lt;/code&gt;, &lt;code&gt;nano&lt;/code&gt;, &lt;code&gt;python&lt;/code&gt;, &lt;code&gt;gcc&lt;/code&gt;, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;NOTE&lt;/p&gt;

&lt;p&gt;⚠️ Modern Linux systems often merge &lt;code&gt;/bin&lt;/code&gt; and &lt;code&gt;/usr/bin&lt;/code&gt; using symbolic links. So the physical separation may no longer exist — but conceptually, this is still true.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/usr/lib&lt;/code&gt; ⇒ 📚 shared libraries for installed programs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Contains the libraries for the non-essential user-level binaries located in &lt;code&gt;/usr/bin&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/usr/local&lt;/code&gt; ⇒ 🧪 custom software installed manually
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Locally compiled programs not managed by the package manager.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/var&lt;/code&gt; ⇒ 📝 logs and variables
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/var&lt;/code&gt; stands for “variable” — it contains files that &lt;strong&gt;change frequently&lt;/strong&gt; , like logs and temporary data.&lt;/li&gt;
&lt;li&gt;It is the writable counterpart to the &lt;code&gt;/usr&lt;/code&gt; directory, which must be read-only in normal operation.&lt;/li&gt;
&lt;li&gt;It stores &lt;strong&gt;system logs&lt;/strong&gt; , like authentication attempts and errors, usually inside &lt;code&gt;/var/log&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;It also holds &lt;strong&gt;spools&lt;/strong&gt; and &lt;strong&gt;queues&lt;/strong&gt; — like for &lt;strong&gt;print jobs&lt;/strong&gt; , &lt;strong&gt;mail&lt;/strong&gt; , or &lt;strong&gt;cron jobs&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;If a system is acting weird or you’re running out of disk space, &lt;code&gt;/var&lt;/code&gt; is often the &lt;strong&gt;first place to check&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/var/log&lt;/code&gt; ⇒ 📂 system and service logs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This is the folder where Linux keeps &lt;strong&gt;log files&lt;/strong&gt; from the system and various services.&lt;/li&gt;
&lt;li&gt;Most of the files here are simple text files.&lt;/li&gt;
&lt;li&gt;Some interesting files under &lt;code&gt;/var/log&lt;/code&gt; are:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/var/log/auth.log&lt;/code&gt;: Captures all &lt;strong&gt;authentication events&lt;/strong&gt; — like login attempts, sudo usage, and SSH access.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/var/log/syslog&lt;/code&gt;: General &lt;strong&gt;system activity log&lt;/strong&gt; , useful for debugging services and applications.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/var/log/kern.log&lt;/code&gt;: Messages from the &lt;strong&gt;Linux kernel&lt;/strong&gt; , helpful when troubleshooting hardware or low-level issues.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/var/log/dpkg.log&lt;/code&gt;: Logs of all &lt;strong&gt;package installations and updates&lt;/strong&gt; (on Debian/Ubuntu systems).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/var/log/boot.log&lt;/code&gt;: Records &lt;strong&gt;messages during the system boot process&lt;/strong&gt; , helpful for startup issues.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/tmp&lt;/code&gt; ⇒ 🧊 temporary files for programs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/tmp&lt;/code&gt; is used to store &lt;strong&gt;temporary files&lt;/strong&gt; created by programs, scripts, or the system itself.&lt;/li&gt;
&lt;li&gt;The data here is &lt;strong&gt;not meant to be permanent&lt;/strong&gt; — it’s usually deleted on &lt;strong&gt;reboot&lt;/strong&gt; or after a certain time.&lt;/li&gt;
&lt;li&gt;Applications use it for things like &lt;strong&gt;installers, locks, or temp caches&lt;/strong&gt; while they run.&lt;/li&gt;
&lt;li&gt;You can manually delete files here to free up space, but be careful &lt;strong&gt;not to remove in-use files&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/dev&lt;/code&gt; ⇒ 🔌 devices as files
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/dev&lt;/code&gt; contains &lt;strong&gt;device files&lt;/strong&gt; that represent your hardware (like disks, USBs, and terminals).&lt;/li&gt;
&lt;li&gt;Linux treats devices like files, so you can interact with them via commands (e.g., &lt;code&gt;/dev/sda&lt;/code&gt;, &lt;code&gt;/dev/null&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;It includes both &lt;strong&gt;physical devices&lt;/strong&gt; and &lt;strong&gt;virtual ones&lt;/strong&gt; (like &lt;code&gt;/dev/random&lt;/code&gt;, &lt;code&gt;/dev/tty&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Device files are managed by the &lt;strong&gt;udev&lt;/strong&gt; system and updated automatically as devices are added or removed.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/proc&lt;/code&gt; ⇒ 🧠 system and process info
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/proc&lt;/code&gt; is a &lt;strong&gt;virtual filesystem&lt;/strong&gt; that shows &lt;strong&gt;real-time information&lt;/strong&gt; about running processes and the kernel. Similarly to &lt;code&gt;/dev&lt;/code&gt;, it doesn’t contain regular files but virtual representations of system internals.&lt;/li&gt;
&lt;li&gt;Each process has a folder like &lt;code&gt;/proc/1234&lt;/code&gt; containing its memory, open files, and status.&lt;/li&gt;
&lt;li&gt;It includes files like &lt;code&gt;/proc/cpuinfo&lt;/code&gt;, &lt;code&gt;/proc/meminfo&lt;/code&gt;, and &lt;code&gt;/proc/uptime&lt;/code&gt; — great for monitoring.&lt;/li&gt;
&lt;li&gt;These files aren’t stored on disk — they’re generated live by the &lt;strong&gt;kernel&lt;/strong&gt; when you access them.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/sys&lt;/code&gt; ⇒ 🛠️ kernel interface to hardware
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/sys&lt;/code&gt; is another &lt;strong&gt;virtual filesystem&lt;/strong&gt; , used to expose and control &lt;strong&gt;kernel data structures&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;It provides detailed info about &lt;strong&gt;hardware devices, drivers, and kernel modules&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;It’s commonly used by tools like &lt;code&gt;udevadm&lt;/code&gt;, &lt;code&gt;systemd&lt;/code&gt;, or &lt;code&gt;udev&lt;/code&gt; to &lt;strong&gt;detect and manage hardware&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;You can even tweak some kernel parameters from here (with caution), usually under &lt;code&gt;/sys/class&lt;/code&gt; or &lt;code&gt;/sys/block&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/lib&lt;/code&gt; ⇒ 📚 Essential common libraries
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This folder contains libraries needed by the binaries found in &lt;code&gt;/bin&lt;/code&gt; and &lt;code&gt;/sbin&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Linux libraries are shared collections of precompiled code that programs can use to perform common tasks.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;/media&lt;/code&gt; &amp;amp; &lt;code&gt;/mnt&lt;/code&gt; ⇒ 💽 mount points for external and manual storage
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Both &lt;code&gt;/media&lt;/code&gt; and &lt;code&gt;/mnt&lt;/code&gt; are used as &lt;strong&gt;mount points&lt;/strong&gt; — places where external or additional filesystems are attached to the main system.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/media&lt;/code&gt; is typically used by the &lt;strong&gt;desktop environment or automount system&lt;/strong&gt; to mount USB drives, SD cards, and external disks automatically (e.g. &lt;code&gt;/media/carlos/USB&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/mnt&lt;/code&gt; is usually reserved for &lt;strong&gt;manual or temporary mounts&lt;/strong&gt; done by system administrators (e.g. mounting a backup disk or ISO).&lt;/li&gt;
&lt;li&gt;You can mount a filesystem to either, but by convention: &lt;strong&gt;automated → &lt;code&gt;/media&lt;/code&gt;&lt;/strong&gt; , &lt;strong&gt;manual → &lt;code&gt;/mnt&lt;/code&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Questions I asked myself 🤔
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/carloslramirez/what-a-shell-is-52m1"&gt;What a Shell is?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="//../Linux/20250516T1834-what-happens-when-you-connect-to-a-server-via-ssh-and-run-a-command"&gt;What Happens When You Connect to a Server via SSH and Run a Command?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="//../Linux/20250519T2138-what-is-a-daemon-in-linux"&gt;What is a Daemon in Linux?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="//../Linux/20250518T1034-what-is-a-binary-in-linux"&gt;What is a Binary in Linux?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Related Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="//../Linux/20250504T0416-linux-upskill-day-3"&gt;My Linux Upskill Challenge: Day 3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="//../Linux/20250521T1822-linux-upskill-day-5"&gt;My Linux Upskill Challenge: Day 5&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>devjournal</category>
      <category>begineers</category>
    </item>
    <item>
      <title>My Linux Upskill Challenge Jounal: Day 3</title>
      <dc:creator>Carlos Leonel Ramirez</dc:creator>
      <pubDate>Sun, 04 May 2025 04:16:27 +0000</pubDate>
      <link>https://dev.to/carloslramirez/my-linux-upskill-challenge-jounal-day-3-42jo</link>
      <guid>https://dev.to/carloslramirez/my-linux-upskill-challenge-jounal-day-3-42jo</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I’ve started following the &lt;a href="https://linuxupskillchallenge.org/" rel="noopener noreferrer"&gt;Linux Upskill Challenge&lt;/a&gt; to sharpen my Linux knowledge and hands-on skills. This is the &lt;strong&gt;third&lt;/strong&gt; in a series of 21 lessons designed to be completed on a daily basis.&lt;/p&gt;

&lt;p&gt;In this lesson, I learned about the types of users that exist in a Linux system, along with their scope and limitations. I also explored the proper way to handle administrative tasks that require elevated privileges—how to temporarily become root in order to perform sensitive actions while minimizing the risk of making a mistake that could break your server.&lt;/p&gt;




&lt;h2&gt;
  
  
  Day 3 - Power trip! 
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;URL:&lt;/strong&gt; &lt;a href="https://linuxupskillchallenge.org/03/" rel="noopener noreferrer"&gt;https://linuxupskillchallenge.org/03/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Previous Lesson:&lt;/strong&gt; &lt;a href="//../Linux/20250501T2009-linux-upskill-day-2"&gt;My Linux Upskill Challenge: Day 2&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🚪 Introduction
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;root&lt;/code&gt; is the power user on a Linux System, it’s the “super user” account that is all powerful. That also means that a typo in a command being root could mess up your server!&lt;/li&gt;
&lt;li&gt;As a Best Practice you shouldn’t use &lt;code&gt;root&lt;/code&gt; user, instead in a production server, instead use a specific user and run root-only commands via the &lt;code&gt;sudo&lt;/code&gt; command.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sudo&lt;/code&gt; is a command that allows a user to execute commands with elevated privileges — typically as &lt;code&gt;root&lt;/code&gt;. What a user is allowed to run with &lt;code&gt;sudo&lt;/code&gt; is defined in the &lt;em&gt;sudoers&lt;/em&gt; configuration.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Lesson’s tasks
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Change the password or your &lt;code&gt;sudo&lt;/code&gt; user&lt;/li&gt;
&lt;li&gt;Change the hostname&lt;/li&gt;
&lt;li&gt;Change the timezone&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  👨‍👦‍👦 Linux type of users
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In a Linux system you can do two kind of changes

&lt;ul&gt;
&lt;li&gt;Global changes: affects all users, programs/environments shared with any user.&lt;/li&gt;
&lt;li&gt;Local changes: affects only one user, programs/environments for a particular user.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;In Linux there are three type of user:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;root&lt;/code&gt; - the all-mighty powerful superuser that can execute any command and can do global changes and local changes for any user as well.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sudoers&lt;/code&gt; - those are regular users (or groups) that are allowed to use &lt;code&gt;sudo&lt;/code&gt; to run commands with elevated privileges. It’s common (and best practice) to grant at least one &lt;code&gt;sudoer&lt;/code&gt; with the same power as root, while others with may be restricted on only certain commands, you specify this in the &lt;code&gt;sudoers&lt;/code&gt; configuration file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;regular user&lt;/code&gt; - only can do local changes, and not allowed to use &lt;code&gt;sudo&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h3&gt;
  
  
  🚀 Sudo Access and User Creation on EC2
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;On an AWS EC2 instance, the &lt;code&gt;root&lt;/code&gt; user is disabled by default. The default user is &lt;code&gt;ubuntu&lt;/code&gt;, who already has &lt;code&gt;sudo&lt;/code&gt; privileges — it’s already a &lt;em&gt;sudoer&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;I confirmed this with the following commands:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;whoami
# ubuntu
groups ubuntu
# ubuntu : ubuntu adm cdrom sudo dip lxd
sudo whoami
# root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You &lt;strong&gt;can&lt;/strong&gt; enable SSH login as the root user by following this &lt;a href="https://tecadmin.net/how-to-enable-ssh-as-root-on-aws-ubuntu-instance/" rel="noopener noreferrer"&gt;guide&lt;/a&gt;, but I didn’t try it — it seemed risky and unnecessary for my purposes.&lt;/li&gt;
&lt;li&gt;Instead, for practice, I created a new user named &lt;code&gt;carlos&lt;/code&gt; and gave him the same privileges as &lt;code&gt;ubuntu&lt;/code&gt; using the following commands:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo adduser carlos
sudo usermod -aG sudo carlos
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;There’s another way to grant elevated privileges to a user: by modifying the &lt;code&gt;/etc/sudoers&lt;/code&gt; file. To safely edit this special file, you should always use the &lt;code&gt;visudo&lt;/code&gt; command. For now, I chose the simpler group-based method instead.&lt;/li&gt;
&lt;li&gt;You can change the password for any given user with &lt;code&gt;passwd&lt;/code&gt; command
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;passwd carlos
Changing password for carlos.
Current password: 
New password: 
Retype new password: 
passwd: password updated successfully
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🔐 SSH Access with Shared Key
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;When I added the new user, it asked me to set a password. However, I wanted &lt;code&gt;carlos&lt;/code&gt; to log in using the same SSH key as the ubuntu user, and also make sure password-based authentication remained disabled.&lt;/li&gt;
&lt;li&gt;I used the following steps:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Create .ssh directory for carlos
sudo mkdir -p /home/carlos/.ssh

# Copy authorized_keys from ubuntu
sudo cp /home/ubuntu/.ssh/authorized_keys /home/carlos/.ssh/

# Set correct ownership and permissions
sudo chown -R carlos:carlos /home/carlos/.ssh
sudo chmod 700 /home/carlos/.ssh
sudo chmod 600 /home/carlos/.ssh/authorized_keys
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;I then started a new SSH session as &lt;code&gt;carlos&lt;/code&gt; , using the same &lt;code&gt;linux.pem&lt;/code&gt; key file.&lt;/li&gt;
&lt;li&gt;I also tested login using a password instead of the SSH key, and it was rejected. As it turns out, password-based SSH authentication is disabled by default on this EC2 AMI, so no extra configuration was needed.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🧪 Password Prompt on &lt;code&gt;sudo&lt;/code&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;One difference I noticed: when running sudo as &lt;code&gt;carlos&lt;/code&gt;, it prompted for the user password, unlike &lt;code&gt;ubuntu&lt;/code&gt;, which doesn’t require it. Here’s the behavior:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;carlos@ip-172-31-92-220:~$ whoami
carlos
carlos@ip-172-31-92-220:~$ sudo whoami
[sudo] password for carlos: 
root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This is because the default &lt;code&gt;sudo&lt;/code&gt; configuration in EC2 lets &lt;code&gt;ubuntu&lt;/code&gt; run &lt;code&gt;sudo&lt;/code&gt; without a password, but any new user added to the &lt;code&gt;sudo&lt;/code&gt; group will be required to authenticate with their password (unless you explicitly configure otherwise in &lt;code&gt;/etc/sudoers&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;To make &lt;code&gt;carlos&lt;/code&gt; run &lt;code&gt;sudo&lt;/code&gt; without a password you need to create the file &lt;code&gt;/etc/sudoers.d/carlos&lt;/code&gt; using &lt;code&gt;visudo&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo visudo -f /etc/sudoers.d/carlos
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;and add the following line:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;carlos ALL=(ALL) NOPASSWD:ALL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Actually AWS pre-configure this for the &lt;code&gt;ubuntu&lt;/code&gt; user in the file &lt;code&gt;/etc/sudoers.d/90-cloud-init-users&lt;/code&gt;, as I checked here:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo cat /etc/sudoers.d/90-cloud-init-users
# Created by cloud-init v. 24.4.1-0ubuntu0~24.04.1 on Fri, 25 Apr 2025 00:08:00 +0000

# User rules for ubuntu
ubuntu ALL=(ALL) NOPASSWD:ALL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Testing the power of &lt;code&gt;sudo&lt;/code&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If you try to use &lt;code&gt;cat /etc/shadow&lt;/code&gt; to view the contents of the file, access will be denied, but if you use &lt;code&gt;sudo cat /etc/shadow&lt;/code&gt; it will work. 🤓 This file contains the &lt;strong&gt;hashed password&lt;/strong&gt; for all system users, so it’s a intentionally restricted or non-authorized users.&lt;/li&gt;
&lt;li&gt;Also If I tried the &lt;code&gt;reboot&lt;/code&gt; command will be rejected, but with &lt;code&gt;sudo reboot&lt;/code&gt; it works and the server will fully restarted. In confirmed with &lt;code&gt;uptime&lt;/code&gt; when the server was online again.&lt;/li&gt;
&lt;li&gt;With the &lt;code&gt;last&lt;/code&gt; command you can see the login history, you can filter by username (e.g. &lt;code&gt;last ubuntu&lt;/code&gt;, &lt;code&gt;last carlos&lt;/code&gt; or `last root)

&lt;ul&gt;
&lt;li&gt;As expected, on my EC2 instance there wasn’t entries for &lt;code&gt;root&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
last root&lt;br&gt;
wtmp begins Fri Apr 25 00:07:50 2025&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;




&lt;ul&gt;
&lt;li&gt;I checked the failed login attempts with the command &lt;code&gt;sudo lastb&lt;/code&gt;, and I found that an IP from China had tried to log in to my server using the a &lt;code&gt;user&lt;/code&gt; user several times on May 2nd. 😱&lt;/li&gt;
&lt;li&gt;Apparently, this is kind of normal for internet-facing servers, and there’s nothing to worry about &lt;em&gt;at this time&lt;/em&gt;. However, implementing &lt;code&gt;fail2ban&lt;/code&gt; could be a good idea.&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;You can use the command &lt;code&gt;sudo -i&lt;/code&gt; to fully become the &lt;code&gt;root&lt;/code&gt; user. That means from now on, you won’t need to prefix commands with &lt;code&gt;sudo&lt;/code&gt; for any high-privilege tasks. This is handy when you have a series of commands to run as “&lt;em&gt;root&lt;/em&gt;.” You’ll also notice that the prompt changes. &lt;strong&gt;I recommend doing this with caution.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;To get back to your normal “&lt;em&gt;sudoer&lt;/em&gt;” account you need to type &lt;code&gt;exit&lt;/code&gt; or &lt;code&gt;logout&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
carlos@ip-172-31-92-220:~$ whoami&lt;br&gt;
carlos&lt;br&gt;
carlos@ip-172-31-92-220:~$ sudo -i&lt;br&gt;
root@ip-172-31-92-220:~# whoami&lt;br&gt;
root&lt;br&gt;
root@ip-172-31-92-220:~# logout&lt;br&gt;
carlos@ip-172-31-92-220:~$ whoami&lt;br&gt;
carlos&lt;br&gt;
carlos@ip-172-31-92-220:~$ &lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With &lt;code&gt;sudo journalctl -e /usr/bin/sudo&lt;/code&gt; you can see the last times when &lt;code&gt;sudo&lt;/code&gt; was used including the user which used and with which command.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  👷 Administrative Tasks
&lt;/h2&gt;

&lt;p&gt;This are some examples of simple administrative tasks that a sysadmin regualar do using &lt;code&gt;sudo&lt;/code&gt;:&lt;/p&gt;

&lt;h3&gt;
  
  
  Change the hostname
&lt;/h3&gt;

&lt;p&gt;One of the must basic task for you’ll need &lt;code&gt;sudo&lt;/code&gt; priviledges is to rename your server, that means change the &lt;code&gt;hostname&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Probably the current &lt;code&gt;hostname&lt;/code&gt; of the server is what you see in the prompt after “&lt;em&gt;username@&lt;/em&gt;”, however if you want to double check, there are several ways to do it on linux: you can issue any of this commands: &lt;code&gt;hostname&lt;/code&gt; , &lt;code&gt;uname-h&lt;/code&gt;, or check the content of this file: &lt;code&gt;cat /etc/hostname&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Also, if you need to change it, you can use any of this options:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Edit these two files: &lt;code&gt;/etc/hostname&lt;/code&gt; and &lt;code&gt;/etc/hosts&lt;/code&gt; , and then reboot the server&lt;/li&gt;
&lt;li&gt;(Recommended) Use the command &lt;code&gt;hostnamectl&lt;/code&gt; withouth rebooting the server, like this:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
sudo hostnamectl set-hostname myec2ubuntu&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To observe the change in the prompt you should open a new session using the command &lt;code&gt;bash&lt;/code&gt; or just logout and login again.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
carlos@ip-172-31-92-220:~$ sudo hostnamectl set-hostname myec2ubuntu&lt;br&gt;
carlos@ip-172-31-92-220:~$ bash&lt;br&gt;
carlos@myec2ubuntu:~$ &lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I stopped and re-started the EC2 instance just to be sure the new hostname preservers after the server restart.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;blockquote&gt;
&lt;p&gt;NOTE&lt;/p&gt;

&lt;p&gt;I decided to deploy a local VM on my computer to not depend on starting an EC2 instance in AWS every time I want to lab, this saves me time (and money!)&lt;/p&gt;

&lt;p&gt;So I installed UTM on my Mac computer and used &lt;a href="https://ubuntu.com/download/server/arm" rel="noopener noreferrer"&gt;Ubuntu Server for ARM (24.04.2 LTS)&lt;/a&gt; ISO image to launch my Linux VM, and I destroyed (Terminate) the EC2 in AWS.&lt;/p&gt;

&lt;p&gt;I may do a &lt;a href="//../Installation-Guide"&gt;Installation Guide&lt;/a&gt; someday&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Change the Timezone
&lt;/h3&gt;

&lt;p&gt;Another regular task when you are in charge or server administration is to setup the correct timezone (this could be the timezone of the region the server is actually located, or a timezone the company agreed). The default for any Linux server is UTM. (that is same as GMT).&lt;/p&gt;

&lt;p&gt;To check the current settings you use:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
timedatectl&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can check the available timezones with:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
timedatectl list-timezones&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After decide which one to use, I change it using this command&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
sudo timedatectl set-timezone Americas/Guatemala&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then I confirmed the change, again with:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
timedatectl&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;           Local time: Thu 2025-05-08 12:51:30 CST
       Universal time: Thu 2025-05-08 18:51:30 UTC
             RTC time: Thu 2025-05-08 18:51:30
            Time zone: America/Guatemala (CST, -0600)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;System clock synchronized: no&lt;br&gt;
              NTP service: active&lt;br&gt;
          RTC in local TZ: no&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Selecting the correct timezone for all your servers take importance when you need configure scheduled tasks that you need to run at certain time, it also allows you to have consistency in the timestamps of your log files (those under &lt;code&gt;/var/log&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Question?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What’s the difference between &lt;code&gt;sudo -i&lt;/code&gt; and &lt;code&gt;sudo -s&lt;/code&gt;?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sudo -i&lt;/code&gt; and &lt;code&gt;sudo -s&lt;/code&gt; are two commands that allow you to “become root” and run elevated-privilege commands without needing to prefix each one with &lt;code&gt;sudo&lt;/code&gt;. However, they have some key differences:&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sudo -i&lt;/code&gt; launches a root shell—it’s like starting a new shell session as if you had logged in directly as the root user. It also loads the root user’s environment and places you in the &lt;code&gt;/root&lt;/code&gt; directory (&lt;code&gt;cd /root&lt;/code&gt;). If you type &lt;code&gt;echo $HOME&lt;/code&gt;, it will point to &lt;code&gt;/root&lt;/code&gt;. The &lt;code&gt;-i&lt;/code&gt; stands for “&lt;em&gt;simulate initial login&lt;/em&gt;”.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sudo -s&lt;/code&gt; also launches a root shell, but it doesn’t load the root environment and keeps you in your current working directory. The &lt;code&gt;-s&lt;/code&gt; stands for “&lt;em&gt;shell&lt;/em&gt;”, and it’s less powerful than &lt;code&gt;-i&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Always double check before pressing &lt;code&gt;Enter&lt;/code&gt; when you’re acting as &lt;code&gt;root&lt;/code&gt; on a server.&lt;/li&gt;
&lt;li&gt;Always try to use for daily operations a “normal” account and add to &lt;code&gt;sudoers&lt;/code&gt; group so need to use &lt;code&gt;sudo&lt;/code&gt; for elevated priviledge commands.&lt;/li&gt;
&lt;li&gt;For critical changes on production systems, take extra precaution actions like using a test environment, check for syntax errors and typos, and monitor the log files.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Additional Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-edit-the-sudoers-file" rel="noopener noreferrer"&gt;How To Edit the Sudoers File&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/@jasonrigden/hardening-ssh-1bcb99cd4cef" rel="noopener noreferrer"&gt;Hardening SSH&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://linuxize.com/post/how-to-setup-ssh-tunneling/" rel="noopener noreferrer"&gt;SSH Tunneling&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-multi-factor-authentication-for-ssh-on-ubuntu-20-04" rel="noopener noreferrer"&gt;How To Set Up Multi-Factor Authentication for SSH on Ubuntu 20.04&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;







&lt;h2&gt;
  
  
  Related Notes:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="//../Linux/20250501T2009-linux-upskill-day-2"&gt;My Linux Upskill Challenge: Day 2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="//../Linux/20250508T1314-linux-upskill-day-4"&gt;My Linux Upskill Challenge - Day 4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>begineers</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>My Linux Upskill Challenge Journey: Day 2</title>
      <dc:creator>Carlos Leonel Ramirez</dc:creator>
      <pubDate>Fri, 02 May 2025 02:09:07 +0000</pubDate>
      <link>https://dev.to/carloslramirez/linux-upskill-challenge-day-2-1fmp</link>
      <guid>https://dev.to/carloslramirez/linux-upskill-challenge-day-2-1fmp</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I’ve started following the &lt;a href="https://linuxupskillchallenge.org/" rel="noopener noreferrer"&gt;Linux Upskill Challenge&lt;/a&gt; to sharpen my Linux knowledge and hands-on skills. It’s a series of 21 lessons designed to be completed daily, but I’ll be going through them at my own pace. I’ll share my journey and notes here as I move forward.&lt;/p&gt;




&lt;h2&gt;
  
  
  Day 2 - Basic navigation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;URL:&lt;/strong&gt; &lt;a href="https://linuxupskillchallenge.org/02/" rel="noopener noreferrer"&gt;https://linuxupskillchallenge.org/02/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Previous Lesson:&lt;/strong&gt; &lt;a href="//../Linux/20250429T1854-linux-upskill-day-1"&gt;My Linux Upskill Challenge: Day 1&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;RTFM&lt;/strong&gt; 
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In this lesson, I learned a new acronym: &lt;strong&gt;RTFM&lt;/strong&gt; – “Read the F***ing Manual.” 😆&lt;/li&gt;
&lt;li&gt;When you’re learning and using Linux (or anything else) and have questions, of course, you’re always free to Google it or ask ChatGPT.&lt;/li&gt;
&lt;li&gt;However, the best system administrators are those who first &lt;strong&gt;RTFM&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;This is something we’re starting to forget nowadays!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Linux systems offer several ways to access documentation. But if—after searching—you still need help, you can always &lt;a href="https://opensource.com/life/16/10/how-ask-technical-questions" rel="noopener noreferrer"&gt;ask a well-written question&lt;/a&gt; in forums, Reddit, Discord, or other communities.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;I think this is even more relevant today, especially when writing good prompts in the “GPT era.”&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Looking for Documentation&lt;/strong&gt; 
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;man&lt;/code&gt; command is a great place to start—most installed applications have their own manual.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For instance, you can find the manual for these commands:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;That said, &lt;code&gt;man&lt;/code&gt; output can be overwhelming for some commands or too minimal for others. That’s where &lt;code&gt;tldr&lt;/code&gt; comes in—it provides simplified, community-written man pages for common Linux (and other OS) commands.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;tldr&lt;/code&gt; is another tool for viewing documentation. I installed it using &lt;code&gt;sudo apt install tldr&lt;/code&gt;, but it didn’t work right away on my EC2 instance.&lt;/li&gt;
&lt;li&gt;I got the following error:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tldr: /home/ubuntu/.local/share/tldr: createDirectory: does not exist (No such file or directory)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;I fixed it with these two commands:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir -p ~/.local/share/tldr
tldr --update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The second command pulls the latest pages from the official GitHub repo (make sure your server has internet access!).&lt;/li&gt;
&lt;li&gt;I tried &lt;code&gt;tldr&lt;/code&gt; with the same commands as before, and yes—it showed me much more simplified info.&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;I also learned about the &lt;code&gt;apropos&lt;/code&gt; command, which is equivalent to &lt;code&gt;man -k&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Both are useful when you kind of know what a command does and want to search for keywords in the manual.&lt;/li&gt;
&lt;li&gt;For example, if you search for the phrase &lt;em&gt;“remove file”&lt;/em&gt; using &lt;code&gt;apropos "remove file"&lt;/code&gt;, you’ll get results like this:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ubuntu@ip-172-31-92-220:~$ apropos "remove file"
git-rm (1) - Remove files from the working tree and from the index
rm (1) - remove files or directories
ubuntu@ip-172-31-92-220:~$ man -k "remove file"
git-rm (1) - Remove files from the working tree and from the index
rm (1) - remove files or directories
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Some commands—especially shell built-ins—don’t have &lt;code&gt;man&lt;/code&gt; pages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For those, you can use the &lt;code&gt;help&lt;/code&gt; command instead.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Example: use &lt;code&gt;help export&lt;/code&gt; instead of &lt;code&gt;man export&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I found exceptions like &lt;code&gt;echo&lt;/code&gt;, which works with both &lt;code&gt;man echo&lt;/code&gt; and &lt;code&gt;help echo&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The best way to check if a command is a shell &lt;em&gt;built-in&lt;/em&gt; is to use the &lt;code&gt;type&lt;/code&gt; command.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;Lastly, there’s the &lt;code&gt;info&lt;/code&gt; command. It gives &lt;strong&gt;more&lt;/strong&gt; detailed documentation, sometimes written in a tutorial style and with hypertext navigation.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Navigate the File Structure&lt;/strong&gt; 
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I discovered a command that gives you documentation about the Linux file system: &lt;code&gt;man hier&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;/&lt;/code&gt; is the top-level directory (called &lt;strong&gt;root&lt;/strong&gt; ) for all other folders.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🧭 To find out where you are in the file system, use &lt;code&gt;pwd&lt;/code&gt;—this is like your GPS in Linux. 🛰&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By default, you’ll start in the &lt;code&gt;/home/&amp;lt;user&amp;gt;&lt;/code&gt; directory, unless you’re logged in as &lt;code&gt;root&lt;/code&gt;, in which case you’ll be in &lt;code&gt;/root&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can move between directories using &lt;code&gt;cd&lt;/code&gt;:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can use either &lt;strong&gt;relative&lt;/strong&gt; or &lt;strong&gt;absolute&lt;/strong&gt; paths to move around:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Just running &lt;code&gt;cd&lt;/code&gt; returns you to your home directory, as does &lt;code&gt;cd ~&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can also use &lt;code&gt;~&lt;/code&gt; as a shortcut to move into folders inside your home directory from anywhere.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ubuntu@ip-172-31-92-220:/var/log$ cd ~/data/example/
ubuntu@ip-172-31-92-220:~/data/example$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Listing Files in a Folder&lt;/strong&gt; 
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I used &lt;code&gt;ls&lt;/code&gt; with different options (“&lt;em&gt;switches&lt;/em&gt;”) to list files.&lt;br&gt;&lt;br&gt;
For example: &lt;code&gt;ls&lt;/code&gt;, &lt;code&gt;ls -l -L&lt;/code&gt;, and &lt;code&gt;ls -l -t -r -a&lt;/code&gt; (or just &lt;code&gt;ls -ltra&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Files or folders that start with a &lt;code&gt;.&lt;/code&gt; are hidden. Use &lt;code&gt;ls -a&lt;/code&gt; to see them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can combine switches and provide a folder path:&lt;br&gt;&lt;br&gt;
e.g., &lt;code&gt;ls -ltra /var/log&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Entries that start with &lt;code&gt;d&lt;/code&gt; are directories.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Some terminals show these in a different color—if not, try &lt;code&gt;--color=auto&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ubuntu@ip-172-31-92-220:~/data/example$ ls -ltra /var/log
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;Basic Directory Manipulation&lt;/strong&gt; 
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;I created a new folder with &lt;code&gt;mkdir test&lt;/code&gt;, then moved into it with &lt;code&gt;cd test&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;You can repeat this to build nested folder structures.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir test
cd test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To move a folder into another directory, I used &lt;code&gt;mv&lt;/code&gt;:&lt;/li&gt;
&lt;li&gt;Created a folder &lt;code&gt;test2&lt;/code&gt;, then moved &lt;code&gt;example&lt;/code&gt; from &lt;code&gt;test&lt;/code&gt; to &lt;code&gt;test2&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mv test/example test2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To remove an &lt;strong&gt;empty&lt;/strong&gt; directory, use &lt;code&gt;rmdir&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;To remove a &lt;strong&gt;non-empty&lt;/strong&gt; one, use &lt;code&gt;rm -r&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Basic File Manipulation&lt;/strong&gt; 
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;To create a new (empty) file: &lt;code&gt;touch newfile.txt&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;To move it: &lt;code&gt;mv newfile.txt test2&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;To delete it: &lt;code&gt;rm&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch newfile.txt
mv newfile.txt test2
rm test2/newfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;A Bit More Advanced Directory Navigation (Stack-Based)&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;I learned about &lt;code&gt;pushd&lt;/code&gt; and &lt;code&gt;popd&lt;/code&gt;, which let you move between folders using a &lt;strong&gt;stack&lt;/strong&gt; (LIFO order).&lt;/li&gt;
&lt;li&gt;It’s different from &lt;code&gt;cd ..&lt;/code&gt;—with &lt;code&gt;pushd&lt;/code&gt; you can hop to &lt;code&gt;/etc&lt;/code&gt;, then &lt;code&gt;/var/log&lt;/code&gt;, and then jump back in reverse order using &lt;code&gt;popd&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;dirs&lt;/code&gt; to see the current directory stack.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pushd /etc
pushd /var/log
dirs
popd
popd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If you run &lt;code&gt;pushd&lt;/code&gt; without arguments, it swaps your current and previous directories—similar to &lt;code&gt;cd -&lt;/code&gt;, but it remembers your path history.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;So these are my notes for the &lt;a href="https://linuxupskillchallenge.org/02/#wrap" rel="noopener noreferrer"&gt;&lt;strong&gt;Day 2 – Basic Navigation&lt;/strong&gt; &lt;/a&gt; of the Linux Upskill Challenge.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Additional Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://unix.stackexchange.com/questions/19451/difference-between-help-info-and-man-command" rel="noopener noreferrer"&gt;Difference between help, info and man command&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gnu.org/software/texinfo/" rel="noopener noreferrer"&gt;GNU Texinfo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-use-cd-pwd-and-ls-to-explore-the-file-system-on-a-linux-server" rel="noopener noreferrer"&gt;Explore the Linux File System&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=2qQTXp4rBEE" rel="noopener noreferrer"&gt;Linux File System – YouTube&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.youtube.com/watch?v=CGBsurVdLGY" rel="noopener noreferrer"&gt;Simple Terminal Commands on Ubuntu – YouTube&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.gsp.com/support/virtual/admin/unix/solaris/commands.html" rel="noopener noreferrer"&gt;Solaris Unix Commands&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Related notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="//../Linux/20250429T1854-linux-upskill-day-1"&gt;My Linux Upskill Challenge: Day 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="//../Linux/20250504T0416-linux-upskill-day-3"&gt;My Linux Upskill Challenge: Day 3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>beginners</category>
      <category>devjournal</category>
    </item>
  </channel>
</rss>
