Linux commands for Kubernetes users
The Linux commands you need before learning Kubernetes. Covers file permissions, chmod, tar, environment variables, systemctl, journalctl, ps, and networking tools.
5 lessons · 16 min · Beginner
Written by
Marketing Team at Civo
Written by
Marketing Team at Civo
Before working with Kubernetes, a working familiarity with the Linux command line is essential. You do not need to be a Linux expert, but certain commands come up constantly when installing tools, managing services, and troubleshooting nodes.
Here is how each category connects to your Kubernetes work:
- File system commands: you will use chmod +x when installing kubectl and other Kubernetes binaries
- Archive commands: you will use tar when extracting downloaded Kubernetes tooling
- Environment variables: you will use export to set KUBECONFIG and other Kubernetes configuration values
- Network commands: you will use ping, ss, and nslookup to diagnose connectivity issues between nodes and pods
- Process commands: you will use ps to check whether the kubelet or container runtime is running
- Service commands: you will use systemctl to manage the kubelet service and journalctl to read its logs
Essential file system commands
List files and directories in the current directory:
ls
For detailed information including permissions, size, and modification time:
ls -ltr
Create a new directory:
mkdir my-directory
Switch into the directory:
cd my-directory
Create a new empty file:
touch myfile.txt
Edit a file with vi:
vi myfile.txt
Press i to enter INSERT mode. Type your content. Press Escape, then type :wq! and press Enter to save and exit.
View the contents of a file:
cat myfile.txt
Copy a file to another directory:
cp myfile.txt ../myfile.txt
Navigate to the parent directory:
cd ..
Clear the terminal screen:
clear
Changing file permissions
Set a file to read-only mode:
chmod 400 myfile.txt
Making a binary executable
When you download a Kubernetes binary like kubectl, it is not executable by default. You need to grant execute permission before you can run it.
Download the kubectl binary:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
Make it executable:
chmod +x kubectl
Run it:
./kubectl
Extracting compressed files
Kubernetes tools are often distributed as compressed archives. Use tar to extract them:
tar -xvf file.tar
The flags do the following: -x extracts the archive, -v lists the files as they are extracted, -f specifies the filename.
Environment variables
View all currently set environment variables:
env
Set a new environment variable:
export demo=training
Verify it was set:
env | grep demo
Print the value of a variable:
echo $demo
Expected output:
training
Check disk space usage in a human-readable format:
du -h
For a summary of total directory size:
du -sh
Network connectivity commands
Test connectivity to a host:
ping www.google.com
Send a single packet:
ping -c 1 www.google.com
View active network connections and listening ports:
ss -tulnp
Note: if you see references to netstat in older tutorials, it has been deprecated on modern Linux distributions and may not be installed by default. ss is the current replacement and provides the same information with a similar syntax.
Look up DNS records for a domain:
nslookup www.google.com
Process status commands
View all running processes with detailed information:
ps -ef
To terminate a process, find its PID from the ps output and run:
kill <PID>
Tail commands
Print the last ten lines of a file:
tail demo
Print the last five lines:
tail -n 5 demo
Service management commands
These commands are critical for Kubernetes node troubleshooting. systemctl controls services and journalctl reads their logs.
Check the status of a service:
systemctl status docker
Start a service:
systemctl start docker
Check kubelet status on a Kubernetes node:
systemctl status kubelet
View systemd logs:
journalctl
View logs for a specific service, for example the kubelet:
journalctl -u kubelet
Monitor CPU and memory utilisation in real time:
top
For a more readable interface:
htop

Marketing Team at Civo
Civo is the Sovereign Cloud and AI platform designed to help developers and enterprises build without limits. We bridge the gap between the openness of the public cloud and the rigorous security of private environments, delivering full cloud parity across every deployment. As a team, we are dedicated to providing scalable compute, lightning-fast Kubernetes, and managed services that are ready in minutes. Through CivoStack Enterprise and our FlexCore appliance, we empower organizations to maintain total data sovereignty on their own hardware.
Our mission is to make the cloud faster, simpler, and fairer. By providing enterprise-grade NVIDIA GPUs and streamlined model management, we ensure that high-performance AI and machine learning are accessible to everyone. Built for transparency and performance, the Civo Team is here to give you total control over your infrastructure, your data, and your spend.
Share this lesson