Linux Servers Introduction¶
Linux is the backbone of modern infrastructure and cloud computing. As a DevOps engineer, mastering Linux is essential for server management, automation, and scalable deployments.
Why Linux for DevOps?¶
- Open Source: Cost-effective and customizable
- Stability: Reliable for production environments
- Security: Strong permission model and security features
- Automation: Excellent scripting and automation capabilities
- Cloud Native: Foundation for containerization and orchestration
Getting Started with Linux¶
Comprehensive Learning Resource¶
Free comprehensive course covering Linux fundamentals, perfect for beginners and those needing a refresher.
Essential Linux Concepts for DevOps¶
File System Hierarchy¶
/ # Root directory
├── /bin # Essential user binaries
├── /boot # Boot loader files
├── /dev # Device files
├── /etc # System configuration
├── /home # User home directories
├── /lib # Essential shared libraries
├── /opt # Optional software packages
├── /proc # Process information
├── /root # Root user home
├── /tmp # Temporary files
├── /usr # User programs and data
└── /var # Variable data (logs, databases)
Key Directories for DevOps¶
| Directory | Purpose | DevOps Relevance |
|---|---|---|
/etc/ | Configuration files | Service configuration, system settings |
/var/log/ | System and application logs | Monitoring and troubleshooting |
/opt/ | Third-party software | Custom application installations |
/srv/ | Service data | Web server content, databases |
/home/ | User directories | Developer workspaces, SSH keys |
Essential Linux Skills for DevOps¶
1. Command Line Proficiency¶
Master these fundamental commands:
# File operations
ls, cd, pwd, mkdir, rmdir, cp, mv, rm, find, locate
# Text processing
cat, less, head, tail, grep, sed, awk, sort, uniq, wc
# System information
ps, top, htop, df, du, free, uptime, who, id
# Network
ping, netstat, ss, curl, wget, ssh, scp, rsync
# Process management
kill, killall, nohup, screen, tmux, jobs, fg, bg
# Permissions
chmod, chown, chgrp, umask, sudo, su
2. Package Management¶
Different distributions use different package managers:
| Distribution | Package Manager | Commands |
|---|---|---|
| Ubuntu/Debian | APT | apt update, apt install, apt remove |
| RHEL/CentOS | YUM/DNF | yum install, dnf install, rpm -qa |
| SUSE | Zypper | zypper install, zypper update |
| Arch Linux | Pacman | pacman -S, pacman -Syu |
tldr: apt
Package manager for Debian/Ubuntu-based distributions.
sudo apt update # Refresh package index
apt search <package> # Search by name or description
apt show <package> # Show package details
sudo apt install <package> # Install or upgrade a package
sudo apt remove <package> # Remove a package (keep config files)
sudo apt purge <package> # Remove package and its config files
sudo apt upgrade # Upgrade all installed packages
apt list --installed # List all installed packages
More info: https://manned.org/apt.8
3. Service Management¶
Modern Linux uses systemd for service management:
# Service operations
systemctl start service-name
systemctl stop service-name
systemctl restart service-name
systemctl reload service-name
systemctl enable service-name
systemctl disable service-name
# Service status
systemctl status service-name
systemctl is-active service-name
systemctl is-enabled service-name
# System operations
systemctl reboot
systemctl poweroff
systemctl suspend
tldr: systemctl
Control the systemd system and service manager.
systemctl status # Show all running services
systemctl status <unit> # Status of a specific service
systemctl start|stop|restart|reload <unit> # Manage a service
systemctl enable|disable <unit> # Enable/disable at boot
systemctl daemon-reload # Reload after unit file changes
systemctl is-active|is-enabled <unit> # Check service state
systemctl list-units --type service --state failed # List failed services
systemctl cat <unit> # Show unit file contents
More info: https://www.freedesktop.org/software/systemd/man/latest/systemctl.html
Linux Security Fundamentals¶
User and Group Management¶
# User operations
useradd username
usermod -aG groupname username
passwd username
userdel username
# Group operations
groupadd groupname
groupmod groupname
groupdel groupname
# Permission management
chmod 755 filename # rwxr-xr-x
chmod u+x,g+r filename # Add execute for user, read for group
chown user:group filename # Change ownership
SSH Security¶
tldr: ssh
Securely connect to and execute commands on remote systems.
# Connect to a remote server
ssh <user>@<host>
# Connect with a specific private key
ssh -i ~/.ssh/my_key <user>@<host>
# Connect on a non-default port
ssh -p 2222 <user>@<host>
# Execute a remote command
ssh <user>@<host> <command>
# Local port forwarding (localhost:9999 → remote:80)
ssh -L 9999:example.com:80 -N -T <user>@<host>
# Dynamic SOCKS proxy on localhost:1080
ssh -D 1080 <user>@<host>
# Jump through a bastion host
ssh -J <user>@<bastion> <user>@<target>
More info: https://man.openbsd.org/ssh
tldr: ssh-keygen
Generate SSH keys for authentication and password-less logins.
# Generate a key interactively (prompts for file and passphrase)
ssh-keygen
# Generate a modern Ed25519 key
ssh-keygen -t ed25519 -C "comment or email"
# Generate an RSA 4096-bit key
ssh-keygen -t rsa -b 4096 -C "comment or email"
# Save key to a specific file
ssh-keygen -f ~/.ssh/my_key -t ed25519
# Change the passphrase on an existing key
ssh-keygen -f ~/.ssh/my_key -p
# Extract the public key from a private key
ssh-keygen -f ~/.ssh/my_key -y
# Remove a stale host from known_hosts
ssh-keygen -R <remote_host>
More info: https://man.openbsd.org/ssh-keygen
# Generate SSH key pair
ssh-keygen -t rsa -b 4096 -C "your-email@example.com"
# Copy public key to server
ssh-copy-id user@server
# SSH with key authentication
ssh -i ~/.ssh/private_key user@server
# SSH config file (~/.ssh/config)
Host myserver
HostName server.example.com
User myuser
Port 2222
IdentityFile ~/.ssh/my_key
Next Learning Steps¶
After mastering Linux basics, explore:
Practical Exercises¶
Hands-on Learning
- Set up a Linux VM or cloud instance
- Practice command line operations daily
- Configure SSH key authentication
- Explore system logs in
/var/log/ - Set up a basic web server
Production Considerations
- Always test commands in development first
- Use configuration management tools for consistency
- Implement proper backup strategies
- Follow the principle of least privilege
- Keep systems updated and patched
DevOps Integration¶
Linux skills directly enable:
- Infrastructure as Code: Ansible, Terraform automation
- Containerization: Docker and Kubernetes deployments
- CI/CD Pipelines: Build agents and deployment scripts
- Monitoring: Log analysis and system monitoring
- Cloud Operations: EC2, VPS, and bare metal management