---
id: linux-administration-fundamentals-of-linux-administration
slug: linux-administration-fundamentals-of-linux-administration
title: "Linux Administration #1: Fundamentals of Linux Administration"
excerpt: "Fundamentals of Linux administration: From system architecture to permission management - Learn the fundamental concepts for getting started with Linux administration"
date: "2024-10-26T09:00:00+01:00"
updated: "2024-10-26T10:00:00+01:00"
author:
  name: "Sebastian Palencsar"
  handle: "AdminDocs"
category: "linux-administration"
tags: ["linux-basics", "shell", "filesystem", "permissions", "history", "cli", "linux-administration"]
toc: true
reading_time: 45
---

**Welcome to the first part of our technical wiki series on Linux administration!**

In the coming eight articles, you will learn all the important fundamentals you need as a Linux administrator. We start with the fundamental concepts and work our way step by step to advanced topics.

## What Is a Linux Administrator?

As a Linux administrator, you are responsible for the management, maintenance, and security of Linux systems. Whether you manage your own home network or work in a company – a deep understanding of Linux administration is more important today than ever before.

The fundamentals you learn in this article form the foundation for all further administrative tasks. Let's start with the system architecture – the heart of every Linux system.

### Basic System Concepts

<span class="nb-accent">System Architecture</span>

Before you start administration, it is important to understand how a Linux system is structured. Think of the system as a multi-story building where each level has a specific task.

**Linux System Architecture Pyramid:**

```markdown
┌─────────── User Applications ────────────────────────────────┐
│     Firefox, LibreOffice, Terminal                           │
├─────────── Shell (Bash, ZSH) ────────────────────────────────┤
│     Command interpreter & scripts                            │
├──────────── System Services ─────────────────────────────────┤
│     systemd, Network Manager, CUPS                           │
├─────────────── Kernel ───────────────────────────────────────┤
│     Processes, Memory, Drivers                               │
└─────────────── Hardware ─────────────────────────────────────┘
```

### System Architecture in Detail

The Linux system architecture consists of several layers that build on each other. Each layer has specific tasks:

<span class="nb-accent">Hardware Layer</span>

* Physical components (CPU, RAM, hard drives)
* Firmware/BIOS/UEFI
* Device drivers

<span class="nb-accent">Kernel Layer</span>

The kernel is the heart of your Linux system. It is the first software loaded after the boot process and controls everything that happens on your system.

```bash
# Display kernel version
uname -r

# Example output: 6.5.0-generic
# Display kernel parameters
sysctl -a

# Manage kernel modules
lsmod                   

# List all loaded modules
modprobe bluetooth      

# Load module
modprobe -r bluetooth   

# Unload module
```

**Important Kernel Tasks:**

* Manages access to hardware
* Controls processes and their priorities
* Controls memory

<span class="nb-accent">Kernel Modules</span>

Kernel modules are like extensions for your kernel. They can be loaded and unloaded as needed:

```bash
# Display all loaded modules
lsmod

# Load specific module
sudo modprobe bluetooth

# Display module information
modinfo bluetooth

# Safely unload module
sudo modprobe -r bluetooth
```

<span class="nb-accent">System Services Layer (systemd)</span>

Since 2015, almost every Linux distribution uses systemd as the init system. It is responsible for:

* The orderly start of all system services
* Managing services during operation
* Clean shutdown of the system

```bash
# Systemd status
systemctl status

# Display all active services
systemctl list-units --type=service --state=active

# Analyze boot time
systemd-analyze
systemd-analyze blame   

# Shows boot time per service
```

**Important for Beginners:**

* The kernel always runs in the background
* Modules can be loaded as needed
* Systemd manages almost all system services
* Logging helps with troubleshooting

<span class="nb-accent">User Layer</span>

```bash
# Display current shell
echo $SHELL

who   

# Display logged-in users
w     

# More detailed information
# Processes of the current user
ps aux | grep $USER
```

### Filesystem Hierarchy

Under Linux, everything is organized in a hierarchical directory structure, starting with the root directory (`/`):

```markdown
┌─────────────────────────────────────────────────────────────┐
│             FILESYSTEM HIERARCHY STANDARD (FHS)             │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│   /                                                         │
│   ├── /bin     → Basic system programs                      │
│   ├── /boot    → Linux kernel & bootloader configuration    │
│   ├── /dev     → Device files (block/character devices)     │
│   ├── /etc     → System-wide configuration files            │
│   ├── /home    → User home directories                      │
│   ├── /lib     → Shared system libraries                    │
│   ├── /proc    → Virtual process filesystem                 │
│   ├── /root    → Home directory of the superuser            │
│   ├── /sbin    → System programs for administration         │
│   ├── /tmp     → Temporary files (volatile)                 │
│   ├── /usr     → Secondary hierarchy for application data   │
│   └── /var     → Variable data (logs, spools, caches)       │
│                                                             │
└─────────────────────────────────────────────────────────────┘
```

**Important Directories in Detail:**

```bash
# /etc - System configuration
ls -l /etc/

# Examples of important files:
# - /etc/passwd    (user information)
# - /etc/fstab     (filesystem configuration)
# - /etc/hosts     (hostname mapping)
# /var - Variable data
ls -l /var/

# Examples of important subdirectories:
# - /var/log      (system logs)
# - /var/spool    (printer and mail queues)
# - /var/www      (web server files)
```

### Filesystem Types

Linux supports various filesystem types for different requirements:

```bash
# Display available filesystems
cat /proc/filesystems

# Currently mounted filesystems
df -Th
```

**Commonly Used Filesystems:**

* **ext4**: Default for most Linux distributions
* **xfs**: Good for large filesystems and servers
* **btrfs**: Modern with snapshot functions
* **tmpfs**: Temporary filesystem in RAM

<span class="nb-accent">Manage Mount Points</span>

```bash
# Display all mount points
mount

# Mount a new hard drive
sudo mount /dev/sdb1 /mnt/data

# Configure automatic mounting in fstab
sudo nano /etc/fstab

# Example entry:
# /dev/sdb1  /mnt/data  ext4  defaults  0  2
```

## User and Permission Management

As a Linux administrator, one of your most important tasks is managing users and their permissions. Think of it as a building where different people have different keys and access permissions.

**Permission Hierarchy:**

```markdown
┌─────────── Root (UID 0) ────────────────────────────────────┐
│ Complete system control                                      │
├─────────── System User ─────────────────────────────────────┤
│ UIDs 1-999 (services, daemons)                              │
├─────────── Normal User ─────────────────────────────────────┤
│ UIDs 1000+ (humans)                                         │
└─────────────────────────────────────────────────────────────┘
```

**File Permissions:**

```markdown
┌─────────────────────────────────────────────────────────────┐
│            STRUCTURE OF LINUX DEFAULT PERMISSIONS           │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│   rwx          rwx          rwx           file.txt          │
│   │            │            └── Others                        │
│   │            └─────────────── Group                         │
│   └──────────────────────────── Owner (User)                 │
│                                                             │
│   r (read)    = 4 (Read)                                    │
│   w (write)   = 2 (Write / Modify)                           │
│   x (execute) = 1 (Execute / Enter directory)                │
│                                                             │
└─────────────────────────────────────────────────────────────┘
```

### Root User

The root user (also called superuser) has absolute control over the system. This is like a master key that opens all doors.

**Commonly Used Filesystems:**

* Root has the user ID `(UID) 0`
* Root can do EVERYTHING on the system
* With great power comes great responsibility
* Use root privileges only when necessary

### Normal Users

```bash
# Display information about your user
id

# Example output:
# uid=1000(max) gid=1000(max) groups=1000(max),27(sudo)
```

**What Does This Output Mean?**

* `uid=1000`: Your unique user ID
* `gid=1000`: Your primary group ID
* `groups=...`: All groups you are a member of

### Create and Manage Users

<span class="nb-accent">Let's go through this step by step:</span>

**Create New User**

```bash
# Create user
sudo useradd -m -s /bin/bash anna

# What do the options mean?
# -m: Creates a home directory (/home/anna)
# -s: Sets the default shell (/bin/bash)
```

**What Do the Options Mean?**

* `-m`: Creates a home directory (`/home/anna`)
* `-s`: Sets the default shell (`/bin/bash`)

<span class="nb-accent">Understand the Home Directory:</span>

```bash
ls -la /home/anna

# Shows:
# drwxr-xr-x 2 anna anna 4096 Feb 20 10:00 .
# drwxr-xr-x 4 root root 4096 Feb 20 10:00 ..
# -rw-r--r-- 1 anna anna  220 Feb 20 10:00 .bash_logout
# -rw-r--r-- 1 anna anna 3526 Feb 20 10:00 .bashrc
# -rw-r--r-- 1 anna anna  807 Feb 20 10:00 .profile
```

**Set Password:**

```bash
sudo passwd anna

# Input: New password
# Input: Repeat password
```

**Important Password Rules:**

* At least 8 characters
* Upper and lower case letters
* Numbers and special characters
* Not easy to guess

### Check User Information:

```markdown
┌─────────────────────────────────────────────────────────────┐
│                STRUCTURE OF /ETC/PASSWD ENTRIES             │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  anna:x:1001:1001:Anna Schmidt:/home/anna:/bin/bash         │
│  │    │ │    │    │            │          │                 │
│  │    │ │    │    │            │          └─ Login Shell     │
│  │    │ │    │    │            └─ Home Directory             │
│  │    │ │    │    └─ Comment / Full Name                     │
│  │    │ │    └─ Primary Group ID (GID)                       │
│  │    │ └─ User ID (UID)                                     │
│  │    └─ Password Placeholder (x = in /etc/shadow)           │
│  └─ Username / Account                                       │
│                                                             │
└─────────────────────────────────────────────────────────────┘
```

## Groups and Permissions

### Understand the Group Concept

Think of an office building where different departments work. Each department (`group`) has access to certain rooms (`directories`) and documents (`files`).

**Group Structure:**

```markdown
┌─────────── System Groups ───────────────────────────────────┐
│ sudo, adm, www-data, etc.                                   │
├─────────── User Groups ─────────────────────────────────────┤
│ developers, marketing, support                              │
└─────────────────────────────────────────────────────────────┘
```

**User-Group Relationship:**

```markdown
┌─── Anna ────────────────────────────────────────────────────┐
│ Primary:    │──→ marketing                                   │
│ Secondary:  │──→ developers, support                         │
└─────────────────────────────────────────────────────────────┘
```

**What Are System Groups?**

* `sudo`: Members may execute admin commands
* `adm`: Access to system logs
* `www-data`: For web server processes
* `etc.`: Other system groups

These groups are automatically created and used by the system

**What Are User Groups?**

* Created by administrators
* For specific purposes (e.g. projects, departments)
* Help organize access permissions

### Create and Manage Groups

```bash
# Create new group
sudo groupadd developers
```

**What Happens in the Background?**
1. Entry in `/etc/group`:

```markdown
┌─────────────────────────────────────────────────────────────┐
│                 STRUCTURE OF /ETC/GROUP ENTRIES             │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  developers:x:1002:anna,ben,clara                           │
│  │          │ │    │                                        │
│  │          │ │    └─ Group members (comma-separated)        │
│  │          │ └─ Group ID (GID)                              │
│  │          └─ Group password (x = mostly unused)            │
│  └─ Group name                                              │
│                                                             │
└─────────────────────────────────────────────────────────────┘
```

**Important for Beginners**

* Group names should be meaningful
* Do not use spaces or special characters
* Prefer lowercase letters
* Use IDs above 1000 for custom groups

### Add Users to Groups

```bash
# Add Anna to the developers group
sudo usermod -aG developers anna

# What do the options mean?
# -a: append (add, do not overwrite)
# -G: secondary group(s)
# Check group membership
groups anna

# Example output: anna : anna developers
```

<span class="nb-accent">Common Errors and Solutions:</span>

```bash
# Error: Group does not exist
sudo groupadd developers

# groupadd: group 'developers' already exists
# Solution: Check group
getent group developers

# Error: User not in group
groups anna 

# anna : anna
# Solution: Add user to group
sudo usermod -aG developers anna
```

**Important for Beginners**

* Always use `-a` together with `-G`, otherwise you overwrite existing groups
* New group memberships only become active after logging out and back in
* Alternatively, `newgrp` activates the new group immediately
* Check changes afterwards with `groups`

**Best Practices:**

* Use descriptive group names
* Avoid spaces and special characters
* Preferably use lowercase letters
* Use IDs above 1000 for custom groups
* Document the purposes and members of the group

## File Permissions in Detail

### Understand the Linux Permission System

It is important to understand that every file and every directory in Linux has three types of permissions for three different categories.

**Complete Permission Structure:**
File: `example.txt`

```markdown
┌─────────────────────────────────────────────────────────────┐
│               STRUCTURE OF A FILE LISTING (LS -L)           │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  -rw-r--r-- 1 anna developers 1024 Feb 20 14:30 app.txt     │
│  │├──┤├──┤├──┤ │  │    │          │    └── Timestamp        │
│  ││  ││  ││  │ │  │    │          └─ Size in bytes          │
│  ││  ││  ││  │ │  │    └─ Owner group                       │
│  ││  ││  ││  │ │  └─ Owner (User)                           │
│  ││  ││  ││  │ └─ Hardlink counter                          │
│  ││  ││  │└──┴─ Others permissions                          │
│  ││  │└──┴─ Group permissions                               │
│  │└──┴─ Owner permissions                                   │
│  └─ File type (- = regular, d = directory, l = link)        │
│                                                             │
└─────────────────────────────────────────────────────────────┘
```

### Permission Types in Detail

<span class="nb-accent">Read (r = read):</span>

**For files, read permission means:**
* Display file content with cat, less, more
* Copy file
* Open and read file
* Search for text with grep
* Display content in editor (but not save)

<span class="nb-accent">Practical Examples:</span>

```bash
# Read file
cat example.txt
less example.txt
head -n 5 example.txt  

# First 5 lines
tail -n 5 example.txt  

# Last 5 lines
```

```bash
# Copy file
cp example.txt copy.txt
```

```bash
# Search in file
grep "search term" example.txt
```

```bash
# What happens without read permission?
chmod u-r example.txt
cat example.txt
```

**Output: "Permission denied"**

**For directories, read permission means:**
* List directory contents with ls
* See files in directory
* Search for files
* See file metadata (size, date, etc.)

**Practical Examples:**

```bash
ls -l directory/
ls -la directory/    

# Also shows hidden files
find directory/ -name "*.txt"
```

**What happens without read permission?**

```bash
chmod u-r directory/
ls directory/

# Output: "Permission denied"
```

<span class="nb-accent">Write (w = write):</span>

**For files, write permission means:**
* Change file content
* Write to file
* Delete file
* Rename file
* Move file
* Change file attributes
* Empty file

<span class="nb-accent">Practical Examples:</span>

```bash
# Create/overwrite file
echo "New text" > example.txt
```

```bash
# Append to file
echo "More text" >> example.txt
```

```bash
# Edit with editor
nano example.txt
vim example.txt
```

```bash
# Rename/move file
mv example.txt new.txt
mv new.txt /tmp/
```

```bash
# Delete file
rm example.txt
```

```bash
# What happens without write permission?
chmod u-w example.txt
echo "Test" > example.txt

# Output: "Permission denied"
```

**For directories, write permission means:**
* Create new files
* Delete existing files
* Rename files
* Move files
* Create subdirectories
* Change directory attributes

**Practical Examples:**

* mkdir directory/new_folder
* touch directory/new_file.txt
* rm directory/old_file.txt
* mv directory/file1.txt directory/file2.txt

```bash
# What happens without write permission?
chmod u-w directory/
touch directory/test.txt

# Output: "Permission denied"
```

<span class="nb-accent">Execute (x = execute):</span>

**For files, execute permission means:**
* Run file as program/script
* Start binary files
* Run shell scripts
* Execute programs

**Practical Examples:**

```bash
# Create shell script
echo '#!/bin/bash' > script.sh
echo 'echo "Hello World"' >> script.sh
chmod u+x script.sh
./script.sh
```

```bash
# What happens without execute permission?
chmod u-x script.sh
./script.sh

# Output: "Permission denied"
```

**For directories, execute permission means:**
* Change into the directory (cd)
* Access files in the directory
* Traverse the directory
* Access subdirectories
* Execute files in the directory (if additionally executable)

**Practical Examples:**

* cd directory/
* ls -l directory/file.txt
* ./directory/program

```bash
# What happens without execute permission?
chmod u-x directory/
cd directory/

# Output: "Permission denied"
```

### Important Combinations:

**Commonly Used Permission Combinations:**

```bash
chmod 755 directory/  

# drwxr-xr-x
```

**Meaning**

* Owner can do everything (`rwx`)
* Group can read and execute (`r-x`)
* Others can read and execute (`r-x`)

**Typical for:** Program directories, public folders

```bash
chmod 644 file.txt    

# -rw-r--r--
```

**Meaning**

* Owner can read & write (`rw-`)
* Group can only read (`r--`)
* Others can only read (`r--`)

**Typical for:** Program directories, public folders

```bash
chmod 600 private.key  

# -rw-------
```

**Meaning:**

* Owner can read and write (`rw-`)
* Group has no permissions (`-`)
* Others have no permissions (`-`)

**Typical for:** Sensitive files, SSH keys

### Extended Permissions (SUID, SGID, Sticky Bit)

In Linux, in addition to the basic permissions (`rwx`), there are special permissions that are important for certain security and administration tasks.

**Special Permissions Visualized:**

```markdown
┌─────────────────────────────────────────────────────────────┐
│                 SPECIAL PERMISSIONS IN LINUX                │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│   SUID (Octal 4)        SGID (Octal 2)      Sticky (Octal 1)│
│   -rwsr-xr-x            drwxrwsr-x          drwxrwxrwt      │
│        │                     │                       │      │
│        │                     │                       │      │
│        │                     │        Only owner     │      │
│        │                     │        may delete     │      │
│        │                     │                       │      │
│        │      Inherits group ownership of directory  │      │
│        │                                                    │
│   Executes with permissions of file owner                  │
│                                                             │
└─────────────────────────────────────────────────────────────┘
```

<span class="nb-accent">SUID (Set User ID) in Detail</span>

**What is SUID?**

* Program runs with permissions of file owner
* Displayed by `S` in owner execute permissions
* Numeric value: 4000

**Practical Examples:**

```bash
# Display SUID
ls -l /usr/bin/passwd

# Output: -rwsr-xr-x root root /usr/bin/passwd
# Note the `s` in owner execute permissions
```

**Why Is This Important?**

* Normal user can change their password
* Program temporarily runs with root privileges
* Access to /etc/shadow is enabled

**Set SUID**

```bash
chmod u+s program
chmod 4755 program  

# Numeric method
```

**What Happens in the Background?**

* 1. User starts program
* 2. Program receives owner's permissions
* 3. Program can perform actions with higher privileges
* 4. After termination, permissions are reset

**Common Use Cases:**

```bash
- /usr/bin/passwd  

# Password change
- /usr/bin/sudo    

# Temporary root privileges
- /usr/bin/ping    

# Network raw sockets
```

### SGID (Set Group ID)

**What is SGID?**

* **For directories:** New files inherit the group of the directory
* **For programs:** Program runs with group permissions
* Displayed by `s` in group execute permissions
* Has numeric value 2000

```markdown
┌─────────────────────────────────────────────────────────────┐
│               SGID MARKING IN FILESYSTEM                    │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  Normal directory:    drwxr-xr-x                            │
│  SGID directory:      drwxr-sr-x                            │
│                               ▲                             │
│  Group execute 'x' becomes 's' (SGID active)               │
│                                                             │
└─────────────────────────────────────────────────────────────┘
```

**Set SGID**

```bash
chmod g+s /shared/project/

# or
chmod 2775 /shared/project/
```

**What Happens Then?**

* 1. You create a new file in the directory
* 2. The file automatically receives the group of the directory
* 3. All team members can collaborate

**Example for a Project Directory:**

`/shared/project/`           (Group: developers)
* ── `documents/`             (inherits group: developers)
* ├── `concept.txt`        (inherits group: developers)
* └── `planning.pdf`       (inherits group: developers)
* ── `source/`                (inherits group: developers)
	  └── `main.cpp`         (inherits group: developers)

**Common Use Cases:**

* Shared project directories
* Web server document directories
* Shared development folders
* Group document collections

**Tips for Practice:**

* Combine SGID with appropriate group permissions
* Make sure the group has the right members
* Check the inheritance after setup

**Check the Settings:**

**Create directory and set SGID:**

* mkdir /shared/project
* chmod 2775 /shared/project
* ls -ld /shared/project

**Create new file and check group:**

* touch /shared/project/test.txt
* ls -l /shared/project/test.txt

### Sticky Bit

**What Is the Sticky Bit?**

A security feature primarily used for directories:

* Only the owner may delete or rename their own files
* Other users cannot delete other people's files
* Displayed by `t` in the others execute permissions
* Has numeric value 1000

**Visualization:**

```markdown
┌─────────────────────────────────────────────────────────────┐
│            STICKY BIT MARKING IN FILESYSTEM                 │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  Normal directory:           drwxrwxrwx                     │
│  Directory with Sticky Bit:  drwxrwxrwt                     │
│                                         ▲                   │
│  Others execute 'x' becomes 't' (Sticky Bit active)        │
│                                                             │
└─────────────────────────────────────────────────────────────┘
```

**Set Sticky Bit**

```bash
chmod +t /shared/public/

# or
chmod 1777 /shared/public/
```

**Example Scenario:**

`/shared/public/`          (Sticky Bit set)
* ── `anna/`                (Owner: anna)
* └── `project.txt`      Only anna can delete this
* ── `bob/`                 (Owner: bob)
* └── `notes.txt`       Only bob can delete this
* ── `shared.txt`           Only the creator can delete this

**What Happens in the Background?**

* 1. A user creates a file in the directory
* 2. The file retains its original owner
* 3. Only the owner (and root) can delete the file
* 4. Other users cannot delete the file, even if they have write permissions

### Practical Test:

As user anna:

* touch /shared/public/anna.txt

**As user bob (will fail):**

* rm /shared/public/anna.txt

<blockquote class="infobox infobox--practice">
❗ Output: `Operation not permitted`
</blockquote>

**Common Use Cases:**

* `/tmp` directory (temporary files)
* Public upload directories
* Shared working directories
* Exchange directories for teams

**Security Aspects:**

* Prevents accidental or malicious deletion
* Enables shared use without data loss
* Important for multi-user systems

**Best Practices:**

* Use Sticky Bit for public directories
* Combine it with sensible access permissions
* Regularly check the settings

**Check the Settings:**

Set and check Sticky Bit:

* mkdir /shared/public
* chmod 1777 /shared/public
* ls -ld /shared/public

## Summary Exercises

### Exercise 1: Basic System Configuration

In this practical exercise, you will apply the learned concepts of system architecture and permission management.

**Scenario:**

You have been hired as a new Linux administrator and need to set up a development system for a team. You must understand the system architecture and set correct permissions.

### Requirements

**1. System Understanding**

* Read kernel information
* Check systemd status
* Identify important system directories

**2. Permission Structure**

* Create developer group
* Create project directories
* Set correct permissions
* Implement extended permissions

**Verification Structure:**

**System Verification:**

```markdown
──────────────────────────────────────────────────────────────/
├── Kernel ──────────────────────────────────────────────────┐
│   ├── Version     [ ]                                       │
│   ├── Modules     [ ]                                       │
│   └── Parameters  [ ]                                       │
│                                                             │
├── Systemd ─────────────────────────────────────────────────┤
│   ├── Status      [ ]                                       │
│   └── Services    [ ]                                       │
│                                                             │
├─── Directories ────────────────────────────────────────────┤
│   ├── /etc       [ ]                                        │
│   ├── /var/log   [ ]                                        │
│   └── /home      [ ]                                        │
└─────────────────────────────────────────────────────────────┘
```

**Permission Verification:**

```markdown
┌─────────────────────────────────────────────────────────────┐
│              PROJECT DIRECTORY PERMISSION STRUCTURE         │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│   /srv/project/                                             │
│   ├── src/                 drwxrwsr-x   root:developers     │
│   │   └── [Files inherit group 'developers' automatically]  │
│   │                                                         │
│   ├── docs/                drwxrwsr-x   root:developers     │
│   │   └── [Documentation for the entire development team]   │
│   │                                                         │
│   └── shared/              drwxrwxrwt   root:root           │
│       └── [Sticky Bit: Delete only by file owner]           │
│                                                             │
└─────────────────────────────────────────────────────────────┘
```

**Possible Solution for Task 1:**

```bash
#!/bin/bash
# 1. System check
echo "=== System Check ==="
uname -a
systemctl status
ls -la /etc /var/log /home

# 2. Create permission structure
echo "=== Create Permission Structure ==="

# Create group
sudo groupadd dev

# Directory structure
sudo mkdir -p /proj/{src,docs,shared}

# Base permissions
sudo chown -R root:dev /proj/src /proj/docs
sudo chown root:root /proj/shared

# Extended permissions
sudo chmod 2775 /proj/src /proj/docs  

# SGID
sudo chmod 1777 /proj/shared          

# Sticky Bit
# 3. Verification
echo "=== Verification ==="
ls -la /proj/
getent group dev
```

<span class="nb-accent">Exercise 2: System Architecture and Permissions</span>

In this practical exercise, you will apply the basic concepts of Linux system architecture and permission management.

**Scenario:**

**As a new Linux administrator, you should:**

* Analyze the system architecture
* Set up a directory system with correct permissions
* Implement extended permissions

<span class="nb-accent">Part 1: System Analysis</span>

**System Component Checklist:**

```markdown
┌─────────── Hardware ────────────────────────────────────────┐
│ [ ] CPU information                                          │
│ [ ] RAM status                                               │
│ [ ] Hard drives                                              │
├─────────── Kernel ──────────────────────────────────────────┤
│ [ ] Version                                                  │
│ [ ] Modules                                                  │
│ [ ] Parameters                                               │
├─────────── Filesystem ─────────────────────────────────────┤
│ [ ] Mount points                                             │
│ [ ] Storage usage                                            │
│ [ ] Directory structure                                      │
└─────────────────────────────────────────────────────────────┘
```

**Part 2: Permission Configuration**

**Project Structure:**

`/project/`
* ── `docs/`                   [2775]
* ├── `internal/`          [2770]
* └── `public/`           [2775]
* ──────── `scripts/`          [2771]
* ──────── `shared/`           [1777]

**Permission Matrix:**
* ────────────┬────────┬─────────┬────────┐
* Directory   │ Owner  │ Group   │ Others │
* ────────────┼────────┼─────────┼────────┤
* docs        │ rwx    │ rwx     │ r-x    │
* internal    │ rwx    │ rwx     │ ---    │
* public      │ rwx    │ rwx     │ r-x    │
* scripts     │ rwx    │ rwx     │ --x    │
* shared      │ rwx    │ rwx     │ rwx    │
* ────────────┴────────┴─────────┴────────┘

**Possible Solution:**

```bash
#!/bin/bash
# Part 1: System analysis
echo "=== System Analysis ==="

# Hardware
echo "CPU Info:"
lscpu | grep "Model name"
echo "RAM Status:"
free -h
echo "Hard drives:"
df -h

# Kernel
echo "Kernel Version:"
uname -r
echo "Loaded Modules:"
lsmod | head -n 5

# Filesystem
echo "Important Directories:"
ls -l / | grep -E "^d"

# Part 2: Permission configuration
echo "=== Permission Configuration ==="

# Create project structure
sudo mkdir -p /project/{docs/{intern,public},scripts,shared}

# Create group
sudo groupadd project

# Set permissions
sudo chown -R root:project /project
sudo chmod 2775 /project/docs
sudo chmod 2770 /project/docs/intern
sudo chmod 2775 /project/docs/public
sudo chmod 2771 /project/scripts
sudo chmod 1777 /project/shared

# Verification
echo "=== Verification ==="
ls -la /project/
```

**Verification:**

**Permission Test Matrix:**

```markdown
┌─────────────────────────────────────────────────────────────┐
│ Test 1: System Analysis                                     │
├─────────────────┬─────────┬─────────────────────────────────┤
│ Component       │ Status  │ Check                           │
├─────────────────┼─────────┼─────────────────────────────────┤
│ Hardware Info   │ [ ]     │ [ ]                             │
│ Kernel Details  │ [ ]     │ [ ]                             │
│ Filesystem      │ [ ]     │ [ ]                             │
└─────────────────┴─────────┴─────────────────────────────────┘
───────────────────────────────────────────────────────────────
┌─────────────────────────────────────────────────────────────┐
│ Test 2: Permissions                                         │
├─────────────────┬─────────┬─────────────────────────────────┤
│ Directory       │ SGID    │ Perm                            │
├─────────────────┼─────────┼─────────────────────────────────┤
│ /project/docs   │ [ ]     │ [ ]                             │
│ intern          │ [ ]     │ [ ]                             │
│ public          │ [ ]     │ [ ]                             │
│ scripts         │ [ ]     │ [ ]                             │
│ shared          │ [ ]     │ [ ]                             │
└─────────────────┴─────────┴─────────────────────────────────┘
```

## Command Reference (Cheatsheet)

For quick access during daily system work, the following reference table summarizes the essential basic commands of Linux administration:

| Command / Syntax | Category | Function & Description |
|---|---|---|
| `uname -a` | System | Displays kernel version, architecture, and hostname. |
| `lsmod` | Kernel | Lists all currently loaded kernel modules. |
| `sudo modprobe <module>` | Kernel | Loads a kernel module including dependencies. |
| `sudo modprobe -r <module>` | Kernel | Safely unloads a kernel module from the kernel. |
| `systemctl status <unit>` | Init / systemd | Shows the state of services and systemd units. |
| `systemd-analyze blame` | Boot | Shows start duration of all services during boot. |
| `df -Th` | Filesystem | Shows mounted partitions, FSType, and storage space. |
| `lsblk -f` | Filesystem | Visualizes block devices, UUIDs, and mount points. |
| `sudo mount /dev/sdX /mnt` | Filesystem | Mounts a filesystem at a defined path. |
| `sudo mount -a` | Filesystem | Tests all entries in `/etc/fstab` without restart. |
| `sudo useradd -m -s /bin/bash <u>` | User | Creates new user with home directory and shell. |
| `sudo passwd <user>` | User | Changes the password of a user. |
| `sudo usermod -aG <grp> <user>` | Groups | Safely adds user to a secondary group. |
| `chmod 755 <file>` | File Permissions | Sets default permissions `rwxr-xr-x` (owner full, rest read). |
| `chmod 644 <file>` | File Permissions | Sets file permissions `rw-r--r--` for standard documents. |
| `chmod 2775 <folder>` | Special Bits | Sets SGID: Automatic group inheritance for new files. |
| `chmod 1777 <folder>` | Special Bits | Sets Sticky Bit: Delete protection in shared team folders. |
| `sudo chown -R <u:g> <path>` | Owner | Recursively changes user and group ownership. |
| `umask` | Security | Shows the default permission mask for new files. |

## Further Resources

The following official standards, documentation, and in-depth articles support you in building your administration knowledge:

| Resource | Description |
|---|---|
| [Filesystem Hierarchy Standard (FHS) 3.0](https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html){.badge-link-text} | Official FHS specification of the Linux Foundation. |
| [systemd System & Service Manager](https://systemd.io/){.badge-link-text} | Official documentation and reference for the systemd ecosystem. |
| [Linux Kernel Module Documentation](https://www.kernel.org/doc/html/latest/kbuild/modules.html){.badge-link-text} | Kernel.org documentation on Linux module management. |
| [chmod & File Permissions Guide](/en/linux-beginners/basics-to-best-practices-all-about-chmod-in-linux){.badge-link-text} | Fundamental deepening of permissions, bitmasks, and octal values. |
| [Command Line Processor in Linux](/en/linux-beginners/command-line-processor-in-linux){.badge-link-text} | Architecture of shell, TTY, pipes, and I/O streams. |
| [Bash Basics #1: First Script](/en/bash-basics/bash-basics-1-create-your-first-bash-shell-script){.badge-link-text} | Fundamental introduction to Bash scripting. |

## Conclusion

With the understanding of the 5-layer system architecture, navigation in the FHS directory tree, persistent storage management via `/etc/fstab`, and precise mastery of standard and special permissions (SUID, SGID, Sticky Bit), you have laid the unshakeable foundation for your career as a Linux administrator.

<blockquote class="infobox infobox--info">
💡 **Practical Tip:** For shared team and project folders, consistently use the **SGID bit** (`chmod 2775`) so that newly created files automatically belong to the shared group and team members can collaborate without manual permission adjustments.
</blockquote>

In the next module of our administration course, we deal with in-depth user management, PAM authentication, and access control:
👉 **Next up:** [Linux Administration #2: Advanced User Management](/en/linux-administration/linux-administration-advanced-user-management){.badge-link-text}

👉 **Course Overview:** [All Linux Administration Articles & Modules](/en/category/linux-administration){.badge-link-text}
