Spiega documentation
- Knowledge sharing
- Portfolio
sysadmin reveal config
utils to manage a linux system
sabeiro
<2026-09-07 Mon> <2026-09-07 Mon>
Created: 2026-10-12 Mon 14:22
:INSTRUCTION: You are a language model to assist different IT projects helping with coding, project planning and documentation. Read the instructions in ~/lav/src/spiega/article/agent_context.org, avoid to write in the chat and let’s communicate via this org files in the folder ~/lav/src/spiega/knowledge/ :ID: reaveal_config
sysadmin
This article contains the most relevant commands and examples to administrate a linux system and networking
installation
I mainly use ubuntu and apt
packages
apt list installed packages
apt list --installed
cleanup packages
sudo apt update
sudo apt clean
sudo apt autoclean
sudo apt autoremove
pip cache purge
journalctl --disk-usage
sudo journalctl --vacuum-size=100M
sudo journalctl --vacuum-time=2weeks
sudo snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
sudo snap remove "$snapname" --revision="$revision"
done
npm
pnpm has better options than npm because it reuses many installation libraries
sudo apt install npm
sudo npm install -g pnpm
to check what packages we installed
npm list -g
/usr/local/lib └── eslint@10.4.1
npm ls -g
/usr/local/lib └── eslint@10.4.1
uninstall
Remove package
dropbox stop
dropbox status # Should report "not running"
rm -rf ~/.dropbox-dist
rm -rf /var/lib/dropbox
rm -rf ~/.dropbox*
sudo apt-get remove nautilus-dropbox
sudo apt-get remove dropbox
rm /etc/apt/source.d/dropbox
fix broken
Fix broken not working
sudo dpkg --force-all --configure -a
sudo dpkg --purge --force-depends libnettle6
sudo apt --fix-broken install
sudo apt-get -f install
sudo apt update & sudo apt upgrade
sysadmin linux
sys info
lsb_release -a
uname -a
Distributor ID: Ubuntu Description: Ubuntu 26.04 LTS Release: 26.04 Codename: resolute Linux manitro 7.0.0-29-generic #29-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 17 20:52:35 UTC 2026 x86_64 GNU/Linux
locale
Many packages suffer with locale different from en_US.UTF-8
locale # check for UTF-8
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
locale # verify settings
terminal
processes
lsof -i :8888 | awk 'NR==1 || $9 ~ /PID/' | grep -v "^$" | awk '{print $1}' | xargs -r kill -9
services
pstree | head -5
systemd-+-ModemManager---3*[{ModemManager}]
|-NetworkManager---3*[{NetworkManager}]
|-accounts-daemon---3*[{accounts-daemon}]
|-avahi-daemon---avahi-daemon
|-bluetoothd
systemctl --type=service --state=running
| UNIT | LOAD | ACTIVE | SUB | DESCRIPTION | |||||||
| accounts-daemon.service | loaded | active | running | Accounts | Service | ||||||
| avahi-daemon.service | loaded | active | running | Avahi | mDNS/DNS-SD | Stack | |||||
| bluetooth.service | loaded | active | running | Bluetooth | service | ||||||
| bolt.service | loaded | active | running | Thunderbolt | system | service | |||||
| chrony.service | loaded | active | running | chrony, | an | NTP | client/server | ||||
| colord.service | loaded | active | running | Manage, | Install | and | Generate | Color | Profiles | ||
| containerd.service | loaded | active | running | containerd | container | runtime | |||||
| cron.service | loaded | active | running | Regular | background | program | processing | daemon | |||
| cups-browsed.service | loaded | active | running | Make | remote | CUPS | printers | available | locally | ||
| cups.service | loaded | active | running | CUPS | Scheduler | ||||||
| dbus.service | loaded | active | running | D-Bus | System | Message | Bus | ||||
| docker.service | loaded | active | running | Docker | Application | Container | Engine | ||||
| fwupd.service | loaded | active | running | Firmware | update | daemon | |||||
| gdm.service | loaded | active | running | GNOME | Display | Manager | |||||
| lemond.service | loaded | active | running | Lemonade | Server | ||||||
| lttng-sessiond.service | loaded | active | running | LTTng | session | daemon | |||||
| ModemManager.service | loaded | active | running | Modem | Manager | ||||||
| networkd-dispatcher.service | loaded | active | running | Dispatcher | daemon | for | systemd-networkd | ||||
| NetworkManager.service | loaded | active | running | Network | Manager | ||||||
| nvidia-persistenced.service | loaded | active | running | NVIDIA | Persistence | Daemon | |||||
| nvidia-powerd.service | loaded | active | running | nvidia-powerd | service | ||||||
| polkit.service | loaded | active | running | Authorization | Manager | ||||||
| postfix.service | loaded | active | running | Postfix | Transport | Agent | (main/default | instance) | |||
| power-profiles-daemon.service | loaded | active | running | Power | Profiles | daemon | |||||
| rsyslog.service | loaded | active | running | System | Logging | Service | |||||
| rtkit-daemon.service | loaded | active | running | RealtimeKit | Scheduling | Policy | Service | ||||
| snap.cups.cups-browsed.service | loaded | active | running | Service | for | snap | application | cups.cups-browsed | |||
| snap.cups.cupsd.service | loaded | active | running | Service | for | snap | application | cups.cupsd | |||
| snapd.service | loaded | active | running | Snap | Daemon | ||||||
| switcheroo-control.service | loaded | active | running | Switcheroo | Control | Proxy | service | ||||
| systemd-journald.service | loaded | active | running | Journal | Service | ||||||
| systemd-logind.service | loaded | active | running | User | Login | Management | |||||
| systemd-oomd.service | loaded | active | running | Userspace | Out-Of-Memory | (OOM) | Killer | ||||
| systemd-resolved.service | loaded | active | running | Network | Name | Resolution | |||||
| systemd-udevd.service | loaded | active | running | Rule-based | Manager | for | Device | Events | and | Files | |
| udisks2.service | loaded | active | running | Disk | Manager | ||||||
| unattended-upgrades.service | loaded | active | running | Unattended | Upgrades | Shutdown | |||||
| upower.service | loaded | active | running | Daemon | for | power | management | ||||
| user@1000.service | loaded | active | running | User | Manager | for | UID | 1000 | |||
| uuidd.service | loaded | active | running | Daemon | for | generating | UUIDs | ||||
| wpa_supplicant.service | loaded | active | running | WPA | supplicant | ||||||
| Legend: | LOAD | → | Reflects | whether | the | unit | definition | was | properly | loaded. | |
| ACTIVE | → | The | high-level | unit | activation | state, | i.e. | generalization | of | SUB. | |
| SUB | → | The | low-level | unit | activation | state, | values | depend | on | unit | type. |
| 41 | loaded | units | listed. |
start/stop/disable
sudo service lemond status
sudo systemctl disable lemond
current window manager
printf 'Desktop: %s\nSession: %s\n' "$XDG_CURRENT_DESKTOP" "$GDMSESSION(tiling for example[[https://extensions.gnome.org/#sort=relevance][web browser addon][GeForce 940MX(rev a2<<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl status docker
sudo systemctl start docker
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
sudo apt-get update
sudo apt-get install -y --no-install-recommends ca-certificates curl gnupg2
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
process on port
ss -tlnp | grep 13305
LISTEN 0 4096 0.0.0.0:13305 0.0.0.0:* LISTEN 0 4096 [::]:13305 [::]:*
# View running processes
ps aux | head -10
#ps -ef --sort=-%cpu
#+BEGIN_SRC shell
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMANDroot 1 0.0 0.0 28020 12880 ? Ss Jun15 4:08 /usr/lib/systemd/systemd --switched-root --system --deserialize=52 splashroot 2 0.0 0.0 0 0 ? S Jun15 0:01 [kthreadd]root 3 0.0 0.0 0 0 ? S Jun15 0:00 [pool_workqueue_release]root 4 0.0 0.0 0 0 ? I< Jun15 0:00 [kworker/R-rcu_gp]root 5 0.0 0.0 0 0 ? I< Jun15 0:00 [kworker/R-sync_wq]root 6 0.0 0.0 0 0 ? I< Jun15 0:00 [kworker/R-kvfree_rcu_reclaim]root 7 0.0 0.0 0 0 ? I< Jun15 0:00 [kworker/R-slub_flushwq]root 8 0.0 0.0 0 0 ? I< Jun15 0:00 [kworker/R-netns]root 10 0.0 0.0 0 0 ? I< Jun15 0:00 [kworker/0:0H-kblockd]
kill -9 <PID>
pkill -f <process-name>
sudo systemctl stop <service>
= User Management =
# Add user
sudo adduser <username>
# Remove user
sudo deluser <username>
sudo userdel -r <username>
# View users
sudo cat /etc/passwd
= File System & Disk =
# Check disk space
df -h
# Check filesystem errors
sudo fsck -f /dev/<device>
# View inode usage
sudo du -sh /* | sort -hr
= Network Diagnostics =
# Test connectivity
ping -c 4 <hostname>
traceroute <hostname>
dig <hostname>
# Check open ports
sudo netstat -tulpn
sudo ss -tulpn
= System Logs =
# View logs
sudo journalctl -xe
sudo tail -f /var/log/syslog
sudo grep <error> /var/log/syslog | tail -100
= Package Management =
# Update packages
sudo apt update && sudo apt upgrade -y
# Search packages
apt search <keyword>
# Remove packages with dependencies
sudo apt remove <package>
gnome
We can configure the system behavior
#sudo apt install dconf-editor
xev -event keyboard
I want to map the menu key
KeyRelease event, serial 28, synthetic NO, window 0x1000001,root 0x352, subw 0x0, time 913179790, (-526,-209), root:(345,337),state 0x0, keycode 135 (keysym 0xff67, Menu), same_screen YES,XLookupString gives 0 bytes:XFilterEvent returns: False
Annoying close window prompt on applications with background operations
# extend ubuntu timeout to check if a window is still alive
gsettings set org.gnome.mutter check-alive-timeout 60000
echo -e "keycode 66 = Hyper_L\nkeycode 118 = Hyper_L\nkeycode 135 = Hyper_L\nkeycode 133 = Hyper_L" > ~/.xmodmap
xmodmap ~/.xmodmap
#xbindkeys
# gsettings reset-recursively org.gnome.desktop.input-sources
# gsettings reset-recursively org.gnome.desktop.wm.keybindings
gsettings list-recursively org.gnome.desktop.input-sources
gsettings set org.gnome.desktop.input-sources xkb-options "['caps:hyper', 'insert:hyper', 'menu:hyper', 'keycode_133:hyper']"
gsettings get org.gnome.desktop.input-sources xkb-options
# gsettings set org.gnome.desktop.wm.keybindings panel-main-menu "[]"
# gsettings set org.gnome.desktop.wm.keybindings show-desktop "[]"
# gsettings set org.gnome.desktop.wm.keybindings toggle-fullscreen "[]"
#xkeyboard-config
org.gnome.desktop.input-sources current uint32 0 org.gnome.desktop.input-sources mru-sources @a(ss) [] org.gnome.desktop.input-sources per-window false org.gnome.desktop.input-sources show-all-sources false org.gnome.desktop.input-sources sources @a(ss) [] org.gnome.desktop.input-sources xkb-model 'pc105+inet' org.gnome.desktop.input-sources xkb-options @as [] ['caps:hyper', 'insert:hyper', 'menu:hyper']
setxkbmap -option caps:hyper -option insert:hyper -option menu:hyper -option keycode_133:hyper
networking
network interfaces
ip addr show
ip link show
Check IP configuration
ip -4 addr show
ip -6 addr show
Check DNS resolution
nslookup intertino.it
dig intertino.it
Test connectivity
ping -c 4 intertino.it
traceroute intertino.it
Check listening ports
ss -tlnp
netstat -tlnp
View routing table
ip route show
route -n
firewall
port scanning (nmap)
Local port scanning
nmap -sT localhost
lsof -i :80
ss -tlnp | grep :80
| LISTEN | 0 | 5 | 127.0.0.1:8001 | 0.0.0.0:* |
| LISTEN | 0 | 512 | 127.0.0.1:8002 | 0.0.0.0:* |
| LISTEN | 0 | 4096 | 0.0.0.0:80 | 0.0.0.0:* |
| LISTEN | 0 | 4096 | [::]:80 | [::]:* |
http
npm install puppeteer
node -e "require('puppeteer').launch().then(async p => {
const browser = await p.newPage();
await browser.goto('http://localhost/13305/api/tags');
console.log(await browser.content());
});"
curl -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" http://localhost:$PORT/api/tags
socat
Socat is a relay for bidirectional data transfers between two independent data channels. Is meant as the advanced version of netcat. article, article, article.
- Files
- Pipes
- Devices (serial line, pseudo-terminal, etc)
- Sockets (UNIX, IP4, IP6 - raw, UDP, TCP)
- SSL sockets
- Proxy CONNECT connections
- File descriptors (stdin, etc)
- The GNU line editor (readline)
- Programs
#socat [options] <address> <address>
socat TCP4-LISTEN:81 TCP4:192.168.1.10:80
socat TCP4-LISTEN:81,fork,reuseaddr TCP4:TCP4:192.168.1.10:80
nc -l localhost 1234 #terminal1
socat STDIO TCP4:localhost:1234 #terminal2
Docker host/container connection
socat TCP-LISTEN:1234,reuseaddr,fork TCP:localhost:80
interface statistics
interface traffic
ip -s link show | head -n 5
| 1: | lo: | <LOOPBACK,UP,LOWER_UP> | mtu | 65536 | qdisc | noqueue | state | UNKNOWN | mode | DEFAULT | group | default | qlen | 1000 |
| link/loopback | 00:00:00:00:00:00 | brd | 00:00:00:00:00:00 | |||||||||||
| RX: | bytes | packets | errors | dropped | missed | mcast | ||||||||
| 207264279 | 818205 | 0 | 0 | 0 | 0 | |||||||||
| TX: | bytes | packets | errors | dropped | carrier | collsns |
real-time traffic network
ip -s link | head -n 5
| 1: | lo: | <LOOPBACK,UP,LOWER_UP> | mtu | 65536 | qdisc | noqueue | state | UNKNOWN | mode | DEFAULT | group | default | qlen | 1000 |
| link/loopback | 00:00:00:00:00:00 | brd | 00:00:00:00:00:00 | |||||||||||
| RX: | bytes | packets | errors | dropped | missed | mcast | ||||||||
| 207312002 | 818381 | 0 | 0 | 0 | 0 | |||||||||
| TX: | bytes | packets | errors | dropped | carrier | collsns |
#+end_src
docker security scaling
Useful commands to use docker
overview
Build & Dev:
docker build -f Dockerfile.dockerfile -t myorg .- Build from Dockerfiledocker run -it --rm -v $PWD:/workspace myorg org mode :start- Launch org-modedocker exec -it myorg bash- Enter containerdocker build -f Dockerfile.dockerfile --build-arg DOCKER_FLAGS“-v $PWD:/workspace” -t myorg .= - Build with volume flags
Run & Manage:
docker run -it --rm -v $PWD:/workspace -w /workspace myorg org mode --no-user-info- Run org without user infodocker run --rm -v $PWD:/workspace myorg org mode :source_block_quote: "hello"- Process org blockdocker run --rm myorg org mode :clear_properties- Clear propertiesdocker run --rm myorg org mode :close_all- Close all buffers
Network & Logs:
docker run --rm -v $PWD:/workspace myorg org mode :start_export "latex"- Export to LaTeXdocker logs myorg- View logsdocker ps -a- List all containers
Useful for Org workflows:
docker cp myorg:/workspace/src/*.org $PWD/- Copy files outdocker cp $PWD/*.org myorg:/workspace/src/- Copy files indocker commit myorg myorg:latest- Save imagedocker stop myorg && docker rm myorg- Stop and remove
links: attachable networks
binds
- 127.0.0.1
- If your application inside a container binds to 127.0.0.1, it means the application can only be accessed by other processes running inside that exact same container.
- 0.0.0.0
- When you bind your application to 0.0.0.0, it makes the service accessible from anywhere that can reach the container—including the host machine, other containers on the same Docker network, and external networks.
network
docker network inspect webserver_webserver-net
[{"Name": "webserver_webserver-net","Id": "95f40f2ec00116f8084f23f936e227ce10ab7ef22103bee3693efb013600b558","Created": "2026-05-26T18:17:17.270114938+02:00","Scope": "local","Driver": "bridge","EnableIPv4": true,"EnableIPv6": false,"IPAM": {"Driver": "default","Options": null,"Config": [{"Subnet": "172.18.0.0/16","Gateway": "172.18.0.1"}]},"Internal": false,"Attachable": false,"Ingress": false,"ConfigFrom": {"Network": ""},"ConfigOnly": false,"Options": {},"Labels": {"com.docker.compose.config-hash": "64abf2a2dacb4953dc4984b37ead26467696eeb6335b234430e02b8eb3bd7f50","com.docker.compose.network": "webserver-net","com.docker.compose.project": "webserver","com.docker.compose.version": "5.1.3"},"Containers": {"17e093fb3202bec6a99e0b1487195a87db56baf4ac7fca022079c1abbc61c7a6": {"Name": "webserver-mysql-1","EndpointID": "810ecddbba3c47f519eb9a4aa4b31be17d2b8d65a3ecf6279a368dc263431b71","MacAddress": "6a:ac:6d:44:78:53","IPv4Address": "172.18.0.2/16","IPv6Address": ""},"d0bfb6f96a583b9ca46c473f279835ec81e6914fc22363a88f6ccf2b77b0f465": {"Name": "nginx","EndpointID": "8314b8d7fb250c15da08e852bc1b389e406625d46823858af21b6039017dbb0d","MacAddress": "fa:bb:79:3a:ff:c0","IPv4Address": "172.18.0.3/16","IPv6Address": ""},"efd0937e20ca6419c5c0b220403dc465fb6505589e0b22ce612243ccce481048": {"Name": "unsloth","EndpointID": "758373f8f45b314204834fa3681dd214f465576146f4de4c18bea62feef8796e","MacAddress": "fe:0e:f8:1c:48:f1","IPv4Address": "172.18.0.4/16","IPv6Address": ""}},"Status": {"IPAM": {"Subnets": {"172.18.0.0/16": {"IPsInUse": 6,"DynamicIPsAvailable": 65530}}}}}]
cleanup
Docker stores containers, volumes, image, and filesystem layers
docker rm $(docker ps -aq)
docker rmi $(docker images -q)
docker image prune -a
docker volume prune
docker system prune
swarm
SWARM_NAME=malestro SWARM_NODE=malestro NET_NAME=webserver-net SERVICE_NAME=db SUBNET=“10.11.0.0/16” GATEWAY=" docker swarm init
#docker network create –scope=swarm $NET_NAME #docker network create –scope=swarm –driver overlay –attachable $NET_NAME docker network create –driver=overlay –attachable $NET_NAME #docker network create –scope=swarm –driver overlay –ingress –opt com.docker.network.driver.mtu=1200 $NET_NAME docker network create –driver overlay –ingress –subnet=$SUBNET –gateway=$GATEWAY –opt com.docker.network.driver.mtu=1200 traefik-ingress
docker network create –subnet $SUBNET –opt com.docker.network.bridge.name=docker_gwbridge –opt com.docker.network.bridge.enable_icc=false –opt com.docker.network.bridge.enable_ip_masquerade=true docker_gwbridge
#docker network create –subnet=172.20.0.1/16 -o com.docker.network.bridge.enable_icc=false -o com.docker.network.bridge.name=docker_gwbridge docker_gwbridge
#docker service update –network-rm traefik-net myservice #docker service create –publish 80:80 –network=$NET_NAME –name nginx nginx docker service update –network-add $NET_NAME db
docker node update –availability active $SWARM_NODE docker swarm init
issues
Docker has many advantages in terms of portability but few topics makes it really hard to use. I wish I can learn how to face time demanding issues:
- user
- is really tedious to have the same user as host, I’m not sure I found the best workaround. Volumes are mounted as root and the container user cannot work ref1
- root
- if a pre-built images starts a user I can’t do any root change
- build
- building takes an enormous amount of time and tentatives. I wish I could find a better way to avoid debugging every single line for unmet dependencies
- mounting
- Dockerfile copies the directory losing the dynamic changes
- volumes
- I use docker because I want a standard on the mounted directory and share LLM for example. Why it is so hard to find out every time where the provider puts the models
- transparency
- I use docker mainly for security reasons because I want to control what each service does on my machine but often compiling and launching from docker is really badly documented and I sometimes don’t manage to have it running
- dependencies
- I can’t count the time spent in figuring out the dependencies for each image
orchestration
We can orchestrate the different containers
docker UI
We start with a simple UI tool
| Feature | Docker UI | Kubernetes |
| --- | --- | --- |
| Primary Role | Container lifecycle management (start, stop, view logs, simple networking). | Orchestration, automated deployment, scaling, networking, and service management. |
| Scale | Single host or small environment. | Large, distributed clusters across many servers. |
| Configuration | Simple command-line or GUI-driven setup. | Complex declarative configuration files (YAML) defining desired state, services, deployments, etc. |
| Resilience | Basic restart capabilities. | Advanced self-healing, automatic failover, and high availability across nodes. |
| Networking | Basic container networking. | Advanced service networking, Ingress controllers, and complex service meshes. |
orchestrator
| Feature | Kubernetes (K8s) | OpenShift |
| --- | --- | --- |
| Nature | orchestration engine (the core API, controllers, and mechanisms). | A complete, integrated platform built on top of Kubernetes. |
| Focus | Providing the mechanism to manage containers (the how). | Providing an end-to-end platform for building, deploying, securing, and managing application. |
| Tooling | Requires users to integrate many separate tools (CI/CD, monitoring, service mesh). | Comes with integrated, opinionated tools for CI/CD pipelines, security scanning, logging, monitoring, and developer portals built-in. |
| Target Audience | Developers, DevOps engineers, infrastructure teams who want maximum flexibility. | Enterprise users, large organizations, and teams needing a standardized, secure, and fully supported platform. |
enterprise
| If you want… | Use this Alternative | Key Advantage |
| --- | --- | --- |
| Maximum Control & Flexibility | Vanilla Kubernetes | Total ownership over the entire stack. |
| Centralized Management of Many Clusters | Rancher | A single pane of glass for multi-cluster operations. |
| Lightweight Deployment (Edge/IoT) | K3s | Minimal resource usage and fast startup time. |
| A Balance of Features (Mid-Tier) | MicroK8s | Simpler setup than vanilla K8s, good for quick starts. |
kubernetes
We install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
Write down in org-mode useful commands and snippets for kubectl with mentions to configuration files
#+begin_src org
kubectl org-mode cheatsheet
Basic Commands
# Get help
kubectl help
# Get cluster info
kubectl cluster-info
# Get nodes
kubectl get nodes
# Get pods (all namespaces)
kubectl get pods --all-namespaces
# Get pods in current namespace
kubectl get pods
Configuration Files
~/.kube/config
- Default kubeconfig file
- Contains cluster information, users, and contexts
- Can be modified with
kubectl configcommands
~/.kube/cache
- Caches authentication tokens
- Used for interactive login
.kube/config (project-specific)
- Local configuration file
- Can be set with
KUBECONFIGenvironment variable
Useful Configuration Commands
# View current context
kubectl config current-context
# List contexts
kubectl config get-contexts
# Switch context
kubectl config use-context <context-name>
# Set current namespace
kubectl config set-context --current --namespace=<namespace-name>
# Add cluster
kubectl config add-cluster <cluster-name> --server=<api-server-url>
# Add user
kubectl config add-user <user-name> --client-certificate=<cert-file> --client-key=<key-file>
Common Operations
# Create resource from file
kubectl apply -f <filename.yaml>
# Delete resource
kubectl delete -f <filename.yaml>
# Get resource description
kubectl describe <resource-type> <resource-name>
# Get resource details in YAML
kubectl get <resource-type> <resource-name> -o yaml
# Get logs
kubectl logs <pod-name>
# Execute command in pod
kubectl exec -it <pod-name> -- <command>
# Port forward
kubectl port-forward <pod-name> <local-port>:<remote-port>
Namespace Management
# Create namespace
kubectl create namespace <namespace-name>
# Switch to namespace
kubectl config set-context --current --namespace=<namespace-name>
# Get all namespaces
kubectl get namespaces
Troubleshooting
# Get events
kubectl get events
# Get pod logs with timestamps
kubectl logs -l <label> --timestamps
# Watch pods
kubectl get pods -w
# Check resource usage
kubectl top nodes
kubectl top pods
Quick Context Switching
# Save current context
kubectl config current-context > /tmp/current-context
# Switch to different context
kubectl config use-context <context-name>
# Switch to default context
kubectl config use-context docker-desktop
Aliases for ~/.bashrc or ~/.zshrc
alias k=kubectl
alias kg='kubectl get'
alias kga='kubectl get all'
alias kd='kubectl describe'
alias kl='kubectl logs'
alias kpf='kubectl port-forward'
#+end_src
Here are useful kubectl commands and snippets in org-mode with configuration file references:
#+BEGIN_SRC org
kubectl Commands and Snippets
Basic Configuration
kubeconfig file locations
- Default: ~/.kube/config
- Custom: KUBECONFIG=/path/to/config kubectl …
Context management
- List contexts:
kubectl config get-contexts - Switch context:
kubectl config use-context <context> - Show current context:
kubectl config current-context - Set user credentials:
kubectl config set-credentials <user>
Common Operations
Pods
- Get pods:
kubectl get pods - Describe pod:
kubectl describe pod <pod-name> - Logs:
kubectl logs <pod-name> - Exec into pod:
kubectl exec -it <pod-name> -- /bin/sh - Port forward:
kubectl port-forward <pod-name> <local-port>:<remote-port>
Deployments
- Get deployments:
kubectl get deployments - Scale deployment:
kubectl scale deployment <deployment> --replicas=<count> - Update image:
kubectl set image deployment/<deployment> <container>=<image>
Services
- Get services:
kubectl get services - Expose deployment:
kubectl expose deployment <deployment> --port=<port>
Useful Snippets
Quick pod creation
kubectl run <name> --image=<image> --port=<port>
Apply configuration from file
kubectl apply -f <config-file.yaml>
Delete resources
kubectl delete -f <config-file.yaml>kubectl delete pod <pod-name>kubectl delete deployment <deployment-name>
Namespace operations
- Create namespace:
kubectl create namespace <name> - Switch namespace:
kubectl config set-context --current --namespace=<namespace> - List namespaces:
kubectl get namespaces
Advanced Tips
JSONPath queries
- Get specific field:
kubectl get pod <pod> -o jsonpath’{.spec.containers[0].image}’= - Format output:
kubectl get pods -o wide --show-labels
Watch operations
- Watch pods:
kubectl get pods -w - Watch deployments:
kubectl get deployments -w
Configuration file examples
# Deployment YAMLapiVersion: apps/v1kind: Deploymentmetadata:name: my-appspec:replicas: 3selector:matchLabels:app: my-apptemplate:metadata:labels:app: my-appspec:containers:- name: appimage: my-image:latestports:- containerPort: 80
Troubleshooting
Check cluster status
kubectl cluster-infokubectl get nodeskubectl get pods --all-namespaces
Debugging
kubectl describe node <node>kubectl logs --previous <pod>kubectl get events
#+END_SRC
multimedia
audio
The current choice is pipewire
- Lower latency for real-time audio processing.
- Better compatibility with Wayland display servers (unlike PulseAudio)
- Hardware-accelerated video passthrough for screen sharing
- Integration with Mesa DRM for improved graphics performance
- Support for native Wayland audio protocol instead of X11
- Reduced CPU overhead and power consumption
- Better support for virtualization and nested audio contexts
- Improved video effects and filters support
- Seamless integration with Ubuntu’s native GNOME environment
- Better support for multimedia applications and games
- More efficient resource management for audio devices
- Improved compatibility with modern Linux kernels
- Reduced latency for audio streaming and VoIP applications
- Better support for audio mixing and routing
- Integration with JACK protocol for professional audio work
sudo apt install pulseaudio-utils
sudo apt install pipewire pipewire-pulse wireplumber pipewire-alsa pipewire-jack -y
pactl info | grep "Server Name"
Server Name: PulseAudio (on PipeWire 1.6.2)
systemctl --user enable --now pipewire pipewire-pulse wireplumber
journalctl --user -u pipewire # Replace "pipewire" with the failing service name
Sep 05 00:36:29 manitro systemd[3162]: Stopping pipewire.service - PipeWire Multimedia Service... Sep 05 00:36:29 manitro systemd[3162]: Stopped pipewire.service - PipeWire Multimedia Service. Sep 05 00:36:29 manitro systemd[3162]: pipewire.service: Consumed 3min 31.719s CPU time over 2d 15h 50min 9.478s wall clock time, 21.7M memory peak, 4.6M memory swap peak. -- Boot 2f8cdd9bf9554f12ba750e8021731469 -- Sep 05 10:15:53 manitro systemd[3180]: Started pipewire.service - PipeWire Multimedia Service.
pw-top
I’m running LMMS configured with alsa and pipewire but I hear no sound, how can I debug it?
echo "=== LMMS Audio Debug Script ==="
echo ""
echo "Checking ALSA devices..."
alsaloop -P default -c 2 -t 2 -p
echo "Checking PulseAudio status..."
if pgrep -x pulseaudio> /dev/null; then
echo "PulseAudio is running"
elif pgrep -x pipewire > /dev/null; then
echo "PipeWire is running"
elif pgrep -x pavucontrol > /dev/null; then
echo "PavuControl is available"
fi
echo "Checking ALSA modules..."
cat /proc/asound/cards
echo "Checking PulseAudio modules..."
pactl info 2>/dev/null || echo "Pactl not available or PulseAudio not running"
echo "Checking PipeWire modules..."
pipewire-pulse-info 2>/dev/null || echo "PipeWire-Pulse not available"
echo "Checking user audio permissions..."
id
ls -la ~/.cache/pulse/ 2>/dev/null || echo "Pulse cache not found"
# Test with a686196b566e5e97b932e4168a028a1295b5b3d06e6d1c3e1e9b17f3d1c2e3f4
echo ""
echo "Test sound output..."
play -t alsa /dev/zero 2>/dev/null &
sleep 1
kill $! 2>/dev/null || true
echo "" echo "
=== LMMS Audio Debug Script ===Checking ALSA devices...Checking PulseAudio status...PipeWire is runningChecking ALSA modules...0 [NVidia ]: HDA-Intel - HDA NVidiaHDA NVidia at 0xbc000000 irq 1241 [Generic ]: HDA-Intel - HD-Audio GenericHD-Audio Generic at 0xbc8c8000 irq 1262 [Generic_1 ]: HDA-Intel - HD-Audio GenericHD-Audio Generic at 0xbc8c0000 irq 1273 [Fold ]: USB-Audio - nanoKEY FoldKORG INC. nanoKEY Fold at usb-0000:66:00.4-1, full speedChecking PulseAudio modules...Server String: /run/user/1000/pulse/nativeLibrary Protocol Version: 35Server Protocol Version: 35Is Local: yesClient Index: 523Tile Size: 65472User Name: sabeiroHost Name: manitroServer Name: PulseAudio (on PipeWire 1.6.2)Server Version: 15.0.0Default Sample Specification: float32le 2ch 48000HzDefault Channel Map: front-left,front-rightDefault Sink: alsa_output.pci-0000_64_00.6.analog-stereoDefault Source: alsa_input.pci-0000_64_00.6.analog-stereoCookie: 0b3e:429aChecking PipeWire modules...PipeWire-Pulse not availableChecking user audio permissions...uid=1000(sabeiro) gid=1000(sabeiro) groups=1000(sabeiro),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),100(users),111(lpadmin),114(lxd),973(docker),994(input)Pulse cache not foundTest sound output...