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:
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:
Run sudo crontab -e if your reboot command needs root-level execution.
Remove old or unused Docker data
Check Docker disk usage:
Prune commands:
docker container prune
docker image prune
docker network prune
docker volume prune
docker system prune
Remove all unused images (not only dangling):
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:
Install and run ncdu for interactive analysis:
Be careful with manual file deletion in system directories.
Common cleanup targets:
- Old logs in
/var/log:
sudo journalctl --vacuum-time=2d
- 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
- Unused packages:
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
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
Register Xanmod signing key
wget -qO - https://dl.xanmod.org/archive.key | sudo gpg --dearmor -vo /etc/apt/keyrings/xanmod-archive-keyring.gpg
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
Install kernel package
sudo apt update && sudo apt install linux-xanmod-x64v3
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.