Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 2 min read

Linux Security Fundamentals Every Developer Should Master

Linux Security Fundamentals Every Developer Should Master Why Developers Need Linux Security Knowledge You might think security is "someone else's job." Wrong. As a developer, you are responsible for: Writ

Linux Security Fundamentals Every Developer Should Master

Why Developers Need Linux Security Knowledge

You might think security is "someone else's job." Wrong. As a developer, you are responsible for:

  • Writing secure code
  • Understanding the systems you deploy to
  • Responding when things go wrong
  • Contributing to your team's security culture

Linux is the backbone of most servers, containers, and cloud infrastructure. Either you learn its security primitives, or you let someone else configure them poorly.

Core Concepts

Permission Models

UNIX permissions are powerful but often misunderstood:

# Read, Write, Execute for owner, group, others
-rwxr-xr-- 1 dev dev 1234 Oct 24 app.py

# Numeric notation
chmod 755 file      # rwx for owner, rx for group/others
chmod 644 config    # rw for owner, r for group/others

Users, Groups, and Sudo

Never run your app as root. Use:

  • Dedicated service users
  • Principle of least privilege
  • Capabilities instead of full root when possible
# Create a service user
sudo useradd -r -s /bin/false appuser

# Run container as non-root
USER appuser

Practical Security Patterns

1. Environment Variable Secrets

Bad:

DB_PASSWORD = "super_secret_password_123"

Good:

import os
from dotenv import load_dotenv

load_dotenv()  # Loads from .env file
DB_PASSWORD = os.getenv("DB_PASSWORD")

# In production, use:
# - Kubernetes secrets
# - HashiCorp Vault
# - AWS Secrets Manager

2. Container Security

Dockerfile security best practices:

# Use specific base image versions
FROM python:3.11-slim-bookworm@sha256:abc123...

# Run as non-root
RUN useradd -m appuser
USER appuser

# Multi-stage builds reduce attack surface
FROM python:3.11-slim as builder
# ... build dependencies ...

FROM python:3.11-slim as runtime
COPY --from=builder /app/dist /app

3. Network Security

Service-to-service communication:

# Use service meshes or mutual TLS
# Example with nginx as reverse proxy
server {
    listen 443 ssl;
    ssl_certificate /etc/ssl/certs/app.crt;
    ssl_certificate_key /etc/ssl/private/app.key;

    location /api {
        proxy_pass http://localhost:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Essential Tools

For Development

  • fail2ban: Protect against brute force attacks
  • auditd: Audit log analysis for suspicious activity
  • lynis: Security auditing tool for Linux systems

For Your Workflow

# Check file permissions
find /app -type f -perm 777

# Monitor processes
ps aux | grep <your-app>

# Check network connections
ss -tuln

# Audit user logins
last

Common Mistakes to Avoid

  1. World-writable files in /tmp: Another user can escalate privileges
  2. SSH with password auth: Use keys only
  3. Default credentials: Admin/admin, root/root are attack magnets
  4. Outdated packages: Use automated updates or package managers
  5. Debug mode in production: Leaks sensitive information

Resources for Continuous Learning

  • Sublime Security: Free Linux security training
  • OWASP: Web application security guides
  • CIS Benchmarks: Configuration standards
  • NIST Cybersecurity Framework: Risk management guidelines

Take Action Today

  1. Run lynis audit system on your development machines
  2. Review Docker images for vulnerabilities with docker scout
  3. Enable audit logging for critical files
  4. Set up automatic security updates

Security is not a destinationβ€”it is a practice. Start small, measure progress, and build security into your development workflow.

What is the biggest security mistake you have seen in a codebase? Share your war stories and lessons learned.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.