Initial commit
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
# Linux – Administration
|
||||
|
||||
Overview of common Linux administration tasks. Focus on day‑to‑day system management rather than distribution‑specific tools.
|
||||
|
||||
For foundational concepts (kernel, filesystem, users, processes), see:
|
||||
|
||||
- [Linux / Basics](./Basics.md)
|
||||
|
||||
---
|
||||
|
||||
## 1. User and Group Management
|
||||
|
||||
Linux uses users and groups to control access to files, processes, and services.
|
||||
|
||||
Typical administration tasks include:
|
||||
|
||||
- Creating and removing users.
|
||||
- Adding users to groups (for example to grant `sudo` access).
|
||||
- Locking or disabling accounts.
|
||||
|
||||
Key ideas:
|
||||
|
||||
- Each user has a numeric user ID (UID) and a primary group ID (GID).
|
||||
- Additional group memberships are used to grant extra permissions (for example access to Docker or systemd‑journal).
|
||||
|
||||
---
|
||||
|
||||
## 2. Privileged Access and sudo
|
||||
|
||||
Administrative operations are usually performed with elevated privileges.
|
||||
|
||||
Approaches:
|
||||
|
||||
- Direct `root` login (less common on modern systems for security reasons).
|
||||
- Using `sudo` to run specific commands as `root`.
|
||||
|
||||
Principles:
|
||||
|
||||
- Only trusted users should have `sudo` rights.
|
||||
- The set of allowed commands can be restricted via the sudoers configuration.
|
||||
|
||||
In practice, administration is often done as an unprivileged user with `sudo` used only when needed.
|
||||
|
||||
---
|
||||
|
||||
## 3. Filesystem Permissions and Ownership
|
||||
|
||||
Correct file and directory permissions are central to system security and stability.
|
||||
|
||||
Key aspects:
|
||||
|
||||
- Ownership (user and group) defines who primarily controls a resource.
|
||||
- Permission bits (read, write, execute) for user, group, and others control what can be done.
|
||||
- Special bits (setuid, setgid, sticky) influence execution and inheritance in specific cases.
|
||||
|
||||
Administration tasks related to permissions include:
|
||||
|
||||
- Adjusting ownership for application data directories.
|
||||
- Ensuring configuration files are restricted when they contain secrets.
|
||||
- Verifying that log and temporary directories have appropriate access.
|
||||
|
||||
Additional reminders and command examples can be kept in:
|
||||
|
||||
- [Linux / Cheat Sheet](./CheatSheet.md)
|
||||
|
||||
---
|
||||
|
||||
## 4. Services and systemd Units
|
||||
|
||||
On many modern Linux distributions, **systemd** is used as the init system and service manager.
|
||||
|
||||
Concepts:
|
||||
|
||||
- A **unit** defines how a service, mount, timer, or other resource is started and managed.
|
||||
- Service units (for example `ssh.service`, `docker.service`) describe how to start and stop daemons.
|
||||
- Targets group units to represent boot states (for example `multi-user.target`).
|
||||
|
||||
Typical administration actions:
|
||||
|
||||
- Starting, stopping, and restarting services.
|
||||
- Enabling or disabling services at boot.
|
||||
- Checking service status and logs.
|
||||
|
||||
Systemd units are usually stored under `/lib/systemd/system` or `/etc/systemd/system`. Local overrides can be created without modifying vendor files.
|
||||
|
||||
---
|
||||
|
||||
## 5. Logs and Troubleshooting
|
||||
|
||||
System logs are essential for diagnosing issues.
|
||||
|
||||
On systemd‑based systems, the journal stores logs from the kernel and many services.
|
||||
|
||||
Common tasks:
|
||||
|
||||
- Viewing recent logs for a specific service.
|
||||
- Filtering logs by priority or time range.
|
||||
- Inspecting boot logs to understand startup problems.
|
||||
|
||||
In addition to the journal, many services also write to files under `/var/log`. Knowing where a service writes its logs is an important part of administration.
|
||||
|
||||
---
|
||||
|
||||
## 6. Software Installation and Updates
|
||||
|
||||
Package management is used to install, update, and remove software.
|
||||
|
||||
Administration concerns:
|
||||
|
||||
- Keeping the system reasonably up to date for security fixes.
|
||||
- Avoiding unnecessary packages on minimal or security‑sensitive systems.
|
||||
- Understanding which repositories are enabled.
|
||||
|
||||
The concrete commands differ per distribution (for example `apt` vs `dnf`), but the underlying tasks are similar.
|
||||
|
||||
Distribution‑specific notes and examples can be recorded in a dedicated cheat sheet or in project‑specific documentation.
|
||||
|
||||
---
|
||||
|
||||
## 7. Scheduled Tasks and Automation
|
||||
|
||||
Linux systems provide several mechanisms for scheduled or automated tasks.
|
||||
|
||||
Common options:
|
||||
|
||||
- `cron` jobs for periodic execution.
|
||||
- systemd timers for more structured scheduling tied to units.
|
||||
|
||||
These mechanisms are used for activities such as log rotation, backups, or periodic health checks.
|
||||
|
||||
---
|
||||
|
||||
## 8. Backup and Recovery Considerations
|
||||
|
||||
From an administrative perspective, backup and recovery planning includes:
|
||||
|
||||
- Identifying which directories and data must be backed up.
|
||||
- Choosing backup tools and storage locations.
|
||||
- Testing restore procedures.
|
||||
|
||||
Details are often project‑specific and can be documented alongside the systems that depend on them (for example in a home‑server or application‑specific section).
|
||||
|
||||
---
|
||||
|
||||
## 9. Relation to Other Documents
|
||||
|
||||
- [Linux / Cheat Sheet](./CheatSheet.md)
|
||||
@@ -0,0 +1,210 @@
|
||||
# Linux – Basics
|
||||
|
||||
---
|
||||
|
||||
## 1. What Is Linux?
|
||||
|
||||
Linux is a family of open-source operating systems built around the Linux kernel. The kernel was created in 1991 by Linus Torvalds and is now maintained by a large community.
|
||||
|
||||
In practice, "Linux" usually refers to a complete system that combines:
|
||||
|
||||
- The Linux kernel (manages hardware, memory, processes).
|
||||
- User space tools and libraries (often from the GNU project).
|
||||
- Additional software such as shells, utilities, and applications.
|
||||
|
||||
These complete systems are distributed as Linux distributions.
|
||||
|
||||
---
|
||||
|
||||
## 2. Linux Distributions
|
||||
|
||||
A Linux distribution ("distro") bundles the kernel with a selection of software, configuration defaults, and a package manager.
|
||||
|
||||
Common examples include:
|
||||
|
||||
- **Debian / Ubuntu** – widely used on servers and desktops; focus on stability and large software repositories.
|
||||
- **Fedora / RHEL / CentOS / AlmaLinux** – often used in enterprise environments.
|
||||
- **Arch Linux** – rolling release, minimal by default, focused on simplicity and control.
|
||||
- **OpenSUSE**, **Gentoo**, and many others.
|
||||
|
||||
Distributions differ mainly by:
|
||||
|
||||
- Package manager (`apt`, `dnf`, `pacman`, etc.).
|
||||
- Release model (stable vs rolling release).
|
||||
- Default configuration and tooling.
|
||||
|
||||
Despite these differences, the core concepts (filesystem layout, permissions, processes, services) are very similar across distributions.
|
||||
|
||||
---
|
||||
|
||||
## 3. Kernel, User Space, and Shell
|
||||
|
||||
### 3.1 Kernel
|
||||
|
||||
The kernel is the central part of the operating system. It is responsible for:
|
||||
|
||||
- Managing memory and CPU time.
|
||||
- Talking to hardware devices (disks, network cards, etc.).
|
||||
- Creating and scheduling processes.
|
||||
- Enforcing basic security boundaries between processes.
|
||||
|
||||
Users and applications normally do not talk directly to the kernel; they use system calls via libraries and tools.
|
||||
|
||||
### 3.2 User Space
|
||||
|
||||
User space contains all programs that run "on top" of the kernel, such as:
|
||||
|
||||
- Command-line tools (`ls`, `cp`, `mv`, `ps`, etc.).
|
||||
- System utilities (`ip`, `systemctl`, `journalctl`, etc.).
|
||||
- Libraries (for example the C standard library `glibc`).
|
||||
|
||||
These tools are what administrators and scripts interact with in daily work.
|
||||
|
||||
### 3.3 Shell
|
||||
|
||||
The shell is the command-line interpreter used to run commands and scripts. Common shells include:
|
||||
|
||||
- **Bash** (Bourne Again SHell).
|
||||
- **Zsh**.
|
||||
- **Fish**.
|
||||
|
||||
The shell provides features such as:
|
||||
|
||||
- Command history and completion.
|
||||
- Variables and environment management.
|
||||
- Scripting (loops, conditions, functions).
|
||||
|
||||
For concrete shell usage and commands, see:
|
||||
|
||||
- [Linux / Cheat Sheet](./CheatSheet.md)
|
||||
|
||||
---
|
||||
|
||||
## 4. Filesystem and Paths
|
||||
|
||||
Linux uses a single hierarchical filesystem tree that starts at the root directory `/`.
|
||||
|
||||
Typical top-level directories include:
|
||||
|
||||
- `/bin`, `/usr/bin` – essential user commands.
|
||||
- `/sbin`, `/usr/sbin` – system administration commands.
|
||||
- `/lib`, `/usr/lib` – shared libraries.
|
||||
- `/etc` – system-wide configuration files.
|
||||
- `/var` – variable data (logs, spool, caches).
|
||||
- `/home` – home directories for regular users.
|
||||
- `/root` – home directory for the `root` user.
|
||||
- `/tmp` – temporary files.
|
||||
|
||||
Additional mount points (such as `/mnt`, `/srv`, or custom locations) are used for disks, network shares, or application data.
|
||||
|
||||
Paths can be:
|
||||
|
||||
- **Absolute** – start with `/` (for example `/etc/hosts`).
|
||||
- **Relative** – based on the current working directory (for example `../logs`).
|
||||
|
||||
---
|
||||
|
||||
## 5. Users, Groups, and Permissions
|
||||
|
||||
Linux is a multi-user system. Access control is based on users, groups, and file permissions.
|
||||
|
||||
### 5.1 Users and Groups
|
||||
|
||||
- Each user has a numeric user ID (UID) and belongs to one or more groups (GID).
|
||||
- The special user `root` (UID 0) has full administrative privileges.
|
||||
- Regular users have limited permissions and may use tools like `sudo` to perform administrative tasks.
|
||||
|
||||
### 5.2 File Permissions
|
||||
|
||||
Every file and directory has:
|
||||
|
||||
- An owner user.
|
||||
- An owner group.
|
||||
- Permission bits for **user**, **group**, and **others**:
|
||||
- Read (`r`)
|
||||
- Write (`w`)
|
||||
- Execute (`x`)
|
||||
|
||||
Permissions control who can read, modify, or execute a file or enter a directory.
|
||||
|
||||
---
|
||||
|
||||
## 6. Processes and Services
|
||||
|
||||
### 6.1 Processes
|
||||
|
||||
A process is an instance of a running program. Each process has:
|
||||
|
||||
- A process ID (PID).
|
||||
- A parent process.
|
||||
- An associated user.
|
||||
|
||||
Basic operations include listing processes, checking resource usage, and sending signals to stop or reload them.
|
||||
|
||||
Concrete commands for process inspection are listed in:
|
||||
|
||||
- [Linux / Cheat Sheet](./CheatSheet.md)
|
||||
|
||||
### 6.2 Services and systemd
|
||||
|
||||
Many modern distributions use **systemd** as the init system and service manager.
|
||||
|
||||
systemd is responsible for:
|
||||
|
||||
- Starting services at boot.
|
||||
- Managing service dependencies.
|
||||
- Monitoring and restarting services on failure.
|
||||
|
||||
Service definitions are stored as **units** (for example `ssh.service`, `docker.service`).
|
||||
|
||||
For more detailed administration topics (services, logs, units), see:
|
||||
|
||||
- [Linux / Administration](./Administration.md)
|
||||
|
||||
---
|
||||
|
||||
## 7. Networking Overview
|
||||
|
||||
Linux provides a full networking stack, including:
|
||||
|
||||
- IPv4 and IPv6 addressing.
|
||||
- Routing between interfaces.
|
||||
- Firewalling and packet filtering.
|
||||
|
||||
Network configuration usually involves:
|
||||
|
||||
- Assigning IP addresses to interfaces.
|
||||
- Setting gateways and routes.
|
||||
- Configuring DNS resolvers.
|
||||
|
||||
For networking concepts specific to this knowledge base, see:
|
||||
|
||||
- [Network / Basics](../Network/Basics.md)
|
||||
|
||||
---
|
||||
|
||||
## 8. Package Management
|
||||
|
||||
Each distribution uses a package manager to install, update, and remove software:
|
||||
|
||||
- Debian/Ubuntu: `apt`, `apt-get`, `dpkg`.
|
||||
- RHEL/Fedora: `dnf`, `yum`, `rpm`.
|
||||
- Arch Linux: `pacman`.
|
||||
|
||||
Package managers handle:
|
||||
|
||||
- Downloading software from repositories.
|
||||
- Dependency resolution.
|
||||
- Keeping a local database of installed packages.
|
||||
|
||||
Concrete command examples for package management can be added to the Cheat Sheet or distribution-specific notes.
|
||||
|
||||
---
|
||||
|
||||
## 9. Where to Go Next
|
||||
|
||||
- For hands-on commands and quick reminders, see [Linux / Cheat Sheet](./CheatSheet.md).
|
||||
- For administration tasks (services, logs, users, updates), see [Linux / Administration](./Administration.md).
|
||||
- For networking details, see [Network / Basics](../Network/Basics.md).
|
||||
|
||||
This basics document is intended as a neutral foundation that other, more specific guides can reference.
|
||||
@@ -0,0 +1,293 @@
|
||||
# Linux Essential Commands – Cheat Sheet
|
||||
|
||||
Each block groups related commands and includes inline comments so it can be copied and pasted as a whole.
|
||||
|
||||
---
|
||||
|
||||
## 1. Navigation & Help
|
||||
|
||||
```bash
|
||||
# Show current directory
|
||||
pwd
|
||||
|
||||
# List files (basic / long / including hidden)
|
||||
ls
|
||||
ls -l # long listing (permissions, owner, size, date)
|
||||
ls -a # include hidden files (starting with .)
|
||||
|
||||
# Change directory
|
||||
cd /path/to/dir
|
||||
cd ~ # go to home directory
|
||||
cd .. # go up one level
|
||||
|
||||
# Command help
|
||||
man ls # full manual page
|
||||
ls --help # quick help for a command
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. Files & Directories
|
||||
|
||||
```bash
|
||||
# Create or update an empty file
|
||||
touch file.txt
|
||||
|
||||
# Copy files and directories
|
||||
cp source.txt dest.txt
|
||||
cp -r src_dir/ dest_dir/ # copy directory recursively
|
||||
|
||||
# Move or rename
|
||||
mv oldname.txt newname.txt
|
||||
mv file.txt /target/dir/
|
||||
|
||||
# Remove files and directories
|
||||
rm file.txt # remove file
|
||||
rm -r dir_to_remove/ # remove directory recursively
|
||||
rm -rf dir_to_force/ # force remove (use with care)
|
||||
|
||||
# Create directories
|
||||
mkdir new_dir
|
||||
mkdir -p a/b/c # create nested directories
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Viewing & Searching Content
|
||||
|
||||
```bash
|
||||
# View file content
|
||||
cat file.txt # print whole file
|
||||
less file.txt # scrollable view (quit with 'q')
|
||||
|
||||
# View start / end of a file
|
||||
head file.txt # first 10 lines
|
||||
head -n 20 file.txt # first 20 lines
|
||||
tail file.txt # last 10 lines
|
||||
tail -f logfile.log # follow log in real time
|
||||
|
||||
# Search text
|
||||
grep "pattern" file.txt # search in single file
|
||||
grep -r "pattern" /path/dir # recursive in directory
|
||||
grep -ri "pattern" /path/dir # recursive and case-insensitive
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Permissions & Ownership
|
||||
|
||||
```bash
|
||||
# View permissions and ownership
|
||||
ls -l /path/to/file_or_dir
|
||||
|
||||
# Change permissions
|
||||
chmod 644 file.txt # owner read/write, group/others read
|
||||
chmod 600 secret.txt # owner read/write only
|
||||
chmod +x script.sh # add execute bit
|
||||
|
||||
# Change owner and group
|
||||
chown user:group file.txt
|
||||
chown -R user:group /path/to/dir # recursive
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. Users, Groups & sudo (Debian/Ubuntu style)
|
||||
|
||||
```bash
|
||||
# Identify current user and groups
|
||||
whoami
|
||||
id # show UID, GID, and groups
|
||||
|
||||
# Run a command as root (if allowed)
|
||||
sudo command # run single command with privileges
|
||||
|
||||
# User management (Debian/Ubuntu)
|
||||
sudo adduser newuser # interactive user creation
|
||||
sudo passwd newuser # set or change password
|
||||
|
||||
# Add user to an additional group
|
||||
sudo usermod -aG sudo newuser # grant sudo rights (example)
|
||||
sudo usermod -aG docker newuser # allow use of docker group
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. Processes & System Monitoring
|
||||
|
||||
```bash
|
||||
# List processes
|
||||
ps aux # all processes with details
|
||||
|
||||
# Real-time monitoring
|
||||
top # built-in monitor
|
||||
htop # improved top (if installed)
|
||||
|
||||
# Kill a process by PID
|
||||
kill 1234 # ask process to terminate
|
||||
kill -9 1234 # force kill (SIGKILL)
|
||||
|
||||
# Jobs in current shell
|
||||
jobs # list background jobs
|
||||
fg %1 # bring job 1 to foreground
|
||||
bg %1 # send job 1 to background
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7. Services & Logs (systemd)
|
||||
|
||||
```bash
|
||||
# Service management (systemd)
|
||||
sudo systemctl status nginx.service # check status
|
||||
sudo systemctl start nginx.service # start service
|
||||
sudo systemctl stop nginx.service # stop service
|
||||
sudo systemctl restart nginx.service # restart service
|
||||
sudo systemctl enable nginx.service # start at boot
|
||||
sudo systemctl disable nginx.service # do not start at boot
|
||||
|
||||
# View logs with journalctl
|
||||
sudo journalctl -u nginx.service # logs for one unit
|
||||
sudo journalctl -u nginx.service -f # follow logs
|
||||
sudo journalctl -b # logs from current boot
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 8. System Information & Resources
|
||||
|
||||
```bash
|
||||
# Basic system info
|
||||
uname -a # kernel and system info
|
||||
hostname # system hostname
|
||||
|
||||
# Disk and filesystem usage
|
||||
df -h # disk usage by filesystem
|
||||
du -sh /path/to/dir # summary size of a directory
|
||||
|
||||
# Memory and swap usage
|
||||
free -h
|
||||
|
||||
# Uptime and logged-in users
|
||||
uptime
|
||||
w # who is logged in and what they do
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 9. Networking Basics
|
||||
|
||||
```bash
|
||||
# IP addresses and links
|
||||
ip a # show interfaces and addresses
|
||||
ip r # routing table
|
||||
|
||||
# Connectivity tests
|
||||
ping 8.8.8.8 # test raw connectivity
|
||||
ping example.com # test DNS + connectivity
|
||||
|
||||
# Open/listening ports
|
||||
sudo ss -tulpn # TCP/UDP sockets with PIDs
|
||||
|
||||
# HTTP requests and downloads
|
||||
curl https://example.com # simple HTTP GET
|
||||
wget https://example.com/file.iso # download file
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 10. Storage & Mounts (Conceptual Commands)
|
||||
|
||||
```bash
|
||||
# List block devices (disks/partitions)
|
||||
lsblk # tree view of devices and mount points
|
||||
|
||||
# Show filesystems and usage
|
||||
df -h # mounted filesystems
|
||||
|
||||
# Show current mounts
|
||||
mount | grep "/"
|
||||
|
||||
# View /etc/fstab (persistent mounts)
|
||||
sudo nano /etc/fstab # edit with care
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 11. Archives & Compression
|
||||
|
||||
```bash
|
||||
# Create and extract tar archives
|
||||
tar -cf archive.tar file1 dir2 # create tar
|
||||
tar -xf archive.tar # extract tar
|
||||
|
||||
# Create and extract compressed tar.gz
|
||||
tar -czf archive.tar.gz file1 dir2 # create tar.gz
|
||||
tar -xzf archive.tar.gz # extract tar.gz
|
||||
|
||||
# Zip archives
|
||||
zip archive.zip file1 file2 # create zip
|
||||
unzip archive.zip # extract zip
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 12. Package Management (Debian / Ubuntu)
|
||||
|
||||
```bash
|
||||
# Update package lists and upgrade
|
||||
sudo apt update # refresh package index
|
||||
sudo apt upgrade # upgrade installed packages
|
||||
|
||||
# Install, remove, purge packages
|
||||
sudo apt install htop # install package
|
||||
sudo apt remove htop # remove package (keep config)
|
||||
sudo apt purge htop # remove package + config
|
||||
|
||||
# Search and inspect packages
|
||||
apt search nginx # search in repositories
|
||||
apt show nginx # show details
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 13. SSH & Remote Access
|
||||
|
||||
```bash
|
||||
# Connect to a remote host
|
||||
ssh user@server.example.com
|
||||
|
||||
# Use a specific key and port
|
||||
ssh -i ~/.ssh/id_ed25519 -p 2222 user@server.example.com
|
||||
|
||||
# Copy files over SSH
|
||||
scp file.txt user@server.example.com:/remote/path/
|
||||
scp -r dir/ user@server.example.com:/remote/path/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 14. Shutdown & Reboot
|
||||
|
||||
```bash
|
||||
# Shutdown and reboot (systemd)
|
||||
sudo shutdown now # immediate shutdown
|
||||
sudo shutdown -r now # immediate reboot
|
||||
sudo shutdown +5 # shutdown in 5 minutes
|
||||
|
||||
sudo reboot # reboot system
|
||||
sudo poweroff # power off system
|
||||
|
||||
sudo systemctl reboot # reboot via systemd
|
||||
sudo systemctl poweroff # power off via systemd
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 15. Shell Shortcuts (Bash)
|
||||
|
||||
- `Ctrl + C` – Cancel current command
|
||||
- `Ctrl + D` – Logout / send EOF
|
||||
- `Ctrl + R` – Search in command history
|
||||
- `↑` / `↓` – Navigate command history
|
||||
- `Tab` – Auto-completion
|
||||
@@ -0,0 +1,172 @@
|
||||
# Linux – Storage
|
||||
|
||||
Overview of storage concepts on Linux systems. It Focus on how disks, partitions, file systems, and mount points fit together.
|
||||
|
||||
General introduction to Linux and its filesystem layout:
|
||||
|
||||
- [Linux / Basics](./Basics.md)
|
||||
|
||||
---
|
||||
|
||||
## 1. Disks, Partitions, and Devices
|
||||
|
||||
On Linux, disks and partitions are exposed as device files under `/dev`.
|
||||
|
||||
Typical examples:
|
||||
|
||||
- `/dev/sda`, `/dev/sdb` – whole disks (SATA/SCSI).
|
||||
- `/dev/nvme0n1` – NVMe disk.
|
||||
- `/dev/sda1`, `/dev/sda2` – partitions on `/dev/sda`.
|
||||
- `/dev/nvme0n1p1` – partition on an NVMe disk.
|
||||
|
||||
Key ideas:
|
||||
|
||||
- A **disk** can contain one or more **partitions**.
|
||||
- A **file system** is created on a partition (or on other block devices such as LVM volumes).
|
||||
|
||||
---
|
||||
|
||||
## 2. File Systems
|
||||
|
||||
Common Linux file systems include:
|
||||
|
||||
- **ext4** – widely used default file system on many distributions.
|
||||
- **xfs** – often used on servers, good for large files and parallel workloads.
|
||||
- **btrfs**, **zfs** – advanced file systems with snapshots and additional features.
|
||||
|
||||
Responsibilities of a file system:
|
||||
|
||||
- Organising data into files and directories.
|
||||
- Tracking metadata (permissions, timestamps, ownership).
|
||||
- Handling allocation on the underlying block device.
|
||||
|
||||
The choice of file system depends on requirements such as performance, robustness, and feature set (for example snapshot support).
|
||||
|
||||
---
|
||||
|
||||
## 3. Mount Points and the Unified Tree
|
||||
|
||||
Linux presents storage through a single unified directory tree.
|
||||
|
||||
To make a file system available, it is **mounted** at a directory path (the mount point).
|
||||
|
||||
Examples:
|
||||
|
||||
- A root file system on `/`.
|
||||
- Additional storage mounted under `/srv`, `/mnt`, or `/data`.
|
||||
- Removable media mounted under `/media` or `/run/media`.
|
||||
|
||||
Important aspects:
|
||||
|
||||
- The same directory path can hide existing contents when a new file system is mounted on top of it.
|
||||
- Consistent mount points simplify backups and documentation.
|
||||
|
||||
---
|
||||
|
||||
## 4. /etc/fstab and Persistent Mounts
|
||||
|
||||
The file `/etc/fstab` defines which file systems are mounted at boot.
|
||||
|
||||
Each entry typically specifies:
|
||||
|
||||
- The device (for example a UUID or `/dev/sda1`).
|
||||
- The mount point (for example `/srv/data`).
|
||||
- The file system type (for example `ext4`).
|
||||
- Mount options.
|
||||
|
||||
Conceptual points:
|
||||
|
||||
- Using UUIDs or labels makes mounts more stable than relying on `/dev/sdX` names.
|
||||
- Mount options can influence performance and safety (for example `noatime`, `defaults`, `ro`).
|
||||
- Misconfigured entries can prevent the system from booting cleanly, so changes should be tested carefully.
|
||||
|
||||
Project‑specific mount layouts (for example for application data) can be documented alongside the systems that use them.
|
||||
|
||||
---
|
||||
|
||||
## 5. LVM and RAID (Overview)
|
||||
|
||||
In addition to simple disk‑partition‑filesystem setups, Linux supports more advanced storage layers.
|
||||
|
||||
### 5.1 LVM (Logical Volume Manager)
|
||||
|
||||
LVM introduces an extra abstraction layer:
|
||||
|
||||
- Physical volumes (PVs) are typically partitions or whole disks.
|
||||
- Volume groups (VGs) combine one or more PVs.
|
||||
- Logical volumes (LVs) are created inside VGs and used like regular block devices.
|
||||
|
||||
Advantages:
|
||||
|
||||
- Flexible resizing of logical volumes.
|
||||
- Ability to span volumes across multiple physical disks.
|
||||
|
||||
### 5.2 RAID (mdadm and hardware RAID)
|
||||
|
||||
RAID (Redundant Array of Independent Disks) is used for redundancy, performance, or both.
|
||||
|
||||
Common levels:
|
||||
|
||||
- RAID 1 – mirroring for redundancy.
|
||||
- RAID 5/6 – striping with parity.
|
||||
- RAID 10 – combination of striping and mirroring.
|
||||
|
||||
Implementation options:
|
||||
|
||||
- Software RAID with `md` devices (managed by tools such as `mdadm`).
|
||||
- Hardware RAID controllers that present a single virtual disk.
|
||||
|
||||
LVM and RAID are often combined for flexibility and resilience.
|
||||
|
||||
---
|
||||
|
||||
## 6. Swap Space
|
||||
|
||||
Swap provides additional virtual memory by using disk space when physical RAM is exhausted.
|
||||
|
||||
Swap can be configured as:
|
||||
|
||||
- A dedicated swap partition.
|
||||
- A swap file on an existing file system.
|
||||
|
||||
Considerations:
|
||||
|
||||
- Swap is much slower than RAM, but can prevent out‑of‑memory conditions.
|
||||
- On some systems, hibernation relies on swap configuration.
|
||||
|
||||
---
|
||||
|
||||
## 7. Monitoring Space Usage (Conceptual)
|
||||
|
||||
Administrators need to keep track of available disk space and inode usage.
|
||||
|
||||
Key concepts:
|
||||
|
||||
- Total vs used vs available space for each mounted file system.
|
||||
- Inode counts (maximum number of files/directories a file system can track).
|
||||
- Distinguishing usage on the root file system from usage on separate data file systems.
|
||||
|
||||
Concrete commands for checking disk and inode usage can be listed in:
|
||||
|
||||
- [Linux / Cheat Sheet](./CheatSheet.md)
|
||||
|
||||
---
|
||||
|
||||
## 8. Backup‑Friendly Layouts
|
||||
|
||||
Storage layout has a strong impact on backup and restore strategies.
|
||||
|
||||
General considerations:
|
||||
|
||||
- Separating system files from application and user data simplifies targeted backups.
|
||||
- Grouping related data under well‑defined mount points (for example `/srv`) makes it easier to snapshot or back up.
|
||||
- Avoiding unnecessary writes on system partitions can reduce wear on SSDs.
|
||||
|
||||
Backup strategies themselves are usually documented alongside the systems or applications that depend on them.
|
||||
|
||||
---
|
||||
|
||||
## 9. Relation to Other Documents
|
||||
|
||||
- High‑level Linux concepts: [Linux / Basics](./Basics.md)
|
||||
- Administration topics (permissions, services, backups): [Linux / Administration](./Administration.md)
|
||||
Reference in New Issue
Block a user