basforge

Search titles, text and the “If it doesn’t work” cases.

    RU
    Cheat sheetLinuxUbuntu server

    An Ubuntu server: everyday commands

    Services, journal, packages, disk, memory, network and users — the commands a server needs every week. The same on Ubuntu 24.04 and 26.04; where they differ, it says so.

    systemd services

    Command What it does
    systemctl status ssh is the service alive, plus its latest log lines
    sudo systemctl restart docker restart
    sudo systemctl reload nginx reread the config without stopping, if the service supports it
    sudo systemctl enable --now chrony enable at boot and start now
    sudo systemctl disable --now snapd stop and remove from boot
    systemctl --failed which services failed
    systemctl list-timers timers: what runs when
    systemctl cat ssh.socket the unit file with all its drop-ins
    sudo systemctl edit docker your own drop-in for a unit; survives package upgrades
    sudo systemctl daemon-reload reread units after editing files

    Journal

    Command What it does
    journalctl -u ssh -n 50 a service’s last 50 lines
    journalctl -u docker -f follow live
    journalctl -b -p err errors since the last boot
    journalctl -b -1 -p warning warnings from the previous boot — why it went down
    journalctl --since "2026-10-18 03:50" --until "04:10" what happened around the nightly reboot
    journalctl -k -g 'Out of memory' whom the OOM killer killed
    journalctl --disk-usage how much the journal takes (Swap, journal and time)
    sudo tail -f /var/log/auth.log SSH logins and sudo

    Packages

    Command What it does
    sudo apt update && apt list --upgradable what can be upgraded
    sudo apt full-upgrade upgrade everything, including dependency changes
    sudo apt install --only-upgrade docker-ce upgrade one package without installing new ones
    sudo apt autoremove --purge remove unneeded dependencies and old kernels
    apt-cache policy openssh-server which version is installed and where a new one would come from
    dpkg -L crowdsec-firewall-bouncer-nftables which files a package installed
    dpkg -S /usr/sbin/sshd which package a file belongs to
    sudo apt-mark hold docker-ce pin a package’s version; unhold releases it
    cat /var/run/reboot-required.pkgs which packages wait for a reboot (Is a reboot needed)
    sudo pro status is Ubuntu Pro and ESM attached

    Disk

    Command What it does
    df -h -x tmpfs -x overlay free space on real disks
    df -i / free inodes: there’s space, but files won’t create
    sudo du -xh / --max-depth=2 | sort -h | tail -15 the biggest directories
    sudo ncdu -x / the same, with navigation; the ncdu package
    sudo docker system df space taken by images, containers, volumes
    sudo docker image prune -a remove images with no containers
    lsblk -f disks, partitions, file systems
    sudo lsof +L1 deleted files a process still holds: the space isn’t freed

    Memory and processes

    Command What it does
    free -h memory and swap; look at available, not free
    uptime load over 1, 5, 15 minutes
    htop processes live; F6 to sort
    ps aux --sort=-%mem | head who ate the memory
    sudo docker stats --no-stream memory and CPU per container
    systemd-cgtop load per service and container

    Network

    Command What it does
    sudo ss -tulpn what listens, and which process
    ip -br a interface addresses, one line each
    ip r routes; default via is the gateway
    resolvectl status which DNS servers the system uses
    curl -4 ifconfig.me the server’s public address
    sudo ufw status numbered firewall rules (The ufw firewall)
    sudo nft list ruleset | less every nftables rule: ufw, Docker, CrowdSec
    mtr -rwc 20 example.org where packets get lost on the way

    System and users

    Command What it does
    lsb_release -d; uname -r Ubuntu version and kernel
    hostnamectl name, OS, virtualization
    timedatectl time zone and clock sync
    who; last -n 10 who’s on the server now and who logged in
    sudo adduser alex && sudo usermod -aG sudo alex a new admin
    sudo deluser --remove-home alex delete a user with their home directory
    id example-user a user’s groups
    sudo -l what sudo allows you
    sudo visudo -f /etc/sudoers.d/90-deploy your own sudo rule, with a syntax check

    On 26.04 sudo is sudo-rs: the same commands, but sudo -E doesn’t keep the environment — pass what you need with --preserve-env=VAR.

    Reboot and shutdown

    Command What it does
    sudo reboot reboot now
    sudo shutdown -r 04:00 reboot at 4:00; shutdown -c cancels
    sudo systemctl rescue single-user mode; the network goes down — only from the provider console
    last -x reboot | head -5 when the server rebooted