Skip to main content
Use this page as a quick reference for common Ubuntu self-hosting tasks.

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.
/etc/systemd/system/myscript.service
[Unit]
Description=Virtual Distributed Ethernet
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/YOUR_SCRIPT
Restart=on-failure

[Install]
WantedBy=multi-user.target
Reload systemd, enable the service, and start it:
Reload and enable service
sudo systemctl daemon-reload
sudo systemctl enable myscript.service
sudo systemctl start myscript.service
sudo systemctl status myscript.service

Schedule a nightly reboot

Open your crontab:
crontab -e
Add this line at the bottom:
0 4 * * * /sbin/shutdown -r +5
This announces reboot at 04:00 and reboots at 04:05. Cron format:
m h dom mon dow command
Run sudo crontab -e if your reboot command needs root-level execution.

Remove old or unused Docker data

Check Docker disk usage:
docker system df
Prune commands:
  • docker container prune
  • docker image prune
  • docker network prune
  • docker volume prune
  • docker system prune
Remove all unused images (not only dangling):
docker image prune -a
Remove most unused Docker objects:
docker system prune --all
-a and --all can remove images you still want to keep for fast redeploys.

Clean your server

Check filesystem usage:
df -h
Install and run ncdu for interactive analysis:
Install ncdu
sudo apt install -y ncdu
Scan root filesystem
sudo ncdu /
Be careful with manual file deletion in system directories.
Common cleanup targets:
  1. Old logs in /var/log:
sudo journalctl --vacuum-time=2d
  1. Unused Docker objects in /var/lib/docker:
sudo docker image prune
sudo docker container prune
sudo docker network prune
sudo docker volume prune
sudo docker system prune -a
  1. Unused packages:
sudo apt autoremove
For Pterodactyl hosts, avoid manual backup deletion in /var/lib/pterodactyl because panel state can become inconsistent.

Scripts

Geo check

wget -qO - "https://raw.githubusercontent.com/vernette/ipregion/refs/heads/master/ipregion.sh" | bash

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 && speedtest

IP check for service blocks

bash <(curl -Ls IP.Check.Place) -l en

Environment info and tests with Russian ISPs

wget -qO- speedtest.artydev.ru | bash

Environment info and tests with ISPs

wget -qO- bench.sh | bash
Review remote scripts before running curl | bash or wget | bash in production.

Install Xanmod kernel

1

Check supported CPU level

wget https://dl.xanmod.org/check_x86-64_psabi.sh
chmod +x check_x86-64_psabi.sh
./check_x86-64_psabi.sh
2

Register Xanmod signing key

wget -qO - https://dl.xanmod.org/archive.key | sudo gpg --dearmor -vo /etc/apt/keyrings/xanmod-archive-keyring.gpg
3

Add Xanmod repository

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
4

Install kernel package

sudo apt update && sudo apt install linux-xanmod-x64v3
5

Finalize

Apply BBR tuning if your stack needs it, then reboot.

Limit ICMP response rate

Add stricter ICMP rate limits in /etc/sysctl.conf:
cat <<'EOT' | sudo tee -a /etc/sysctl.conf
net.ipv4.icmp_msgs_burst=1
net.ipv4.icmp_msgs_per_sec=1
net.ipv4.icmp_ratelimit=1
net.ipv6.icmp.ratelimit=1
EOT
sudo sysctl -p
Use this only after testing, because aggressive ICMP limits can complicate troubleshooting and network diagnostics.