Linux Operating System: The Foundation of DevOps Engineering

Md. Afzal Hassan Ehsani

Linux is an operating system that has revolutionized the computing world. It’s the backbone of modern infrastructure, especially in the world of DevOps, where automation, scalability, and reliability are paramount. This blog will take you through the origins of Linux, its structure, the role it plays in DevOps, and provide a detailed exploration of the commands that are essential for any DevOps engineer.


The Birth of Linux: A Journey Through Time

In 1991, a Finnish student named Linus Torvalds laid the foundation for what would become one of the most important pieces of software in modern computing: the Linux kernel. While studying computer science at the University of Helsinki, Torvalds was frustrated by the limitations of the existing operating systems. He had access to a UNIX-based system but found it restrictive and expensive. This frustration led him to develop his own kernel, which he initially described as a hobby project.

Linus Torvalds posted his initial version on the MINIX newsgroup in August 1991, offering it for free. Soon, developers from around the world began contributing to the project, and the kernel rapidly evolved into a powerful, open-source operating system that now powers the majority of servers, supercomputers, and mobile devices across the globe. This open-source nature, coupled with its modular architecture, made Linux a favorite for developers and system administrators alike, and eventually, a cornerstone of the DevOps revolution.


Why Linux Dominates the DevOps World

In the realm of DevOps, Linux reigns supreme. There are several reasons why Linux is preferred over other operating systems, like Windows, especially for server and infrastructure management:

  • Open-source: Linux is freely available and can be modified to suit the needs of developers and engineers.
  • Customizability: Linux’s modular architecture allows users to customize the operating system to meet specific requirements.
  • Security: Linux is widely regarded as a more secure platform due to its robust permissions system and smaller attack surface.
  • Stability: Linux systems, especially distributions like Ubuntu, CentOS, and Debian, are known for their stability and long-term support.
  • Package Management: Tools like apt, yum, and dnf make installing, updating, and managing software on Linux servers incredibly efficient.
  • Automation: The strong support for scripting and automation tools makes Linux ideal for automating repetitive tasks, which is a core principle in DevOps.

Windows, while powerful in desktop environments, falls short in areas like scripting, package management, and system resource efficiency when compared to Linux. This makes Linux the clear choice for servers and cloud infrastructure, where performance and reliability are critical.


Why DevOps Engineers Use Linux

  • Scalability: Linux supports a wide range of hardware architectures and can scale efficiently across systems, from small embedded devices to large server farms.
  • Automation: Linux allows seamless integration with tools like Docker, Kubernetes, Jenkins, and Ansible, essential for automation.
  • Cost-Effective: Linux is free and open-source, allowing companies to reduce costs without sacrificing functionality.

Linux Architecture Components

Linux has a modular architecture, which consists of several key components that ensure its stability and functionality.

Key Components:

  • Kernel: The core of the operating system that manages resources (CPU, memory, I/O devices) and communicates between hardware and software.
  • System Libraries: Provide standard interfaces for software applications to interact with the kernel. For example, glibc (GNU C Library) is a core system library used by almost all Linux applications.
  • System Daemons: These are background services (like sshd for SSH or cron for scheduled tasks) that start at boot time and run continuously.
  • User Space: Where user applications run, separated from the kernel for security. User space includes programs, desktop environments, and utilities.
  • Shell: A command interpreter that provides a user interface to interact with the system.

The Linux Kernel

The kernel is the heart of the Linux OS, acting as a bridge between hardware and software. It handles system resources such as CPU, memory, and I/O devices, making sure they are properly allocated and managed.

How the Kernel Works:

The kernel provides an abstraction layer between user applications and hardware. For example, when a program wants to read a file from disk, it sends a request to the kernel, which retrieves the data by interfacing with the hardware. The kernel then sends the requested data back to the program.

Key Functions of the Kernel:

  • Memory Management: The kernel manages RAM and swap space, allocating memory to processes and freeing it when no longer needed.
  • Process Management: It handles the creation, scheduling, and termination of processes.
  • Device Management: The kernel manages device drivers, allowing communication between software and hardware peripherals (e.g., keyboards, disks).
  • File System Management: It organizes and handles file operations on various file systems, such as ext4, XFS, and Btrfs.

Here’s a diagram illustrating how the Linux kernel works:

graph TD;
    A["User Applications"] --> B["System Call Interface"];
    B --> C["Linux Kernel"];
    C --> D["Process Management"];
    C --> E["Memory Management"];
    C --> F["File System Management"];
    C --> G["Device Drivers"];
    D --> H["Hardware"];
    E --> H;
    F --> H;
    G --> H;

This diagram shows how user applications interact with the kernel through the system call interface. The kernel then manages various aspects of the system, including processes, memory, file systems, and devices, which all interface with the hardware.

What is the primary function of the Linux kernel?

Answer: The Linux kernel is responsible for managing system resources, providing an interface between hardware and software, and handling core operating system functions like process scheduling, memory management, and device drivers.


Linux System Libraries

System libraries are essential for running applications on Linux. They provide standard routines and interfaces that allow programs to interact with system resources.

Key System Libraries:

  • Glibc (GNU C Library): The most commonly used system library that provides essential routines for the kernel and user space programs.
  • libstdc++: A widely used C++ standard library that supports object-oriented programming.

How Libraries Work:

When an application runs, it relies on libraries to perform tasks like memory allocation, file input/output, and process control. These libraries are loaded into memory dynamically during runtime.


Daemons in Linux

Daemons are background processes in Linux that are responsible for various system services. They start at boot and usually run without user intervention.

Common Daemons:

  • sshd: The SSH daemon, responsible for managing incoming SSH connections.
  • cron: The cron daemon, used for scheduling tasks to run at specific times.
  • systemd: The init system and service manager, responsible for managing daemons, services, and system resources.

Managing Daemons:

You can control daemons with the systemctl command in systemd-based distributions:

sudo systemctl start sshd

sudo systemctl enable sshd

sudo systemctl restart cron

As a DevOps engineer, you notice that the SSH daemon (sshd) on a production server is not starting automatically after system reboots. How would you ensure that sshd starts automatically on boot?

Answer: To ensure that the SSH daemon (sshd) starts automatically on boot, you would use the following command:

sudo systemctl enable sshd

This command enables the sshd service to start automatically at boot time. After running this command, you should also start the service immediately if it’s not already running:

sudo systemctl start sshd

These commands utilize systemd, which is the init system in most modern Linux distributions, to manage services like sshd.

You're managing a web server running Apache, and you need to reload the Apache configuration without interrupting active connections. Which daemon-related command would you use to achieve this?

Answer: To reload the Apache configuration without interrupting active connections, you would use the following command:

sudo systemctl reload apache2

or on some systems:

sudo systemctl reload httpd

This command sends a signal to the Apache daemon to reload its configuration files without fully stopping and starting the service. It’s less disruptive than a full restart and is commonly used when making configuration changes that don’t require a full service restart.

If a reload is not sufficient and you need to fully restart the service, you would use:

sudo systemctl restart apache2

These commands demonstrate how systemd is used to manage daemon processes in a DevOps environment, allowing for fine-grained control over system services.


User Space

User space refers to the environment where user applications and utilities run. It is separated from the kernel to prevent accidental or malicious interference with the core system functions. When an application needs access to hardware or system resources, it must make a system call to the kernel.

  • Applications: Programs like web browsers, editors, and database servers run in user space.
  • Processes: All user-initiated tasks are created and managed as processes in user space.

Shells in Linux

A shell is an interface between the user and the kernel, allowing the user to execute commands, run programs, and manage the system. Shells are an essential tool for DevOps engineers because they enable command-line interaction and script automation.

Types of Shells:

  1. Bash (Bourne Again Shell):
    • The default shell on most Linux systems, Bash is powerful for both interactive use and scripting.

    • Example:This Bash script prints numbers from 1 to 5.

for i in {1..5}; do echo "Number $i"; done
  1. Zsh (Z Shell):
    • Zsh offers advanced features like auto-completion, spelling correction, and plugins for customization. It’s popular for its user-friendly enhancements.
  2. Fish (Friendly Interactive Shell):
    • Known for its simplicity and intuitive nature, Fish provides syntax highlighting and autosuggestions out of the box.
  3. KornShell (ksh):
    • A Unix shell developed for scripting and interactive use, ksh has features similar to Bash but is more common in enterprise Unix systems.

Linux File System

What Is a File System?

A file system defines how data is stored and retrieved on disk. It manages the organization of files and directories and keeps track of where data is located.

Types of File Systems in Linux

  • ext4: The most common file system for Linux, offering journaling, better performance, and larger storage limits.
  • XFS: Known for its scalability, especially on large file systems.
  • Btrfs: Offers advanced features like snapshotting, pooling, and checksums.
  • ZFS: Highly reliable, supporting RAID, compression, and error correction, often used in storage servers.

File System Quiz: Real-World Scenarios

As a DevOps engineer, you're setting up a new server for a high-traffic website. Which file system would you choose for the root partition to ensure optimal performance and journaling capabilities?

Answer: Ext4 would be an excellent choice for this scenario. It offers good performance, journaling for data integrity, and is widely supported. Its ability to handle large file sizes and volumes makes it suitable for a high-traffic website server.

You're managing a large data storage server that requires features like data compression, snapshots, and self-healing. Which file system would be most appropriate?

Answer: ZFS would be ideal for this scenario. It offers advanced features like built-in compression, snapshots for easy backups, and self-healing capabilities to detect and correct data corruption.

Your team is working on a project that involves frequent reading and writing of small files. Which file system would you recommend to minimize fragmentation and improve performance?

Answer: Btrfs (B-tree File System) would be a good choice here. It’s designed to handle small files efficiently and includes features like copy-on-write and online defragmentation, which can help maintain performance over time.

You're setting up a file server that needs to support very large file sizes (over 16 TB) and high throughput. Which file system would you choose?

Answer: XFS would be an excellent choice for this scenario. It’s designed for scalability and can handle very large file sizes (up to 8 exbibytes) and high I/O throughput, making it suitable for large file servers.

You're configuring a system for scientific computing that requires support for data integrity checks and easy volume management. Which file system would you recommend?

Answer: ZFS would be a great fit for this scenario. It provides built-in checksums for data integrity, easy volume management with zpools, and features like snapshots that can be useful in a scientific computing environment where data integrity and versioning are crucial.

Why Ext4 and Beyond

In Linux, the Ext4 (Fourth Extended Filesystem) is one of the most commonly used file systems. Its widespread usage can be attributed to its robustness, journaling feature, and ability to handle large volumes and file sizes. Ext4 is particularly good at reducing fragmentation and improving performance, especially with solid-state drives (SSDs).


Linux Security Features and SELinux

Why Linux is Secure

  • Permissions: Linux has a robust permission model where each file and process is owned by a user and a group, with three permission levels: read, write, and execute.
  • Open-Source Community: Linux’s open-source nature means vulnerabilities are often patched quickly by a global community of developers.
  • Reduced attack surface: Linux uses privilege separation (root and user), minimizing the number of services running with full administrative access.

Security is a key feature of Linux, making it ideal for server environments and large-scale deployments.

SELinux (Security-Enhanced Linux): A security architecture integrated into Linux that provides a mechanism for supporting access control security policies. It uses mandatory access controls (MAC) instead of the traditional discretionary access controls (DAC).

- <strong>Usage</strong>: SELinux is used in high-security environments to enforce strict policies on what processes can access, execute, or modify. For example, even if a service gets compromised, SELinux will prevent it from executing certain commands or accessing sensitive files.
- <strong>Modes</strong>:
	- _Enforcing_: SELinux enforces security policies.
	- _Permissive_: SELinux logs policy violations without enforcing them.
	- _Disabled_: SELinux is turned off.

### Checking SELinux Status:


<div class="code-block-wrapper">
sestatus
### Changing SELinux Modes:


<div class="code-block-wrapper">
sudo setenforce 0  # Switch to permissive mode
	sudo setenforce 1  # Switch to enforcing mode

The Linux File System: Structure and Directories

The Linux file system is structured in a hierarchical tree format. Understanding this structure is critical for DevOps engineers, as it organizes the files and directories that power the system. Each directory serves a unique purpose. Below is a comprehensive look at the primary directories in Linux.

1. / (Root Directory)

The root directory is the top of the file system hierarchy. Every other directory and file resides within this directory.

  • Example: cd / moves the user to the root directory.

2. /home

The /home directory contains user-specific directories. Each user has their own subdirectory within /home, where their personal files, settings, and data are stored.

  • Example: /home/devopsuser/ stores the files of the user devopsuser.

3. /etc

This directory stores system configuration files. Any software you install, services you configure, or system settings will typically have corresponding configuration files here.

  • Example: The file /etc/ssh/sshd_config holds the configuration for the SSH service.

4. /var

The /var directory contains variable data that changes during system operation, such as logs, databases, and cache files.

  • Example: Logs are usually stored in /var/log/. You can view the system logs by navigating to this directory and using the cat or tail commands.
    • cat /var/log/syslog displays the system log.
    • tail -f /var/log/syslog shows the most recent entries in real-time.

5. /bin

The /bin directory contains essential user binaries (executables). These are the commands available to all users, such as ls, cat, and cp.

  • Example: ls /bin lists all the basic user commands available.

6. /sbin

Similar to /bin, but this directory contains system binaries. These are essential commands for system administration, such as iptables, reboot, and fdisk.

  • Example: sudo /sbin/reboot restarts the system.

7. /usr

The /usr directory contains user applications and utilities. This is where you’ll find most of the executables for software installed on the system.

  • Example: /usr/local/bin contains locally compiled software that is not part of the distribution’s main repository.

8. /opt

The /opt directory is reserved for third-party software installations. For example, if you install custom software packages or manually compile software, it is often stored here.

  • Example: /opt/myapp/ could store a custom application you install.

9. /boot

This directory contains the files necessary for the system to boot, including the Linux kernel and bootloader configuration files.

  • Example: /boot/grub/grub.cfg is the GRUB bootloader configuration file.

10. /dev

The /dev directory contains device files that represent hardware components, such as hard drives, USB drives, and network interfaces.

  • Example: /dev/sda represents the first hard drive.

11. /lib

The /lib directory contains libraries necessary for the essential binaries in /bin and /sbin.

  • Example: /lib/x86_64-linux-gnu/ holds shared libraries for the system architecture.

12. /tmp

The /tmp directory is used for storing temporary files that are deleted upon reboot.

  • Example: cd /tmp takes you to the temporary storage directory.

Example Use Cases for DevOps:

  • /etc is critical for configuration management. If you need to change how a service operates, you’ll typically modify files in /etc. For example, SSH server configurations are found in /etc/ssh/sshd_config.
  • /var/log is where you’ll find logs for troubleshooting. Application logs are often stored in /var/log, which is vital for debugging services.

Directory Structure Quiz

What is the primary use of the /var directory?

Answer: The /var directory contains variable data files, including log files, temporary files, and spool files that change frequently during normal system operation.

As a DevOps engineer, you need to create a temporary file to store intermediate results of a CI/CD pipeline. Which directory would be most appropriate for this purpose?

Answer: The /tmp directory would be the most appropriate for this scenario. The /tmp directory is designed for storing temporary files that are deleted upon system reboot. In a CI/CD pipeline, you often need to create temporary files for intermediate processing steps, and /tmp is ideal for this as it’s cleaned automatically, helping to prevent disk space issues.

You're troubleshooting a system boot issue and need to examine the kernel modules. Which directory would you investigate?

Answer: The /lib directory would be the most relevant for this scenario. The /lib directory contains essential shared libraries and kernel modules necessary for the system to boot and run. When troubleshooting boot issues related to kernel modules, you’d likely need to examine files in /lib/modules/[kernel-version]/ to ensure all necessary modules are present and correctly configured.

As part of a system health check, you need to verify the presence of a specific hardware device. Which directory would you check to confirm its detection by the system?

Answer: The /dev directory would be the most appropriate for this task. The /dev directory contains device files that represent hardware components recognized by the system. By checking this directory, you can verify if a specific hardware device has been detected and is accessible to the system. For example, you might look for /dev/sda to confirm the presence of the first SATA drive.

You're updating the bootloader configuration for a multi-boot setup. In which directory would you find and modify the necessary files?

Answer: The /boot directory is where you’d find and modify bootloader configuration files. This directory contains essential files for the system boot process, including the kernel, initial ramdisk (initrd), and bootloader configuration files like grub.cfg for GRUB. When setting up a multi-boot system or modifying boot parameters, you’d typically work with files in the /boot directory.

What is the purpose of the /home directory?

Answer: The /home directory contains personal directories for regular users, where they store their personal files and configurations.

Your team has developed a custom monitoring tool that needs to be installed system-wide but kept separate from the standard system utilities. Which directory would be the most suitable for installing this software?

Answer: The /opt directory would be the most suitable for installing custom software like this. The /opt directory is reserved for the installation of add-on application software packages. By installing your custom monitoring tool in /opt, you keep it separate from the core system utilities, making it easier to manage, update, and potentially remove without affecting other system components.

What is the purpose of the /root directory?

Answer: The /root directory is the home directory for the root user (system administrator). It contains the root user’s personal files and configurations.

What type of files are typically found in the /etc directory?

Answer: The /etc directory contains system-wide configuration files and directories that are used by many programs.

You need to compile and install a specific version of Python for a project. Where would you typically install it to ensure it doesn't interfere with the system's default Python installation?

Answer: The /usr/local directory would be the most appropriate place to install a custom Python version. While /usr contains user programs and data, /usr/local is specifically intended for locally compiled software that is not part of the main system distribution. By installing your custom Python version in /usr/local/bin, you ensure it’s available system-wide but doesn’t interfere with the default Python installation in /usr/bin.

As a system administrator, you need to run a critical system maintenance script. Which directory would you check first for system administration commands?

Answer: The /sbin directory would be the first place to look for system administration commands. The /sbin directory contains essential system binaries and administration tools that are typically only meant to be run by the root user or system administrators. Commands for system maintenance, network configuration, and other administrative tasks are often found in /sbin.

What is stored in the /bin directory?

Answer: The /bin directory contains essential command binaries that are needed in single-user mode and by all system users, such as ls, cp, and mv.

You're writing a shell script for user management that needs to use common Unix commands. Which directory contains these essential user commands?

Answer: The /bin directory contains essential user binaries and common commands used in shell scripts and by all system users. Commands like ls, cp, mv, and rm are typically found in /bin. When writing shell scripts for user management or any general-purpose scripting, you’ll often use commands located in the /bin directory.


Linux Package Management

Package management is a crucial part of system administration. It allows you to install, update, and remove software from your system.

  • APT (Advanced Package Tool): Used in Debian-based systems like Ubuntu.
    • Example:

    sudo apt update
      	sudo apt install nginx
  • YUM/DNF: Used in RHEL-based distributions like CentOS and Fedora.
    • Example:

    sudo yum install httpd
  • RPM (Red Hat Package Manager): A low-level package manager used in RHEL-based systems.
    • Example:

    sudo rpm -ivh package.rpm
  • Snap: A universal package manager that works across distributions.
    • Example:

    sudo snap install vlc
  • Flatpak: Another universal package manager for Linux.
    • Example:

    flatpak install flathub com.spotify.Client

Linux Permissions and Ownership

Linux permissions are key to maintaining security and control over who can access, modify, or execute files.

File Permissions:

Permissions in Linux are divided into three categories: owner, group, and others. Each category can have read (r), write (w), and execute (x) permissions.

  • Read (r): The file can be read.
  • Write (w): The file can be modified.
  • Execute (x): The file can be executed.

Example of Changing Permissions:

chmod 755 script.sh

This command gives the owner read, write, and execute permissions, while the group and others only get read and execute permissions.

Changing Ownership:

chown username:groupname file.txt

This command changes the ownership of file.txt to the specified user and group.


File and Directory Management

ls - List Directory Contents

  • Usage: ls -l /var/log
  • Flags:
    • l: Long format listing.
    • a: Include hidden files.
    • h: Human-readable sizes.
What command would you use to list all files, including hidden ones, in a directory?

Answer: ls -a

cd - Change Directory

  • Usage: cd /etc/nginx

mkdir - Make Directories

  • Usage: mkdir /opt/myapp
  • Flags:
    • p: Create parent directories if they don’t exist.

rm - Remove Files or Directories

  • Usage: rm -rf /var/tmp/*
  • Flags:
    • r: Recursively delete.
    • f: Force deletion.

cp - Copy Files or Directories

  • Usage: cp config.yaml /etc/myapp/config.yaml
  • Flags:
    • r: Recursively copy.
    • v: Verbose output.

mv - Move or Rename Files

  • Usage: mv oldfile.txt newfile.txt
  • Flags:
    • v: Verbose output.

touch - Create an Empty File

  • Usage: touch index.html

find - Search for Files in a Directory Hierarchy

  • Usage: find /var/log -name “*.log”
  • Flags:
    • name: Match files by name.
    • type: Filter by file type.

chmod - Change File Permissions

  • Usage: chmod 755 script.sh

chown - Change File Owner and Group

  • Usage: chown root:root /var/www/html

Text and File Content Manipulation

cat - Concatenate and Display Files

  • Usage: cat /var/log/nginx/access.log

less - View File Contents Page by Page

  • Usage: less /var/log/nginx/access.log

head - Output the First Part of Files

  • Usage: head -n 10 /var/log/nginx/error.log
  • Flags:
    • n: Specify number of lines to display.

tail - Output the Last Part of Files

  • Usage: tail -f /var/log/nginx/error.log
  • Flags:
    • f: Follow log updates in real time.

grep - Search Text Using Patterns

  • Usage: grep “ERROR” /var/log/nginx/error.log
  • Flags:
    • i: Case-insensitive search.
    • r: Recursive search.
How would you search for the word "error" in a log file named "app.log"?

Answer: grep “error” app.log

sed - Stream Editor for Text Manipulation

  • Usage: sed ‘s/localhost/127.0.0.1/g’ config.yaml
  • Flags:
    • i: Edit files in place.

awk - Pattern Scanning and Processing Language

  • Usage: awk ‘{print $1, $4}’ /var/log/nginx/access.log

cut - Remove Sections from Each Line of Files

  • Usage: cut -d: -f1 /etc/passwd
  • Flags:
    • d: Specify a delimiter.
    • f: Fields to extract.

sort - Sort Lines of Text Files

  • Usage: sort access.log

uniq - Report or Omit Repeated Lines

  • Usage: sort access.log | uniq -c

Process and System Monitoring

top - Display System Tasks

  • Usage: top
  • Flags:
    • u username: Display processes of a specific user.

htop - Interactive Process Viewer

  • Usage: htop

ps - Report Process Status

  • Usage: ps aux | grep nginx
  • Flags:
    • aux: List all processes.

kill - Terminate Processes

  • Usage: kill -9 1234
  • Flags:
    • 9: Forcefully kill a process.

pkill - Kill Processes by Name

  • Usage: pkill nginx

systemctl - Control Systemd Services

  • Usage: systemctl start nginx
  • Flags:
    • start: Start a service.
    • stop: Stop a service.
    • restart: Restart a service.
    • status: Check service status.

service - Control SysVinit Services

  • Usage: service nginx start

Disk and Filesystem Management

df - Display Disk Space Usage

  • Usage: df -h
  • Flags:
    • h: Human-readable format.

du - Estimate File Space Usage

  • Usage: du -sh /var/log
  • Flags:
    • s: Summarize usage.
    • h: Human-readable format.

mount - Mount a Filesystem

  • Usage: mount /dev/sdb1 /mnt

umount - Unmount a Filesystem

  • Usage: umount /mnt

fsck - Check and Repair a Filesystem

  • Usage: fsck /dev/sda1

Networking Commands

ping - Send ICMP Echo Requests

  • Usage: ping google.com

netstat - Print Network Connections

  • Usage: netstat -tuln
  • Flags:
    • tuln: Show TCP/UDP connections and listening ports.

ifconfig - Configure Network Interfaces

  • Usage: ifconfig eth0

ip - Show/Manipulate Routing and Devices

  • Usage: ip addr show
  • Flags:
    • addr: Display IP addresses.

curl - Transfer Data from URLs

wget - Download Files from the Web

scp - Secure Copy over SSH

  • Usage: scp file.txt user@server:/path/to/destination

ssh - OpenSSH Client to Log into Remote Machines

  • Usage: ssh user@server

nslookup - Query Internet Name Servers

  • Usage: nslookup google.com

dig - DNS Lookup Utility

  • Usage: dig google.com

Package Management

apt - Advanced Package Tool (Debian/Ubuntu)

  • Usage: apt install nginx
  • Flags:
    • install: Install a package.
    • update: Update the package list.
    • upgrade: Upgrade all packages.

yum - Yellowdog Updater Modified (RHEL/CentOS)

  • Usage: yum install nginx

dnf - Dandified Yum (RHEL 8+/Fedora)

  • Usage: dnf install nginx

rpm - RPM Package Manager

  • Usage: rpm -ivh package.rpm

Archiving and Compression

tar - Archive Files

  • Usage: tar -cvf archive.tar /path/to/directory
  • Flags:
    • c: Create an archive.
    • x: Extract an archive.
    • v: Verbose output.
    • f: Specify filename.

gzip - Compress Files

  • Usage: gzip file.txt

gunzip - Decompress Gzip Files

  • Usage: gunzip file.txt.gz

Scripting and Automation

bash - Bourne-Again Shell

  • Usage: bash script.sh
  • Flags:
    • x: Debug mode (show command execution).

sh - Execute Shell Scripts

  • Usage: sh script.sh

crontab - Schedule Periodic Tasks

  • Usage: crontab -e
  • Flags:
    • e: Edit crontab entries.

at - Schedule a One-time Task

  • Usage: echo “backup.sh” | at 02:00

System Administration

sudo - Execute Commands as Root

  • Usage: sudo apt update

passwd - Change User Password

  • Usage: passwd username

useradd - Create a New User

  • Usage: useradd -m username
  • Flags:
    • m: Create home directory.

usermod - Modify User Accounts

  • Usage: usermod -aG sudo username

groupadd - Create a New Group

  • Usage: groupadd devops

Conclusion

In this guide, we’ve explored nearly every aspect of Linux, focusing on the core concepts that a DevOps engineer needs to be proficient in. From understanding the kernel and filesystems to mastering user and volume management, every topic has been covered to provide a comprehensive view of Linux in a DevOps context. By mastering these Linux fundamentals, DevOps engineers can ensure efficient, secure, and scalable infrastructure management, which is crucial for the success of any modern IT operation. Whether you’re automating tasks, managing servers, or deploying applications, Linux remains an indispensable tool in the DevOps toolkit.

iemafzalhassan

© 2025 All Rights Reserved.

Made with 🖤

LinkedIn 𝕏 GitHub