Day 2 - Essential Linux Commands for DevOps

Bhushan DabhadeBhushan Dabhade
4 min read

Hey everyone, welcome back to Day 2 of my DevOps blog series! Today, we're exploring the basics of Linux and some Essential Commands that are Super useful for anyone working in tech, especially in DevOps.

For today’s demo, I’m using Ubuntu 24.04.1 LTS on VirtualBox, with an image download from the OSBOXES ( Link- https://www.osboxes.org/ )

Let’s start by understanding what Linux is, explore some popular Linux distributions, and then go over the commands you'll likely use the most. So, let’s get into it!

What is Linux?

Linux is an open-source operating system, which means it’s free and anyone can use, modify, or distribute it. It’s the go-to system for many developers and DevOps engineers, especially because of its stability and flexibility. At its core, Linux has a kernel, which manages everything from hardware to software.

There are many different "flavors" of Linux, called distributions. Each is designed for specific needs. Here are some popular ones:

  • Ubuntu – User-friendly and great for beginners.

  • Red Hat Enterprise Linux – Used by big organizations for its stability.

  • Debian – Known for being super reliable.

  • Fedora – Cutting-edge, used for testing new technologies.

  • Linux Mint – Great for users switching from Windows.

Basic Linux Commands

If you’re working with Linux, you’ll use the command line a lot. Let’s break down some of the basic commands you’ll need to navigate and manage your system:

  1. pwd – Prints the current directory.

    • Example: pwd
      This shows the full path of the folder you’re currently in.

  2. ls – Lists the files and folders in your current directory.

    • Example: ls -l (detailed list), ls -a (shows hidden files)

  3. cd – Changes the current directory.

    • Example: cd /path/to/directory
      To go back to the previous folder, use cd ...

  4. mkdir – Creates a new folder.

    • Example: mkdir new_folder
      You can also create multiple or nested folders, like this: mkdir -p A/B/C.

      Here, we use the "tree" command to view the file structure.

  5. touch – Creates an empty file.

    • Example: touch newfile.txt
      This makes a file called "newfile.txt" in your current directory.

  6. rm – Removes (deletes) files or directories.

    • Example: rm filename
      To delete folders and their contents, use rm -r folder_name.

  7. cp – Copies files from one location to another.

    • Example: cp source_file destination
      Copies "source_file" to the destination you specify.

  8. mv – Moves or renames files.

    • Example: mv old_name new_name
      This renames or moves a file from one place to another.

  9. cat – Displays the contents of a file.

    • Example: cat filename
      Use this to quickly check what's inside a file.

  10. chmod – Changes file permissions.

    • Example: chmod 755 filename
      This sets permissions for who can read, write, and execute the file.

Common Linux Commands for DevOps Engineers

If you’re working in DevOps, here are a few additional commands that will come in handy:

  • sudo – Runs commands with admin (superuser) privileges.

    • Example: sudo command
      Use this when you need extra permissions for a task.

      Example: sudo apt-get update
      The sudo command allows you to run tasks that need higher-level permissions. In this example, you're updating the package list on your system, which requires admin access.
      Use sudo anytime you need extra permissions for installing, updating, or managing system files.

  • systemctl – Manages services (start, stop, restart).

    • Example: systemctl stop nginx
      Useful for controlling web services or other background tasks.
      The systemctl command is essential for managing services running on your server. In this case, you’re stopping the Nginx service (a popular web server).
      You can also use this command to start, stop, enable, or disable services like nginx, apache, or docker.

  • df and du – Checks disk space.

    • Example (for df): df -h
      The df command shows how much disk space is being used by each file system. The -h flag displays this information in a human-readable format (e.g., GB, MB).

    • Example (for du): du -sh /var/log
      The du command checks the disk usage of specific directories or files. The -sh flag displays the size of the /var/log directory, showing how much space it’s consuming.

  • grep – Searches for specific text inside files.

    • Example: grep "error" /var/log/syslog
      The grep command is used to search for a specific pattern or string within files. In this example, it scans the syslog file for the word "error" and prints any matching lines.
      This is especially useful for debugging or scanning large log files to quickly find errors or important messages.
  • tar – Creates or extracts archives.

    • Example: tar -cvf archive.tar folder_name
      Commonly used for backing up or transferring files.


These are just a few of the many Linux commands that form the backbone of system management. Whether you’re a beginner or looking to refine your skills, mastering these commands will help you feel more confident working on Linux-based systems. Stay tuned for more tips as we continue this #90DaysOfDevOps challenge!

0
Subscribe to my newsletter

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

Written by

Bhushan Dabhade
Bhushan Dabhade