Miscellaneous Tips and One-Liners
A collection of useful snippets and quick fixes that are too small for full articles but worth remembering.
Ghostty Terminal Profile
Copy Ghostty's terminal info to a remote machine for Linux machines that don't have Ghostty's terminal profile, which can cause broken less, vim, systemctl, and other terminal-based tools.
infocmp -x xterm-ghostty | ssh YOUR-SERVER -- tic -x -
This command extracts the Ghostty terminal information from your local machine and installs it on the remote server, ensuring proper terminal behavior.
Source: Ghostty Documentation - Copy Ghostty's terminfo to a remote machine
Enable Touch ID for Terminal on macOS
Use Touch ID authentication for sudo commands in Terminal instead of typing your password:
# Edit the sudo PAM configuration
sudo vim /etc/pam.d/sudo
# Add this line as the first line in the file
auth sufficient pam_tid.so
# Save and exit with :wq! (force write since the file is readonly)
After this change, sudo commands will prompt for Touch ID authentication. If Touch ID fails or is unavailable, it falls back to password authentication. Note that macOS updates may reset this configuration, requiring you to reapply it.
Git Remote Prune
Remove references in your local git repository to remote branches that have been deleted:
git remote prune origin
This command cleans up stale remote-tracking branches that no longer exist on the remote repository, keeping your local repository tidy.
Full explanation: Git Documentation - git-remote prune
Install Homebrew on Linux
On a Linux machine with password-less sudo access, install Homebrew with:
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
You can skip the NONINTERACTIVE=1 part if your Linux user's sudo access requires a password.
K3s Certificate Renewal
When encountering kubectl and terraform issues with errors like "server unreachable" or "invalid tokens", the K3s server certificate may have expired.
To renew the certificates on the server:
# Check the certificate status
k3s certificate check --output table
# Stop K3s
systemctl stop k3s
# Rotate certificates
k3s certificate rotate
# Start K3s
systemctl start k3s
This process refreshes all K3s certificates and resolves authentication issues.
Reference: K3s Documentation - Certificate Management
K3s Auto Upgrade
Set up automatic K3s upgrades following the official documentation at K3s Automated Upgrades.
For a single server setup:
Install the System Upgrade Controller
If not already installed:
kubectl apply -f https://github.com/rancher/system-upgrade-controller/releases/latest/download/crd.yaml \
-f https://github.com/rancher/system-upgrade-controller/releases/latest/download/system-upgrade-controller.yaml
Create an Upgrade Plan
Create a server plan for upgrading to the stable release:
# upgrade-plan.yaml
apiVersion: upgrade.cattle.io/v1
kind: Plan
metadata:
name: server-plan
namespace: system-upgrade
spec:
concurrency: 1
cordon: true
nodeSelector:
matchExpressions:
- key: node-role.kubernetes.io/control-plane
operator: In
values:
- "true"
serviceAccountName: system-upgrade
upgrade:
image: rancher/k3s-upgrade
channel: https://update.k3s.io/v1-release/channels/stable
Apply the Plan
kubectl apply -f upgrade-plan.yaml
The system upgrade controller will automatically handle K3s upgrades based on the specified channel. Run
kubectl -n system-upgrade get jobs
to monitor the upgrade jobs.
Manually Trigger GitHub Workflow
Trigger a GitHub workflow manually from the command line using the GitHub CLI:
gh workflow run --repo jingkaihe/homebrew-kodelet update-formula.yml
Replace the repository and workflow filename with your target values. You can list available workflows using gh workflow list.