Skip to content

SubbuTechOps/linux-for-devops

Repository files navigation

Linux Administration Tasks for a DevOps Engineer

Linux is the backbone of modern-day DevOps, serving as the primary OS for servers, containers, and cloud environments. This guide describes the most important Linux administration tasks with which DevOps engineers must be familiar in order to manage infrastructure effectively and ensure smooth operations of CI/CD pipelines.


Table of Contents


i. Introduction to Linux Administration in DevOps

Linux Administration in the DevOps is mainly related to the management and automation of the Linux system to support applications for deployment, scalability, and reliability. Through Linux, DevOps engineers can configure server, host, or deploy containerized applications with system stability support, making it crucial.

ii. Core Linux Administration Tasks

1) Process and System Monitoring:

Monitoring ensures the health and performance of Linux servers. Common tools include:

  • top, htop: View real-time resource usage.

  • vmstat, iostat: Monitor CPU and I/O statistics.

  • sar: Collect, report, and save system activity.

  • nmon: Visualize system metrics like CPU, memory, and network usage.

2) User and Group Management:

Managing user accounts and permissions is vital to secure multi-user systems.

Commands:

  • useradd, usermod, passwd: Manage users.

  • groupadd, gpasswd: Manage groups.

  • chown, chmod: Set file permissions.

Best Practices:

  • Use least-privilege principles.
  • Employ sudo for controlled administrative access.

3) Package Management:

Linux distributions rely on package managers to install, update, and remove software.

  • Debian-based (e.g., Ubuntu):

    • Commands: apt, dpkg
  • Red Hat-based (e.g., CentOS, RHEL):

    • Commands: yum, dnf, rpm
  • Use automation tools like Ansible or Chef for large-scale package management.

4) File and Directory Management:

Efficient file management ensures organized and secure systems.

  • Commands:

    • ls, cd, mkdir, rmdir: Directory navigation and creation.

    • cp, mv, rm: File operations.

    • find, locate, grep: Search files.

    • tar, gzip, rsync: Compress and sync files.

  • Pro Tip: Use rsync for efficient backup and file transfer.

5) Disk and Storage Management:

Disk management ensures proper utilization and storage capacity.

  • Commands:

    • df, du: Check disk usage.
    • mount, umount: Manage mounted filesystems.
    • fdisk, lsblk: Partition management.
  • Implement LVM (Logical Volume Management) for flexible storage.

6) Networking Configuration:

Linux servers often act as network nodes, requiring proper setup and monitoring.

  • Commands:
    • ifconfig, ip: View and configure network interfaces.
    • netstat, ss: Analyze network connections.
    • iptables, firewalld: Manage firewall rules.
  • Tools:
    • tcpdump, nmap: Network debugging and scanning.
    • ping, traceroute: Diagnose network issues.

7) Process and Service Management:

Manage active processes and services for system stability.

  • Commands:
    • ps, top, kill: Process management.
    • systemctl, service: Manage system services.
  • Tip: Automate service monitoring with tools like Monit or Nagios.

iii. Advanced Administration Tasks:

1) Shell Scripting for Automation:

Automation reduces manual effort and ensures consistency.

  • Write reusable scripts for tasks like backups, log rotations, or updates.
  • Use tools like cron or at to schedule scripts.

2) Security Hardening:

Ensure system security by:

  • Implementing firewalls and SELinux/AppArmor.
  • Regularly applying patches and updates.
  • Enforcing SSH key-based authentication.
  • Monitoring login attempts using fail2ban.

3) Backup and Restore:

Plan robust backup strategies to prevent data loss.

  • Tools:
    • rsync: Incremental backups.
    • tar, gzip: File-based backups.
    • Automate periodic backups and test restore processes.

4) Log Management:

Logs help diagnose and audit system activities.

  • Use tools like Logrotate to manage log file sizes.
  • Centralize logs with ELK Stack (Elasticsearch, Logstash, Kibana).

5) Kernel Tuning and Performance Optimization:

Optimize the kernel for specific workloads:

  • Adjust kernel parameters with sysctl.
  • Analyze system bottlenecks with perf, dstat, or iotop.

iv. Practical Real-World Scenarios:

Scenario 1: High CPU Utilization

Problem: A service consumes excessive CPU.

Solution:

  1. Use top to identify the process.
  2. Check logs or configurations for anomalies.
  3. Adjust system limits in /etc/security/limits.conf.

Scenario 2: Network Latency

Problem: Applications experience slow network responses.

Solution:

  1. Diagnose with ping and traceroute.
  2. Use tcpdump or iftop for deeper analysis.
  3. Optimize configurations in /etc/sysctl.conf.

Scenario 3: Disk Space Issues

Problem: A server runs out of disk space.

Solution:

  1. Identify large files with **du -sh ***.
  2. Archive or delete unnecessary files.
  3. Extend storage using LVM or mount new partitions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published