Linux Essentials

Foundation for DevOps Engineers

Day 3: Shell, Files, and Scripting

Why Linux for DevOps?

Open Source

Free, customizable, and community-driven

Stability

Reliable for servers and production systems

Automation

Powerful scripting and command-line tools

Cloud Native

Powers most cloud infrastructure

Essential Shell Commands

ls -la - List files with details

cd /path/to/dir - Change directory

pwd - Print working directory

cat file.txt - Display file contents

grep "pattern" file - Search in files

File Permissions

rwx rwx rwx
Owner
Read Write Execute
Group
Read Write Execute
Others
Read Write Execute

chmod 755 script.sh - Change permissions

chown user:group file - Change ownership

Process Management

ps aux - List all processes

top - Real-time process monitor

kill PID - Terminate process

systemctl status nginx - Check service status

systemctl restart nginx - Restart service

Bash Scripting Basics

#!/bin/bash

# Variables
NAME="DevOps"
echo "Hello, $NAME"

# Conditionals
if [ -f "file.txt" ]; then
    echo "File exists"
fi

# Loops
for i in {1..5}; do
    echo "Number: $i"
done

Key Takeaways

  • ✓ Master essential shell commands
  • ✓ Understand file permissions and ownership
  • ✓ Manage processes and services
  • ✓ Write basic bash scripts for automation
  • ✓ Practice log analysis and troubleshooting
1 / 7