Mastering Essential Linux Commands for DevOps & Development

Hey everyone! 👋
In my DevOps learning journey, I’ve been diving deep into Linux, and today I’m going to share some of the key commands I’ve learned so far. Whether you're a beginner or just want to brush up on your Linux skills, these commands will help you manage processes, monitor logs, and handle files and networks efficiently.

Let’s get into it! 🚀


1. Killing Processes: top, kill, pidof, and ps -aux

  • What it does:
    These commands help you find and stop processes that are taking up too much memory or CPU.

  • How to use:

      top               # View running processes in real-time
      kill <PID>        # Kill a process by its Process ID (PID)
      pidof <program>   # Find the PID of a running program
      ps -aux           # List all running processes
    
  • Example: Use top to find a process that’s slowing down your system, get its PID, and then use kill <PID> to stop it.

  • Why it's useful:
    Killing unnecessary processes helps keep your system running smoothly.


2. Difference Between which and whatis

  • What it does:
    which enable you to find where a program is installed, and whatis gives you a quick summary of what a command does.

  • How to use:

      which python     # Find the location of the Python executable
      whatis python    # Get a short description of Python
    
  • Example:

      which git
      whatis git
    
  • Why it's useful:
    These commands are helpful when you want to check if a program is installed or quickly understand what a command does.


3. Monitoring Logs with tail -f

  • What it does:
    tail -f shows you the last 10 lines of a file and keeps updating as new lines are added. Great for watching logs in real time!

  • How to use:

      tail -f /var/log/syslog    # Monitor the system log in real-time
    
  • Why it's useful:
    When debugging or troubleshooting, real-time log monitoring is super helpful to catch errors as they happen.


  • What it does:
    ln creates links between files. Hardlinks are actual copies of files, while softlinks (symlinks) are just shortcuts.

  • How to use:

      ln <source> <destination>      # Create a hardlink
      ln -s <source> <destination>   # Create a softlink
    
  • Example:

      bashCopy codeln file.txt hardlink.txt
      ln -s file.txt symlink.txt
    
  • Why it's useful:
    Symlinks are great for creating shortcuts, and hardlinks are useful when you want to reference the same data without duplicating it.


5. Running Background Processes with nohup

  • What it does:
    nohup allows you to run processes that won’t stop even if you log out.

  • How to use:

      nohup <command> &   # Run a command in the background
    
  • Example:

      nohup long_script.sh &
    
  • Why it's useful:
    Perfect for long-running processes that you want to keep going after you close your terminal.


6. Viewing System Resources: df, du, free, vmstat

  • What it does:
    These commands help you check how much disk space, memory, and CPU your system is using.

  • How to use:

      df -h      # View disk usage
      du -sh     # View the size of a directory
      free -h    # View memory usage
      vmstat     # View CPU, memory, and IO stats
    
  • Why it's useful:
    Keeping an eye on system resources helps prevent issues like running out of memory or disk space.


7. User and Group Management: useradd, userdel, groupadd, groupdel

  • What it does:
    These commands allow you to manage users and groups on your system.

  • How to use:

      sudo useradd <username>    # Add a new user
      sudo groupadd <groupname>  # Add a new group
      sudo userdel <username>    # Delete a user
      sudo groupdel <username>   # Delete a group
    
  • Why it's useful:
    Managing users and groups is important for security and controlling access to resources.


8. File Permissions: chmod, chown, chgrp

  • What it does:
    These commands let you control who can read, write, and execute files.

  • How to use:

      chmod 755 <file>      # Change file permissions
      chown user:group <file>  # Change file owner
      chgrp <group> <file>  # Change file's group
    
  • Example:

      chmod 755 myscript.sh
    
  • Why it's useful:
    Ensuring files have the right permissions helps keep your system secure.


9. Service Management: systemctl

  • What it does:
    systemctl lets you start, stop, and check the status of services running on your system.

  • How to use:

      sudo systemctl status <service>   # Check service status
      sudo systemctl start <service>    # Start a service
      sudo systemctl stop <service>     # Stop a service
    
  • Why it's useful:
    It's essential for managing background services like web servers or databases.


10. Networking Commands: ping, netstat, ifconfig, traceroute, nmap

  • What it does:
    These are network-related commands that help you check connectivity, scan ports, or monitor network traffic.

  • How to use:

      ping <host>         # Check if a host is reachable
      netstat -tuln       # View network connections
      ifconfig            # View and configure network interfaces
      traceroute <host>   # Trace the route to a host
      nmap <host>         # Scan open ports on a host
    
  • Why it's useful:
    These commands are crucial for diagnosing network issues and improving connectivity.


11. Data Manipulation: awk, sed, grep

  • What it does:
    These are powerful commands for searching, replacing, and formatting text in files.

  • How to use:

      awk '{print $1}' <file>   # Print the first column of a file
      sed 's/old/new/g' <file>  # Replace text in a file
      grep 'pattern' <file>     # Search for a pattern in a file
    
  • Example:

      grep "error" log.txt  # Find occurrences of "error" in a log file
    
  • Why it's useful:
    When dealing with large files, these commands help you quickly find and manipulate the data you need.


Conclusion 📝

Learning these Linux commands has been a game-changer for me. Whether you're managing services, debugging issues, or simply checking system performance, mastering these commands will help you stay on top of your DevOps or development tasks.

Have any questions or want to share your favorite commands? Let me know in the comments! 🙌


References for Learning

3
Subscribe to my newsletter

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

Written by

Abhishek Prajapati
Abhishek Prajapati

I am a passionate Software Engineer with over two years of experience in the tech industry, specializing in Full Stack Development and DevOps practices. Currently, I work on innovative projects in the automotive sector, where I develop and automate solutions that enhance user experience and streamline operations. With a keen interest in cloud technologies, automation, and infrastructure management, I am dedicated to mastering the DevOps landscape. I believe in simplifying complex concepts and sharing practical insights to help others in their learning journeys. Join me as I document my experiences, challenges, and triumphs in the world of DevOps!