<?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: Olatunde salami</title>
    <description>The latest articles on DEV Community by Olatunde salami (@salamilinux).</description>
    <link>https://dev.to/salamilinux</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%2F3027077%2F90788e89-0248-4883-aca3-4fc13f8405a1.jpeg</url>
      <title>DEV Community: Olatunde salami</title>
      <link>https://dev.to/salamilinux</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/salamilinux"/>
    <language>en</language>
    <item>
      <title>Monitoring Users and Login Activity (with last, w, who)</title>
      <dc:creator>Olatunde salami</dc:creator>
      <pubDate>Sat, 24 May 2025 11:19:10 +0000</pubDate>
      <link>https://dev.to/salamilinux/monitoring-users-and-login-activity-with-last-w-who-3ohc</link>
      <guid>https://dev.to/salamilinux/monitoring-users-and-login-activity-with-last-w-who-3ohc</guid>
      <description>&lt;p&gt;Welcome to Day 17 of our &lt;em&gt;Linux Security Basics&lt;/em&gt; series! After setting up a firewall with &lt;code&gt;ufw&lt;/code&gt; or &lt;code&gt;firewalld&lt;/code&gt; on Day 5, we added a strong layer of network security. Now, let’s turn our attention to what’s happening &lt;em&gt;inside&lt;/em&gt; your system. Monitoring user activity is like having a security camera for your Linux server it helps you spot unauthorized access, track user behaviour, and respond to potential threats. Today, we’ll use three simple yet powerful commands: &lt;code&gt;last&lt;/code&gt;, &lt;code&gt;w&lt;/code&gt;, and &lt;code&gt;who&lt;/code&gt;, to keep an eye on users and login activity. Let’s dive in with a story and some real-world scenarios!&lt;/p&gt;

&lt;h2&gt;
  
  
  Index
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Why Monitor User Activity? A SysAdmin’s Wake-Up Call&lt;/li&gt;
&lt;li&gt;Command 1: &lt;code&gt;last&lt;/code&gt; - Review Login History&lt;/li&gt;
&lt;li&gt;Command 2: &lt;code&gt;w&lt;/code&gt; - Who’s Online Right Now?&lt;/li&gt;
&lt;li&gt;Command 3: &lt;code&gt;who&lt;/code&gt; - A Quick Snapshot of Logged-In Users&lt;/li&gt;
&lt;li&gt;Best Practices: Keeping Your System Safe&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="why-monitor-user-activity"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Monitor User Activity? A SysAdmin’s Wake-Up Call
&lt;/h2&gt;

&lt;p&gt;Picture this: You’re a sysadmin named Jamie, managing a Linux server for a small company. One Monday morning, you notice the server is running slower than usual. Digging deeper, you discover a user account you don’t recognise has been logging in at odd hours 2 a.m., 3 a.m. from an unfamiliar IP address. Someone compromised an old account with a weak password and has been running malicious scripts! If only you had been monitoring login activity, you could have caught this sooner.&lt;/p&gt;

&lt;p&gt;Monitoring users and logins helps you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Detect unauthorized access (e.g., brute force attacks or compromised accounts).&lt;/li&gt;
&lt;li&gt;Track user behavior for auditing or troubleshooting.&lt;/li&gt;
&lt;li&gt;Respond quickly to suspicious activity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s use &lt;code&gt;last&lt;/code&gt;, &lt;code&gt;w&lt;/code&gt;, and &lt;code&gt;who&lt;/code&gt; to ensure Jamie’s nightmare doesn’t happen to you.&lt;/p&gt;

&lt;p&gt;&lt;a id="command-1-last"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Command 1: &lt;code&gt;last&lt;/code&gt; - Review Login History
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;last&lt;/code&gt; command shows a history of user logins, including who logged in, when, from where, and for how long.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-Life Use Case: Investigating a Breach
&lt;/h3&gt;

&lt;p&gt;Jamie wants to investigate the unauthorized logins on the company server.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 1: Run &lt;code&gt;last&lt;/code&gt;
&lt;/h4&gt;



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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output example&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;jamie    pts/0        192.168.1.10    Mon May 19 09:00 - 10:00  (01:00)
unknown  pts/1        203.0.113.5     Sun May 18 02:00 - 03:00  (01:00)
root     tty1         localhost       Sat May 17 14:00 - 15:00  (01:00)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;jamie&lt;/strong&gt;: Logged in from a known IP.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;unknown&lt;/strong&gt;: Suspicious login from an unknown IP at 2 a.m.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;root&lt;/strong&gt;: Local login, likely during maintenance.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Step 2: Narrow Down with Options
&lt;/h4&gt;

&lt;p&gt;To focus on a specific user:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;To see logins from a specific IP:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;last &lt;span class="nt"&gt;-i&lt;/span&gt; 203.0.113.5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Jamie uses &lt;code&gt;last&lt;/code&gt; to confirm the &lt;code&gt;unknown&lt;/code&gt; user logged in multiple times over the weekend. The IP address (203.0.113.5) isn’t from the company network—a red flag! Jamie disables the account and starts investigating further.&lt;/p&gt;

&lt;p&gt;&lt;a id="command-2-w"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Command 2: &lt;code&gt;w&lt;/code&gt; - Who’s Online Right Now?
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;w&lt;/code&gt; command shows who is currently logged into the system, what they’re doing, and how long they’ve been idle.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-Life Use Case: Spotting Suspicious Activity in Real Time
&lt;/h3&gt;

&lt;p&gt;Jamie wants to see if the intruder is still on the system while investigating.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 1: Run &lt;code&gt;w&lt;/code&gt;
&lt;/h4&gt;



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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output example&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; 10:41:00 up 5 days, 2:00,  2 users,  load average: 0.10, 0.15, 0.20
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
jamie    pts/0    192.168.1.10     09:00    0.00s  0.03s  0.01s bash
unknown  pts/1    203.0.113.5      10:30    5:00   1:20   0.50s python3 script.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;jamie&lt;/strong&gt;: Actively working in a bash shell.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;unknown&lt;/strong&gt;: Running a Python script, logged in from the same suspicious IP.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Step 2: Take Action
&lt;/h4&gt;

&lt;p&gt;Jamie sees the &lt;code&gt;unknown&lt;/code&gt; user is still active, running a script. To stop them, Jamie terminates the session:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;pkill &lt;span class="nt"&gt;-u&lt;/span&gt; unknown
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By using &lt;code&gt;w&lt;/code&gt;, Jamie caught the intruder in the act and kicked them off the system before more damage was done.&lt;/p&gt;

&lt;p&gt;&lt;a id="command-3-who"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Command 3: &lt;code&gt;who&lt;/code&gt; - A Quick Snapshot of Logged-In Users
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;who&lt;/code&gt; command provides a simpler view of currently logged-in users, showing their username, terminal, login time, and source.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-Life Use Case: Routine Checks for a Shared Server
&lt;/h3&gt;

&lt;p&gt;Jamie manages a shared server for a university lab where multiple students log in. She wants a quick way to see who’s online during her daily checks.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 1: Run &lt;code&gt;who&lt;/code&gt;
&lt;/h4&gt;



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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output example&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;jamie    pts/0    2025-05-24 09:00 (192.168.1.10)
student1 pts/1    2025-05-24 10:00 (172.16.2.15)
student2 pts/2    2025-05-24 10:15 (172.16.2.20)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All IPs are from the university network, and the users are recognised no immediate concerns.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 2: Add Details with Options
&lt;/h4&gt;

&lt;p&gt;To see more details, use:&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;who&lt;/span&gt; &lt;span class="nt"&gt;-H&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This adds headers for clarity.&lt;/p&gt;

&lt;p&gt;Jamie uses &lt;code&gt;who&lt;/code&gt; for quick checks, ensuring only authorized students are logged in. One day, she spots an unfamiliar IP, cross checks with &lt;code&gt;last&lt;/code&gt;, and discovers a student shared their credentials prompting a security training session!&lt;/p&gt;

&lt;p&gt;&lt;a id="best-practices"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices: Keeping Your System Safe
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Schedule Regular Checks&lt;/strong&gt;: Run &lt;code&gt;who&lt;/code&gt; or &lt;code&gt;w&lt;/code&gt; daily to spot unusual activity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automate Monitoring&lt;/strong&gt;: Create a script to log &lt;code&gt;last&lt;/code&gt; output and email alerts for suspicious IPs:
&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="c"&gt;#!/bin/bash&lt;/span&gt;
  last &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /var/log/login_history.log
  &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"203.0.113.5"&lt;/span&gt; /var/log/login_history.log | mail &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"Suspicious Login Alert"&lt;/span&gt; admin@example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save as &lt;code&gt;monitor_logins.sh&lt;/code&gt;, make it executable (&lt;code&gt;chmod +x monitor_logins.sh&lt;/code&gt;), and schedule with &lt;code&gt;cron&lt;/code&gt;. For example, add to &lt;code&gt;crontab&lt;/code&gt; to run daily at 2 a.m.:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  0 2 &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; /path/to/monitor_logins.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Combine with Logs&lt;/strong&gt;: Check &lt;code&gt;/var/log/auth.log&lt;/code&gt; (Debian/Ubuntu) or &lt;code&gt;/var/log/secure&lt;/code&gt; (Red Hat) for more details on login attempts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Act Quickly&lt;/strong&gt;: If you spot suspicious activity, disable accounts (&lt;code&gt;sudo passwd -l username&lt;/code&gt;) and investigate.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Troubleshooting: False Alarms and Missed Intruders
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;False Positives&lt;/strong&gt;: Jamie once panicked over an unfamiliar IP, but it was a student using a VPN. Cross check IPs with known users before acting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Missed Activity&lt;/strong&gt;: If &lt;code&gt;last&lt;/code&gt; shows no data, ensure &lt;code&gt;/var/log/wtmp&lt;/code&gt; isn’t corrupted. Reset it with &lt;code&gt;sudo truncate -s 0 /var/log/wtmp&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What’s Next?
&lt;/h2&gt;

&lt;p&gt;You’re now equipped to monitor user activity and spot potential threats! Tomorrow, on Day 18, we’ll explore &lt;strong&gt;Introduction to SELinux or AppArmor for Advanced Hardening&lt;/strong&gt;, taking your security to the next level. Stay tuned!&lt;/p&gt;

&lt;p&gt;I would love to hear your thoughts, experiences, or tips about Linux! Feel free to share in the comments and join the conversation. Connect with me on &lt;a href="https://www.linkedin.com/in/olatundesalami" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;!&lt;/p&gt;

&lt;h1&gt;
  
  
  30DaysLinuxChallenge #CloudWhistler #RedHat #CloudSecurity #DevOps #Linux #OpenSource #CloudComputing #RedHatEnterpriseLinux #SystemLogs #EnterpriseIT #Observability #Logging #SysAdmin #Automation #CloudEngineer #TechForBusiness #ITSupport #SRE #CloudOps
&lt;/h1&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;

</description>
      <category>devops</category>
      <category>cloudcomputing</category>
      <category>cloudwhistler</category>
      <category>linux</category>
    </item>
    <item>
      <title>Simple Firewall with ufw or firewalld</title>
      <dc:creator>Olatunde salami</dc:creator>
      <pubDate>Wed, 21 May 2025 22:33:03 +0000</pubDate>
      <link>https://dev.to/salamilinux/simple-firewall-with-ufw-or-firewalld-i9d</link>
      <guid>https://dev.to/salamilinux/simple-firewall-with-ufw-or-firewalld-i9d</guid>
      <description>&lt;p&gt;Welcome to Day 16 of our &lt;em&gt;Linux Security Basics&lt;/em&gt; series! After securing file permissions on topic 5, it’s time to add a layer of network security with a firewall. A firewall controls incoming and outgoing traffic, protecting your system from unauthorized access. Today, we’ll explore two user friendly tools: &lt;strong&gt;ufw&lt;/strong&gt; (Uncomplicated Firewall) and &lt;strong&gt;firewalld&lt;/strong&gt;. Let’s set up a simple firewall to fortify your Linux system!&lt;/p&gt;

&lt;h2&gt;
  
  
  Index
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Why Use a Firewall?&lt;/li&gt;
&lt;li&gt;Choosing Between ufw and firewalld&lt;/li&gt;
&lt;li&gt;Setting Up a Firewall with ufwd&lt;/li&gt;
&lt;li&gt;Setting Up a Firewall with firewalld&lt;/li&gt;
&lt;li&gt;Best Practices&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Why Use a Firewall?"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use a Firewall?
&lt;/h2&gt;

&lt;p&gt;A firewall acts as a gatekeeper, allowing only trusted traffic while blocking potential threats. Without one, your system is vulnerable to attacks like port scanning or unauthorized remote logins. Both ufw and firewalld simplify firewall management, making them ideal for beginners and experienced users alike.&lt;/p&gt;

&lt;p&gt;&lt;a id="Choosing Between ufw and firewalld"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing Between ufw and firewalld
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ufw&lt;/strong&gt;: Lightweight and easy to use, pre installed on Ubuntu and Debian-based systems. Best for simple setups.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;firewalld&lt;/strong&gt;: More dynamic, with support for runtime changes and zones. Common on Red Hat-based systems (e.g., CentOS, Fedora).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check which tool is available:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For ufw: &lt;code&gt;sudo ufw version&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;For firewalld: &lt;code&gt;sudo firewall-cmd --version&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If both are installed, you can use either let’s cover both!&lt;/p&gt;

&lt;p&gt;&lt;a id="Setting Up a Firewall with ufw"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up a Firewall with ufw
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Check Status
&lt;/h3&gt;

&lt;p&gt;Ensure ufw is active:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;If it says "inactive," proceed to enable it.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Enable ufw
&lt;/h3&gt;

&lt;p&gt;Enable the firewall (this may disrupt existing connections, so plan ahead):&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Allow Essential Services
&lt;/h3&gt;

&lt;p&gt;Allow traffic for services you need (e.g., SSH on port 22):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow 22/tcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or use service names (if configured):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Deny Unwanted Traffic
&lt;/h3&gt;

&lt;p&gt;Block specific ports (e.g., deny port 23, used for telnet):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw deny 23
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Set Default Policies
&lt;/h3&gt;

&lt;p&gt;Restrict all incoming traffic by default, allowing only specified ports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw default deny incoming
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw default allow outgoing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6. Verify and Apply
&lt;/h3&gt;

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

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

&lt;/div&gt;



&lt;p&gt;Apply changes (usually automatic with &lt;code&gt;enable&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;a id="Setting Up a Firewall with firewalld"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up a Firewall with firewalld
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Check Status
&lt;/h3&gt;

&lt;p&gt;See if firewalld is running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;firewall-cmd &lt;span class="nt"&gt;--state&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it returns "not running," start it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start firewalld
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Enable firewalld
&lt;/h3&gt;

&lt;p&gt;Ensure it starts on boot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;firewalld
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Allow Services
&lt;/h3&gt;

&lt;p&gt;Allow SSH (port 22):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;firewall-cmd &lt;span class="nt"&gt;--add-service&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ssh &lt;span class="nt"&gt;--permanent&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Add Custom Ports
&lt;/h3&gt;

&lt;p&gt;Allow a custom port (e.g., 8080 for a web server):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;firewall-cmd &lt;span class="nt"&gt;--add-port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;8080/tcp &lt;span class="nt"&gt;--permanent&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Reload Rules
&lt;/h3&gt;

&lt;p&gt;Apply changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;firewall-cmd &lt;span class="nt"&gt;--reload&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6. Check Rules
&lt;/h3&gt;

&lt;p&gt;View active rules:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;firewall-cmd &lt;span class="nt"&gt;--list-all&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a id="Best Practices"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Allow Only Necessary Ports&lt;/strong&gt;: Minimize open ports to reduce attack surfaces.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test After Changes&lt;/strong&gt;: Ensure services (e.g., SSH) still work after enabling rules.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backup Rules&lt;/strong&gt;: Save ufw rules with &lt;code&gt;sudo ufw show raw&lt;/code&gt; or firewalld with &lt;code&gt;sudo firewall-cmd --runtime-to-permanent&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monitor Logs&lt;/strong&gt;: Check &lt;code&gt;/var/log/ufw.log&lt;/code&gt; (ufw) or &lt;code&gt;firewalld&lt;/code&gt; logs for issues.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Locked Out?&lt;/strong&gt;: If you block SSH, use the console or a rescue method to regain access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conflicting Rules?&lt;/strong&gt;: Reset with &lt;code&gt;sudo ufw reset&lt;/code&gt; or &lt;code&gt;sudo firewall-cmd --reload&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What’s Next?
&lt;/h2&gt;

&lt;p&gt;You’ve now added a firewall to protect your network traffic! On our next topic, we’ll explore &lt;strong&gt;Monitoring Users and Login Activity&lt;/strong&gt; with commands like &lt;code&gt;last&lt;/code&gt;, &lt;code&gt;w&lt;/code&gt;, and &lt;code&gt;who&lt;/code&gt;. Stay tuned!&lt;/p&gt;

&lt;p&gt;I would love to hear your thoughts, experiences, or tips about Linux!&lt;br&gt;
Feel free to share in the comments and join the conversation.&lt;br&gt;
Connect with me on &lt;a href="https://www.linkedin.com/in/olatundesalami" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; !&lt;/p&gt;

&lt;p&gt;#30DaysLinuxChallenge #CloudWhistler #RedHat #Cloudsecurity #DevOps #Linux #OpenSource #CloudComputing #RedHatEnterpriseLinux #SystemLogs #EnterpriseIT #Observability #Logging #SysAdmin #Automation #CloudEngineer #TechForBusiness #ITSupport #SRE #CloudOps&lt;/p&gt;

</description>
      <category>cloudwhistler</category>
      <category>linux</category>
      <category>cloudcomputing</category>
      <category>devops</category>
    </item>
    <item>
      <title>Hardening File Permissions: Practical Steps to Lock Down Data</title>
      <dc:creator>Olatunde salami</dc:creator>
      <pubDate>Mon, 19 May 2025 14:31:13 +0000</pubDate>
      <link>https://dev.to/salamilinux/hardening-file-permissions-practical-steps-to-lock-down-data-186p</link>
      <guid>https://dev.to/salamilinux/hardening-file-permissions-practical-steps-to-lock-down-data-186p</guid>
      <description>&lt;p&gt;Welcome to Day 15 of 30days linux challenge. We will be treating the 4th topic in our  &lt;strong&gt;&lt;em&gt;Linux Security Basics&lt;/em&gt;&lt;/strong&gt; series! By now, you've learned why Linux is secure by design, how to secure SSH, and how to protect against brute force attacks with &lt;code&gt;fail2ban&lt;/code&gt;. Today, we’re diving into a critical aspect of Linux security: &lt;strong&gt;hardening file permissions&lt;/strong&gt;. Properly managing file permissions ensures that only authorized users can access sensitive data, reducing the risk of unauthorized access or accidental leaks. Let’s explore practical steps to lock down your data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Index
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Why File Permissions Matter&lt;/li&gt;
&lt;li&gt;Understanding Linux File Permissions&lt;/li&gt;
&lt;li&gt;Practical Steps to Harden File Permissions&lt;/li&gt;
&lt;li&gt;Harden Home Directories&lt;/li&gt;
&lt;li&gt;Secure Directories with Sticky Bits&lt;/li&gt;
&lt;li&gt;Secure Directories with Sticky Bits&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;chown&lt;/code&gt; to Correct Ownership&lt;/li&gt;
&lt;li&gt;Find and Fix Risky Permissions&lt;/li&gt;
&lt;li&gt;Automate with a Script&lt;/li&gt;
&lt;li&gt;Best Practices&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Why File Permissions Matter"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why File Permissions Matter
&lt;/h2&gt;

&lt;p&gt;In Linux, every file and directory has permissions that dictate who can &lt;strong&gt;read&lt;/strong&gt;, &lt;strong&gt;write&lt;/strong&gt;, or &lt;strong&gt;execute&lt;/strong&gt; it. Misconfigured permissions can expose sensitive files (like configuration files or user data) to attackers or unprivileged users. For example, a world readable file containing passwords or a world writable directory could allow malicious changes. Hardening file permissions is about applying the &lt;strong&gt;principle of least privilege&lt;/strong&gt;: users and processes should only have the access they need.&lt;/p&gt;

&lt;p&gt;&lt;a id="Understanding Linux File Permissions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Linux File Permissions
&lt;/h2&gt;

&lt;p&gt;Before we start, let’s recap how permissions work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Permission Types&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Read (r)&lt;/strong&gt;: View file contents or list directory contents.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write (w)&lt;/strong&gt;: Modify a file or create/delete files in a directory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Execute (x)&lt;/strong&gt;: Run a file (e.g., a script or binary) or access a directory.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Permission Groups&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Owner (u)&lt;/strong&gt;: The user who owns the file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Group (g)&lt;/strong&gt;: Users in the file’s group.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Others (o)&lt;/strong&gt;: Everyone else.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;Viewing Permissions&lt;/strong&gt;:&lt;br&gt;&lt;br&gt;
Use &lt;code&gt;ls -l&lt;/code&gt; to see permissions. Example output:&lt;br&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;  -rwxr-xr--  1 alice users  4096 May 19 2025 script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;rwxr-xr--&lt;/code&gt; means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Owner (&lt;code&gt;alice&lt;/code&gt;): Read, write, execute (&lt;code&gt;rwx&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Group (&lt;code&gt;users&lt;/code&gt;): Read, execute (&lt;code&gt;r-x&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Others: Read only (&lt;code&gt;r--&lt;/code&gt;).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Numeric Notation&lt;/strong&gt;:
Permissions can be represented as numbers:&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Read = 4, Write = 2, Execute = 1.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Example: &lt;code&gt;755&lt;/code&gt; = &lt;code&gt;rwx&lt;/code&gt; (7 = 4+2+1) for owner, &lt;code&gt;r-x&lt;/code&gt; (5 = 4+1) for group and others.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a id="Practical Steps to Harden File Permissions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical Steps to Harden File Permissions
&lt;/h2&gt;

&lt;p&gt;Let’s walk through actionable steps to secure your files and directories. These commands assume you’re logged in as a user with &lt;code&gt;sudo&lt;/code&gt; privileges.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Audit Existing Permissions
&lt;/h3&gt;

&lt;p&gt;Start by checking permissions on critical files and directories.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Command&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;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; /etc /home /var/log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;What to Look For&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sensitive files (e.g., &lt;code&gt;/etc/shadow&lt;/code&gt;, &lt;code&gt;/etc/passwd&lt;/code&gt;) should not be world-readable or writable.&lt;/li&gt;
&lt;li&gt;User home directories (&lt;code&gt;/home/username&lt;/code&gt;) should not be accessible to others.&lt;/li&gt;
&lt;li&gt;Log files in &lt;code&gt;/var/log&lt;/code&gt; should be restricted to &lt;code&gt;root&lt;/code&gt; or specific services.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;br&gt;&lt;br&gt;
If &lt;code&gt;/etc/shadow&lt;/code&gt; shows &lt;code&gt;-rw-r--r--&lt;/code&gt; (world-readable), it’s a security risk. Fix it later in Step 2.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Set Secure Permissions for Sensitive Files
&lt;/h3&gt;

&lt;p&gt;Use the &lt;code&gt;chmod&lt;/code&gt; command to adjust permissions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Secure Configuration Files&lt;/strong&gt;:
The &lt;code&gt;/etc/shadow&lt;/code&gt; file (containing hashed passwords) should only be readable/writable by &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 shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo chmod &lt;/span&gt;600 /etc/shadow
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sets &lt;code&gt;rw-------&lt;/code&gt; (owner only).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Protect User Configuration Files&lt;/strong&gt;:
Files like &lt;code&gt;~/.ssh/id_rsa&lt;/code&gt; (SSH private keys) should be private.
&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;600 ~/.ssh/id_rsa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Remove World-Readable Permissions&lt;/strong&gt;:
For files that don’t need public access, remove permissions for "others."
&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 chmod &lt;/span&gt;o-rwx /etc/myapp.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a id="Harden Home Directories"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Harden Home Directories
&lt;/h3&gt;

&lt;p&gt;Home directories should be accessible only by their owners.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Check Permissions&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;ls&lt;/span&gt; &lt;span class="nt"&gt;-ld&lt;/span&gt; /home/&lt;span class="k"&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a directory shows &lt;code&gt;drwxr-xr-x&lt;/code&gt;, others can list its contents.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Restrict Access&lt;/strong&gt;:
Set permissions to &lt;code&gt;700&lt;/code&gt; (owner only access).
&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 chmod &lt;/span&gt;700 /home/username
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Set Default Permissions for New Files&lt;/strong&gt;:
Use &lt;code&gt;umask&lt;/code&gt; to control default permissions. A &lt;code&gt;umask&lt;/code&gt; of &lt;code&gt;022&lt;/code&gt; ensures new files are not world-writable. Check your current &lt;code&gt;umask&lt;/code&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;umask&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To set it permanently, add &lt;code&gt;umask 022&lt;/code&gt; to &lt;code&gt;~/.bashrc&lt;/code&gt; or &lt;code&gt;/etc/profile&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a id="Secure Directories with Sticky Bits"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Secure Directories with Sticky Bits
&lt;/h3&gt;

&lt;p&gt;In shared directories (e.g., &lt;code&gt;/tmp&lt;/code&gt;), users might delete others’ files. The &lt;strong&gt;sticky bit&lt;/strong&gt; prevents this.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Set the Sticky Bit&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 chmod&lt;/span&gt; +t /tmp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check with &lt;code&gt;ls -ld /tmp&lt;/code&gt;. The permissions should show &lt;code&gt;drwxrwxrwt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a id="Use  raw `chown` endraw  to Correct Ownership"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Use &lt;code&gt;chown&lt;/code&gt; to Correct Ownership
&lt;/h3&gt;

&lt;p&gt;Ensure files are owned by the right user or group.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Check Ownership&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;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; /var/www
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Web server files should typically be owned by the web server user (e.g., &lt;code&gt;www-data&lt;/code&gt;).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Change Ownership&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 chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; www-data:www-data /var/www
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a id="Find and Fix Risky Permissions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Find and Fix Risky Permissions
&lt;/h3&gt;

&lt;p&gt;Search for files with overly permissive settings.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Find World Writable Files&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;find / &lt;span class="nt"&gt;-type&lt;/span&gt; f &lt;span class="nt"&gt;-perm&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt;+w
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Review the output and remove unnecessary write permissions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo chmod &lt;/span&gt;o-w /path/to/file
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Find World Readable Sensitive Files&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;find /etc &lt;span class="nt"&gt;-type&lt;/span&gt; f &lt;span class="nt"&gt;-perm&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt;+r
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restrict access as needed.&lt;/p&gt;

&lt;p&gt;&lt;a id="Automate with a Script"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Automate with a Script
&lt;/h3&gt;

&lt;p&gt;To simplify, create a script to check and fix common issues.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# Secure critical files&lt;/span&gt;
&lt;span class="nb"&gt;sudo chmod &lt;/span&gt;600 /etc/shadow /etc/gshadow
&lt;span class="nb"&gt;sudo chmod &lt;/span&gt;644 /etc/passwd
&lt;span class="nb"&gt;sudo chmod &lt;/span&gt;700 /home/&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt;
&lt;span class="nb"&gt;sudo chmod&lt;/span&gt; +t /tmp
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Permissions hardened!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save this as &lt;code&gt;harden_permissions.sh&lt;/code&gt;, make it executable (&lt;code&gt;chmod +x harden_permissions.sh&lt;/code&gt;), and run it with &lt;code&gt;sudo ./harden_permissions.sh&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a id="Best Practices"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Regularly Audit Permissions&lt;/strong&gt;: Use &lt;code&gt;find&lt;/code&gt; or tools like &lt;code&gt;lynix&lt;/code&gt; to monitor changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backup Before Changes&lt;/strong&gt;: Always back up critical files before modifying permissions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test Changes&lt;/strong&gt;: Ensure services (e.g., web servers) still function after permission changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Document Exceptions&lt;/strong&gt;: If a file needs unusual permissions, document why.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I would love to hear your thoughts, experiences, or tips about Linux!&lt;br&gt;
Feel free to share in the comments and join the conversation.&lt;br&gt;
Connect with me on &lt;a href="https://www.linkedin.com/in/olatundesalami" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; !&lt;/p&gt;

&lt;p&gt;#30DaysLinuxChallenge #CloudWhistler #RedHat #Cloudsecurity #DevOps #Linux #OpenSource #CloudComputing #RedHatEnterpriseLinux #SystemLogs #EnterpriseIT #Observability #Logging #SysAdmin #Automation #CloudEngineer #TechForBusiness #ITSupport #SRE #CloudOps&lt;/p&gt;

</description>
      <category>cloudwhistler</category>
      <category>linux</category>
      <category>cloudcomputing</category>
      <category>devops</category>
    </item>
    <item>
      <title>Using Fail2Ban to Protect Against Brute Force Attacks</title>
      <dc:creator>Olatunde salami</dc:creator>
      <pubDate>Sat, 17 May 2025 20:40:20 +0000</pubDate>
      <link>https://dev.to/salamilinux/using-fail2ban-to-protect-against-brute-force-attacks-2j6k</link>
      <guid>https://dev.to/salamilinux/using-fail2ban-to-protect-against-brute-force-attacks-2j6k</guid>
      <description>&lt;h2&gt;
  
  
  Table Of Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;Why Fail2Ban?&lt;/li&gt;
&lt;li&gt;Step 1: Installing Fail2Ban&lt;/li&gt;
&lt;li&gt;Step 2: Configuring Fail2Ban&lt;/li&gt;
&lt;li&gt;Step 3: Testing Your Setup&lt;/li&gt;
&lt;li&gt;Step 4: Protecting Other Services&lt;/li&gt;
&lt;li&gt;Step 5: Monitoring and Fine Tuning&lt;/li&gt;
&lt;li&gt;Summary&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Introduction"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Brute force attacks are like a thief trying every key on a ring to unlock your server. They’re relentless, automated, and can overwhelm your system if left unchecked. Enter &lt;strong&gt;Fail2Ban&lt;/strong&gt;, a lightweight, open-source tool that acts like a vigilant security guard, banning malicious IPs after too many failed login attempts.&lt;/p&gt;

&lt;p&gt;In this article, we’ll walk through how to set up Fail2Ban to protect your server, with practical examples and tips to keep things engaging.&lt;/p&gt;

&lt;p&gt;Let’s lock down your server! 🔒&lt;/p&gt;




&lt;h3&gt;
  
  
  Why Fail2Ban?
&lt;/h3&gt;

&lt;p&gt;Imagine this: your SSH server logs show &lt;strong&gt;hundreds of login attempts from a single IP in minutes&lt;/strong&gt;. Without protection, your server could be compromised, or at least slowed to a crawl.&lt;/p&gt;

&lt;p&gt;Fail2Ban monitors logs, detects suspicious patterns, and &lt;strong&gt;temporarily bans IPs&lt;/strong&gt; using firewall rules (like &lt;code&gt;iptables&lt;/code&gt; or &lt;code&gt;firewalld&lt;/code&gt;). It’s simple, effective, and works for services like &lt;strong&gt;SSH, Apache, Nginx&lt;/strong&gt;, and more.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Fun Fact:&lt;/strong&gt; Fail2Ban has been around since 2004 and is still a go-to tool for sysadmins. Its simplicity is its superpower!&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;a id="Step 1: Installing Fail2Ban"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Installing Fail2Ban
&lt;/h2&gt;

&lt;p&gt;Let’s get Fail2Ban up and running. Most Linux distros make this a breeze.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On Ubuntu/Debian:&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;sudo apt update
sudo apt install fail2ban

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;On CentOS/RHEL:&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;sudo yum install epel-release
sudo yum install fail2ban
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;After installation, start and enable Fail2Ban:&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;sudo systemctl start fail2ban
sudo systemctl enable fail2ban
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Interactive Tip: Run fail2ban client status in your terminal. What do you see? Share your output in the comments it’s a great way to confirm your setup!&lt;/p&gt;

&lt;p&gt;&lt;a id="Step 2: Configuring Fail2Ban"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Configuring Fail2Ban
&lt;/h2&gt;

&lt;p&gt;Fail2Ban’s magic happens in its config files, located in /etc/fail2ban/.&lt;/p&gt;

&lt;p&gt;Note: Don’t edit jail.conf directly it might get overwritten. Instead, create a jail.local file or use the jail.d/ directory for custom rules.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: jail.local for SSH&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;DEFAULT&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nx"&gt;bantime&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;600&lt;/span&gt;
&lt;span class="nx"&gt;findtime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;600&lt;/span&gt;
&lt;span class="nx"&gt;maxretry&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;sshd&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nx"&gt;enabled&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="nx"&gt;port&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ssh&lt;/span&gt;
&lt;span class="nx"&gt;filter&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sshd&lt;/span&gt;
&lt;span class="nx"&gt;logpath&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sr"&gt;/var/&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;
&lt;span class="nx"&gt;maxretry&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="nx"&gt;bantime&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3600&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What’s Happening Here?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;bantime: How long (in seconds) an IP is banned (600 = 10 minutes).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;findtime: The time window (in seconds) to look for failed attempts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;maxretry: Number of failed attempts before banning.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;[sshd]: Protects the SSH service, using the sshd filter and monitoring /var/log/auth.log.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Engage with This: Try tweaking maxretry to 2 or bantime to 7200 (2 hours). What’s the trade off? Too strict, and you might lock out legit users; too lenient, and attackers slip through. Share your thoughts below!&lt;/p&gt;

&lt;p&gt;&lt;a id="Step 3: Testing Your Setup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Testing Your Setup
&lt;/h3&gt;

&lt;p&gt;Let’s simulate a brute force attack (safely, of course).&lt;/p&gt;

&lt;p&gt;From another machine, try logging into your server via SSH with incorrect credentials multiple times:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh user@your-server-ip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After hitting the maxretry limit, check Fail2Ban status:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo fail2ban-client status sshd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see the offending IP in the Banned IP list.&lt;/p&gt;

&lt;p&gt;To unban an IP (for testing):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo fail2ban-client unban &amp;lt;IP_ADDRESS&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Interactive Challenge: Set up Fail2Ban on a test server and try this. How many attempts did it take to get banned? Post your results!&lt;/p&gt;

&lt;p&gt;&lt;a id="Step 4: Protecting Other Services"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Protecting Other Services
&lt;/h3&gt;

&lt;p&gt;Fail2Ban isn’t just for SSH. Want to secure your web server? Enable jails for Apache or Nginx.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Example: Protect WordPress Login
[wordpress]
enabled  = true
port     = http,https
filter   = wordpress
logpath  = /var/log/apache2/access.log
maxretry = 3
bantime  = 3600
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll need to create a custom filter file, e.g., &lt;code&gt;/etc/fail2ban/filter.d/wordpress.conf:&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;[Definition]
failregex = ^.*wp-login\.php.* 401
ignoreregex =
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Pro Tip:&lt;/strong&gt; Check Fail2Ban’s GitHub for pre-made filters for popular services.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Got a service you want to protect? Drop it in the comments, and let’s brainstorm a filter together!&lt;/p&gt;

&lt;p&gt;&lt;a id="Step 5: Monitoring and Fine Tuning"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Monitoring and Fine Tuning
&lt;/h3&gt;

&lt;p&gt;Fail2Ban logs to &lt;code&gt;/var/log/fail2ban.log.&lt;/code&gt; To monitor activity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo tail -f /var/log/fail2ban.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adjust &lt;code&gt;maxretry&lt;/code&gt; or &lt;code&gt;findtime&lt;/code&gt; if you see too many false positives.&lt;/p&gt;

&lt;p&gt;Want notifications? Integrate with email, Slack, etc., via the action directive in jail.local.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Engagement Prompt: How do you monitor your server security? Do you pair Fail2Ban with tools like Logwatch, Prometheus, or Grafana? Share your stack!&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Common Pitfalls (and How to Avoid Them)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Wrong Log Path&lt;/strong&gt;&lt;br&gt;
Ensure &lt;code&gt;logpath&lt;/code&gt; matches your system’s log location (e.g., &lt;code&gt;/var/log/secure&lt;/code&gt; on CentOS).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Overly Aggressive Bans&lt;/strong&gt;&lt;br&gt;
Test your settings to avoid locking out legitimate users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Firewall Conflicts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ensure Fail2Ban’s firewall rules don’t conflict with other firewall tools.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Quick Poll:&lt;/strong&gt; What’s the biggest security oops you’ve made?&lt;br&gt;
No judgment mine was leaving port 22 open with a weak password.&lt;br&gt;
Share yours below!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Wrapping Up: Stay One Step Ahead
&lt;/h3&gt;

&lt;p&gt;Fail2Ban is a powerful ally against brute force attacks, but it’s not a silver bullet. Combine it with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Strong passwords&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SSH key authentication&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Regular log monitoring&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;...for a robust defense. Your server deserves it!&lt;/p&gt;

&lt;p&gt;&lt;a id="Summary"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;Fail2Ban is an open source intrusion prevention tool that helps protect Linux servers from brute force attacks. It works by monitoring log files for suspicious activity (e.g., repeated failed login attempts) and automatically bans offending IP addresses using firewall rules like iptables or firewalld.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Steps to Use Fail2Ban:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.Installation&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Available via package managers (apt for Ubuntu/Debian, yum for CentOS/RHEL).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enable and start the Fail2Ban service.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2.Configuration&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Customize rules using &lt;code&gt;jail.local&lt;/code&gt; or files in &lt;code&gt;jail.d/&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Define parameters like &lt;code&gt;bantime&lt;/code&gt;, &lt;code&gt;findtime&lt;/code&gt;, and &lt;code&gt;maxretry&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3.Testing&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Simulate failed SSH logins and verify bans using fail2ban client status.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unban test IPs if needed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4.Protecting Other Services&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Extend Fail2Ban to web servers (e.g., Apache, Nginx) and applications like WordPress by writing custom filters.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5.Monitoring &amp;amp; Fine Tuning&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;View logs in &lt;code&gt;/var/log/fail2ban.log&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Adjust thresholds to avoid false positives.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set up alerts for better visibility. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I would love to hear your thoughts, experiences, or tips about Linux!&lt;br&gt;
Feel free to share in the comments and join the conversation.&lt;br&gt;
Connect with me on &lt;a href="https://www.linkedin.com/in/olatundesalami" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; !&lt;/p&gt;

&lt;p&gt;#30DaysLinuxChallenge #CloudWhistler #RedHat #Cloudsecurity #DevOps #Linux #OpenSource #CloudComputing #RedHatEnterpriseLinux #SystemLogs #EnterpriseIT #Observability #Logging #SysAdmin #Automation #CloudEngineer #TechForBusiness #ITSupport #SRE #CloudOps&lt;/p&gt;

</description>
      <category>cloudwhistler</category>
      <category>cloudcomputing</category>
      <category>devops</category>
      <category>linux</category>
    </item>
    <item>
      <title>Fortify Your SSH: Lock Out Root, Shift Ports, Key In Security.</title>
      <dc:creator>Olatunde salami</dc:creator>
      <pubDate>Thu, 15 May 2025 21:41:26 +0000</pubDate>
      <link>https://dev.to/salamilinux/securing-ssh-disable-root-login-change-port-use-key-based-access-34eh</link>
      <guid>https://dev.to/salamilinux/securing-ssh-disable-root-login-change-port-use-key-based-access-34eh</guid>
      <description>&lt;h2&gt;
  
  
  Table Of Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;Why SSH Needs Protection&lt;/li&gt;
&lt;li&gt;Disable Root Login&lt;/li&gt;
&lt;li&gt;Change the Default SSH Port&lt;/li&gt;
&lt;li&gt;Set Up Key-Based Authentication&lt;/li&gt;
&lt;li&gt;Summary  What I Learned Today&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Introduction"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Yesterday, I talked about how Linux is secure by design  but only if you take action. Today, I’m locking down one of the most important services on any Linux system:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;SSH  Your remote door into the system.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If SSH is exposed and misconfigured, it becomes a high-value target for brute-force attacks and exploits. So let’s secure it step-by-step.&lt;/p&gt;




&lt;p&gt;&lt;a id="Why SSH Needs Protection"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why SSH Needs Protection
&lt;/h3&gt;

&lt;p&gt;By default, SSH can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Allow root login
&lt;/li&gt;
&lt;li&gt;Use password authentication
&lt;/li&gt;
&lt;li&gt;Run on the default port (22)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is convenient, but it also makes your system &lt;strong&gt;predictable&lt;/strong&gt; and &lt;strong&gt;vulnerable&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;&lt;a id="Disable Root Login"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Disable Root Login
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Allowing root to log in remotely is risky if someone cracks the password, they get full control instantly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the SSH config file:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/ssh/sshd_config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Find or add this line:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PermitRootLogin no
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Save and restart SSH:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   sudo systemctl restart ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now, root cannot log in via SSH.&lt;/p&gt;

&lt;p&gt;&lt;a id="Change the Default SSH Port"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Change the Default SSH Port
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Why?&lt;/strong&gt;&lt;br&gt;
Bots scan port 22 constantly. Moving SSH to a non-standard port reduces noise and avoids low effort attacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Edit the SSH config again:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/ssh/sshd_config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Change the port:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Port 2222
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;em&gt;(Pick any unused port between 1024 and 65535)&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Allow the new port in the firewall:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   sudo ufw allow 2222/tcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Restart SSH:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   sudo systemctl restart ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;✅ You’ll now connect 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;ssh -p 2222 user@your-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a id="Set Up Key-Based Authentication"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Set Up Key-Based Authentication
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why?&lt;/strong&gt;&lt;br&gt;
SSH keys are &lt;strong&gt;far more secure&lt;/strong&gt; than passwords and resistant to brute-force attacks.&lt;/p&gt;

&lt;h3&gt;
  
  
  🧩 Step-by-Step:
&lt;/h3&gt;

&lt;p&gt;** On Your Local Machine (Client):**&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Generate a key pair:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   ssh-keygen -t rsa -b 4096
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Copy the public key to the server:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   ssh-copy-id user@your-server -p 2222
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;This adds your public key to the server’s &lt;code&gt;~/.ssh/authorized_keys&lt;/code&gt; file.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;strong&gt;On Your Server:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Edit the SSH config again:
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Ensure these settings are enabled:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   PubkeyAuthentication yes
   PasswordAuthentication no
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Restart SSH:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   sudo systemctl restart ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Now, only systems with your private key can log in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: Test Before Locking Yourself Out
&lt;/h2&gt;

&lt;p&gt;Always open a second terminal and &lt;strong&gt;test your changes&lt;/strong&gt; before closing your current SSH session. That way, if anything breaks, you're still connected and can fix it.&lt;/p&gt;

&lt;p&gt;&lt;a id="Summary  What I Learned Today"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary  What I Learned Today
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Remote root login is dangerous, I disabled it.&lt;/li&gt;
&lt;li&gt;Port 22 is predictable, I moved SSH to a safer port.&lt;/li&gt;
&lt;li&gt;Passwords can be brute forced, I switched to SSH keys.&lt;/li&gt;
&lt;li&gt;I always test SSH changes before restarting or disconnecting.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; My Linux SSH access is now much harder to exploit. &lt;/p&gt;

&lt;p&gt;I would love to hear your thoughts, experiences, or tips about Linux!&lt;br&gt;
Feel free to share in the comments and join the conversation.&lt;br&gt;
Connect with me on &lt;a href="https://www.linkedin.com/in/olatundesalami" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; !&lt;/p&gt;

&lt;p&gt;#30DaysLinuxChallenge #CloudWhistler #RedHat #Cloudsecurity #DevOps #Linux #OpenSource #CloudComputing #RedHatEnterpriseLinux #SystemLogs #EnterpriseIT #Observability #Logging #SysAdmin #Automation #CloudEngineer #TechForBusiness #ITSupport #SRE #CloudOps&lt;/p&gt;

</description>
      <category>cloudwhistler</category>
      <category>devops</category>
      <category>cloudcomputing</category>
      <category>linux</category>
    </item>
    <item>
      <title>Why Linux Is Secure by Design (But Still Needs You)</title>
      <dc:creator>Olatunde salami</dc:creator>
      <pubDate>Wed, 14 May 2025 14:22:55 +0000</pubDate>
      <link>https://dev.to/salamilinux/why-linux-is-secure-by-design-but-still-needs-you-3ic4</link>
      <guid>https://dev.to/salamilinux/why-linux-is-secure-by-design-but-still-needs-you-3ic4</guid>
      <description>&lt;h2&gt;
  
  
  Table Of Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;What Makes Linux Secure by Design?&lt;/li&gt;
&lt;li&gt;Multi-User Architecture&lt;/li&gt;
&lt;li&gt;Root vs Regular Users&lt;/li&gt;
&lt;li&gt;Permission Based File Access&lt;/li&gt;
&lt;li&gt;Minimal Default Services&lt;/li&gt;
&lt;li&gt;Open Source Advantage&lt;/li&gt;
&lt;li&gt;Summary&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Introduction"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Welcome to the start of my new series: &lt;strong&gt;Linux Security Basics&lt;/strong&gt;. Over the next few days, I’ll explore how to protect a Linux system from the basics to the essentials every system admin, developer, or enthusiast should know.&lt;/p&gt;

&lt;p&gt;We’re starting with a fundamental question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Why is Linux considered secure by design?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s unpack what makes Linux such a resilient operating system and why &lt;strong&gt;"secure by design" ≠ "secure by default."&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;a id="What Makes Linux Secure by Design"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Makes Linux Secure by Design?
&lt;/h2&gt;

&lt;p&gt;Linux didn’t become known for its security by accident. Several &lt;strong&gt;core principles&lt;/strong&gt; make Linux a solid choice for both personal and enterprise environments.&lt;/p&gt;




&lt;p&gt;&lt;a id="Multi-User Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Multi-User Architecture&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;From day one, Linux was built for multiple users. That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every user has their own account.&lt;/li&gt;
&lt;li&gt;Every file and process belongs to a user.&lt;/li&gt;
&lt;li&gt;Regular users cannot access system files or affect other users’ processes.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;This separation enforces boundaries that prevent accidental or malicious interference.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;a id="Root vs Regular Users"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2.Root vs Regular Users
&lt;/h3&gt;

&lt;p&gt;Linux uses a strict privilege model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Root&lt;/strong&gt; (administrator) has full access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Normal users&lt;/strong&gt; have limited access by default.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Commands that modify the system must be run with elevated privileges (e.g., &lt;code&gt;sudo&lt;/code&gt;).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This makes it difficult for malware or bad commands to damage the entire system unless you’re running as root (which you shouldn't!).&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;a id="Permission Based File Access"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3.Permission Based File Access
&lt;/h3&gt;

&lt;p&gt;Every file and directory in Linux has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Owner&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Group&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Permissions&lt;/strong&gt; (&lt;code&gt;read&lt;/code&gt;, &lt;code&gt;write&lt;/code&gt;, &lt;code&gt;execute&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With these controls, you can precisely limit who can access or change files.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Linux follows the principle of &lt;strong&gt;least privilege&lt;/strong&gt;  users get only the access they need.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;a id="Minimal Default Services"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. &lt;strong&gt;Minimal Default Services&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Unlike some operating systems that run numerous background services by default, many Linux distros:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start with only essential services&lt;/li&gt;
&lt;li&gt;Let you enable others manually&lt;/li&gt;
&lt;li&gt;Offer tools to audit running processes (&lt;code&gt;ps&lt;/code&gt;, &lt;code&gt;ss&lt;/code&gt;, &lt;code&gt;netstat&lt;/code&gt;, etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Fewer services = fewer vulnerabilities = smaller attack surface.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;a id="Open Source Advantage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. &lt;strong&gt;Open Source Advantage&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Linux is open source, meaning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Code is publicly available for scrutiny.&lt;/li&gt;
&lt;li&gt;Vulnerabilities are often found and fixed quickly.&lt;/li&gt;
&lt;li&gt;The community and vendors (like Red Hat, Ubuntu, Debian) actively patch security holes.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Transparency leads to faster response and higher trust.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  ⚠️ So… Is Linux Automatically Secure?
&lt;/h2&gt;

&lt;p&gt;Not quite.&lt;/p&gt;

&lt;p&gt;Linux is &lt;strong&gt;secure by design&lt;/strong&gt;, but not &lt;strong&gt;secure by default&lt;/strong&gt;. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SSH may allow root login unless you configure it.&lt;/li&gt;
&lt;li&gt;Firewalls may be inactive unless you enable them.&lt;/li&gt;
&lt;li&gt;Software updates are manual unless you schedule them.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Security still requires YOU  the user/admin  to take action.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That’s what this series is all about.&lt;/p&gt;




&lt;p&gt;&lt;a id="Summary"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Linux’s architecture gives it a strong foundation for security.&lt;/li&gt;
&lt;li&gt;Features like user separation, strict permissions, and fewer default services reduce risk.&lt;/li&gt;
&lt;li&gt;But you still need to &lt;strong&gt;configure&lt;/strong&gt;, &lt;strong&gt;update&lt;/strong&gt;, and &lt;strong&gt;monitor&lt;/strong&gt; your system actively.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security is a process, not a checkbox.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I would love to hear your thoughts, experiences, or tips about Linux!&lt;br&gt;
Feel free to share in the comments and join the conversation.&lt;br&gt;
Connect with me on &lt;a href="https://www.linkedin.com/in/olatundesalami" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; !&lt;/p&gt;

&lt;p&gt;#30DaysLinuxChallenge #CloudWhistler #RedHat #Cloudsecurity #DevOps #Linux #OpenSource #CloudComputing #RedHatEnterpriseLinux #SystemLogs #EnterpriseIT #Observability #Logging #SysAdmin #Automation #CloudEngineer #TechForBusiness #ITSupport #SRE #CloudOps&lt;/p&gt;

</description>
      <category>cloudwhistler</category>
      <category>devops</category>
      <category>linux</category>
      <category>cloudcomputing</category>
    </item>
    <item>
      <title>Access Unlocked: The Sudo Way</title>
      <dc:creator>Olatunde salami</dc:creator>
      <pubDate>Wed, 14 May 2025 12:10:03 +0000</pubDate>
      <link>https://dev.to/salamilinux/access-unlocked-the-sudo-way-3937</link>
      <guid>https://dev.to/salamilinux/access-unlocked-the-sudo-way-3937</guid>
      <description>&lt;h2&gt;
  
  
  Table Of Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;What is sudo?&lt;/li&gt;
&lt;li&gt;Why Use sudo?&lt;/li&gt;
&lt;li&gt;How to Configure sudo Access&lt;/li&gt;
&lt;li&gt;Best Practices&lt;/li&gt;
&lt;li&gt;Why Is sudo an Important Command?&lt;/li&gt;
&lt;li&gt;Summary&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Introduction"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;One of the core principles of Linux is the separation of standard users and administrative (root) privileges. Today, I explored how to configure sudo access, which allows users to execute commands with elevated privileges safely and securely.&lt;/p&gt;

&lt;p&gt;&lt;a id="What is sudo?"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;s​udo (short for “superuser do”) is a command line utility that allows a permitted user to execute a command as the superuser or another user, as defined by the security policy.&lt;/p&gt;

&lt;p&gt;Rather than logging in as root (which can be dangerous), users can gain temporary administrative access using sudo.&lt;/p&gt;

&lt;p&gt;&lt;a id="Why Use sudo?"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use sudo?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Security: Limits access to sensitive commands.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Auditability: Logs all commands run with sudo for accountability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Convenience: Avoids full root logins, reducing the risk of system wide mistakes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="How to Configure sudo Access"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Configure sudo Access
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Add a User to the sudo Group
Most Linux distros (like Ubuntu and Debian) use the sudo group to grant sudo privileges.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo usermod -aG sudo &amp;lt;username&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Replace  with the actual user’s name.&lt;/p&gt;

&lt;p&gt;For example, to grant sofia sudo access:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;To apply the group changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;su - Sofia

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

&lt;/div&gt;



&lt;p&gt;Or have the user log out and back in.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Verify Access
Switch to the user and test:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



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

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Edit the sudoers File (Safely!)
To customize permissions or define more specific rules, use:
&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
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command opens the /etc/sudoers file in a safe editor that prevents syntax errors.&lt;/p&gt;

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

&lt;p&gt;Allow a user to run only specific commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sofia ALL=(ALL) NOPASSWD: /usr/sbin/service apache2 restart

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

&lt;/div&gt;



&lt;p&gt;This allows sofia to restart Apache without a password.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating a Sudoers File in /etc/sudoers.d/
For better management, you can create custom sudoers files:
&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/sofia
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside the file:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This method is preferred for organizing permissions per user or group.&lt;br&gt;
&lt;a id="Best Practices"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Best Practices
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Avoid using the root account directly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Limit sudo access to trusted users only.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Log all sudo usage (by default, it’s stored in /var/log/auth.log).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use visudo instead of editing /etc/sudoers directly.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a id="Why Is sudo an Important Command?"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Why Is sudo an Important Command?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;s​udo is one of the most essential tools in Linux system administration. Here’s why:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security Through Least Privilege:&lt;/strong&gt;&lt;br&gt;
By default, users operate with limited permissions. sudo ensures that only trusted users can perform sensitive tasks like installing software, modifying system files, or managing services.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reduces Risk of Damage:&lt;/strong&gt;&lt;br&gt;
Running as root all the time is dangerous. A single mistyped command can crash the system. sudo limits the time and scope of privileged actions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Accountability and Logging:&lt;/strong&gt;&lt;br&gt;
Every sudo action is logged (usually in /var/log/auth.log), allowing administrators to track changes or investigate issues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Granular Control:&lt;/strong&gt;&lt;br&gt;
With sudo, you can fine-tune what commands specific users can run ideal in multi user environments.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Promotes Best Practices:&lt;/strong&gt;&lt;br&gt;
Encourages the principle of “least privilege” by allowing users to elevate privileges only when necessary.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Summary"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Today, I learned about the importance of the sudo command in Linux, which allows users to perform administrative tasks securely without logging in as root. I explored how to grant sudo access to users, safely edit the sudoers file, and follow best practices to maintain system security. sudo is a critical tool for privilege management, promoting safety, accountability, and control in multi user environments.&lt;/p&gt;

&lt;p&gt;I would love to hear your thoughts, experiences, or tips about Linux!&lt;br&gt;
Feel free to share in the comments and join the conversation.&lt;br&gt;
Connect with me on &lt;a href="https://www.linkedin.com/in/olatundesalami" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; !&lt;/p&gt;

&lt;p&gt;#30DaysLinuxChallenge #CloudWhistler #RedHat #Cloudsecurity #DevOps #Linux #OpenSource #CloudComputing #RedHatEnterpriseLinux #SystemLogs #EnterpriseIT #Observability #Logging #SysAdmin #Automation #CloudEngineer #TechForBusiness #ITSupport #SRE #CloudOps&lt;/p&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>cloudcomputing</category>
      <category>redhat</category>
    </item>
    <item>
      <title>🛡️Understanding and Using Special Permissions in Linux (with Real-Life Analogies)</title>
      <dc:creator>Olatunde salami</dc:creator>
      <pubDate>Thu, 08 May 2025 09:01:27 +0000</pubDate>
      <link>https://dev.to/salamilinux/understanding-and-using-special-permissions-in-linux-with-real-life-analogies-411m</link>
      <guid>https://dev.to/salamilinux/understanding-and-using-special-permissions-in-linux-with-real-life-analogies-411m</guid>
      <description>&lt;h2&gt;
  
  
  Table Of Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Introduction&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SUID  (Borrowing the Boss's Authority)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SGID  (Group Consistency Keeper)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sticky Bit  (Don't Touch My Stuff!)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Numeric Representation of Special Permissions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Security Importance of Special Permissions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Best Practices&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conclusion&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Introduction"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Have you ever wondered how Linux ensures users can collaborate without stepping on each other's toes or how a regular user can run powerful programs without being given the keys to the whole system?&lt;br&gt;
That's where special permissions come in. These are not your everyday read, write, and execute. These are the VIP badges: &lt;strong&gt;SUID&lt;/strong&gt;, &lt;strong&gt;SGID&lt;/strong&gt;, and the &lt;strong&gt;Sticky Bit&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Quick Recap: Standard vs Special Permissions&lt;br&gt;
here’s the usual setup:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;r (read): View contents&lt;/code&gt;&lt;br&gt;
&lt;code&gt;w (write): Modify contents&lt;/code&gt;&lt;br&gt;
&lt;code&gt;x (execute): Run files or access directories&lt;/code&gt;&lt;br&gt;
But sometimes, that's not enough...&lt;/p&gt;

&lt;p&gt;That's why we  have these special permissions that are important in multiuser environments and shared directories.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;SUID (Set User ID)&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SGID (Set Group ID)&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sticky Bit&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;&lt;a id="SUID  (Borrowing the Boss's Authority)"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  1. SUID  (Borrowing the Boss's Authority)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SUID (Set User ID)&lt;/strong&gt; allows users to run a program as if they were the file owner. Commonly, the owner is root.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-Life Analogy:&lt;/strong&gt;&lt;br&gt;
Imagine a guest in a hotel needs to access a restricted floor. Instead of giving them a master key (root access), the elevator (program) temporarily acts as if they are the manager (file owner) just to get them there and only there.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
Check the file's permissions before:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls -l script.sh
-rwxr-xr-x 1 root users 123 May  8 2025 script.sh

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The owner is root, and the script is executable (x).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Run the command:&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;chmod u+s script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Check permissions after:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls -l script.sh
-rwsr-xr-x 1 root users 123 May  8 2025 script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The s in rws indicates the setuid bit is set.&lt;/p&gt;

&lt;p&gt;&lt;a id="SGID  (Group Consistency Keeper)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. SGID  (Group Consistency Keeper)
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Set Group ID&lt;/code&gt;&lt;br&gt;
Purpose&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On &lt;strong&gt;files&lt;/strong&gt;: Runs the file with the group ID of the file's group owner.&lt;/li&gt;
&lt;li&gt;On &lt;strong&gt;directories&lt;/strong&gt;: Ensures new files/folders inherit the directory's group ownership.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Real-Life Analogy:&lt;/strong&gt;&lt;br&gt;
You and your coworkers share a project folder. SGID makes sure everything dropped in stays under the same project group, so collaboration is smooth and consistent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir /shared  
chgrp developers /shared  
chmod g+s /shared
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now anything placed in /shared stays in the developers group.&lt;/p&gt;

&lt;p&gt;Set It:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod g+s /some/dir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tip: SGID is your friend when working in /var/www, /projects, or shared Git workspaces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Listing:&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;drwxr-sr-x 2 www-data www-data 4096 May 8 10:30 html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a id="Sticky Bit  (Don't Touch My Stuff!)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Sticky Bit  (Don't Touch My Stuff!)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Purpose:&lt;/strong&gt; &lt;br&gt;
Restricts file deletion in a directory so only the file’s owner (or root) can delete or rename files, even if others have write permission.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-Life Analogy:&lt;/strong&gt;&lt;br&gt;
 Think of a public bulletin board. Everyone can post notes, but only the original author can take theirs down. That’s the sticky bit.&lt;/p&gt;

&lt;p&gt;Set Sticky Bit:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;drwxrwxrwt 10 root root 4096 May 8 10:30 /tmp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See the t at the end? That’s the sticky bit.&lt;/p&gt;

&lt;p&gt;🔧 Set It:&lt;br&gt;
chmod +t /shared-folder&lt;br&gt;
💡 Use this anywhere multiple users need to share space, but still need file safety.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Set Sticky Bit:&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;chmod +t directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example:&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;drwxrwxrwt 10 root root 4096 May 8 10:30 /tmp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;a id="Numeric Representation of Special Permissions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Numeric Representation of Special Permissions
&lt;/h2&gt;

&lt;p&gt;Use octal numbers to combine special permissions with standard ones:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SUID = 4&lt;/li&gt;
&lt;li&gt;SGID = 2&lt;/li&gt;
&lt;li&gt;Sticky Bit = 1&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;4755 myscript.sh   &lt;span class="c"&gt;# Sets SUID&lt;/span&gt;
&lt;span class="nb"&gt;chmod &lt;/span&gt;2755 shared_folder &lt;span class="c"&gt;# Sets SGID&lt;/span&gt;
&lt;span class="nb"&gt;chmod &lt;/span&gt;1777 /tmp          &lt;span class="c"&gt;# Sets Sticky Bit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;a id="Security Importance of Special Permissions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Security Importance of Special Permissions
&lt;/h2&gt;

&lt;p&gt;Special permissions help enforce secure system behavior while allowing necessary flexibility:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SUID&lt;/strong&gt; allows limited privilege escalation. It ensures that users can run specific programs with higher privileges &lt;em&gt;without&lt;/em&gt; granting them full root access. However, misconfigured SUID programs are a common target for attackers to gain unauthorized root access.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SGID&lt;/strong&gt; ensures group consistency, especially in shared development or collaboration directories. It helps prevent users from accidentally assigning wrong group ownership, which could leak sensitive data or cause privilege issues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sticky Bit&lt;/strong&gt; protects shared directories by preventing users from deleting or renaming each other’s files, which is crucial in directories like &lt;code&gt;/tmp&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Best Practices"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best Practices:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Audit SUID and SGID files&lt;/span&gt;
find / &lt;span class="nt"&gt;-perm&lt;/span&gt; /6000 &lt;span class="nt"&gt;-type&lt;/span&gt; f 2&amp;gt;/dev/null

&lt;span class="c"&gt;# Audit Sticky Bit directories&lt;/span&gt;
find / &lt;span class="nt"&gt;-perm&lt;/span&gt; /1000 &lt;span class="nt"&gt;-type&lt;/span&gt; d 2&amp;gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Avoid setting SUID/SGID on scripts, as they are more easily exploited than compiled binaries.&lt;/li&gt;
&lt;li&gt;Use special permissions &lt;strong&gt;only when necessary&lt;/strong&gt; and monitor for unauthorized changes.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;a id="Conclusion"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Special permissions in Linux SUID, SGID, and Sticky Bit are powerful tools for controlling access and behavior in a multi-user environment. They support secure delegation of privileges and controlled collaboration, but they must be used carefully. Misuse or misconfiguration can lead to serious security vulnerabilities. Always apply the principle of least privilege and audit permissions regularly to maintain a secure system.&lt;/p&gt;

&lt;p&gt;I would love to hear your thoughts, experiences, or tips about Linux!&lt;br&gt;
Feel free to share in the comments and join the conversation.&lt;br&gt;
Connect with me on &lt;a href="https://www.linkedin.com/in/olatundesalami" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; !&lt;/p&gt;

&lt;p&gt;#30DaysLinuxChallenge #CloudWhistler #RedHat #Cloudsecurity #DevOps #Linux #OpenSource #CloudComputing #RedHatEnterpriseLinux #SystemLogs #EnterpriseIT #Observability #Logging #SysAdmin #Automation #CloudEngineer #TechForBusiness #ITSupport #SRE #CloudOps&lt;/p&gt;

</description>
      <category>cloudwhistler</category>
      <category>devops</category>
      <category>cloudcomputing</category>
      <category>linux</category>
    </item>
    <item>
      <title>SSH and OpenSSH Overview: Secure Remote Access for Linux</title>
      <dc:creator>Olatunde salami</dc:creator>
      <pubDate>Tue, 06 May 2025 18:43:17 +0000</pubDate>
      <link>https://dev.to/salamilinux/ssh-and-openssh-overview-secure-remote-access-for-linux-4g92</link>
      <guid>https://dev.to/salamilinux/ssh-and-openssh-overview-secure-remote-access-for-linux-4g92</guid>
      <description>&lt;h2&gt;
  
  
  Table Of Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Introduction&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What is SSH?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What is OpenSSH?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Key Components of OpenSSH&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How SSH Works&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Security Importance of SSH&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Best Practices for SSH Security&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Why SSH Matters for Your Linux Challenge&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conclusion&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Introduction"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;As part of my 30 days Linux challenge, understanding SSH (Secure Shell) and its most popular implementation, OpenSSH, is essential. SSH is a cryptographic network protocol that enables secure communication over an unsecured network, commonly used for remote access to Linux systems. OpenSSH is the open source toolset that brings this protocol to life. This article provides an overview of SSH, OpenSSH, their key features, the critical importance of SSH for security, and practical applications for Linux users.&lt;/p&gt;

&lt;p&gt;&lt;a id="What is SSH?"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;SSH is a protocol designed to provide secure, encrypted communication between two systems, typically a client (your local machine) and a server (a remote machine). It was developed in 1995 by Tatu Ylönen as a secure alternative to insecure protocols like Telnet, which transmitted data, including passwords, in plain text. SSH ensures:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Confidentiality:&lt;/strong&gt; Data is encrypted, preventing eavesdropping.&lt;br&gt;
Authentication: Verifies the identity of both client and server.&lt;br&gt;
Integrity: Ensures data isn’t tampered with during transmission.&lt;/p&gt;
&lt;h3&gt;
  
  
  SSH is widely used for:
&lt;/h3&gt;

&lt;p&gt;Remote command-line access to servers.&lt;br&gt;
Secure file transfers (via SCP or SFTP).&lt;br&gt;
Tunneling other protocols securely.&lt;/p&gt;

&lt;p&gt;&lt;a id="What is OpenSSH?"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What is OpenSSH?
&lt;/h2&gt;

&lt;p&gt;OpenSSH is the most widely used open source implementation of the SSH protocol, maintained by the OpenBSD project. It’s pre installed on most Linux distributions and macOS, making it the go to tool for secure remote administration. OpenSSH supports SSH version 2 (SSH-2), which is the current standard due to its enhanced security over the deprecated SSH-1.&lt;/p&gt;

&lt;p&gt;&lt;a id="Key Components of OpenSSH"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Key Components of OpenSSH
&lt;/h3&gt;

&lt;p&gt;OpenSSH provides several tools, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ssh:&lt;/strong&gt; The client program for connecting to a remote server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;sshd:&lt;/strong&gt; The SSH daemon running on the server, listening for incoming connections (default port: 22).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;scp:&lt;/strong&gt; A tool for secure file copying between hosts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;sftp:&lt;/strong&gt; A secure alternative to FTP for file transfers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ssh-keygen:&lt;/strong&gt; Generates public private key pairs for authentication.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ssh-agent:&lt;/strong&gt; Manages private keys for seamless authentication.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ssh-copy-id:&lt;/strong&gt; Simplifies copying public keys to remote servers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="How SSH Works"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  How SSH Works
&lt;/h3&gt;

&lt;p&gt;SSH operates on a client server model using public key cryptography or password based authentication. Here’s a simplified workflow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Connection Initiation:&lt;/strong&gt; The client (your terminal) contacts the server’s SSH daemon (sshd) on port 22.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Key Exchange:&lt;/strong&gt; The client and server negotiate a session key using algorithms like Diffie-Hellman to encrypt the session.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Authentication:&lt;/strong&gt; The client authenticates using:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Password:&lt;/strong&gt; A username and password (less secure, often disabled).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Public-Key:&lt;/strong&gt; A private key on the client and a matching public key on the server (preferred for security).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Secure Session:&lt;/strong&gt; Once authenticated, an encrypted session is established for commands, file transfers, or tunneling.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="The Security Importance of SSH"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  The Security Importance of SSH
&lt;/h3&gt;

&lt;p&gt;SSH is a cornerstone of network security, particularly for Linux systems, due to its ability to protect sensitive data and prevent unauthorized access. Its security features address several critical risks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Protection Against Eavesdropping:&lt;br&gt;
Unlike older protocols like Telnet or FTP, SSH encrypts all data transmitted between client and server. This ensures that sensitive information, such as passwords, configuration files, or proprietary data, cannot be intercepted by attackers on the same network (e.g., public WiFi).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mitigation of Man-in-the-Middle Attacks:&lt;br&gt;
SSH uses host key verification to confirm the server’s identity, preventing attackers from impersonating a legitimate server. Public key authentication further strengthens this by ensuring only authorized clients can connect.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Secure Remote Administration:&lt;br&gt;
System administrators often manage servers located in different geographic regions. SSH allows them to execute commands, update software, or troubleshoot issues remotely without exposing credentials or data to potential threats.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Defense Against Brute force Attacks:&lt;br&gt;
By using key based authentication and disabling password logins, SSH significantly reduces the risk of automated brute force attacks, which target weak passwords.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Secure Data Transfers:&lt;br&gt;
Tools like scp and sftp leverage SSH’s encryption to transfer files securely, protecting sensitive data from interception during transit.&lt;br&gt;
Compliance with Security Standards: Many organizations must comply with regulations like GDPR, HIPAA, or PCI DSS, which mandate secure data transmission. SSH’s robust encryption and authentication mechanisms help meet these requirements.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without SSH, remote access and file transfers would rely on insecure protocols, exposing systems to data breaches, unauthorized access, and other cyber threats. For Linux users, mastering SSH is not just about convenience it’s about safeguarding systems and data in an increasingly connected world.&lt;/p&gt;

&lt;p&gt;&lt;a id="Setting Up OpenSSH on Linux"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Setting Up OpenSSH on Linux
&lt;/h2&gt;

&lt;p&gt;For your Linux challenge, here’s how to get started with OpenSSH:&lt;br&gt;
&lt;strong&gt;1. Install OpenSSH&lt;/strong&gt;&lt;br&gt;
Most Linux distributions include OpenSSH by default. To verify or install:&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 update &amp;amp;&amp;amp; sudo apt install openssh-client openssh-server  # Ubuntu/Debian
sudo dnf install openssh-clients openssh-server  # Fedora/RHEL

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

&lt;/div&gt;



&lt;p&gt;Start and enable the SSH daemon:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl enable sshd
sudo systemctl start sshd

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Connect to a Remote Server&lt;/strong&gt;&lt;br&gt;
Use the ssh command to connect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh username@remote_host

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

&lt;/div&gt;



&lt;p&gt;Example: ssh &lt;a href="mailto:user@192.168.1.100"&gt;user@192.168.1.100&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Generate SSH Keys&lt;/strong&gt;&lt;br&gt;
Passwordless authentication with keys is more secure. Generate a key pair:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-keygen -t ed25519 -C "your_email@example.com"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a private key (&lt;code&gt;~/.ssh/id_ed25519&lt;/code&gt;) and a public key (&lt;code&gt;~/.ssh/id_ed25519.pub&lt;/code&gt;). Copy the public key to the remote server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-copy-id username@remote_host
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you can log in without a password.&lt;br&gt;
&lt;strong&gt;4. Secure File Transfer&lt;/strong&gt;&lt;br&gt;
Copy files securely with scp:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp file.txt username@remote_host:/path/to/destination
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or use sftp for an interactive session:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sftp username@remote_host
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Best Practices for SSH Security
&lt;/h3&gt;

&lt;p&gt;To maximize SSH’s security benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Disable Root Login:&lt;/strong&gt; Edit &lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt; and set &lt;code&gt;PermitRootLogin no&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Change Default Port:&lt;/strong&gt; Modify Port 22 to a non standard port in sshd_config to reduce automated attacks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use Key-Based Authentication:&lt;/strong&gt; Disable password authentication by setting &lt;code&gt;PasswordAuthentication no&lt;/code&gt; in &lt;code&gt;sshd_config&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Enable a Firewall:&lt;/strong&gt; Use &lt;code&gt;ufw&lt;/code&gt; or &lt;code&gt;firewalld&lt;/code&gt; to allow only trusted IP addresses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Keep OpenSSH Updated:&lt;/strong&gt; Regularly update to patch vulnerabilities.&lt;br&gt;
Monitor Logs: Check &lt;code&gt;/var/log/auth.log&lt;/code&gt; or &lt;code&gt;/var/log/secure&lt;/code&gt; for suspicious activity.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Why SSH Matters for Your Linux Challenge"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why SSH Matters for Your Linux Challenge
&lt;/h3&gt;

&lt;p&gt;Mastering SSH and OpenSSH is a cornerstone of Linux administration. Whether you’re managing a home server, deploying applications, or accessing a cloud instance, SSH provides a secure, reliable way to interact with remote systems. Its security features protect against real-world threats, making it indispensable for both personal and professional use. &lt;/p&gt;

&lt;p&gt;&lt;a id="Conclusion"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;SSH, through OpenSSH, is a powerful and essential tool for secure remote access in the Linux ecosystem. Its robust encryption, flexible authentication methods, and versatile utilities make it indispensable for both beginners and advanced users. By emphasizing security, SSH protects systems and data from eavesdropping, unauthorized access, and other threats. Incorporating SSH into your  Linux learning  will equip you with practical skills for managing systems securely and efficiently.&lt;/p&gt;

&lt;p&gt;I would love to hear your thoughts, experiences, or tips about Linux!&lt;br&gt;
Feel free to share in the comments and join the conversation.&lt;br&gt;
Connect with me on &lt;a href="https://www.linkedin.com/in/olatundesalami" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; !&lt;/p&gt;

&lt;p&gt;#30DaysLinuxChallenge #CloudWhistler #RedHat #Cloudsecurity #DevOps #Linux #OpenSource #CloudComputing #RedHatEnterpriseLinux #SystemLogs #EnterpriseIT #Observability #Logging #SysAdmin #Automation #CloudEngineer #TechForBusiness #ITSupport #SRE #CloudOps&lt;/p&gt;

</description>
      <category>cloudwhistler</category>
      <category>devops</category>
      <category>linux</category>
      <category>cloudcomputing</category>
    </item>
    <item>
      <title>The Key to Control: Navigating Users, Groups, and Permissions</title>
      <dc:creator>Olatunde salami</dc:creator>
      <pubDate>Sun, 04 May 2025 09:59:11 +0000</pubDate>
      <link>https://dev.to/salamilinux/the-key-to-control-navigating-users-groups-and-permissions-2nf0</link>
      <guid>https://dev.to/salamilinux/the-key-to-control-navigating-users-groups-and-permissions-2nf0</guid>
      <description>&lt;h2&gt;
  
  
  Table Of Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Introduction&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What Are Users, Groups, and Permissions?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Getting to Know Users&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Permissions: Who’s Allowed to Do What?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Groups: The Cool kid's Club&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Changing Permissions with chmod&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Changing Ownership with chown&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tips for Fellow Beginners&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conclusion&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Introduction"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Welcome to Day 8 of my 30 day Linux challenge! Today, I’m treating a topic that's important to navigating linux effectively : users, groups, and permissions. If you’re new to Linux like me, these might feel like a mystery, but they’re the key to keeping your system organized and secure. Think of it as deciding who gets the keys to your Linux house and what rooms they can enter. In this article, I’ll break it down in simple terms, share my learning curve, my awkward mistake, and make it fun so you’ll want to keep reading!&lt;/p&gt;

&lt;p&gt;&lt;a id="What Are Users, Groups, and Permissions?"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Users, Groups, and Permissions?
&lt;/h2&gt;

&lt;p&gt;Linux is like a big shared apartment building. Users are the people living there (like you or your friend logging in). Groups are like clubs that users can join to share access to certain things. Permissions are the rules about who can open, edit, or delete files and folders. Together, they make sure everyone plays nice and nobody messes with someone else’s stuff.&lt;/p&gt;

&lt;p&gt;For example, I’m the main user on my Linux system (let’s call me “Bigtee”), but I can add other users, like “crew,” and put them in groups to share files. Permissions let me decide if “crew” can just look at my files or edit them too.&lt;/p&gt;

&lt;p&gt;&lt;a id="Getting to Know Users"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting to Know Users
&lt;/h3&gt;

&lt;p&gt;Every time you log into Linux, you’re using a user account. There’s also a super powerful user called root, who can do anything (like the landlord of the building). To see who you are, open the terminal (Ctrl + Alt + T) and type:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To see all users on your system, check the /etc/passwd file:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;p&gt;This lists everyone, including system users (like “nobody” or “daemon”) that Linux uses behind the scenes. Don’t worry about them for now I’m just focusing on my account and maybe a friend’s.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can add a new user with:
&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 crew
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This asks for a password and some details. Now “crew” can log in! I tried this and felt like I was hiring a new teammate for my Linux adventure.&lt;/p&gt;

&lt;p&gt;&lt;a id="Groups: The Cool kid's Club"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Groups: The Cool kid's Club
&lt;/h3&gt;

&lt;p&gt;Groups make sharing easier. Imagine you have a folder of project files you want to share with “crew” but not everyone. You put you and “crew” in a group called “team.” To see what groups you’re in, type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;groups
Bigtee team
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create a group:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo groupadd team
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To add someone to it:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Now “crew” is in the “team” group! I messed up once by forgetting the &lt;strong&gt;-a&lt;/strong&gt; flag and kicked myself out of my own group lesson learned!&lt;/p&gt;

&lt;p&gt;&lt;a id="Permissions: Who’s Allowed to Do What?"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Permissions: Who’s Allowed to Do What?
&lt;/h3&gt;

&lt;p&gt;Permissions are where the fun happens. Every file and folder has rules about who can read (look at it), write (edit it), or execute (run it, like a script). To see permissions, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls -l
-rw-r--r-- 1 Bigtee team 123 may 4 12:00 notes.txt
drwxr-xr-x 2 Bigtee team 4096 may 4 12:00 project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That string of letters (-rw-r--r-- or drwxr-xr-x) is the permission code. Here’s the breakdown:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;First character:&lt;/strong&gt; - means it’s a file, &lt;strong&gt;d&lt;/strong&gt; means it’s a folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Next three:&lt;/strong&gt; Permissions for the owner (e.g., rw- means Bigtee can read and write but not execute).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Middle three:&lt;/strong&gt; Permissions for the group (e.g., r-- means team can only read).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Last three:&lt;/strong&gt; Permissions for everyone else (e.g., r-- means others can read).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, for notes.txt, I (Bigtee) can read and edit it, the “team” group can only read it, and so can everyone else. For the “project” folder, I can do everything, but “team” and others can only look inside and run stuff.&lt;/p&gt;

&lt;p&gt;&lt;a id="Changing Permissions with chmod"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Changing Permissions with chmod
&lt;/h4&gt;

&lt;p&gt;If I want to let “team” edit notes.txt, I change its permissions with chmod (change mode):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod g+w notes.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the group has write access. Check it with ls -l:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-rw-rw-r-- 1 Bigtee team 123 Oct 10 12:00 notes.txt

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

&lt;/div&gt;



&lt;p&gt;You can also use numbers, like chmod 664 notes.txt, where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;6 = read (4) + write (2) for owner and group.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;4 = read for others.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I accidentally made a file executable once &lt;strong&gt;(chmod +x)&lt;/strong&gt; and wondered why it wouldn’t run, turns out it wasn’t a script.&lt;/p&gt;

&lt;p&gt;&lt;a id="Changing Ownership with chown"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Changing Ownership with chown
&lt;/h4&gt;

&lt;p&gt;If I want &lt;strong&gt;“crew”&lt;/strong&gt; to own notes.txt instead of me, I use chown (change owner):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo chown crew notes.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To give it to the “team” group:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo chown :team notes.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I tried this and got confused when permissions didn’t work as expected, i figured I forgot to check the group settings. Always double check!&lt;br&gt;
When I started this topic, I thought permissions would be boring, but it’s like playing gatekeeper for my files! I set up a “crew” user and a “team” group, shared a folder, and felt like a Linux boss. My big oops was changing permissions on a folder and locking myself out thankfully, sudo saved me. The terminal commands (chmod, chown) are starting to feel like second nature, and I’m getting better at spotting mistakes.&lt;/p&gt;

&lt;p&gt;&lt;a id="Tips for Fellow Beginners"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Tips for Fellow Beginners
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Start Small:&lt;/strong&gt;Create a test user and group to practice without risking your main files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Check Before You Change:&lt;/strong&gt;Use ls -l to see permissions before messing with chmod or chown.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use sudo Wisely:&lt;/strong&gt; It’s powerful but can cause chaos if you’re not careful.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Write It Down:&lt;/strong&gt;I keep a notebook with commands like chmod g+w so I don’t forget.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Have Fun:&lt;/strong&gt;Pretend you’re running a secret club it makes permissions way more exciting!&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Conclusion"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Users, groups, and permissions are like the rules of a Linux party who’s invited, who’s in the VIP group, and what they’re allowed to do. As a beginner, I’m fascinated to understand how to keep my system secure and share files like a pro. This Day 8 challenge has me pumped to explore more Linux tricks. If I can figure this out, so can you! Open that terminal, play with some permissions, and let’s keep rocking this Linux journey together.&lt;/p&gt;

&lt;p&gt;I’d love to hear your thoughts, experiences, or tips about Linux!&lt;br&gt;
Feel free to share in the comments and join the conversation.&lt;br&gt;
Connect with me on &lt;a href="https://www.linkedin.com/in/olatundesalami" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; !&lt;/p&gt;

&lt;p&gt;#30DaysLinuxChallenge #CloudWhistler #RedHat #Cloudsecurity #DevOps #Linux #OpenSource #CloudComputing #RedHatEnterpriseLinux #SystemLogs #EnterpriseIT #Observability #Logging #SysAdmin #Automation #CloudEngineer #TechForBusiness #ITSupport #SRE #CloudOps&lt;/p&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>cloudwhistler</category>
      <category>cloudcomputing</category>
    </item>
    <item>
      <title>Command Prompt, the Magical Wand of Linux !</title>
      <dc:creator>Olatunde salami</dc:creator>
      <pubDate>Sat, 03 May 2025 06:52:15 +0000</pubDate>
      <link>https://dev.to/salamilinux/command-prompt-the-magical-wand-of-linux--4f50</link>
      <guid>https://dev.to/salamilinux/command-prompt-the-magical-wand-of-linux--4f50</guid>
      <description>&lt;h2&gt;
  
  
  Table Of Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Introduction&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What is This Magical Wand?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Essential Commands for Beginners&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tips That Saved Me&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;My Experience and Challenges&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conclusion&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Introduction"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Welcome to my 30 days Linux challenge, where I’m waving the magical wand of Linux the command prompt, or as we cool kids call it, the terminal! If you’ve ever stared at that blinking cursor like it’s a cryptic riddle, don’t worry. This wand might not shoot sparkles like  Harry Potters wand, but it casts powerful spells to bend Linux to your will. In this article, I’ll share my journey mastering the terminal, sprinkle some humor to keep you enchanted, and teach you the incantations (aka commands) to wield this magic like a Linux wizard.&lt;/p&gt;

&lt;p&gt;&lt;a id="What is This Magical Wand?"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What is This Magical Wand?
&lt;/h3&gt;

&lt;p&gt;The command prompt is Linux’s spell book, a text based interface where you type commands to make things happen. Want to summon a file?  Need to banish a folder? Abracadabra! Unlike point and click GUIs, the terminal gives you raw, unfiltered control over your system. It’s not like clicking icons it’s more like casting spells to make stuff happen fast.&lt;br&gt;
To open the terminal, press Ctrl + Alt + T (works on most Linux versions like Ubuntu or Fedora) or search for “Terminal” in your apps. You’ll see something like::&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;hostname&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="nx"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That &lt;strong&gt;&lt;em&gt;$&lt;/em&gt;&lt;/strong&gt; means you’re a regular user. A &lt;strong&gt;&lt;em&gt;#&lt;/em&gt;&lt;/strong&gt; means you’re the all-powerful &lt;strong&gt;root&lt;/strong&gt; wizard, Be careful with great power, you could accidentally break your system!&lt;/p&gt;

&lt;p&gt;&lt;a id="Essential Commands for Beginners"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Essential Commands for Beginners
&lt;/h3&gt;

&lt;p&gt;Here are my favourite commands that I’ve been practicing, with examples to help you try them too. I’ve made some mistakes, but that’s how I’m learning!&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Navigating the File System
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;pwd (Print Working Directory)&lt;/strong&gt;:
Shows where you are in your computer’s folders. It’s like a map when you’re lost.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;pwd&lt;/span&gt;
&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;home&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ls (List)&lt;/strong&gt;: Lists files and folders in your current spot.
text
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;ls&lt;/span&gt;
&lt;span class="nx"&gt;documents&lt;/span&gt;  &lt;span class="nx"&gt;downloads&lt;/span&gt;  &lt;span class="nx"&gt;music&lt;/span&gt;  &lt;span class="nx"&gt;spellbook&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;txt&lt;/span&gt;  &lt;span class="nx"&gt;potions&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Try ls -l for more details or ls -a to see hidden files.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;cd (Change Directory)&lt;/strong&gt;: Teleports you to another realm
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;cd&lt;/span&gt; &lt;span class="nx"&gt;documents&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;To go back one folder, use cd ... It’s like hitting the back button.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2.  Managing Files and Directories
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;mkdir (Make Directory)&lt;/strong&gt;: Creates a new directory.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;mkdir&lt;/span&gt; &lt;span class="nx"&gt;my_project&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;means create a directory called my_project&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;touch&lt;/strong&gt;: Creates an empty file.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;touch&lt;/span&gt; &lt;span class="nx"&gt;notes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;cp (Copy)&lt;/strong&gt;: Copies files or directories.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;cp&lt;/span&gt; &lt;span class="nx"&gt;notes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;txt&lt;/span&gt; &lt;span class="nx"&gt;notes_backup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;means copy notes.txt&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;mv (Move)&lt;/strong&gt;: Moves or renames files.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;mv&lt;/span&gt; &lt;span class="nx"&gt;notes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;txt&lt;/span&gt; &lt;span class="nx"&gt;documents&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;notes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;rm (Remove)&lt;/strong&gt;: Deletes files or directories (use with caution!).
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;rm&lt;/span&gt; &lt;span class="nx"&gt;notes_backup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3.Viewing and Editing Files
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;cat: Displays file contents.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;cat&lt;/span&gt; &lt;span class="nx"&gt;notes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;less&lt;/strong&gt;:Views large files one page at a time.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;less&lt;/span&gt; &lt;span class="nx"&gt;long_file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Press &lt;strong&gt;q&lt;/strong&gt; to quit.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;nano&lt;/strong&gt;: A beginner-friendly text editor.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;nano&lt;/span&gt; &lt;span class="nx"&gt;notes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Save with Ctrl + O, exit with Ctrl + X&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  4. System Information
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;whoami&lt;/strong&gt; : Shows your username.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;whoami&lt;/span&gt;
&lt;span class="nx"&gt;user&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;df -h:&lt;/strong&gt; Displays disk space usage in a human-readable format.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;df&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;h&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;free -h&lt;/strong&gt;: Shows memory usage.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;free&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;h&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  5. Permissions and Ownership(&lt;em&gt;Keeping My Files Safe&lt;/em&gt;)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;chmod:&lt;/strong&gt; Changes file permissions.(&lt;em&gt;Controls who can use my files&lt;/em&gt;)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;chmod&lt;/span&gt; &lt;span class="nx"&gt;u&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sh&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;This makes &lt;strong&gt;script.sh&lt;/strong&gt;  executable for the user.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;chown:&lt;/strong&gt; Gives a file to someone else (&lt;em&gt;like sharing a toy&lt;/em&gt;)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;sudo&lt;/span&gt; &lt;span class="nx"&gt;chown&lt;/span&gt; &lt;span class="nx"&gt;user2&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;txt&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;a id="Tips That Saved Me"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Tips That Saved Me
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Press Tab&lt;/strong&gt;: If I start typing a command or file name and hit &lt;strong&gt;&lt;em&gt;Tab&lt;/em&gt;&lt;/strong&gt;, the terminal finishes it for me. It’s like magic!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use man&lt;/strong&gt;: Typing &lt;strong&gt;&lt;em&gt;man ls&lt;/em&gt;&lt;/strong&gt; shows a guide for any command. It’s a bit boring but super helpful.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Try Pipes(|)&lt;/strong&gt;: I can mix commands, like &lt;strong&gt;&lt;em&gt;ls | grep txt&lt;/em&gt;&lt;/strong&gt; to find only text files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Be Careful&lt;/strong&gt;: I almost deleted something important with &lt;strong&gt;&lt;em&gt;rm&lt;/em&gt;&lt;/strong&gt;. Now I double-check everything.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Make Shortcuts&lt;/strong&gt; : I added this to my &lt;strong&gt;&lt;em&gt;~/.bashrc&lt;/em&gt;&lt;/strong&gt; file to make &lt;strong&gt;&lt;em&gt;ls -l&lt;/em&gt;&lt;/strong&gt; just &lt;strong&gt;&lt;em&gt;ll&lt;/em&gt;&lt;/strong&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 javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;alias&lt;/span&gt; &lt;span class="nx"&gt;ll&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ls -l&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;a id="My Experience and Challenges"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  My Experience and Challenges
&lt;/h3&gt;

&lt;p&gt;This 30day challenge has been wild. The first time I typed &lt;strong&gt;&lt;em&gt;ls&lt;/em&gt;&lt;/strong&gt; and felt like a hacker. I remember when i accidentally deleted a file with &lt;strong&gt;&lt;em&gt;rm&lt;/em&gt;&lt;/strong&gt; and just sat there looking for the file, until I figured that I had deleted it earlier . &lt;br&gt;
But by Day 7, I am moving through folders and editing files with &lt;strong&gt;_nano _&lt;/strong&gt;like it was no big deal. The terminal is picky if you misspell something, it won’t work but it’s teaching me to pay attention. Finding &lt;strong&gt;&lt;em&gt;man&lt;/em&gt;&lt;/strong&gt; pages was like discovering a secret library, and now I’m hooked.&lt;/p&gt;

&lt;p&gt;&lt;a id="Conclusion"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Conclusion
&lt;/h4&gt;

&lt;p&gt;Making command prompt my new best friend in Linux has helped me. It’s not as scary as it looks, and with a few commands, 1 can do so much! I’m still a beginner, but I’m excited to keep going in my 30day challenge. I’m excited and looking to explore advanced topics to automate stuff. If you’re new to Linux , embrace the terminal it’s your key to unlocking the power of Linux!&lt;/p&gt;

&lt;p&gt;I’d love to hear your thoughts, experiences, or tips about Linux!&lt;br&gt;
Feel free to share in the comments and join the conversation.&lt;br&gt;
Connect with me on &lt;a href="https://www.linkedin.com/in/olatundesalami" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; !&lt;/p&gt;

&lt;p&gt;#30DaysLinuxChallenge #CloudWhistler #RedHat #Cloudsecurity #DevOps #Linux #OpenSource #CloudComputing #RedHatEnterpriseLinux #SystemLogs #EnterpriseIT #Observability #Logging #SysAdmin #Automation #CloudEngineer #TechForBusiness #ITSupport #SRE #CloudOps&lt;/p&gt;

</description>
      <category>linux</category>
      <category>redhat</category>
      <category>cloudwhistler</category>
      <category>cloudcomputing</category>
    </item>
    <item>
      <title>Taming the Daemons: Mastering Service Control with systemd</title>
      <dc:creator>Olatunde salami</dc:creator>
      <pubDate>Thu, 01 May 2025 16:14:46 +0000</pubDate>
      <link>https://dev.to/salamilinux/taming-the-daemons-mastering-service-control-with-systemd-39ni</link>
      <guid>https://dev.to/salamilinux/taming-the-daemons-mastering-service-control-with-systemd-39ni</guid>
      <description>&lt;p&gt;As a newcomer to Linux, one of the most empowering skills you can learn is managing system services. Whether you're starting a web server, scheduling a backup, or running a database, understanding how to control these services is key. In Linux, systemd is the tool that makes this possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Index
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;What is systemd?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Why You need to Manage Services?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What Preceded systemd?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mastering systemctl&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Troubleshooting Tips&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Summary&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="What is systemd?"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;systemd is a system and service manager for Linux. It’s responsible for starting, stopping, and managing background processes (called services or daemons) that keep your system running. Think of it as the conductor of an orchestra, ensuring all parts of your Linux system like networking, logging, or web servers work together smoothly.&lt;br&gt;
Unlike older systems, systemd is fast, efficient, and widely adopted by distributions like Ubuntu, Fedora, and Debian. As a beginner, learning systemd gives you control over your system’s behavior, from booting up to running critical applications.&lt;/p&gt;

&lt;p&gt;&lt;a id="Why You need to Manage Services?"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Why You need to Manage Services?
&lt;/h3&gt;

&lt;p&gt;Services are programs that run in the background to perform essential tasks. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;nginx or apache2 for hosting websites.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;sshd for remote access via SSH.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;cron for scheduling tasks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;By managing services, you can:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Start or stop them as needed.&lt;br&gt;
Ensure they run automatically at boot.&lt;br&gt;
Troubleshoot issues when something goes wrong.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;All these are necessary in managing your linux service &lt;/p&gt;

&lt;p&gt;&lt;a id="What Preceded systemd?"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  What Preceded systemd?
&lt;/h4&gt;

&lt;p&gt;Before systemd and its systemctl command became the standard for managing services, Linux used other tools to handle system startup and services. Here’s a quick look at the main ones:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SysVinit:&lt;/strong&gt; The classic system, using shell scripts in /etc/init.d/ to start or stop services. It was simple but slow, as services started one at a time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Upstart:&lt;/strong&gt; Developed by Ubuntu, this event-driven system was faster and more flexible, using config files in /etc/init/ to manage services.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;OpenRC:&lt;/strong&gt; A lightweight tool, popular in Gentoo, that combined scripts with better dependency handling for faster startups.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These tools worked but lacked systemd’s speed, advanced features, and unified control, which is why most Linux systems switched to systemd starting around 2010.&lt;/p&gt;

&lt;p&gt;&lt;a id="Mastering systemctl"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Mastering systemctl:
&lt;/h2&gt;

&lt;p&gt;Essential Commands for System Service Control&lt;br&gt;
These systemctl command lets you control services. You’ll often need to run these commands with sudo because managing services requires administrative privileges. Below are the most common tasks you’ll perform as a beginner.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Checking a Service’s Status&lt;/strong&gt;&lt;br&gt;
To see if a service is running, use the status command. For example, to check the status of the SSH service (sshd):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;sudo&lt;/span&gt; &lt;span class="nx"&gt;systemctl&lt;/span&gt; &lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="nx"&gt;sshd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;Whether the service is active (running), inactive, or failed.&lt;/li&gt;
&lt;li&gt;Recent logs to help diagnose issues.&lt;/li&gt;
&lt;li&gt;The service’s process ID (PID). &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you see “active (running),” the service is up and working!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Starting and Stopping a Service&lt;/strong&gt;&lt;br&gt;
To start a service, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;sudo&lt;/span&gt; &lt;span class="nx"&gt;systemctl&lt;/span&gt; &lt;span class="nx"&gt;start&lt;/span&gt; &lt;span class="nx"&gt;sshd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To stop it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;sudo&lt;/span&gt; &lt;span class="nx"&gt;systemctl&lt;/span&gt; &lt;span class="nx"&gt;stop&lt;/span&gt; &lt;span class="nx"&gt;sshd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, if you’re testing a web server like Nginx, you might stop it to free up resources or start it to serve a website. These commands only affect the service’s current state—they don’t change what happens at boot.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Enabling and Disabling Services at Boot&lt;/strong&gt;&lt;br&gt;
Want a service to start automatically when your system boots? Use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;sudo&lt;/span&gt; &lt;span class="nx"&gt;systemctl&lt;/span&gt; &lt;span class="nx"&gt;enable&lt;/span&gt; &lt;span class="nx"&gt;sshd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures the SSH service is always ready when your system starts. To disable autostart:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;sudo&lt;/span&gt; &lt;span class="nx"&gt;systemctl&lt;/span&gt; &lt;span class="nx"&gt;disable&lt;/span&gt; &lt;span class="nx"&gt;sshd&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Disabling a service doesn’t stop it immediately it just prevents it from starting at boot.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Restarting or Reloading a Service&lt;/strong&gt;&lt;br&gt;
Sometimes, you need to restart a service to apply changes. Use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;sudo&lt;/span&gt; &lt;span class="nx"&gt;systemctl&lt;/span&gt; &lt;span class="nx"&gt;restart&lt;/span&gt; &lt;span class="nx"&gt;sshd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This stops and then starts the service. If the service supports reloading (applying changes without stopping), you can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;sudo&lt;/span&gt; &lt;span class="nx"&gt;systemctl&lt;/span&gt; &lt;span class="nx"&gt;reload&lt;/span&gt; &lt;span class="nx"&gt;sshd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reloading is gentler, as it doesn’t interrupt active connections.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Listing All Services&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To see all services on your system, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;systemctl&lt;/span&gt; &lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;units&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;service&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To see only services set to start at boot, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;systemctl&lt;/span&gt; &lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;unit&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;files&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;service&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;enabled&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;These commands help you explore what’s running on your system and understand its components.&lt;/p&gt;

&lt;p&gt;&lt;a id="Troubleshooting Tips"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;## Troubleshooting Tips&lt;/strong&gt;&lt;br&gt;
If a service isn’t working:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Check its status: sudo systemctl status .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Look at logs: journalctl u .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ensure the service is enabled if it needs to start at boot: systemctl is enabled .&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you’re stuck, searching online for the error message (from logs or status) often points to solutions. Linux communities on forums like Stack Exchange are great resources.&lt;/p&gt;

&lt;p&gt;&lt;a id="Summary"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Learning systemd is a gateway to mastering Linux. It gives you control over critical system components, from web servers to databases. As you grow, you’ll use systemd to create custom services, optimize boot times, and manage complex setups. For now, mastering systemctl commands like start, stop, enable, and status is a solid foundation.&lt;/p&gt;

&lt;p&gt;I’d love to hear your thoughts, experiences, or tips about Linux!&lt;br&gt;
Feel free to share in the comments and join the conversation.&lt;br&gt;
Connect with me on &lt;a href="https://www.linkedin.com/in/olatundesalami" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; !&lt;/p&gt;

&lt;p&gt;#30DaysLinuxChallenge #CloudWhistler #RedHat #Cloudsecurity #DevOps #Linux #OpenSource #CloudComputing #RedHatEnterpriseLinux #SystemLogs #EnterpriseIT #Observability #Logging #SysAdmin #Automation #CloudEngineer #TechForBusiness #ITSupport #SRE #CloudOps&lt;/p&gt;

</description>
      <category>cloudwhistler</category>
      <category>linux</category>
      <category>redhat</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
