CKA: Essential Shell commands


Redirection operators(>> vs >) :
>
and>>
are redirection operators used to send output to files instead of the terminal. Here's what they mean:>
: Redirect and OverwriteRedirects stdout (standard output) to a file.
Overwrites the file if it exists.
>>
: Redirect and AppendRedirects stdout to a file.
Appends to the file if it exists.
Creates the file if it doesn't exist.
tail
utility : Thetail
utility is a command-line tool used to display the end (tail) of a file, usually text files like logs, defaults to displaying the last 10 lines of a file.-f
flag intail -f
stands for "follow", which means: shows the last 10 lines and then keep the file open and continuously output new lines as they are appended to the file.
dpkg
: A low-level tool that Installs.deb
files without dependency resolution.apt-get
: A package manager used to install/remove/update packages which can resolve dependencies and fetch packages from online repositories (which dpkg cannot).systemctl
: The command-line tool used to interact withsystemd
, the modern init system and service manager used in most major Linux distributions (like Ubuntu, CentOS, Debian, RHEL, etc.)Used to manage systemd services (start/stop services, enable at boot, etc.).
# Start, stop, restart, enable, disable, and check the status of services. systemctl start nginx # Start nginx service systemctl stop nginx # Stop it systemctl restart nginx # Restart systemctl status nginx # Show current status systemctl enable nginx # Start nginx automatically at boot systemctl disable nginx # Disable it from auto-starting
grep
: Global Regular Expression Print, go-to utility for searching text in files, logs, or command output using patterns or regular expressions.-i
flag for case-insensitive search-r
or-R
for recursive search in all files in a directory-n
shows line numbers of matching lines-w
will match whole words only--color
for highlighting the match in the output# eg, how to combine it with kubectl for debugging kubectl get pods -A | grep CrashLoopBackOff
sysctl
: Used to view or modify kernel parameters (like net.ipv4.ip_forward).sysctl net.ipv4.ip_forward # Check value sysctl -w net.ipv4.ip_forward=1 # Set temporarily
sudo −i
: sudo utility in Linux systems lets you run commands with elevated privileges, typically as the root (superuser) account, without having to log in asroot
directlyAlthough it stands for “superuser do“, now it can be configured to let you run commands as any user, not just root
sudo -i
is a special form ofsudo
that gives you an interactive root login shell, almost as if you logged in directly as theroot
user
curl & wget
: Bothcurl
andwget
are command-line utilities for transferring data over networkscurl
: Transfers data to/from a server using many supported protocols (HTTP, HTTPS, FTP, SFTP, SCP, LDAP, IMAP, POP3, SMTP, etc)It’s actually a general-purpose HTTP/HTTPS client for making requests to any endpoint.
wget
: Primarily for downloading files from the web (HTTP, HTTPS, FTP).While
curl
is very flexible for both download and upload, it is mostly used for making http request in CKA;wget
is designed mainly for retrieving content, especially useful for big files or recursive site downloads.
nslookup
: command-line tool used to query DNS (Domain Name System) servers to get information about domain names, IP addresses, and other DNS records.Looks up the IP address for a given domain name and vice-versa (reverse lookup).
Retrieves specific DNS record types (A, AAAA, MX, TXT, NS, etc.).
Useful for testing or troubleshooting DNS configuration issues.
netstat
: Displays active TCP connections, ports on which the computer is listening, Ethernet statistics, the IP routing table, IPv4 statistics.Shows active TCP/UDP connections (both incoming and outgoing).
Lists ports the system is listening on.
Displays routing tables.
Shows network interface statistics (packets sent/received, errors).
Helps identify which process is using which port.
netstat -tulnp
is used to display all actively listening TCP and UDP ports, along with the processes using them.
Good to know
kubectl --help
: shows the you the built-in usage guide forkubectl
including all the subcommands and options- My favourite and super helpful during the exam, saves a lot of time wasted searching through docs.
yq
: command-line utility for reading, writing, and transforming YAML fileyq
can be a big time-saver when working with YAML manifests for KubernetesFor example: use
yq '.spec.containers[].image' pod.yaml
for grabbing image of pod
man
: displays the manual pages for commands, basically the built-in, offline reference guide for most CLI tools- Useful for instantly check syntax for CLI tools right in the terminal
kubectl explain
: shows the API schema for any Kubernetes objectHelpful when working with custom CRDs as CRDs docs are not available in the official exam
Using
explain
subcommand we can see the details of our API schema such as field names and descriptions
Most of the utilities listed here are used by SysAdmins and DevOps folks on day to day basis, however having it listed out like this could be a good reference during preparation.
This list is not exhaustive, let me know if I’ve missed any commands so that I can keep the list updated as much as possible!! 🤞
Subscribe to my newsletter
Read articles from Vishnu Mohan directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Vishnu Mohan
Vishnu Mohan
Software Engineer | DevOps & CloudNative