- Kloudnative
- Posts
- 10 Basic Linux Commands Every DevOps Engineer Pretends to Know
10 Basic Linux Commands Every DevOps Engineer Pretends to Know
Why These Basics Matter and What You Need to Master for Everyday Excellence
If you're stepping into the world of DevOps, you'll soon discover that Linux is your best friend. Whether you're managing servers, deploying applications, or troubleshooting issues, knowing your way around the Linux command line is a must. In this guide, we’ll walk you through the most commonly used Linux commands that every DevOps engineer should have in their toolkit.
At its heart, Linux is a robust, open-source operating system that offers flexibility, stability, and security—attributes that make it particularly well-suited for the demands of DevOps. Linux gives users full control over their systems through its command-line interface (CLI), which is a game-changer for DevOps engineers who need to automate tasks, configure servers, or orchestrate complex infrastructure.
Kloudnative is committed to staying free for all our users. We kindly encourage you to explore our sponsors to help support us.
This Smart Home Company Has Already Hit $10 Million in Revenue—and It’s Just Getting Started
What if your window shades could do more than just block sunlight?
Meet RYSE, the company transforming everyday window shades into smart, automated devices. With over $10 million in total revenue, 10 granted patents, and products already available in 127 Best Buy locations, RYSE is growing at an incredible pace—200% over the last month, to be exact.
And they’re only getting started. With plans to expand internationally and partnerships with major retailers like Home Depot and Lowe’s, RYSE is set to become a household name in the rapidly growing smart home market.
Now, you have the chance to invest for just $1.75 per share and join a company poised for explosive growth.
☝️ Support Kloudnative by clicking the link above to explore our sponsors!
Key Benefits of Linux for DevOps:
Open Source and Free: Unlike proprietary systems, Linux is open-source, meaning it’s free to use, modify, and distribute. This reduces the cost of infrastructure and provides unmatched flexibility in customizing the system to meet specific needs.
Stability and Reliability: Linux is renowned for its stability and reliability, especially in server environments. It's less prone to crashes and can handle heavy workloads, making it ideal for running mission-critical applications.
Security: Linux offers robust security features like SELinux (Security-Enhanced Linux), iptables, and a strong user permission system. These features help protect data and prevent unauthorized access, making Linux the OS of choice for secure deployments.
Efficiency in Automation: Linux shines in automation. With scripting tools like Bash, DevOps engineers can write powerful scripts to automate repetitive tasks, from server configuration to deployment pipelines, saving time and effort.
Wide Industry Adoption: Linux runs on nearly all cloud platforms, including AWS, Google Cloud, and Azure. Understanding Linux is critical for managing cloud infrastructure and ensuring smooth application deployment and scaling.
Large Support Community: Being open-source, Linux has an active, global community of developers and system administrators who continuously contribute to its improvement and offer solutions to common challenges. Let’s dive right in!
System Info Commands
hostname
Shows the name of your system’s host.hostname
hostid
Displays the host ID assigned by the OS.hostid
date
Prints the current date and time in UTC format.date
whoami
Displays the username of the currently logged-in user.whoami
uptime
Tells you how long the machine has been running.uptime
uname
Prints information about your system's kernel.uname
clear
Clears the terminal screen, giving you a fresh start.clear
history
Displays a list of all the commands you’ve executed so far.history
sudo
Run commands with superuser privileges.sudo <command>
echo $?
Shows the exit status of the last executed command (0 means success, 1–127 means failure).echo $?
Directory Commands
pwd
Shows the current working directory.pwd
cd
Changes the current directory.cd /path/to/directory
cd ..
Goes to the parent directory.cd ..
mkdir
Creates a new directory.mkdir new_directory
File Commands
touch
Creates an empty file.touch newfile.txt
ls -l
Lists files in a directory with detailed information.ls -l
vim
A powerful text editor for editing files.Normal Mode: Default mode for navigation and editing.
Insert Mode: Press
i
to start typing. PressEsc
to return to Normal Mode.Command Mode: Press
:
to enter commands like saving or quitting.
vim file.txt
cat
Concatenates and displays the content of files.cat file.txt
rm
Removes files or directories.rm -f <file>
: Force remove a file.rm -rf <dir>
: Recursively force remove files and directories.
rm -f file.txt rm -rf directory_name
cp
Copies files or directories.cp source_file destination_file
mv
Moves or renames files.mv oldname.txt newname.txt
Network Commands
ping <hostname>
Tests the reachability of a remote host.ping google.com
ifconfig
Displays the system’s network interfaces.ifconfig
netstat -lntp
Shows all active TCP ports.netstat -lntp
nslookup
Resolves domain names to IP addresses (or vice versa).nslookup google.com
Process Information Commands
ps
Displays the currently running processes.ps
ps -ef
Lists all processes on the system.ps -ef
top
Provides a dynamic, real-time view of system processes.top
kill <pid>
Gracefully terminates a process by its PID.kill <pid>
df -h
Shows disk space usage in human-readable format.df -h
Package Management (Red Hat)
yum
The package manager for RHEL-based systems.yum update -y
: Updates the package list.
yum update -y
yum list --installed
Lists all installed packages.yum list --installed
Service Management
sudo systemctl list-units -t service
Lists all running services on the system.sudo systemctl list-units -t service
sudo systemctl start <service>
Starts a specified service (e.g.,nginx
).sudo systemctl start nginx
sudo systemctl status <service>
Checks the status of a service.sudo systemctl status nginx
sudo systemctl restart <service>
Restarts a service.sudo systemctl restart nginx
Other Useful Commands
grep
Searches for a string in a text file (like a CLI version of Ctrl+F).grep "search_string" file.txt
tail
Displays the last N lines of a file. By default, it shows the last 10 lines.tail -n 20 file.txt
head
Displays the first N lines of a file. By default, it shows the first 10 lines.head -n 20 file.txt
free
Shows system memory usage, including free, used, and swap memory.free -h
ssh-keygen
Generates SSH key pairs for secure remote login without passwords.ssh-keygen
curl
Transfers data to/from a server via various protocols (HTTP, HTTPS, FTP).curl https://example.com
tar
Creates and extracts tar archive files.
Example:tar -xvzf archive.tar.gz
cron
&crontab
Schedule tasks at specific intervals.
Example:Edit a crontab file:
crontab -e
Set up a
cron
job to run every hour:0 * * * * /path/to/script.sh
File Permissions
chmod <octalNumber> <fileName>
Changes the permissions of a file.
Example:chmod 777 file.txt
Wrapping It Up
Mastering these Linux commands is just the beginning of your journey as a DevOps engineer. The real power lies in how you apply these commands to automate tasks, optimize workflows, and troubleshoot complex issues across different environments. As you grow in your DevOps career, you'll also start to explore advanced topics like containerization with Docker, continuous integration/continuous delivery (CI/CD) pipelines, and cloud automation tools—skills that are essential for modern infrastructure management.
Stay tuned as we delve deeper into these advanced concepts in upcoming articles, where we’ll explore how to combine these Linux commands with other DevOps tools to streamline your workflows even further. Ready to level up? Let’s continue building a solid foundation that will empower you to tackle any DevOps challenge with confidence.