From 563202f9869685d096df0885720581f5133c2ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Thu, 5 Mar 2026 17:47:01 +0100 Subject: [PATCH] Initial commit --- .gitignore | 35 +++ Doc/Containerisation/Basics.md | 0 Doc/Containerisation/Docker/Basics.md | 0 Doc/Containerisation/Docker/Commands.md | 0 Doc/Home-Server/Containers/Stacks.md | 15 + Doc/Home-Server/Implementations/DNS/Caddy.md | 19 ++ .../Implementations/DNS/dnsmasq.md | 19 ++ .../Implementations/Monitoring/Overview.md | 15 + .../Implementations/VPN/WireGuard.md | 24 ++ Doc/Home-Server/Introduction.md | 117 +++++++ Doc/Linux/Administration.md | 147 +++++++++ Doc/Linux/Basics.md | 210 +++++++++++++ Doc/Linux/CheatSheet.md | 293 ++++++++++++++++++ Doc/Linux/Storage.md | 172 ++++++++++ Doc/Network/Basics.md | 16 + Doc/Network/DNS.md | 18 ++ Doc/Network/ReverseProxy.md | 18 ++ Doc/Network/SSH.md | 1 + Doc/Network/VPN/Basics.md | 12 + Doc/Security/Certificates.md | 5 + 20 files changed, 1136 insertions(+) create mode 100644 .gitignore create mode 100644 Doc/Containerisation/Basics.md create mode 100644 Doc/Containerisation/Docker/Basics.md create mode 100644 Doc/Containerisation/Docker/Commands.md create mode 100644 Doc/Home-Server/Containers/Stacks.md create mode 100644 Doc/Home-Server/Implementations/DNS/Caddy.md create mode 100644 Doc/Home-Server/Implementations/DNS/dnsmasq.md create mode 100644 Doc/Home-Server/Implementations/Monitoring/Overview.md create mode 100644 Doc/Home-Server/Implementations/VPN/WireGuard.md create mode 100644 Doc/Home-Server/Introduction.md create mode 100644 Doc/Linux/Administration.md create mode 100644 Doc/Linux/Basics.md create mode 100644 Doc/Linux/CheatSheet.md create mode 100644 Doc/Linux/Storage.md create mode 100644 Doc/Network/Basics.md create mode 100644 Doc/Network/DNS.md create mode 100644 Doc/Network/ReverseProxy.md create mode 100644 Doc/Network/SSH.md create mode 100644 Doc/Network/VPN/Basics.md create mode 100644 Doc/Security/Certificates.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c77a332 --- /dev/null +++ b/.gitignore @@ -0,0 +1,35 @@ +# Dépendances Node +node_modules/ + +# Build Docusaurus +build/ +.docusaurus/ + +# Logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +*.log + +# Caches +.cache/ +.tmp/ + +# Environnements locaux +.env +.env.local +.env.development.local +.env.test.local +.env.production.local + +# Éditeurs / IDE +.vscode/ +.idea/ + +# OS +.DS_Store +Thumbs.db + +# Divers +dist/ \ No newline at end of file diff --git a/Doc/Containerisation/Basics.md b/Doc/Containerisation/Basics.md new file mode 100644 index 0000000..e69de29 diff --git a/Doc/Containerisation/Docker/Basics.md b/Doc/Containerisation/Docker/Basics.md new file mode 100644 index 0000000..e69de29 diff --git a/Doc/Containerisation/Docker/Commands.md b/Doc/Containerisation/Docker/Commands.md new file mode 100644 index 0000000..e69de29 diff --git a/Doc/Home-Server/Containers/Stacks.md b/Doc/Home-Server/Containers/Stacks.md new file mode 100644 index 0000000..be4f807 --- /dev/null +++ b/Doc/Home-Server/Containers/Stacks.md @@ -0,0 +1,15 @@ +# Docker Stacks Layout + +This page is my reference for how I structure Docker stacks on the home server. + +## Scope + +- Where stacks live on disk. +- How I name stacks, services, and volumes. +- How I update or recreate a stack safely. + +## Notes / TODO + +- Describe `/srv/ssd` layout in detail. +- Document a real example stack (e.g. monitoring or media). +- Add a short “update procedure” for a stack. diff --git a/Doc/Home-Server/Implementations/DNS/Caddy.md b/Doc/Home-Server/Implementations/DNS/Caddy.md new file mode 100644 index 0000000..b120146 --- /dev/null +++ b/Doc/Home-Server/Implementations/DNS/Caddy.md @@ -0,0 +1,19 @@ +# Caddy Reverse Proxy – Home Server Implementation + +This page is my reference for how I use Caddy as a reverse proxy on the home server. + +For generic concepts, see: + +- [Network / Reverse Proxy](../../../Network/ReverseProxy.md) (when written) +- [Security / Certificates](../../../Security/Certificates.md) + +## Scope + +- Caddy virtual hosts for `.lan` domains. +- TLS with the internal CA (`tls internal`). +- How I add a new internal HTTPS service. + +## Notes / TODO + +- Document the Caddyfile pattern I use for HTTP → HTTPS. +- Add a checklist for adding a new service (DNS + Caddy + Docker + Caddy). diff --git a/Doc/Home-Server/Implementations/DNS/dnsmasq.md b/Doc/Home-Server/Implementations/DNS/dnsmasq.md new file mode 100644 index 0000000..09ce255 --- /dev/null +++ b/Doc/Home-Server/Implementations/DNS/dnsmasq.md @@ -0,0 +1,19 @@ +# dnsmasq – Home Server Implementation + +This page is my reference for how I configured dnsmasq as internal DNS on the home server. + +For generic DNS concepts, see: + +- [Network / DNS](../../../Network/DNS.md) + +## Scope + +- dnsmasq config for `.lan` internal domains. +- How clients use the home server as DNS. +- How this integrates with Caddy and WireGuard. + +## Notes / TODO + +- Add example dnsmasq config for `vaultwarden.lan`, `home.lan`, etc. +- Document how I point LAN clients and VPN clients to this DNS. +- Add a short troubleshooting section (cache, logs, typical mistakes). diff --git a/Doc/Home-Server/Implementations/Monitoring/Overview.md b/Doc/Home-Server/Implementations/Monitoring/Overview.md new file mode 100644 index 0000000..cd0a6da --- /dev/null +++ b/Doc/Home-Server/Implementations/Monitoring/Overview.md @@ -0,0 +1,15 @@ +# Monitoring and Dashboard + +This page is my overview of the monitoring stack on the home server. + +## Scope + +- Homepage, Uptime Kuma, Dozzle, Glances. +- How they are wired together (ports, Caddy, DNS, Docker). +- What I check first when something looks wrong. + +## Notes / TODO + +- Summarise the docker-compose layout for `/srv/ssd/stacks/monitoring`. +- Add examples of Homepage widgets and Kuma checks I use. +- Document a basic "health check" routine for the server. diff --git a/Doc/Home-Server/Implementations/VPN/WireGuard.md b/Doc/Home-Server/Implementations/VPN/WireGuard.md new file mode 100644 index 0000000..a2e6aa5 --- /dev/null +++ b/Doc/Home-Server/Implementations/VPN/WireGuard.md @@ -0,0 +1,24 @@ +# WireGuard VPN – Home Server Implementation + +This page is my reference for how I use WireGuard for remote access to the home server. + +For generic concepts, see: + +- [Network / VPN Basics](../../../Network/VPN/Basics.md) +- [Security / Certificates](../../../Security/Certificates.md) + +For the original full step-by-step guide I used at the beginning, see: + +- WireGuard v1 doc (legacy) – to be migrated here. + +## Scope + +- IP plans for LAN and VPN. +- Server and client roles. +- How I add a new peer safely. + +## Notes / TODO + +- Summarise the `wg0.conf` structure from the v1 doc. +- Document the exact steps I follow to add a new client. +- Add a short troubleshooting section (common mistakes). diff --git a/Doc/Home-Server/Introduction.md b/Doc/Home-Server/Introduction.md new file mode 100644 index 0000000..1108e0b --- /dev/null +++ b/Doc/Home-Server/Introduction.md @@ -0,0 +1,117 @@ +# Home Server – Overview + +--- + +## 1. Goals + +- Central point for my home-lab and dev-ops learning. +- Self-hosted services for media viewers, git, password manager, home assistant, etc. +- Clean separation between OS, data, and Docker stacks. +- Easy to maintain, backup, and rebuild if needed. + +--- + +## 2. Hardware and Base OS + +- Hardware: ZimaBoard used as a low-power home server. +- OS: Debian installed on the internal eMMC. +- Role: main server for the home LAN and VPN clients. + +Linux basics and commands: +- [Linux / Basics](../Linux/Basics.md) +- [Linux / Administration](../Linux/Administration.md) +- [Linux / Cheat Sheet](../Linux/CheatSheet.md) + +--- + +## 3. Storage Layout + +OS, Docker, and data are clearly separated: + +- eMMC: system root (`/`), `/boot`, and base Debian. +- NVMe SSD mounted on `/srv/ssd` for Docker (data-root, stacks, appdata). +- Data disks: + - `/srv/ebooks` (sda1, ext4) for ebooks and comics. + - `/srv/media` (sdb1, ext4) for movies, series, etc. + +Key idea: Docker stacks and appdata live on the NVMe (`/srv/ssd`), not on `/`. + +- [Linux / Storage](../Linux/Storage.md) + +--- + +## 4. Docker and Application Stacks + +Docker runs on the Debian host and is my main way to deploy services. + +- Docker data-root and volumes live under `/srv/ssd`. +- Stacks are organised under `/srv/ssd/stacks//`. +- Typical services: + - Media: Komga (ebooks), Jellyfin (videos). + - Dev: Gitea + Postgres. + - Security: Vaultwarden. + - Monitoring: Homepage, Uptime Kuma, Dozzle, Glances. +- Containers use `restart: unless-stopped` so they come back after reboot. + +Containerisation, Docker concepts and commands: + +- [Containerisation](../Containerisation/Basics.md) +- [Containerisation / Docker](../Containerisation/Docker/Basics.md) +- [Containerisation / Docker / Commands](../Containerisation/Docker/Commands.md) + +--- + +## 5. Networking, DNS, and Reverse Proxy + +Home server is the central point for internal names and HTTPS access. + +- Internal DNS: `dnsmasq` on the host, listening on `0.0.0.0:53`. + - Resolves `*.lan` names (vaultwarden.lan, komga.lan, home.lan, etc.) to the server IP (for example 192.168.1.18). + - Forwards public domains to external resolvers. +- Reverse proxy: Caddy in front of services on ports 80/443. + - Exposes internal virtual hosts like `vaultwarden.lan`, `home.lan`, `status.lan`, `logs.lan`, `metrics.lan`, `komga.lan`, `gitea.lan`, `jellyfin.lan`. + - Uses `tls internal` with an internal CA; I install the root CA certificate on clients so browsers trust `*.lan`. + +Networking, DNS, and Reverse Proxy Documentation + +- [Network / Basics](../Network/Basics.md) +- [Network / DNS](../Network/DNS.md) +- [Network / Reverse Proxy](../Network/ReverseProxy.md) + +--- + +## 6. Remote Access + +Remote access is provided by a WireGuard VPN running on the Debian host. + +- Server interface: `wg0` with address `10.10.10.1/24`, listening on UDP 51820. +- Clients (PC, smartphone, etc.) get one IP each in `10.10.10.0/24`. +- NAT rules allow VPN clients to reach the home LAN (`192.168.1.0/24`). +- Clients send both VPN and LAN traffic through the tunnel via `AllowedIPs = 10.10.10.0/24, 192.168.1.0/24`. +- DNS for clients is the home server itself (10.10.10.1) so `.lan` names always work. + +Remote access documentation: + +- [Network / VPN Basics](../Network/VPN/Basics.md) +- [Security / Certificates](../Security/Certificates.md) +- [Home-Server / WireGuard implementation](../Home-Server/Implementations/VPN/WireGuard.md) + +--- + +## 7. Monitoring and Dashboard + +Monitoring is based on a lightweight stack under `/srv/ssd/stacks/monitoring`: + +- Homepage: main dashboard and entry point for services, with basic widgets. +- Uptime Kuma: service availability checks. +- Dozzle: real‑time Docker logs. +- Glances: system metrics (CPU, RAM, disks, Docker, network). + +These services are exposed internally via Caddy and DNS: + +- `https://home.lan` → Homepage +- `https://status.lan` → Uptime Kuma +- `https://logs.lan` → Dozzle +- `https://metrics.lan` → Glances + +--- diff --git a/Doc/Linux/Administration.md b/Doc/Linux/Administration.md new file mode 100644 index 0000000..3d03e92 --- /dev/null +++ b/Doc/Linux/Administration.md @@ -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) \ No newline at end of file diff --git a/Doc/Linux/Basics.md b/Doc/Linux/Basics.md new file mode 100644 index 0000000..be5e389 --- /dev/null +++ b/Doc/Linux/Basics.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. \ No newline at end of file diff --git a/Doc/Linux/CheatSheet.md b/Doc/Linux/CheatSheet.md new file mode 100644 index 0000000..8e8092f --- /dev/null +++ b/Doc/Linux/CheatSheet.md @@ -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 diff --git a/Doc/Linux/Storage.md b/Doc/Linux/Storage.md new file mode 100644 index 0000000..f1c80eb --- /dev/null +++ b/Doc/Linux/Storage.md @@ -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) \ No newline at end of file diff --git a/Doc/Network/Basics.md b/Doc/Network/Basics.md new file mode 100644 index 0000000..60707c4 --- /dev/null +++ b/Doc/Network/Basics.md @@ -0,0 +1,16 @@ +# Network – Basics + +This page is for general networking concepts I reuse across projects. + +At the end of each topic, I link to my home server implementation when it exists. + +Related detailed pages: + +- [Network / DNS](./DNS.md) +- [Network / VPN Basics](./VPN/Basics.md) +- [Network / Reverse Proxy](./ReverseProxy.md) + +## TODO + +- Add sections for IP addressing, routing, DNS, and HTTP(S). +- Link to home-server implementation pages from each section. diff --git a/Doc/Network/DNS.md b/Doc/Network/DNS.md new file mode 100644 index 0000000..56f14f9 --- /dev/null +++ b/Doc/Network/DNS.md @@ -0,0 +1,18 @@ +# DNS – Basics + +This page is for generic DNS concepts I reuse across projects. + +## Scope + +- What DNS does (names → IPs). +- Difference between public DNS and internal DNS. +- Common record types (A, AAAA, CNAME, etc.). + +## Notes / TODO + +- Add examples with public domains. +- Explain how internal `.lan` domains fit into this picture. + +For my concrete home server DNS setup, see: + +- [Home-Server / dnsmasq implementation](../Home-Server/Implementations/DNS/dnsmasq.md) diff --git a/Doc/Network/ReverseProxy.md b/Doc/Network/ReverseProxy.md new file mode 100644 index 0000000..532a254 --- /dev/null +++ b/Doc/Network/ReverseProxy.md @@ -0,0 +1,18 @@ +# Reverse Proxy – Basics + +This page is for generic reverse-proxy concepts (HTTP, HTTPS, virtual hosts) without being tied to a specific tool. + +## Scope + +- Role of a reverse proxy in front of services. +- Virtual hosts and routing by hostname. +- TLS termination and certificates. + +## Notes / TODO + +- Add a small diagram of client → reverse proxy → backend. +- Compare briefly Caddy / Nginx / Traefik. + +For my concrete Caddy setup on the home server, see: + +- [Home-Server / Caddy implementation](../Home-Server/Implementations/DNS/Caddy.md) diff --git a/Doc/Network/SSH.md b/Doc/Network/SSH.md new file mode 100644 index 0000000..a16511d --- /dev/null +++ b/Doc/Network/SSH.md @@ -0,0 +1 @@ +## TODO \ No newline at end of file diff --git a/Doc/Network/VPN/Basics.md b/Doc/Network/VPN/Basics.md new file mode 100644 index 0000000..6b3eca6 --- /dev/null +++ b/Doc/Network/VPN/Basics.md @@ -0,0 +1,12 @@ +# VPN – Basics + +This page is for generic VPN concepts (tunnels, peers, routing, AllowedIPs) without being tied to a specific implementation. + +## TODO + +- Summarise common patterns for split-tunnel vs full-tunnel. +- Explain the idea of "server" vs "peer" in WireGuard terms. + +For my concrete WireGuard setup on the home server, see: + +- [Home-Server / WireGuard implementation](../../Home-Server/Implementations/VPN/WireGuard.md) diff --git a/Doc/Security/Certificates.md b/Doc/Security/Certificates.md new file mode 100644 index 0000000..4d4eb28 --- /dev/null +++ b/Doc/Security/Certificates.md @@ -0,0 +1,5 @@ +# Certificates and Internal PKI + +## Scope + +- What's a certificate, how does it work, how to manage them