Linux Commands for DevOps

Mithun KMithun K
3 min read

Introduction

If you're starting your journey into DevOps, there's one skill you absolutely need to build a strong foundation: Linux. Most servers in the cloud run on Linux, and many DevOps tools are designed to work best with it. But don't worry—you don’t need to become a Linux wizard overnight. In this blog, we’ll go through essential Linux commands that you'll actually use in real-world DevOps tasks.

This guide avoids technical jargon and keeps things simple and practical. Let's dive in.

1. Navigating the File System

Think of Linux as a tree with folders (called directories) branching out. To move around:

  • pwd → Shows you where you are right now.

  • ls → Lists files and folders in your current directory.

  • cd → Lets you move into another directory. Example:

  • cd /home/username/projects

  • cd .. → Moves one step back.

These commands are your GPS when working in Linux.

2. Viewing and Editing Files

  • cat filename → Displays the content of a file.

  • less filename → Opens a file for viewing, one screen at a time. Use q to quit.

  • nano filename → A simple text editor to edit files inside the terminal.

For example:

  • nano config.txt

This opens the file and lets you make changes right away.

3. Copying, Moving, and Deleting Files

  • cp file1 file2 → Copies file1 to file2.

  • mv file1 folder/ → Moves file1 into a folder.

  • rm file1 → Deletes a file.

To remove a folder and its contents:

  • rm -r foldername

Be careful with this command. Once removed, files are gone unless backups exist.

4. Managing Permissions

In DevOps, you'll often need to give or restrict access to files.

  • chmod → Changes file permissions.

  • chown → Changes the owner of a file.

Example:

  • chmod +x script.sh - Makes a script executable

  • chown user:user file - Gives ownership to a user

These commands help control who can do what with files.

5. Monitoring Processes

  • top → Shows running processes and system resource usage.

  • ps aux → Lists all current processes.

  • kill PID → Stops a process by its ID (you get PID from ps or top).

Example:

kill 12345

Use this when a script or app gets stuck.

6. Network Commands

  • ping google.com → Tests internet connection.

  • curl example.com → Fetches data from a web server.

  • ifconfig or ip a → Shows network info like IP addresses.

These are super useful for checking if your server is connected and talking to the internet.

7. System Updates and Packages

Depending on your system:

Debian/Ubuntu:

  • sudo apt update - Refresh package list

  • sudo apt install nginx - Install a package like Nginx

CentOS/RHEL:

  • sudo yum update

  • sudo yum install nginx

This is how you install and update software on your server.

8. Disk and Space Management

  • df -h → Shows disk space in a human-readable format.

  • du -sh foldername/ → Shows how much space a folder uses.

Example:

  • du -sh /var/log

This helps you figure out where space is being used.

9. Searching and Finding Files

  • find → Looks for files and folders by name.

  • find / -name filename.txt

  • grep → Searches inside files for specific words.

  • grep "error" /var/log/syslog

Use this to troubleshoot issues or find specific lines in logs.

10. Running Tasks with Superuser Access

Sometimes, you need admin rights to perform actions. Prefix the command with sudo:

It will ask for your password and then run the command with higher privileges.

Final Thoughts

You don’t need to memorize all these commands at once. Just start using them as you explore Linux and DevOps tools. With time, they’ll become second nature.

0
Subscribe to my newsletter

Read articles from Mithun K directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mithun K
Mithun K