Mastering Linux for DevOps: A Comprehensive Guide for Beginners

M
Manikanta Talanki
Author
79 views 3 min read min read
Mastering Linux for DevOps: A Comprehensive Guide for Beginners

1. Introduction


What is Linux?

Linux is an open-source operating system and a core foundation of modern DevOps. Its stability, flexibility, and security make it the go-to OS for DevOps engineers. Whether you’re automating infrastructure or managing services, Linux is the bedrock.

Why Learn Linux for DevOps?

Almost all cloud infrastructure and container-based tools (like Docker and Kubernetes) run on Linux. Mastering Linux commands and shell scripting will enhance your efficiency as a DevOps engineer.

2. Core Concepts

  1. Linux Basics
  • Distributions: Ubuntu, CentOS, Fedora
  • Package Management: apt, yum, dnf
  • File System Hierarchy: /home, /etc, /var, /usr
  • Permissions: chmod, chown, umask
  1. Common Linux Commands
  • Navigating the File System:
cd /path/to/directory       # Change directory
ls -la                       # List files and directories with details
pwd                          # Print working directory
  • File Manipulation:
touch file.txt               # Create a new file
cat file.txt                 # Display file contents
cp file1.txt file2.txt        # Copy file
mv file.txt /new/path        # Move/rename file
  • File Permissions:
chmod 755 file.sh            # Change file permissions
chown user:group file.sh     # Change file ownership
  1. Shell Scripting Basics
  • Shell scripting is a way to automate tasks by writing a series of commands in a file.
  • Example: Simple Backup Script
#!/bin/bash
src="/home/user/docs"
dest="/backup/docs"
cp -r $src $dest
echo "Backup completed!"

3. Hands-On Example

Scenario: Set up a simple web server on Linux using Apache.

  1. Install Apache on Ubuntu:
sudo apt update
sudo apt install apache2
  1. Start Apache and check status:
sudo systemctl start apache2
sudo systemctl status apache2
  1. Access Web Server:
  • Visit http://localhost on your browser. If everything is set up correctly, you should see the Apache welcome page.
  1. Automate Web Server Setup: Create a shell script for quick setup.
#!/bin/bash
sudo apt update
sudo apt install apache2 -y
sudo systemctl start apache2
echo "Web server installed and started!"

4. Best Practices

  • Regular Updates: Always keep your Linux server updated by running sudo apt update && sudo apt upgrade.
  • Security: Use firewall tools like ufw and iptables to secure your Linux servers.
  • Backup: Regularly backup critical files using rsync or automated scripts.

5. Interview Questions

  • Q: What is the difference between chmod 755 and chmod 644? A: chmod 755 gives the owner full permissions (read, write, execute) and others read and execute permissions. chmod 644 gives the owner read and write permissions, while others can only read.
  • Q: How do you find large files in a Linux system? A: Use the find command:
find / -type f -size +100M
  • Q: What is a symbolic link in Linux? A: A symbolic link is a file that points to another file or directory. Use ln -s target linkname to create one.


Join the conversation
79 views
0 comments
Oct 16, 2025

Comments

0
No comments yet

Be the first to start the discussion!