⌂ Home

Ubuntu Linux Cheat Sheet

An interactive quick-grasp guide for file system work, users and permissions, services and logs, package management, shell history, and the Linux skills that show up constantly in Kubernetes labs.

Kubernetes feels much easier once Linux stops feeling mysterious. This page focuses on practical command usage, common switches, safe beginner habits, and examples that connect directly to kubelet, containerd, manifests, logs, packages, and troubleshooting on Ubuntu hosts.
Core Mindset

What Linux Skills Matter Most for Kubernetes

Why It Matters

Kubernetes nodes are Linux systems

You regularly inspect files under /etc, logs under /var/log, services managed by systemd, packages installed through apt, and permissions that decide what can run.

Beginner Rule

Read first, change second

Prefer inspection commands like pwd, ls -l, cat, less, systemctl status, and journalctl before running edits or restarts.

Kubernetes Habit

Map the symptom to the layer

Pod issue? Check manifests and events. Node issue? Check kubelet, containerd, disk, network, and package state on the host.

Learning Flow

Beginner Progression

1

Know where you are

Use pwd, ls, and cd confidently before anything else.

2

Read files safely

Use cat, less, tail -f, and grep to inspect config and logs.

3

Understand ownership

Learn sudo, id, groups, chmod, and chown.

4

Inspect services

Use systemctl and journalctl for kubelet and container runtime issues.

5

Check packages and processes

Use apt, ps, ss, df, and free when the node itself behaves badly.

Must Know

Commands beginners should stop skipping

  • man command or command --help to learn safely
  • which and type to see what command will actually run
  • history and Ctrl+r to reuse previous commands
  • sudo -l to see what you are allowed to do
  • hostnamectl, ip a, and ss -tulpn for host identity and network basics
K8s Paths

Common Linux paths from a Kubernetes perspective

  • /etc/kubernetes/ for kubeadm-generated configuration
  • /etc/kubernetes/manifests/ for static control plane Pod manifests
  • /var/lib/kubelet/ for kubelet-managed state
  • /etc/containerd/ for container runtime config
  • /var/log/ for host logs and troubleshooting clues
Files and Folders

Navigate, Inspect, Find, and Edit Safely

Command What It Does Common Switches Kubernetes-Flavored Example
pwd Print the current working directory. No common switch needed for basics. pwd before editing manifests so you know which folder you are in.
ls List files and directories. -l detailed, -a hidden, -h human readable ls -lh /etc/kubernetes/manifests
cd Change directory. cd - previous directory, cd ~ home cd /etc/kubernetes when inspecting kubeadm-generated files.
mkdir Create directories. -p create parents too mkdir -p ~/k8s-labs/yaml
cp Copy files or folders. -r recursive, -p preserve metadata sudo cp /etc/kubernetes/admin.conf ~/.kube/config
mv Move or rename files. No major switch for basics mv old.yaml deployment.yaml
cat, less Read file contents. less is better for long files. less +G go to end less /etc/containerd/config.toml
tail Show the end of a file, useful for logs. -n 50 last 50 lines, -f follow live changes sudo tail -f /var/log/syslog during cluster setup.
find Search for files by name, path, or type. -name, -type f, -type d find /etc -name '*kubelet*'
grep Search inside files for matching text. -i ignore case, -n line numbers, -r recursive grep -n 'SystemdCgroup' /etc/containerd/config.toml
du and df Inspect disk usage. du -sh, df -h Check if image pulls fail because the node is full: df -h.
tar Archive or extract file collections. -czf create gzip archive, -xzf extract gzip archive Useful for packaging logs or manifests before sharing for support.
Example Session

Inspect the control plane manifest directory

cd /etc/kubernetes/manifests
pwd
ls -lh
less kube-apiserver.yaml
grep -n "advertise-address" kube-apiserver.yaml
Good Habit

Prefer safe readers before editors

When you are new, start with cat, less, tail, grep, and find. That habit prevents accidental damage when you are only trying to understand the system.

Access and Ownership

Users, Groups, sudo, and File Permissions

Who Am I

Identity commands

  • whoami shows current username
  • id shows UID, GID, and groups
  • groups shows supplementary groups
  • getent passwd username looks up user record
Ownership

Why permissions matter in K8s labs

Many Kubernetes setup steps need root because they touch system packages, services, kernel settings, or protected directories like /etc/kubernetes and /var/lib/kubelet.

Remember

sudo elevates one command

Use sudo command when you need privilege for a specific action. Avoid staying in a root shell unless you truly need it.

Command What It Does Common Switches Example
sudo Run one command with elevated privilege. -l list allowed commands, -k forget cached credentials, -i login shell sudo systemctl restart kubelet
chmod Change file mode bits. Numeric modes like 644, 600, 755 chmod 600 ~/.kube/config
chown Change file owner and group. -R recursive sudo chown -R $USER:$USER ~/.kube
useradd / adduser Create users. On Ubuntu, adduser is friendlier. --disabled-password, interactive prompts Create a demo user for shell practice.
usermod Change user settings like group membership. -aG append supplementary groups sudo usermod -aG sudo student
sudo and History

How to look up what you ran

  • history shows shell command history
  • history | grep sudo finds previous sudo commands
  • Ctrl+r interactively searches command history
  • journalctl _COMM=sudo or journalctl SYSLOG_IDENTIFIER=sudo can show sudo events when logged by the system
  • sudo -l shows what you are permitted to run
Permissions Decoder

Read common modes quickly

  • 644: owner can read/write, others read
  • 600: owner only, ideal for sensitive config
  • 755: executable directories and scripts
  • 777: almost never a good idea
systemd and Logs

systemctl, journalctl, Processes, and Runtime Troubleshooting

Command Purpose Common Switches Kubernetes Example
systemctl status Check whether a service is active and recent log lines. --no-pager easier output in scripts sudo systemctl status kubelet
systemctl start|stop|restart Control service lifecycle. No major switch for basics sudo systemctl restart containerd
systemctl enable Start service automatically at boot. --now enable and start immediately sudo systemctl enable --now kubelet
journalctl Read systemd journal logs. -u unit, -xeu detailed errors, -f follow, -n 100 last lines sudo journalctl -u kubelet -n 100 --no-pager
ps List running processes. aux broad listing, -ef full format ps -ef | grep kubelet
top Interactive process and CPU/memory view. No major beginner switch Check whether the node is under memory pressure during labs.
ss Inspect listening sockets and connections. -tulpn TCP/UDP listening with process names sudo ss -tulpn | grep 6443 for the API server port.
Common K8s Flow

When kubectl is failing, think host-side too

sudo systemctl status kubelet
sudo journalctl -u kubelet -xe --no-pager
sudo systemctl status containerd
sudo journalctl -u containerd -n 100 --no-pager
sudo ss -tulpn | grep 6443
What Beginners Miss

journalctl is often more useful than log files

On Ubuntu systems using systemd, many service logs live in the journal rather than a plain file. If you keep searching only under /var/log, you may miss the real error.

System Administration Basics

apt, updates, networking, memory, disk, and quick diagnostics

Command Use Common Switches Example
apt update Refresh package index metadata. No common switch needed here Run before installing kubeadm, kubelet, or kubectl.
apt install Install packages. -y answer yes automatically sudo apt install -y curl apt-transport-https ca-certificates
apt remove Remove package but often keep config. -y automatic yes Useful when rebuilding a training node cleanly.
apt purge Remove package and config where applicable. -y automatic yes Use carefully during reinstall or reset workflows.
apt-cache policy See candidate version and source repositories. No major switch for basics apt-cache policy kubeadm
hostnamectl Show or change host identity. set-hostname hostnamectl before joining nodes to a cluster.
ip a Show network interfaces and addresses. No major switch for basics Check the node IP used by kubelet.
free -h Show memory usage. -h human readable Helpful when Pods fail because the VM is too small.
uname -a Show kernel and system identity. No major switch for basics Useful while checking compatibility and environment details.
curl Make HTTP requests from the CLI. -I headers, -k ignore TLS verification, -L follow redirects curl -k https://127.0.0.1:6443/version for API checks on a control plane node.
Package Sequence

Typical Ubuntu install rhythm

sudo apt update
sudo apt install -y curl ca-certificates gnupg
apt-cache policy kubeadm
sudo apt install -y kubelet kubeadm kubectl
sudo systemctl enable --now kubelet
Useful Extras

Small commands that save time

  • watch -n 2 command reruns a command every 2 seconds
  • tee writes output to screen and file at the same time
  • xargs helps feed output into another command in bulk
  • env and printenv show environment variables
Kubernetes Lens

Translate Linux Commands into Kubernetes Learning Tasks

Kubernetes Relevant Directory Structure /etc/kubernetes/ ├── manifests/ │ ├── kube-apiserver.yaml │ ├── kube-controller-manager.yaml │ ├── kube-scheduler.yaml │ └── etcd.yaml ├── admin.conf └── kubelet.conf /var/lib/ ├── kubelet/ │ ├── config.yaml │ ├── pods/ │ └── pki/ └── containerd/ ├── io.containerd.content.v1.content/ └── io.containerd.snapshotter.v1.overlayfs/ /var/log/ ├── syslog ├── pods/ │ └── {namespace}_{pod}_{uid}/ └── containers/ └── {container-logs}.log Note: Use journalctl for systemd services /etc/containerd/ └── config.toml Key settings: • SystemdCgroup = true • sandbox_image = "registry.k8s.io/pause:3.9" • endpoint = ["/var/run/containerd/containerd.sock"] Modified during kubeadm setup
Static Pods

Control plane manifests

Use ls, less, and grep under /etc/kubernetes/manifests to understand how the API server, scheduler, and controller manager are launched.

sudo ls -lh /etc/kubernetes/manifests
sudo less /etc/kubernetes/manifests/kube-apiserver.yaml
Node Troubleshooting

kubelet and runtime logs

When Pods are not coming up, host services are often the real place to inspect.

sudo systemctl status kubelet
sudo journalctl -u kubelet -n 100 --no-pager
sudo journalctl -u containerd -n 100 --no-pager
Storage and Capacity

Check disk and memory before blaming Kubernetes

Image pull errors, eviction, and scheduling pain can all come from host resource pressure.

df -h
du -sh /var/lib/containerd
free -h
Linux Need Typical Command Why It Helps in K8s
Find config files find /etc -name '*kube*' Locate kubelet, container runtime, or kubeadm-generated config.
Inspect service health sudo systemctl status kubelet Quickly see whether kubelet is active, failed, or flapping.
Read recent error logs sudo journalctl -u kubelet -xe Surface certificate, cgroup, swap, CRI, or bootstrap errors.
Verify listening ports sudo ss -tulpn Check whether expected control plane ports are actually open.
Confirm user access ls -l ~/.kube/config Permission mistakes on kubeconfig files break local admin access.
Check package versions apt-cache policy kubeadm kubelet kubectl Helpful during upgrades, skew checks, and installation issues.
Linux skills do not replace Kubernetes concepts, but they remove a lot of friction. If you can comfortably inspect files, services, logs, permissions, packages, and host resources, most Kubernetes labs become far easier to debug and explain.