<?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: Yeasin's </title>
    <description>The latest articles on DEV Community by Yeasin's  (@yeasin4745).</description>
    <link>https://dev.to/yeasin4745</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3237863%2F08ec2a57-9ad3-4bcc-88c6-aef9b3f41a49.png</url>
      <title>DEV Community: Yeasin's </title>
      <link>https://dev.to/yeasin4745</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yeasin4745"/>
    <language>en</language>
    <item>
      <title>Linux File System Structure and Navigation</title>
      <dc:creator>Yeasin's </dc:creator>
      <pubDate>Sun, 11 Oct 2026 17:55:00 +0000</pubDate>
      <link>https://dev.to/yeasin4745/linux-file-system-structure-and-navigation-lb0</link>
      <guid>https://dev.to/yeasin4745/linux-file-system-structure-and-navigation-lb0</guid>
      <description>&lt;p&gt;Every Linux journey starts at the same place: the root directory, written as a single forward slash (&lt;code&gt;/&lt;/code&gt;). Unlike Windows, which scatters files across multiple drives like &lt;code&gt;C:\&lt;/code&gt; and &lt;code&gt;D:\&lt;/code&gt;, Linux organizes &lt;strong&gt;everything&lt;/strong&gt; into one unified tree. Your USB drive, your configuration files, your terminal, even your running processes — they all live somewhere inside that one tree.&lt;/p&gt;

&lt;p&gt;Understanding this structure is not optional knowledge. When an application fails to start, when a disk fills up, or when a security audit asks "who owns this file," the answer is almost always found by navigating the file system confidently. In this article, we'll walk through the Linux directory hierarchy from the top down, then master the commands that let you move through it efficiently.&lt;/p&gt;




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

&lt;p&gt;Linux distributions follow a shared layout called the &lt;strong&gt;Filesystem Hierarchy Standard (FHS)&lt;/strong&gt;, maintained by the Linux Foundation. The FHS defines what each major directory should contain, which means a script you write on Debian will very likely work the same way on Ubuntu, Fedora, or Arch — because &lt;code&gt;/etc&lt;/code&gt; means the same thing everywhere.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The FHS describes conventions, not strict laws. Some distributions and tools make small deviations, but the core layout described below is consistent across virtually all modern Linux systems.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The Root Directory (&lt;code&gt;/&lt;/code&gt;) and Its Key Subdirectories
&lt;/h2&gt;

&lt;p&gt;The top of the entire file system is &lt;code&gt;/&lt;/code&gt; (pronounced "root"). Everything else sits underneath it. Let's look at the directories you'll interact with most often.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Directory&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/home&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Personal user directories (e.g., &lt;code&gt;/home/yeasin&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/root&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Home directory of the root (administrator) user&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;System-wide configuration files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/var&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Variable data: logs, caches, spool files, databases&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/usr&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;User programs, libraries, documentation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/tmp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Temporary files, usually cleared on reboot&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/dev&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Device files representing hardware&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/proc&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Virtual filesystem exposing kernel and process info&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/boot&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Kernel and boot loader files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/opt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Optional/third-party software&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/mnt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Temporary mount point for manually mounted filesystems&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/media&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Auto-mounted removable media (USB drives, DVDs)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;/bin&lt;/code&gt;, &lt;code&gt;/sbin&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Essential user and administrator binaries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/lib&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Shared libraries and kernel modules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/srv&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Data served by the system (e.g., web or FTP content)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/run&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Runtime data since boot (process IDs, sockets)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/home&lt;/code&gt; — Your Personal Space
&lt;/h3&gt;

&lt;p&gt;Each regular user gets a directory here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; /home
&lt;span class="c"&gt;# output:&lt;/span&gt;
&lt;span class="c"&gt;# yeasin&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your documents, downloads, and personal configuration files (the "dotfiles" like &lt;code&gt;~/.bashrc&lt;/code&gt;) all live under &lt;code&gt;/home/yourusername&lt;/code&gt;. This is the only directory where a normal user should freely create and delete files.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/etc&lt;/code&gt; — The Control Room
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;/etc&lt;/code&gt; holds plain-text configuration files for the entire system. This is where you'll go to change hostname settings, configure SSH, or edit system-wide shell behavior:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; /etc | &lt;span class="nb"&gt;head&lt;/span&gt;
&lt;span class="c"&gt;# output (partial):&lt;/span&gt;
&lt;span class="c"&gt;# hostname&lt;/span&gt;
&lt;span class="c"&gt;# hosts&lt;/span&gt;
&lt;span class="c"&gt;# fstab&lt;/span&gt;
&lt;span class="c"&gt;# ssh&lt;/span&gt;
&lt;span class="c"&gt;# passwd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; Editing files in &lt;code&gt;/etc&lt;/code&gt; affects the whole system. A typo in a file like &lt;code&gt;/etc/fstab&lt;/code&gt; can prevent your system from booting. Always back up a config file before modifying it:&lt;/p&gt;


&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo cp&lt;/span&gt; /etc/fstab /etc/fstab.bak
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/var&lt;/code&gt; — Data That Changes
&lt;/h3&gt;

&lt;p&gt;The name stands for "variable" — data that grows and changes while the system runs. The most important subdirectory for daily administration is &lt;code&gt;/var/log&lt;/code&gt;, where the system writes its logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; /var/log
&lt;span class="c"&gt;# output (partial):&lt;/span&gt;
&lt;span class="c"&gt;# auth.log&lt;/span&gt;
&lt;span class="c"&gt;# syslog&lt;/span&gt;
&lt;span class="c"&gt;# dmesg&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When something breaks, &lt;code&gt;/var/log&lt;/code&gt; is usually the first place to investigate.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/tmp&lt;/code&gt; — Use It, Don't Trust It
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;/tmp&lt;/code&gt; is world-writable and intended for short-lived files. On most modern distributions (including Debian and Ubuntu using &lt;code&gt;systemd&lt;/code&gt;), its contents are cleared on every reboot. Never store anything there that you want to keep.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/proc&lt;/code&gt; and &lt;code&gt;/dev&lt;/code&gt; — Files That Aren't Files
&lt;/h3&gt;

&lt;p&gt;This is where Linux gets interesting. &lt;code&gt;/proc&lt;/code&gt; is a &lt;strong&gt;virtual filesystem&lt;/strong&gt; — it doesn't exist on disk. The kernel generates its contents in memory to expose live system information as if it were files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /proc/cpuinfo        &lt;span class="c"&gt;# live CPU information&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /proc/meminfo        &lt;span class="c"&gt;# live memory usage&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; /proc/self            &lt;span class="c"&gt;# info about the currently running shell process&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Similarly, &lt;code&gt;/dev&lt;/code&gt; contains &lt;strong&gt;device files&lt;/strong&gt;. Your terminal, your disks, and &lt;code&gt;/dev/null&lt;/code&gt; (the famous "black hole" that discards anything written to it) all appear here as files. This "everything is a file" design is one of Linux's most powerful ideas.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/usr&lt;/code&gt; and the Merged &lt;code&gt;/bin&lt;/code&gt;, &lt;code&gt;/sbin&lt;/code&gt;, &lt;code&gt;/lib&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Historically, &lt;code&gt;/bin&lt;/code&gt; held essential command binaries and &lt;code&gt;/usr/bin&lt;/code&gt; held less critical programs. Modern Debian (since Debian 11 "Bullseye") and Ubuntu (since 19.04) implement &lt;strong&gt;usrmerge&lt;/strong&gt;: &lt;code&gt;/bin&lt;/code&gt;, &lt;code&gt;/sbin&lt;/code&gt;, and &lt;code&gt;/lib&lt;/code&gt; are now symlinks pointing into &lt;code&gt;/usr&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; /bin
&lt;span class="c"&gt;# output:&lt;/span&gt;
&lt;span class="c"&gt;# lrwxrwxrwx 1 root root 7 ... /bin -&amp;gt; usr/bin&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can still type &lt;code&gt;/bin/bash&lt;/code&gt; and it works — but on modern systems, the real files live under &lt;code&gt;/usr/bin&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Absolute vs. Relative Paths
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;path&lt;/strong&gt; describes a file or directory's location in the tree. There are two kinds:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Absolute path&lt;/strong&gt; — starts from &lt;code&gt;/&lt;/code&gt;. It works from anywhere:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Relative path&lt;/strong&gt; — starts from your current location. It only works relative to where you are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;log        &lt;span class="c"&gt;# only works if you're already inside /var&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two special notations power relative paths:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symbol&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The current directory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;..&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The parent directory (one level up)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;~&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Your home directory (shortcut)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The previous directory you were in (with &lt;code&gt;cd&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So if you are in &lt;code&gt;/var/log&lt;/code&gt;, then &lt;code&gt;..&lt;/code&gt; means &lt;code&gt;/var&lt;/code&gt;, and &lt;code&gt;../spool&lt;/code&gt; means &lt;code&gt;/var/spool&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Navigation Commands You'll Use Every Day
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;pwd&lt;/code&gt; — Where Am I?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;pwd&lt;/code&gt; (print working directory) shows your absolute current location:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;
&lt;span class="c"&gt;# output:&lt;/span&gt;
&lt;span class="c"&gt;# /var/log&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The prompt often shows your location, but &lt;code&gt;pwd&lt;/code&gt; is the definitive answer. Use it whenever you're disoriented.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;cd&lt;/code&gt; — Change Directory
&lt;/h3&gt;

&lt;p&gt;The workhorse of navigation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /etc              &lt;span class="c"&gt;# go to /etc (absolute)&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;ssh               &lt;span class="c"&gt;# go to ./ssh (relative)&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ..                &lt;span class="c"&gt;# go up one level&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt;                   &lt;span class="c"&gt;# go to your home directory&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ~                 &lt;span class="c"&gt;# same as above&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; -                 &lt;span class="c"&gt;# go back to the previous directory&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; /home/yeasin/Documents   &lt;span class="c"&gt;# jump anywhere with an absolute path&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A useful habit: after &lt;code&gt;cd -&lt;/code&gt;, bash prints the directory you switched to, which is handy for bouncing between two distant locations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /var/log
&lt;span class="nb"&gt;cd&lt;/span&gt; /etc
&lt;span class="nb"&gt;cd&lt;/span&gt; -
&lt;span class="c"&gt;# output:&lt;/span&gt;
&lt;span class="c"&gt;# /var/log&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;ls&lt;/code&gt; — Look Around
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;ls&lt;/code&gt; lists directory contents. Its most useful flags:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt;                  &lt;span class="c"&gt;# basic listing&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;               &lt;span class="c"&gt;# long format: permissions, owner, size, date&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt;               &lt;span class="c"&gt;# include hidden files (starting with .)&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt;              &lt;span class="c"&gt;# both combined&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-lh&lt;/span&gt;              &lt;span class="c"&gt;# long format with human-readable sizes (K, M, G)&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt;               &lt;span class="c"&gt;# recursive listing of subdirectories&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-ld&lt;/span&gt; /var         &lt;span class="c"&gt;# details of the directory itself, not its contents&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-lt&lt;/span&gt;              &lt;span class="c"&gt;# sort by modification time, newest first&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-lh&lt;/span&gt; /etc/hostname
&lt;span class="c"&gt;# output:&lt;/span&gt;
&lt;span class="c"&gt;# -rw-r--r-- 1 root root 8 Oct 12 09:41 /etc/hostname&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; Files whose names begin with a dot (like &lt;code&gt;.bashrc&lt;/code&gt;) are hidden from normal &lt;code&gt;ls&lt;/code&gt; output. Use &lt;code&gt;ls -a&lt;/code&gt; to see them. Most of your shell's personal configuration lives in these files.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;tree&lt;/code&gt; — See the Structure at a Glance
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;tree&lt;/code&gt; displays directories as an indented hierarchy — excellent for exploring unfamiliar territory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tree &lt;span class="nt"&gt;-L&lt;/span&gt; 2 /etc/ssh
&lt;span class="c"&gt;# output:&lt;/span&gt;
&lt;span class="c"&gt;# /etc/ssh&lt;/span&gt;
&lt;span class="c"&gt;# ├── moduli&lt;/span&gt;
&lt;span class="c"&gt;# ├── ssh_config&lt;/span&gt;
&lt;span class="c"&gt;# ├── sshd_config&lt;/span&gt;
&lt;span class="c"&gt;# └── ssh_host_rsa_key&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Debian/Ubuntu, install it first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;tree
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-L&lt;/code&gt; flag limits the depth, which keeps output readable on large directories.&lt;/p&gt;




&lt;h2&gt;
  
  
  Practical Workflow: Exploring an Unfamiliar System
&lt;/h2&gt;

&lt;p&gt;Here's a realistic scenario: you've just logged into a new server and need to get oriented.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 — Confirm where you are and who you are:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2 — Check the top-level layout and disk usage:&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;ls&lt;/span&gt; /
&lt;span class="nb"&gt;df&lt;/span&gt; &lt;span class="nt"&gt;-h&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3 — Investigate the logs to see the system's recent activity:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4 — Check what services are configured:&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;ls&lt;/span&gt; /etc/ssh
&lt;span class="nb"&gt;cat&lt;/span&gt; /etc/hostname
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Within a minute, you know the OS layout, available disk space, recent log activity, and configured services — all through navigation alone.&lt;/p&gt;




&lt;h2&gt;
  
  
  Common Mistakes and Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Mistake 1: Confusing &lt;code&gt;/root&lt;/code&gt; with &lt;code&gt;/&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/&lt;/code&gt; is the root of the entire file system. &lt;code&gt;/root&lt;/code&gt; is the home directory of the administrator user. They look similar but are completely different places.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mistake 2: Spaces in paths&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /home/yeasin/My Documents
&lt;span class="c"&gt;# bash: cd: too many arguments&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The shell splits arguments at spaces. Quote the path instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"/home/yeasin/My Documents"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Mistake 3: Assuming &lt;code&gt;.&lt;/code&gt; is always safe in scripts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A relative path like &lt;code&gt;./script.sh&lt;/code&gt; depends on the current directory. In scripts, prefer absolute paths for anything critical.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mistake 4: Forgetting that &lt;code&gt;cd&lt;/code&gt; requires execute permission on the target&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To &lt;code&gt;cd&lt;/code&gt; into a directory, you need &lt;strong&gt;execute&lt;/strong&gt; (&lt;code&gt;x&lt;/code&gt;) permission on it — not read. If you get &lt;code&gt;Permission denied&lt;/code&gt; while navigating, check permissions with &lt;code&gt;ls -ld /path/to/dir&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mistake 5: Editing files in &lt;code&gt;/etc&lt;/code&gt; without a backup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Covered above, but worth repeating: this is the single most common way beginners break a working system.&lt;/p&gt;




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

&lt;ul&gt;
&lt;li&gt;Linux uses &lt;strong&gt;one unified tree&lt;/strong&gt; rooted at &lt;code&gt;/&lt;/code&gt;, standardized by the &lt;strong&gt;FHS&lt;/strong&gt; — no drive letters.&lt;/li&gt;
&lt;li&gt;Learn the core directories: &lt;code&gt;/etc&lt;/code&gt; for config, &lt;code&gt;/var/log&lt;/code&gt; for logs, &lt;code&gt;/home&lt;/code&gt; for users, &lt;code&gt;/proc&lt;/code&gt; for live kernel data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Absolute paths&lt;/strong&gt; start with &lt;code&gt;/&lt;/code&gt;; &lt;strong&gt;relative paths&lt;/strong&gt; depend on your current location. &lt;code&gt;..&lt;/code&gt;, &lt;code&gt;~&lt;/code&gt;, and &lt;code&gt;-&lt;/code&gt; are your shortcuts.&lt;/li&gt;
&lt;li&gt;Master &lt;code&gt;pwd&lt;/code&gt;, &lt;code&gt;cd&lt;/code&gt;, &lt;code&gt;ls&lt;/code&gt;, and &lt;code&gt;tree&lt;/code&gt; — these four commands cover 95% of daily navigation.&lt;/li&gt;
&lt;li&gt;Modern Debian and Ubuntu merge &lt;code&gt;/bin&lt;/code&gt;, &lt;code&gt;/sbin&lt;/code&gt;, and &lt;code&gt;/lib&lt;/code&gt; into &lt;code&gt;/usr&lt;/code&gt;; the old paths still work as symlinks.&lt;/li&gt;
&lt;li&gt;Before editing anything in &lt;code&gt;/etc&lt;/code&gt;, make a backup copy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The file system hierarchy rewards curiosity. The next time you're unsure what something does, &lt;code&gt;cd&lt;/code&gt; into it, &lt;code&gt;ls&lt;/code&gt; it, and &lt;code&gt;cat&lt;/code&gt; the files. On Linux, the system rarely hides from you — you just need to know where to walk.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;What directory confused you the most when you started with Linux? Share it in the comments — it's probably someone else's question too.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>sysadmi</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Managing Users and Groups in Linux: A Beginner-Friendly Guide</title>
      <dc:creator>Yeasin's </dc:creator>
      <pubDate>Sat, 10 Oct 2026 01:57:40 +0000</pubDate>
      <link>https://dev.to/yeasin4745/managing-users-and-groups-in-linux-a-beginner-friendly-guide-39l6</link>
      <guid>https://dev.to/yeasin4745/managing-users-and-groups-in-linux-a-beginner-friendly-guide-39l6</guid>
      <description>&lt;p&gt;Linux is a multi-user system. That means many people (and many programs) can use the same computer at the same time — but each one gets its own separate identity and its own limits.&lt;/p&gt;

&lt;p&gt;Every person who logs in, and every service that runs in the background, has its own &lt;strong&gt;user account&lt;/strong&gt;. This is how Linux decides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which files you can open&lt;/li&gt;
&lt;li&gt;Which programs you can run&lt;/li&gt;
&lt;li&gt;Who is allowed to use &lt;code&gt;sudo&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Which service can touch which files&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to manage a Linux server — or even just understand your own system better — users and groups are the first thing you need to learn.&lt;/p&gt;

&lt;p&gt;In this guide, we will go step by step: what users and groups are, where Linux stores this information, and how to create, change, and delete them safely.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is a User in Linux?
&lt;/h2&gt;

&lt;p&gt;When you create a user, Linux gives that user two important numbers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;UID (User ID)&lt;/strong&gt; — a unique number for the user&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GID (Group ID)&lt;/strong&gt; — a unique number for the user's main group&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your username is just a friendly label. Deep inside, Linux only cares about the numbers.&lt;/p&gt;

&lt;p&gt;For example, when the system checks if you can open a file, it looks at your UID — not your name.&lt;/p&gt;

&lt;p&gt;Linux has three main types of users:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;UID&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Root user&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;root&lt;/code&gt; — the superuser, can do anything&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;System users&lt;/td&gt;
&lt;td&gt;1–999&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;www-data&lt;/code&gt;, &lt;code&gt;mysql&lt;/code&gt;, &lt;code&gt;sshd&lt;/code&gt; — used by services&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Normal users&lt;/td&gt;
&lt;td&gt;1000+&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;yeasin&lt;/code&gt;, &lt;code&gt;rahim&lt;/code&gt; — real humans&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; On Debian and Ubuntu, the first normal user you create during installation gets UID 1000.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  What Is a Group?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;group&lt;/strong&gt; is a collection of users. It makes sharing easy.&lt;/p&gt;

&lt;p&gt;Example: you have a folder that only the "developers" team should edit. Instead of giving permission to each person one by one, you put them all in one group and give permission to that group.&lt;/p&gt;

&lt;p&gt;Every user has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One primary group&lt;/strong&gt; — usually a group with the same name as the user. New files you create belong to this group.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero or more secondary groups&lt;/strong&gt; — extra groups you join, like &lt;code&gt;sudo&lt;/code&gt; or &lt;code&gt;docker&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Where Linux Stores User Information
&lt;/h2&gt;

&lt;p&gt;All user and group information lives in simple text files inside the &lt;code&gt;/etc&lt;/code&gt; directory:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;File&lt;/th&gt;
&lt;th&gt;What it contains&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc/passwd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;All users: name, UID, home folder, shell&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc/shadow&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Encrypted passwords (only root can read it)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc/group&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;All groups and their members&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Let's look at one line from &lt;code&gt;/etc/passwd&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yeasin\:x:1000:1000\:MD Yeasin Ali:/home/yeasin:/bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each part has a meaning, separated by &lt;code&gt;:&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;yeasin&lt;/code&gt; — username&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;x&lt;/code&gt; — password is stored in &lt;code&gt;/etc/shadow&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;1000&lt;/code&gt; — UID&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;1000&lt;/code&gt; — GID of the primary group&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;MD Yeasin Ali&lt;/code&gt; — full name / comment&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/home/yeasin&lt;/code&gt; — home directory&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/bin/bash&lt;/code&gt; — the shell used at login&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; Never edit these files by hand with a normal editor. One small mistake can lock you out of your whole system. Always use the commands shown below.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Creating a New User
&lt;/h2&gt;

&lt;p&gt;Debian and Ubuntu have two commands for this, and mixing them up is very common.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option 1: &lt;code&gt;adduser&lt;/code&gt; — the easy way (recommended for beginners)
&lt;/h3&gt;



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

&lt;/div&gt;



&lt;p&gt;The command will ask you a few questions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Adding user 'rahim' ...
Adding new group 'rahim' (1001) ...
Creating home directory '/home/rahim' ...
Copying files from '/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for rahim
Enter the new value, or press ENTER for the default
  Full Name []: Rahim Uddin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. &lt;code&gt;adduser&lt;/code&gt; does everything for you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates the user&lt;/li&gt;
&lt;li&gt;Creates a private group with the same name&lt;/li&gt;
&lt;li&gt;Creates the home directory&lt;/li&gt;
&lt;li&gt;Copies default files from &lt;code&gt;/etc/skel&lt;/code&gt; (like &lt;code&gt;.bashrc&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Sets the password&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; &lt;code&gt;/etc/skel&lt;/code&gt; is the "skeleton" folder. Anything you put there is automatically copied into every new user's home directory. Great for default configs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Option 2: &lt;code&gt;useradd&lt;/code&gt; — the manual way
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;useradd&lt;/code&gt; is the basic, low-level command. By default it does very little — no home directory, no password. You have to ask for everything yourself:&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;useradd &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; /bin/bash &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"Rahim Uddin"&lt;/span&gt; rahim
&lt;span class="nb"&gt;sudo &lt;/span&gt;passwd rahim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Flag&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-m&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Create the home directory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-s&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Set the login shell&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-c&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Add a full name / comment&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-u&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Use a specific UID&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-e&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Set an expiry date for the account&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; On Debian and Ubuntu, &lt;code&gt;adduser&lt;/code&gt; is friendly and interactive. On other distros (like Fedora), &lt;code&gt;adduser&lt;/code&gt; behaves like &lt;code&gt;useradd&lt;/code&gt;. So it's good to know both commands.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Creating a user for a service (not a human)
&lt;/h3&gt;

&lt;p&gt;When you deploy your own app, never run it as root. Create a special system user for 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;adduser &lt;span class="nt"&gt;--system&lt;/span&gt; &lt;span class="nt"&gt;--group&lt;/span&gt; &lt;span class="nt"&gt;--no-create-home&lt;/span&gt; &lt;span class="nt"&gt;--shell&lt;/span&gt; /usr/sbin/nologin myapp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your app can run as &lt;code&gt;myapp&lt;/code&gt;, with the minimum possible permissions. If an attacker ever compromises the app, they only get the &lt;code&gt;myapp&lt;/code&gt; account — not root.&lt;/p&gt;




&lt;h2&gt;
  
  
  Changing an Existing User
&lt;/h2&gt;

&lt;p&gt;Use &lt;code&gt;usermod&lt;/code&gt; to change a user's settings:&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;# Add user to a group (secondary group)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; docker rahim

&lt;span class="c"&gt;# Change the username&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-l&lt;/span&gt; newname oldname

&lt;span class="c"&gt;# Change the home directory and move the files&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-d&lt;/span&gt; /home/newname &lt;span class="nt"&gt;-m&lt;/span&gt; newname

&lt;span class="c"&gt;# Lock the account (user cannot log in)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-L&lt;/span&gt; rahim

&lt;span class="c"&gt;# Unlock the account&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-U&lt;/span&gt; rahim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; With &lt;code&gt;-G&lt;/code&gt;, always include &lt;code&gt;-a&lt;/code&gt; (append). &lt;code&gt;sudo usermod -G docker rahim&lt;/code&gt; &lt;strong&gt;without&lt;/strong&gt; &lt;code&gt;-a&lt;/code&gt; removes rahim from all his other groups — including &lt;code&gt;sudo&lt;/code&gt;. That can lock you out of admin access on your own machine. Write it as &lt;code&gt;-aG&lt;/code&gt;, always.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Deleting a User
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Delete the user, keep the home directory&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;userdel rahim

&lt;span class="c"&gt;# Delete the user AND the home directory&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;userdel &lt;span class="nt"&gt;-r&lt;/span&gt; rahim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before deleting, it's smart to check what files the user still owns:&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;find / &lt;span class="nt"&gt;-user&lt;/span&gt; rahim 2&amp;gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you delete a user but keep their files, those files will show a number instead of a name:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;That &lt;code&gt;1001&lt;/code&gt; is the old UID. If a new user gets UID 1001 later, they suddenly own those files. So either delete the files or give them to someone else first.&lt;/p&gt;




&lt;h2&gt;
  
  
  Managing Groups
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Create a group
&lt;/h3&gt;



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

&lt;/div&gt;



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



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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Add a user to a group
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; developers rahim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or with &lt;code&gt;gpasswd&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;gpasswd &lt;span class="nt"&gt;-a&lt;/span&gt; rahim developers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Remove a user from a group
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;gpasswd &lt;span class="nt"&gt;-d&lt;/span&gt; rahim developers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Check which groups a user belongs to
&lt;/h3&gt;



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

&lt;/div&gt;



&lt;p&gt;Or get full details:&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;id &lt;/span&gt;rahim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uid=1002(rahim) gid=1002(rahim) groups=1002(rahim),27(sudo),1001(developers)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Group changes apply on the &lt;strong&gt;next login&lt;/strong&gt;. If you just added yourself to a group in your current session, log out and log back in for it to take effect.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The &lt;code&gt;sudo&lt;/code&gt; group is special
&lt;/h3&gt;

&lt;p&gt;On Debian and Ubuntu, anyone in the &lt;code&gt;sudo&lt;/code&gt; group can use &lt;code&gt;sudo&lt;/code&gt;. That's the whole mechanism. Want to make someone an admin? Just:&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;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;rahim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Real-World Example: A Shared Project Folder
&lt;/h2&gt;

&lt;p&gt;Let's put it all together with a common real situation.&lt;/p&gt;

&lt;p&gt;Your team has a folder, and three people need to edit the same files. Here's how to set it up cleanly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 — Create a shared group:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2 — Add the users to the group:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; webteam yeasin
&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; webteam rahim
&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; webteam karim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3 — Create the folder and give it to the group:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /srv/webproject
&lt;span class="nb"&gt;sudo chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; &lt;span class="se"&gt;\:&lt;/span&gt;webteam /srv/webproject
&lt;span class="nb"&gt;sudo chmod&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; 2775 /srv/webproject
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What does &lt;code&gt;2775&lt;/code&gt; mean?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;2775&lt;/code&gt; = special bit &lt;code&gt;2&lt;/code&gt; + normal permissions &lt;code&gt;775&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;2&lt;/code&gt; is the &lt;strong&gt;setgid bit&lt;/strong&gt;. It makes every new file inside this folder automatically belong to &lt;code&gt;webteam&lt;/code&gt;, no matter who creates it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;775&lt;/code&gt; means: owner can do everything, group members can do everything, others can only read and open the folder.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 4 — Verify:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;drwxrwsr-x 2 root webteam 4096 Oct 10 12:00 /srv/webproject
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when rahim creates a file, karim can edit it too — automatically. No manual permission fixing needed.&lt;/p&gt;




&lt;h2&gt;
  
  
  Common Mistakes and Fixes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Using &lt;code&gt;usermod -G&lt;/code&gt; without &lt;code&gt;-a&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This removes the user from all their other groups. Fix it by adding them back:&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;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;rahim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Editing &lt;code&gt;/etc/passwd&lt;/code&gt; by hand&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One typo and you may not be able to log in anymore. If you must edit it, use the safe tools:&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;vipw
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;vipw&lt;/code&gt; checks the file for mistakes before saving.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. "I'm in the group, but I still get permission denied"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Group changes need a new login. Log out and back in — or use this for a quick fix:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. A deleted user's files show numbers instead of names&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The UID no longer matches any user. Delete those files, or give them a new owner:&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 chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; yeasin&lt;span class="se"&gt;\:&lt;/span&gt;yeasin /var/oldstuff
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Checking why a user cannot log in&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;getent passwd rahim     &lt;span class="c"&gt;# is the shell set to nologin?&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;passwd &lt;span class="nt"&gt;-S&lt;/span&gt; rahim    &lt;span class="c"&gt;# is the account locked?&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;chage &lt;span class="nt"&gt;-l&lt;/span&gt; rahim     &lt;span class="c"&gt;# any expiry date?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






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

&lt;p&gt;Here are the key points from this guide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linux identifies every user by a &lt;strong&gt;UID&lt;/strong&gt;, and permissions are always checked against numbers, not names.&lt;/li&gt;
&lt;li&gt;User data lives in &lt;code&gt;/etc/passwd&lt;/code&gt;, &lt;code&gt;/etc/shadow&lt;/code&gt;, and &lt;code&gt;/etc/group&lt;/code&gt; — never edit them by hand.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;&lt;code&gt;adduser&lt;/code&gt;&lt;/strong&gt; for easy, interactive user creation on Debian/Ubuntu.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;&lt;code&gt;usermod -aG&lt;/code&gt;&lt;/strong&gt; to add users to groups — never forget the &lt;code&gt;-a&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;&lt;code&gt;sudo&lt;/code&gt; group&lt;/strong&gt; is what gives someone admin power.&lt;/li&gt;
&lt;li&gt;Create a &lt;strong&gt;separate system user&lt;/strong&gt; for every service you deploy.&lt;/li&gt;
&lt;li&gt;Use the &lt;strong&gt;setgid bit (&lt;code&gt;2775&lt;/code&gt;)&lt;/strong&gt; on shared folders so group permissions flow automatically to new files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you understand users and groups, everything else in Linux security starts to make sense — because almost every permission question comes down to one simple thing: &lt;em&gt;who is asking, and are they allowed?&lt;/em&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>ubuntu</category>
      <category>yeasin4745</category>
      <category>sysadmin</category>
    </item>
    <item>
      <title>Linux File Permissions: Understanding chmod and chown</title>
      <dc:creator>Yeasin's </dc:creator>
      <pubDate>Thu, 08 Oct 2026 12:33:52 +0000</pubDate>
      <link>https://dev.to/yeasin4745/linux-file-permissions-understanding-chmod-and-chown-5e6k</link>
      <guid>https://dev.to/yeasin4745/linux-file-permissions-understanding-chmod-and-chown-5e6k</guid>
      <description>&lt;p&gt;If you have ever seen the error &lt;strong&gt;"Permission denied"&lt;/strong&gt; on a Linux system, you have already met file permissions. Every file and directory on a Linux system has an owner, a group, and a set of permissions that decide exactly who can read, write, or execute it.&lt;/p&gt;

&lt;p&gt;Understanding &lt;code&gt;chmod&lt;/code&gt; and &lt;code&gt;chown&lt;/code&gt; is one of the most practical skills for any Linux user, developer, or system administrator. In this article, we will break it down step by step.&lt;/p&gt;




&lt;h2&gt;
  
  
  How Linux Views File Permissions
&lt;/h2&gt;

&lt;p&gt;Run this command on any file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will see something like this:&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="nt"&gt;-rw-r--r--&lt;/span&gt; 1 deploy deploy 2048 Oct  8 10:24 file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first part (&lt;code&gt;-rw-r--r--&lt;/code&gt;) is the permission string. Let's decode it:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Position&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1st character&lt;/td&gt;
&lt;td&gt;File type (&lt;code&gt;-&lt;/code&gt; = file, &lt;code&gt;d&lt;/code&gt; = directory, &lt;code&gt;l&lt;/code&gt; = symlink)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Characters 2–4&lt;/td&gt;
&lt;td&gt;Permissions for the &lt;strong&gt;owner&lt;/strong&gt; (&lt;code&gt;rw-&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Characters 5–7&lt;/td&gt;
&lt;td&gt;Permissions for the &lt;strong&gt;group&lt;/strong&gt; (&lt;code&gt;r--&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Characters 8–10&lt;/td&gt;
&lt;td&gt;Permissions for &lt;strong&gt;others&lt;/strong&gt; (&lt;code&gt;r--&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each permission has a meaning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;r (read)&lt;/strong&gt; — view the file contents (or list a directory)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;w (write)&lt;/strong&gt; — modify the file (or create/delete files inside a directory)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;x (execute)&lt;/strong&gt; — run the file as a program (or enter a directory)&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; For directories, &lt;code&gt;x&lt;/code&gt; means "can enter". Without it, you cannot &lt;code&gt;cd&lt;/code&gt; into the directory, even if you can read it.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  chown: Changing Ownership
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;chown&lt;/code&gt; command changes who owns a file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic syntax:&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;chown &lt;/span&gt;owner&lt;span class="se"&gt;\:&lt;/span&gt;group file
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Practical 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="c"&gt;# Change the owner to "deploy"&lt;/span&gt;
&lt;span class="nb"&gt;sudo chown &lt;/span&gt;deploy file.txt

&lt;span class="c"&gt;# Change both owner and group&lt;/span&gt;
&lt;span class="nb"&gt;sudo chown &lt;/span&gt;deploy&lt;span class="se"&gt;\:&lt;/span&gt;deploy file.txt

&lt;span class="c"&gt;# Recursively change ownership of a whole directory&lt;/span&gt;
&lt;span class="nb"&gt;sudo chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; deploy&lt;span class="se"&gt;\:&lt;/span&gt;deploy /var/www/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; &lt;code&gt;chown&lt;/code&gt; usually requires &lt;code&gt;sudo&lt;/code&gt;. Be careful with &lt;code&gt;-R&lt;/code&gt; — it changes everything inside the directory, including files you may not expect. A wrong recursive &lt;code&gt;chown&lt;/code&gt; on a system directory can break your system.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  chmod: Changing Permissions
&lt;/h2&gt;

&lt;p&gt;While &lt;code&gt;chown&lt;/code&gt; decides &lt;strong&gt;who&lt;/strong&gt;, &lt;code&gt;chmod&lt;/code&gt; decides &lt;strong&gt;what&lt;/strong&gt; they can do.&lt;/p&gt;

&lt;p&gt;There are two ways to use &lt;code&gt;chmod&lt;/code&gt;:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Symbolic Mode (letters)
&lt;/h3&gt;



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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;u&lt;/code&gt; = owner (user), &lt;code&gt;g&lt;/code&gt; = group, &lt;code&gt;o&lt;/code&gt; = others, &lt;code&gt;a&lt;/code&gt; = all&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;+&lt;/code&gt; adds a permission, &lt;code&gt;-&lt;/code&gt; removes it, &lt;code&gt;=&lt;/code&gt; sets it exactly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples:&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;u+x script.sh       &lt;span class="c"&gt;# Owner can execute&lt;/span&gt;
&lt;span class="nb"&gt;chmod &lt;/span&gt;g-w file.txt        &lt;span class="c"&gt;# Remove write from group&lt;/span&gt;
&lt;span class="nb"&gt;chmod &lt;/span&gt;&lt;span class="nv"&gt;a&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;r file.txt        &lt;span class="c"&gt;# Everyone can only read&lt;/span&gt;
&lt;span class="nb"&gt;chmod &lt;/span&gt;&lt;span class="nv"&gt;u&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;rwx,g&lt;span class="o"&gt;=&lt;/span&gt;rx,o&lt;span class="o"&gt;=&lt;/span&gt; file.txt  &lt;span class="c"&gt;# Full control for owner, read+execute for group, nothing for others&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Numeric (Octal) Mode
&lt;/h3&gt;

&lt;p&gt;Each permission has a value:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;r&lt;/code&gt; = 4&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;w&lt;/code&gt; = 2&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;x&lt;/code&gt; = 1&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You add them up for each category (owner, group, others):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Number&lt;/th&gt;
&lt;th&gt;Permission&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;rwx (4+2+1)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;rw- (4+2)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;r-x (4+1)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;r--&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;---&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So:&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;755 script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Owner:&lt;/strong&gt; 7 → read, write, execute&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Group:&lt;/strong&gt; 5 → read, execute&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Others:&lt;/strong&gt; 5 → read, execute&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Common real-world values:&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;644 file.txt      &lt;span class="c"&gt;# Normal file: owner reads/writes, everyone else reads&lt;/span&gt;
&lt;span class="nb"&gt;chmod &lt;/span&gt;755 script.sh     &lt;span class="c"&gt;# Executable script or open directory&lt;/span&gt;
&lt;span class="nb"&gt;chmod &lt;/span&gt;600 ~/.ssh/id_ed25519   &lt;span class="c"&gt;# Private SSH key: only owner can read/write&lt;/span&gt;
&lt;span class="nb"&gt;chmod &lt;/span&gt;700 ~/.ssh        &lt;span class="c"&gt;# SSH directory: only owner has full access&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; The &lt;code&gt;600&lt;/code&gt; permission on SSH private keys is not optional. &lt;code&gt;ssh&lt;/code&gt; will refuse to use a private key that others can read.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  A Real-World Scenario
&lt;/h2&gt;

&lt;p&gt;Imagine you deploy a web app on an Ubuntu 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 chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; www-data&lt;span class="se"&gt;\:&lt;/span&gt;www-data /var/www/app
&lt;span class="nb"&gt;sudo chmod&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; 755 /var/www/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;www-data&lt;/code&gt; is the user the web server runs as on Debian/Ubuntu.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;755&lt;/code&gt; lets the web server read and use the files, while other users can read but not modify them.&lt;/li&gt;
&lt;li&gt;Secrets like &lt;code&gt;.env&lt;/code&gt; should be locked down further:
&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;640 /var/www/app/.env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the everyday reality of permissions: &lt;strong&gt;give the minimum access needed, and nothing more&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Common Mistakes and Troubleshooting
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;chmod 777&lt;/code&gt; as a "fix"&lt;/strong&gt; — It makes the file writable by everyone. It often "works", but it is a security hole. Almost always, the correct answer is proper ownership, not 777.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forgetting &lt;code&gt;-R&lt;/code&gt; on directories&lt;/strong&gt; — &lt;code&gt;chmod 644 mydir&lt;/code&gt; changes the directory itself, not its contents.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Removing &lt;code&gt;x&lt;/code&gt; from a directory&lt;/strong&gt; — You lose the ability to enter it, even as the owner.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ownership vs permission confusion&lt;/strong&gt; — If you own a file, you can change its permissions even without write access to the file itself.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Quick diagnostic habit:&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;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; file.txt        &lt;span class="c"&gt;# Who owns it? What are the permissions?&lt;/span&gt;
&lt;span class="nb"&gt;id&lt;/span&gt;                    &lt;span class="c"&gt;# What groups am I in?&lt;/span&gt;
namei &lt;span class="nt"&gt;-l&lt;/span&gt; /var/www/app/index.html   &lt;span class="c"&gt;# Check permissions on every level of the path&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;namei -l&lt;/code&gt; trick is underrated — "Permission denied" can come from any parent directory in the path, not just the file itself.&lt;/p&gt;




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

&lt;ul&gt;
&lt;li&gt;Every file has an &lt;strong&gt;owner&lt;/strong&gt;, a &lt;strong&gt;group&lt;/strong&gt;, and &lt;strong&gt;others&lt;/strong&gt;, each with &lt;code&gt;r&lt;/code&gt;, &lt;code&gt;w&lt;/code&gt;, and &lt;code&gt;x&lt;/code&gt; permissions.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;chown&lt;/code&gt; changes &lt;strong&gt;who&lt;/strong&gt; owns a file; &lt;code&gt;chmod&lt;/code&gt; changes &lt;strong&gt;what&lt;/strong&gt; they can do.&lt;/li&gt;
&lt;li&gt;Symbolic mode (&lt;code&gt;u+x&lt;/code&gt;) is readable; numeric mode (&lt;code&gt;755&lt;/code&gt;) is compact and fast.&lt;/li&gt;
&lt;li&gt;Follow the principle of least privilege: give the minimum permission required.&lt;/li&gt;
&lt;li&gt;Avoid &lt;code&gt;chmod 777&lt;/code&gt;. Diagnose with &lt;code&gt;ls -l&lt;/code&gt;, &lt;code&gt;id&lt;/code&gt;, and &lt;code&gt;namei -l&lt;/code&gt; instead.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once this clicks, "Permission denied" stops being a mystery and becomes a simple question: &lt;em&gt;who owns this file, and what are they allowed to do?&lt;/em&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>chmod</category>
      <category>sysadmin</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>Linux Server User Management: A Complete Practical Guide</title>
      <dc:creator>Yeasin's </dc:creator>
      <pubDate>Wed, 07 Oct 2026 13:18:35 +0000</pubDate>
      <link>https://dev.to/yeasin4745/linux-server-user-management-a-complete-practical-guide-34bk</link>
      <guid>https://dev.to/yeasin4745/linux-server-user-management-a-complete-practical-guide-34bk</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Every Linux server, whether it hosts a small personal project or a large-scale production application, depends on one fundamental administrative task: user management. Properly managed users and groups are the first line of defense for your server's security, and they form the foundation of a well-organized, maintainable system.&lt;/p&gt;

&lt;p&gt;When I first started working with Linux servers, user management seemed like a simple topic — just create a user, set a password, and move on. In practice, it is much more than that. Understanding how users, groups, permissions, and privileges work together is essential for anyone who administers a server, whether you are a DevOps engineer, a backend developer deploying your first application, or a student building a home lab.&lt;/p&gt;

&lt;p&gt;In this article, I will walk you through everything you need to know about user management on a Linux server: creating and deleting users, managing groups, assigning sudo privileges, securing SSH access, and following industry best practices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why User Management Matters
&lt;/h2&gt;

&lt;p&gt;Before diving into commands, it is important to understand why this topic deserves your attention:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Security:&lt;/strong&gt; Each user account is a potential entry point. Unused accounts, weak passwords, and excessive privileges are among the most common ways servers get compromised.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accountability:&lt;/strong&gt; When every action can be traced back to a specific user, auditing and troubleshooting become far easier.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Least privilege:&lt;/strong&gt; Users should only have the access they actually need — no more, no less.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Collaboration:&lt;/strong&gt; Groups allow teams to share files and resources safely without exposing them to everyone else.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;In Linux, every user is identified by two values:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Username:&lt;/strong&gt; The human-readable name used to log in (for example, &lt;code&gt;yeasin&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UID (User ID):&lt;/strong&gt; The numeric identifier the system actually uses internally. Regular users typically start at &lt;code&gt;1000&lt;/code&gt;, while system accounts use lower values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;User information is stored in a few key files:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;File&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc/passwd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Stores usernames, UIDs, home directories, and default shells&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc/shadow&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Stores encrypted passwords and password aging policies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc/group&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Stores group names, GIDs, and group memberships&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/etc/sudoers&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Defines which users or groups may run commands with &lt;code&gt;sudo&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You should never edit these files directly with a text editor. Instead, use the dedicated commands covered below, which handle locking and validation for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating Users
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Adding a New User
&lt;/h3&gt;

&lt;p&gt;The standard command to create a user is &lt;code&gt;useradd&lt;/code&gt;, but on most modern distributions, &lt;code&gt;adduser&lt;/code&gt; is a friendlier, interactive alternative.&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;adduser yeasin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command automatically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates the user,&lt;/li&gt;
&lt;li&gt;Assigns a UID,&lt;/li&gt;
&lt;li&gt;Creates a home directory at &lt;code&gt;/home/yeasin&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;Copies default configuration files into the home directory,&lt;/li&gt;
&lt;li&gt;Prompts you to set a password and optional details.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your distribution only ships the low-level &lt;code&gt;useradd&lt;/code&gt; command, create a user with a home directory and Bash shell like this:&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;useradd &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; /bin/bash yeasin
&lt;span class="nb"&gt;sudo &lt;/span&gt;passwd yeasin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the &lt;code&gt;-m&lt;/code&gt; flag creates the home directory, and &lt;code&gt;-s&lt;/code&gt; sets the default shell.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Verifying the User
&lt;/h3&gt;

&lt;p&gt;Confirm that the user was created correctly:&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;id &lt;/span&gt;yeasin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uid=1001(yeasin) gid=1001(yeasin) groups=1001(yeasin)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Managing Passwords and Account Policies
&lt;/h2&gt;

&lt;p&gt;A strong password policy is a core part of server security. Set or change a user's password with:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;You can also enforce password aging so that passwords expire periodically:&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;chage &lt;span class="nt"&gt;-M&lt;/span&gt; 90 yeasin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This forces the user to change their password every 90 days. To review a user's password policy:&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;chage &lt;span class="nt"&gt;-l&lt;/span&gt; yeasin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For production servers, consider requiring strong passwords using PAM (Pluggable Authentication Modules) configuration, and always prefer key-based authentication over passwords for remote access.&lt;/p&gt;

&lt;h2&gt;
  
  
  Working with Groups
&lt;/h2&gt;

&lt;p&gt;Groups make permission management dramatically simpler. Instead of assigning permissions to users one by one, you assign them to a group once.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Creating a Group
&lt;/h3&gt;



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

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Adding a User to a Group
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; developers yeasin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-aG&lt;/code&gt; flags are critical: &lt;code&gt;-a&lt;/code&gt; appends the user to the group without removing them from other groups, and &lt;code&gt;-G&lt;/code&gt; specifies the group. If you omit &lt;code&gt;-a&lt;/code&gt;, the user will be removed from all their other secondary groups — a common and painful mistake.&lt;/p&gt;

&lt;p&gt;Verify group membership after the user logs in again:&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;groups &lt;/span&gt;yeasin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Deleting a Group
&lt;/h3&gt;



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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Granting Sudo Privileges
&lt;/h2&gt;

&lt;p&gt;Sometimes a user needs administrative rights. There are two recommended ways to grant them.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Using the Sudo Group
&lt;/h3&gt;

&lt;p&gt;On Ubuntu and Debian, members of the &lt;code&gt;sudo&lt;/code&gt; group automatically receive administrative privileges:&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;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;yeasin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On CentOS, RHEL, and Fedora, the equivalent group is called &lt;code&gt;wheel&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; wheel yeasin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Using a Custom Sudoers File
&lt;/h3&gt;

&lt;p&gt;For fine-grained control, create a dedicated sudoers file for the user:&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;visudo &lt;span class="nt"&gt;-f&lt;/span&gt; /etc/sudoers.d/yeasin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add this line to allow full access:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Always use &lt;code&gt;visudo&lt;/code&gt; when editing sudo configuration. It validates the syntax before saving, which prevents you from accidentally locking yourself out of administrative access.&lt;/p&gt;

&lt;h2&gt;
  
  
  Locking, Unlocking, and Deleting Users
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Locking an Account
&lt;/h3&gt;

&lt;p&gt;When someone leaves a team, disable their account immediately:&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;usermod &lt;span class="nt"&gt;-L&lt;/span&gt; yeasin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unlock it later if needed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-U&lt;/span&gt; yeasin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Deleting a User
&lt;/h3&gt;

&lt;p&gt;To remove a user along with their home directory and mail spool:&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;userdel &lt;span class="nt"&gt;-r&lt;/span&gt; yeasin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Double-check the username before running this command, because deletion is permanent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Securing SSH Access
&lt;/h2&gt;

&lt;p&gt;User management on a server goes hand in hand with SSH security. A few essential practices:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Use Key-Based Authentication
&lt;/h3&gt;

&lt;p&gt;Generate a key pair on your local machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; ed25519
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy the public key to the server:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Disable Root Login and Password Authentication
&lt;/h3&gt;

&lt;p&gt;Edit the SSH daemon configuration at &lt;code&gt;/etc/ssh/sshd_config&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;PermitRootLogin no
PasswordAuthentication no
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then restart the SSH service:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Restrict Which Users Can Log In
&lt;/h3&gt;

&lt;p&gt;Allow only specific users to connect over SSH:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AllowUsers yeasin deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep an SSH session open while testing configuration changes, so you never lock yourself out of your own server.&lt;/p&gt;

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

&lt;p&gt;To summarize the habits of a well-managed server:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a separate user for every person and every service; never share accounts.&lt;/li&gt;
&lt;li&gt;Disable root login over SSH and use &lt;code&gt;sudo&lt;/code&gt; for administrative tasks instead.&lt;/li&gt;
&lt;li&gt;Prefer key-based authentication over password authentication.&lt;/li&gt;
&lt;li&gt;Apply the principle of least privilege: grant only the access a user actually needs.&lt;/li&gt;
&lt;li&gt;Regularly audit accounts with &lt;code&gt;last&lt;/code&gt;, &lt;code&gt;lastlog&lt;/code&gt;, and &lt;code&gt;/var/log/auth.log&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Lock or delete accounts as soon as they are no longer needed.&lt;/li&gt;
&lt;li&gt;Enforce password aging policies with &lt;code&gt;chage&lt;/code&gt; where key-based login is not possible.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;User management may appear to be a basic administrative chore, but it is genuinely one of the most important pillars of Linux server security. A server with carefully controlled users, groups, and privileges is dramatically harder to compromise, far easier to audit, and much simpler to maintain over time.&lt;/p&gt;

&lt;p&gt;The commands in this guide are the same ones used daily by professional system administrators. Practice them on a virtual machine or a cloud instance, break things safely, and rebuild your understanding from the ground up. The more comfortable you become with user management, the more confident you will feel running production servers.&lt;/p&gt;

&lt;p&gt;If you found this guide helpful, consider saving it for reference and sharing it with others who are learning Linux administration.&lt;/p&gt;

&lt;p&gt;Thank you for reading.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>security</category>
      <category>ubuntu</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
