Skip to content

Latest commit

Β 

History

History
216 lines (155 loc) Β· 4.94 KB

File metadata and controls

216 lines (155 loc) Β· 4.94 KB

Linux Basics for DevOps

This guide explains the core concepts of Linux from a DevOps perspective. It includes users and permission management, file system navigation, package installation, system monitoring, and essential tools for daily operations. It is structured for clarity and applies directly to server maintenance, CI/CD pipelines, cloud environments, and containerized systems.

πŸ” Linux Users and Permissions

User Types:

  • Root User (UID = 0): Superuser with unrestricted access.
  • Normal Users: Limited access, usually for human operators.
  • System Users: Non-human accounts for services like nginx, mysql.

Understanding Permissions:

Each file or directory has three permission sets:

  • User (owner)
  • Group (group members)
  • Others (everyone else)

Each set uses three permission types:

  • r – read
  • w – write
  • x – execute

Example from ls -l output:

-rwxr-xr-- 1 user group 1024 Jun 17 08:00 script.sh

Means:

  • User: rwx β†’ read/write/execute
  • Group: r-x β†’ read/execute
  • Others: r-- β†’ read-only

Permission Commands:

ls -l                      # View permissions
chmod 755 file.sh         # rwxr-xr-x
chmod +x script.sh        # Add execute
chown wahba:admin file.sh # Change owner and group

πŸ“ Filesystem and Directories

Navigation Commands:

cd /var/log      # Go to folder
ls -lah          # Detailed list + hidden files
pwd              # Show current path

Important Linux Directories:

Directory Purpose
/ Root directory
/etc System configuration files
/home User home directories
/var Logs, caches, databases
/usr/bin User commands and apps
/bin Core binaries (e.g., ls, cat)
/tmp Temporary files (auto-cleaned)
/dev Device files (disks, input)
/proc Virtual filesystem (kernel info)
/root Root user’s home directory
/boot Bootloader, kernel files

πŸ“¦ Package Management

Debian/Ubuntu:

sudo apt update          # Refresh package index
sudo apt install nginx   # Install nginx
sudo apt remove nginx    # Remove nginx

RHEL/CentOS:

sudo yum update            # Refresh packages (older systems)
sudo yum install httpd     # Install Apache
sudo dnf install nginx     # Use dnf on newer RHEL/CentOS

🧠 System & Process Monitoring

View Processes:

ps aux          # All processes
htop            # Interactive process monitor
top             # Dynamic process view

Kill Processes:

kill 1234       # Gracefully stop PID 1234
kill -9 1234    # Force kill PID 1234

System Info:

uname -a        # Kernel info
hostname        # System hostname
df -h           # Disk usage (human-readable)
free -m         # Memory in MB
uptime          # Load and uptime
whoami          # Current user

πŸ“‘ Networking & Connectivity

Interface and IP:

ip a                  # Show all IPs
ip route              # Routing table

Testing Tools:

ping 8.8.8.8          # Connectivity test
curl https://google.com  # HTTP GET
wget https://file.com   # Download file

Ports & Listeners:

ss -tuln             # Show TCP/UDP listeners
netstat -tuln        # Legacy alternative

Tracing:

traceroute 8.8.8.8   # Network path to host

πŸ“‚ Text Processing & File Search

File Discovery:

find /etc -name "*.conf"         # Find all config files

Grep / Awk / Sed:

grep "ERROR" logfile.txt         # Find error lines
awk '{print $1}' file.txt         # Print first column
sed 's/old/new/g' file.txt        # Replace text

Utilities:

cut -d":" -f1 /etc/passwd         # Extract usernames
tee output.log                    # Print + write to file

πŸ‘€ User & Group Management

Create Users:

adduser wahba
passwd wahba
usermod -aG sudo wahba     # Give sudo access

View Info:

id              # UID/GID and groups
who             # Who is logged in
last            # Last logins

πŸ”’ File Permission Modes

Symbolic to Numeric:

Symbolic Numeric Meaning
rwx------ 700 Only owner full access
rwxr-xr-- 754 Owner full, group RX
rw-r--r-- 644 Owner RW, rest read
chmod 644 file.txt
chmod u+x deploy.sh

Tips

  • man <command> β†’ Manual pages
  • Use TAB to auto-complete commands/paths
  • Use !! to repeat last command
  • history | grep ssh β†’ Search shell history
  • alias ll='ls -lah' β†’ Add to ~/.bashrc for convenience

πŸ“˜ Author: Wahba Mousa β€” Senior DevOps Engineer (2025)

πŸ“ Back to Linux Essentials Overview