Spiega documentation
- Knowledge sharing
- Portfolio
sysadmin
utils to manage a linux system
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 updatesudo apt cleansudo apt autocleansudo apt autoremovepip cache purge
journalctl --disk-usagesudo journalctl --vacuum-size=100Msudo journalctl --vacuum-time=2weeks
sudo snap list --all | awk '/disabled/{print $1, $3}' |while read snapname revision; dosudo snap remove "$snapname" --revision="$revision"done
npm
pnpm has better options than npm because it reuses many installation libraries
sudo apt install npmsudo 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
pnpm
I prefer pnpm which shares node_modules directories
pnpm config set store-dir ~/.pnpm-store#cat "store-dir=~/.pnpm-store\nshamefully-hoist=true\nglobal-dir=~/.config/node_modules\ncache-dir=~/.cache/pnpm\ncolor=auto\nloglevel=info" > ~/.npmrcpnpm config get store-dir
uninstall
Remove package
dropbox stopdropbox status # Should report "not running"rm -rf ~/.dropbox-distrm -rf /var/lib/dropboxrm -rf ~/.dropbox*sudo apt-get remove nautilus-dropboxsudo apt-get remove dropboxrm /etc/apt/source.d/dropbox
fix broken
Fix broken not working
sudo dpkg --force-all --configure -asudo dpkg --purge --force-depends libnettle6sudo apt --fix-broken installsudo apt-get -f installsudo apt update & sudo apt upgrade
sysadmin linux
sys info
lsb_release -auname -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-8sudo apt update && sudo apt install localessudo locale-gen en_US en_US.UTF-8sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8export LANG=en_US.UTF-8locale # 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 statussudo 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<<EOFTypes: debURIs: https://download.docker.com/linux/ubuntuSuites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")Components: stableArchitectures: $(dpkg --print-architecture)Signed-By: /etc/apt/keyrings/docker.ascEOFsudo apt updatesudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginsudo systemctl status dockersudo systemctl start dockersudo groupadd dockersudo usermod -aG docker $USERnewgrp docker
sudo apt-get updatesudo apt-get install -y --no-install-recommends ca-certificates curl gnupg2curl -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.listsudo 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 processesps 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 usersudo adduser <username># Remove usersudo deluser <username>sudo userdel -r <username># View userssudo cat /etc/passwd
= File System & Disk =
# Check disk spacedf -h# Check filesystem errorssudo fsck -f /dev/<device># View inode usagesudo du -sh /* | sort -hr
= Network Diagnostics =
# Test connectivityping -c 4 <hostname>traceroute <hostname>dig <hostname># Check open portssudo netstat -tulpnsudo ss -tulpn
= System Logs =
# View logssudo journalctl -xesudo tail -f /var/log/syslogsudo grep <error> /var/log/syslog | tail -100
= Package Management =
# Update packagessudo apt update && sudo apt upgrade -y# Search packagesapt search <keyword># Remove packages with dependenciessudo apt remove <package>
gnome
We can configure the system behavior
#sudo apt install dconf-editorxev -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 alivegsettings 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" > ~/.xmodmapxmodmap ~/.xmodmap
#xbindkeys# gsettings reset-recursively org.gnome.desktop.input-sources# gsettings reset-recursively org.gnome.desktop.wm.keybindingsgsettings list-recursively org.gnome.desktop.input-sourcesgsettings 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 showip link show
Check IP configuration
ip -4 addr showip -6 addr show
Check DNS resolution
nslookup intertino.itdig intertino.it
Test connectivity
ping -c 4 intertino.ittraceroute intertino.it
Check listening ports
ss -tlnpnetstat -tlnp
View routing table
ip route showroute -n
port scanning (nmap)
Local port scanning
nmap -sT localhost
lsof -i :80ss -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:80socat TCP4-LISTEN:81,fork,reuseaddr TCP4:TCP4:192.168.1.10:80
nc -l localhost 1234 #terminal1socat 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": {},...
We often need to install ping to check communication between containers
apt updateapt install iputils-ping
cleanup
Docker stores containers, volumes, image, and filesystem layers
docker rm $(docker ps -aq)docker rmi $(docker images -q)docker image prune -adocker volume prunedocker 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 --checksudo 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 helpkubectl help# Get cluster infokubectl cluster-info# Get nodeskubectl get nodes# Get pods (all namespaces)kubectl get pods --all-namespaces# Get pods in current namespacekubectl 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 contextkubectl config current-context# List contextskubectl config get-contexts# Switch contextkubectl config use-context <context-name># Set current namespacekubectl config set-context --current --namespace=<namespace-name># Add clusterkubectl config add-cluster <cluster-name> --server=<api-server-url># Add userkubectl config add-user <user-name> --client-certificate=<cert-file> --client-key=<key-file>
Common Operations
# Create resource from filekubectl apply -f <filename.yaml># Delete resourcekubectl delete -f <filename.yaml># Get resource descriptionkubectl describe <resource-type> <resource-name># Get resource details in YAMLkubectl get <resource-type> <resource-name> -o yaml# Get logskubectl logs <pod-name># Execute command in podkubectl exec -it <pod-name> -- <command># Port forwardkubectl port-forward <pod-name> <local-port>:<remote-port>
Namespace Management
# Create namespacekubectl create namespace <namespace-name># Switch to namespacekubectl config set-context --current --namespace=<namespace-name># Get all namespaceskubectl get namespaces
Troubleshooting
# Get eventskubectl get events# Get pod logs with timestampskubectl logs -l <label> --timestamps# Watch podskubectl get pods -w# Check resource usagekubectl top nodeskubectl top pods
Quick Context Switching
# Save current contextkubectl config current-context > /tmp/current-context# Switch to different contextkubectl config use-context <context-name># Switch to default contextkubectl config use-context docker-desktop
Aliases for ~/.bashrc or ~/.zshrc
alias k=kubectlalias 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-utilssudo 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 wireplumberjournalctl --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 -pecho "Checking PulseAudio status..."if pgrep -x pulseaudio> /dev/null; thenecho "PulseAudio is running"elif pgrep -x pipewire > /dev/null; thenecho "PipeWire is running"elif pgrep -x pavucontrol > /dev/null; thenecho "PavuControl is available"fiecho "Checking ALSA modules..."cat /proc/asound/cardsecho "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..."idls -la ~/.cache/pulse/ 2>/dev/null || echo "Pulse cache not found"# Test with a686196b566e5e97b932e4168a028a1295b5b3d06e6d1c3e1e9b17f3d1c2e3f4echo ""echo "Test sound output..."play -t alsa /dev/zero 2>/dev/null &sleep 1kill $! 2>/dev/null || trueecho "" 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...