Linux questions and answers
Use this page as a quick reference for common Ubuntu self-hosting tasks.
Run a script as a service
Section titled “Run a script as a service”If you run a script like ./myscript.sh and want it to start automatically after reboot, create a systemd unit.
[Unit]Description=Virtual Distributed EthernetAfter=network.target
[Service]Type=simpleExecStart=/usr/bin/YOUR_SCRIPTRestart=on-failure
[Install]WantedBy=multi-user.targetReload systemd, enable the service, and start it:
sudo systemctl daemon-reloadsudo systemctl enable myscript.servicesudo systemctl start myscript.servicesudo systemctl status myscript.serviceSchedule a nightly reboot
Section titled “Schedule a nightly reboot”Open your crontab:
crontab -eAdd this line at the bottom:
0 4 * * * /sbin/shutdown -r +5This announces reboot at 04:00 and reboots at 04:05.
Cron format:
m h dom mon dow commandRemove old or unused Docker data
Section titled “Remove old or unused Docker data”Check Docker disk usage:
docker system dfPrune commands:
docker container prunedocker image prunedocker network prunedocker volume prunedocker system prune
Remove all unused images (not only dangling):
docker image prune -aRemove most unused Docker objects:
docker system prune --allClean your server
Section titled “Clean your server”Check filesystem usage:
df -hInstall and run ncdu for interactive analysis:
sudo apt install -y ncdusudo ncdu /Common cleanup targets:
-
Old logs in
/var/log:Terminal window sudo journalctl --vacuum-time=2d -
Unused Docker objects in
/var/lib/docker:Terminal window sudo docker image prunesudo docker container prunesudo docker network prunesudo docker volume prunesudo docker system prune -a -
Unused packages:
Terminal window sudo apt autoremove
Scripts
Section titled “Scripts”Geo check
Section titled “Geo check”wget -qO - "https://raw.githubusercontent.com/vernette/ipregion/refs/heads/master/ipregion.sh" | bashSpeedtest
Section titled “Speedtest”sudo apt update && sudo apt install -y curl && curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash && sudo apt install -y speedtest && speedtestIP check for service blocks
Section titled “IP check for service blocks”bash <(curl -Ls IP.Check.Place) -l enEnvironment info and tests with Russian ISPs
Section titled “Environment info and tests with Russian ISPs”wget -qO- speedtest.artydev.ru | bashEnvironment info and tests with ISPs
Section titled “Environment info and tests with ISPs”wget -qO- bench.sh | bashInstall Xanmod kernel
Section titled “Install Xanmod kernel”-
Check supported CPU level
Terminal window wget https://dl.xanmod.org/check_x86-64_psabi.shchmod +x check_x86-64_psabi.sh./check_x86-64_psabi.sh -
Register Xanmod signing key
Terminal window wget -qO - https://dl.xanmod.org/archive.key | sudo gpg --dearmor -vo /etc/apt/keyrings/xanmod-archive-keyring.gpg -
Add Xanmod repository
Terminal window echo 'deb [signed-by=/etc/apt/keyrings/xanmod-archive-keyring.gpg] http://deb.xanmod.org releases main' | sudo tee /etc/apt/sources.list.d/xanmod-release.list -
Install kernel package
Terminal window sudo apt update && sudo apt install linux-xanmod-x64v3 -
Apply BBR tuning if your stack needs it, then reboot.
Limit ICMP response rate
Section titled “Limit ICMP response rate”Add stricter ICMP rate limits in /etc/sysctl.conf:
cat <<'EOT' | sudo tee -a /etc/sysctl.confnet.ipv4.icmp_msgs_burst=1net.ipv4.icmp_msgs_per_sec=1net.ipv4.icmp_ratelimit=1net.ipv6.icmp.ratelimit=1EOTsudo sysctl -pUse this only after testing, because aggressive ICMP limits can complicate troubleshooting and network diagnostics.