Skip to main content

disk/file management

FHS - Filesystem Hierarchy Standard

📂 The Core System Directories

  • / (Root): The starting point of the entire directory tree.
  • /bin (Essential Binaries): Contains fundamental user command binaries like ls, cp, and ping.
  • /sbin (System Binaries): Essential commands for system administration, like iptables and reboot.
  • /boot (Boot Loader): Stores files needed to boot the system, including the Linux kernel.
  • /etc (Configuration): Holds all system-wide configuration files and startup scripts.
  • /lib (System Libraries): Contains shared library files required by binaries in /bin and /sbin.

👥 User and Application Data

  • /home (User Profiles): Personal folders for regular users (e.g., /home/john).
  • /root (Admin Home): The separate home directory for the root (administrator) user.
  • /usr (User Programs): The largest directory; contains user binaries, documentation, and libraries.
  • /opt (Optional Software): Reserved for manual installation of third-party software packages.

⚙️ Virtual and Runtime Directories

  • /dev (Device Files): Represents hardware components as files (e.g., /dev/sda for a hard drive).
  • /proc (Process Info): A virtual filesystem showing system resource and process information.
  • /sys (System Devices): A virtual directory to view and change kernel-tuned hardware settings.
  • /run (Runtime Data): Stores volatile runtime data since the last system boot.

💾 Storage and Temporary Files

  • /var (Variable Data): Files that change constantly, such as system logs (/var/log) and mail.
  • /tmp (Temporary Files): Stores temporary files created by applications; usually cleared on reboot.
  • /media (Removable Media): Automatic mount points for USB drives, CDs, and external disks.
  • /mnt (Mount Point): A location for administrators to manually mount temporary filesystems.

disk

  • lsblk: Lists all block devices (hard drives, partitions, and USBs) in a visual tree layout without needing root rights.
  • lsblk -f: Shows block devices along with their assigned file system types and unique UUIDs.
  • df -h - show disk size human readable

show folder size

  • show folder size: sudo du -shc ./*

find biggest folders of current directory

du -hs * | sort -rh | head -5

backup and write usb drive

  • sudo dd if=/dev/sdX of=~/MeinLaufwerkBackup.img bs=4M status=progress conv=fdatasync create image of usb drive
    • if=/dev/sdX: The input file (your target physical disk or block device, e.g., /dev/sda or /dev/sdb).
    • of=...: The output file path where the raw .img will be written.
    • bs=4M: Sets a larger block size (4 megabytes) to dramatically accelerate the reading and writing speed.
    • status=progress: Prints a live counter showing bytes transferred and elapsed time.
    • conv=fdatasync: Forces the system to physically write and flush all buffers to the destination storage before finalizing the command.
  • sudo dd if=/path/to/image.iso of=/dev/sdX bs=4M status=progress oflag=sync write image on usb drive
    • oflag=sync forces the system to physically write both data and metadata

resize partition

use gparted

file movements

rsync

  • https://wiki.ubuntuusers.de/rsync/

options

  • a - contains highly recommended
    • -r copy subfolder
    • -l copy symbolic links
    • -p keep permissions of source files
    • -t keep timestamps of source files
    • -g keep group permissions of source files
    • -o keep user permissions of source files (only root)
    • -D keep device permissions of source files (only root)
  • v - verbose
  • h - human readable
  • z - with compression
  • -e - remote shell auswählen
    • -e 'ssh -p 222' ändert ssh port auf e.g. 222

local to remote server

rsync [option] [source] user@hostname-or-ip:[destination path]
rsync -avhz /home/source-rsync/ user@your-remote-server.com:/home/dest-rsync/

remote to local server

rsync -avhz user@your-remote-server.com:/home/dest-rsync/ /home/source-rsync/

scp

scp <Optionen> <Quellpfad> <Zielpfad>

  • Quellpfad: <Nutzer>@<Host>:<Verzeichnis/Datei.Endung>
  • optionen:
    • -C Kompression nutzen (compression)
    • -p Datei-Attribute auf Zieldateien übertragen (permissions)
    • -r Verzeichnisse rekursiv kopieren (recursive)
    • -v Erweiterte Ausgabe anzeigen (verbose)
    • -q Ausgabe unterdrücken (quiet)
    • -3 Daten durch lokales System senden (third party)

example:

scp -r srv01-local_draab:/var/lib/docker/volumes/wireguard_wireguard-config/_data/ /home/danielraab/wireguard/