Skip to content

Instantly share code, notes, and snippets.

@kriegalex
Last active December 4, 2025 09:31
Show Gist options
  • Select an option

  • Save kriegalex/f8c0591c63aebcd8691e8d9e81081bce to your computer and use it in GitHub Desktop.

Select an option

Save kriegalex/f8c0591c63aebcd8691e8d9e81081bce to your computer and use it in GitHub Desktop.
A cheat sheet for regular commands when administering a standard homelab installation (truenas, unraid ...)

Useful homelab administration commands

Switch to another user

su - USER
sudo su - USER

View human readable size of subfolders/files

du -sh PATH/*

Rsync through remote SSH and custom private key

rsync -Aavx -e 'ssh -p 8022 -i /PATH/PRIVATE-KEY' root@10.0.0.1:/PATH/ /PATH/

Useful TrueNAS Scale administration commands

Mount a PVC

// find the PVC data volume
k3s kubectl get pvc -A | sort -u | awk '{print "\t" $1 "\t" $2 "\t" $4}' | column -t
// check it (volume, not name)
zfs list | grep PVC_VOLUME
// mount it (you need FULL_PVC_PATH when remounting it)
zfs set mountpoint=/temporary/NAME FULL_PVC_PATH

// open / modify what is needed

// remount it
zfs set mountpoint=legacy POOL_NAME/ix-applications/releases/APP-NAME/volumes/VOLUME-NAME
// clean
rmdir /mnt/temporary/NAME

Useful K3S administration commands

Get the list of running pods

k3s kubectl get pods --all-namespaces

Access the bash shell of a pod in a non default namespace

k3s kubectl exec -n ix-namespace --stdin --tty shell-demo -- /bin/bash
k3s kubectl exec -n ix-nextcloud --stdin --tty nextcloud-XXXXXXXXXX-YYYYY -- su -s /bin/bash www-data

Useful nextcloud administration commands

Useful OCC commands

Put nextcloud in maintenance mode

sudo -u www-data php occ maintenance:mode --on

Scan all user files

sudo -u www-data php occ files:scan --all

Modify nextcloud config for HTTPS reverse proxy

  1. Setup a reverse proxy (see guides online, i.e. NginxProxyManager)
  2. Locate your config.php file
  3. Add your HTTPS domain in the trusted_domains list

Config.php file

'trusted_domains' =>
array (
  0 => '10.0.0.2:444',
  1 => 'nextcloud.domain.com',
),

Backup / restore

Backup nextcloud folders

rsync -Aavx nextcloud/ nextcloud-dirbkp_`date +"%Y%m%d"`/
rsync -Aavx ~/PATH/nextcloud/ test@192.168.56.100:~/PATH/nextcloud

Backup nextcloud MariaDB

// might need --default-character-set=utf8mb4 if 4 bytes charset for emoji
mysqldump --single-transaction -h [server] -u [username] -p[password] [db_name] > nextcloud-sqlbkp_`date +"%Y%m%d"`.bak

Backup nextcloud PostgreSQL

PGPASSWORD="password" pg_dump [db_name] -h [server] -U [username] -f nextcloud-sqlbkp_`date +"%Y%m%d"`.bak

Restore nextcloud folders

rsync -Aax nextcloud-dirbkp/ nextcloud/

Create MariaDB user and DB for nextcloud

mysql -uroot -p

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES on nextcloud.* to 'username'@'localhost';
FLUSH privileges;

quit;

Create PostgreSQL user and DB for nextcloud

psql -hlocalhost -Upostgres

CREATE USER nextcloud WITH PASSWORD 'password' CREATEDB;
CREATE DATABASE nextcloud TEMPLATE template0 ENCODING 'UTF8';
ALTER DATABASE nextcloud OWNER TO nextcloud;
GRANT ALL PRIVILEGES ON DATABASE nextcloud TO nextcloud;
GRANT ALL PRIVILEGES ON SCHEMA public TO nextcloud;

\q

Restore MariaDB

mysql -h [server] -u [username] -p[password] -e "DROP DATABASE nextcloud"
// -e "CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"
mysql -h [server] -u [username] -p[password] -e "CREATE DATABASE nextcloud"
mysql -h [server] -u [username] -p[password] [db_name] < nextcloud-sqlbkp.bak

Restore PostgreSQL

PGPASSWORD="password" psql -h [server] -U [username] -d template1 -c "DROP DATABASE \"nextcloud\";"
PGPASSWORD="password" psql -h [server] -U [username] -d template1 -c "CREATE DATABASE \"nextcloud\";"
PGPASSWORD="password" psql -h [server] -U [username] -d nextcloud -f nextcloud-sqlbkp.bak

K3S

Backup nextcloud

mkdir -p ./dumps
k3s kubectl exec -n "ix-nextcloud" -c nextcloud-postgresql nextcloud-postgresql-0 -- bash -c 'PGPASSWORD=$POSTGRES_PASSWORD pg_dump -Fc -U $POSTGRES_USER -d $POSTGRES_DB -f /tmp/nextcloud.sql'
k3s kubectl cp -n ix-nextcloud -c nextcloud-postgresql "nextcloud-postgresql-0:tmp/nextcloud.sql" ./dumps/nextcloud.sql

Useful Docker administration commands

List running dockers

docker ps

Monitor resource usage

docker stats

Launch a command inside a docker

docker exec -it DOCKER_NAME CMD
docker exec -it DOCKER_NAME /bin/bash
docker exec -it DOCKER_NAME sudo -u USER /bin/bash 

Useful Gitea administration commands

PostgreSQL preparation

CREATE ROLE gitea WITH LOGIN PASSWORD 'password';
CREATE DATABASE giteadb WITH OWNER gitea TEMPLATE template0 ENCODING UTF8 LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8';

Useful Git administration commands

Save git credentials

// only for 900 seconds locally (900sec = 15 min)
git config credential.helper 'cache --timeout=900'

// globally forever
git config --global credential.helper store

Push existing repo to new git repo

git checkout branch
git fetch --tags
git remote rm origin
git remote add origin <url to NEW gitea repo>
git push origin --all
git push --tags

Common homelab apps/services hardware requirements

Plex

  • Intel Core i3 (or equivalent) or faster (depending on transcoding requirements, if no GPU)
  • 2GB of RAM is typically more than sufficient and some installs (particularly Linux-based installs) can often happily run with even less.

Jellyfin

  • Similar to Plex
  • CPU power depending on transcoding requirements (if no GPU)

Nextcloud

  • A 64-bit CPU, speed depending on the number of users
  • Nextcloud needs a minimum of 128MB RAM per process
  • Recommended is a minimum of 512MB RAM per process.

MariaDB

  • ~500MB RAM

PostgreSQL

  • 1 GHz processor
  • 2 GB of RAM
  • 512 MB of HDD

Home assistant

  • Raspberry Pi 3 or equivalent hardware

Grafana

  • Minimum recommended memory: 255 MB
  • Minimum recommended CPU: 1

Servarr stack (Sonarr/Radarr/Prowlarr/...)

  • ~1GB RAM (~200M per app)
  • 1 CPU

Deluge

  • Minimum RAM: 512M (can climb to 2GB+)
  • 1 CPU for super seeders

Rancher K3S

  • RAM: 512 MiB
  • 1 CPU

Gitea

  • A Raspberry Pi 3 is powerful enough to run Gitea for small workloads.
  • 2 CPU cores and 1GB RAM is typically sufficient for small teams/projects.

Gitlab-CE

  • 4 cores is the recommended minimum number of cores and supports up to 500 users
  • 4 GB RAM is the required minimum memory size and supports up to 500 users
  • (recommended) At least 2 GB of swap on your server
  • The Omnibus GitLab package requires about 2.5 GB of storage space for installation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment