DEV Community

alok-38
alok-38

Posted on

Learn Backend Engineering with a DevOps Mindset – Tips for New Developers

DevOps-Aware Backend Engineering: A Beginner’s Guide

🧭 What You’ll Learn

This guide will show you how to think like a DevOps-aware backend engineer from day one. You’ll learn how to set up a safe development environment, prepare your system for backend development, and write scripts that are both practical and production-conscious.

Here’s what we’ll cover:

  1. Setting up a DevOps-safe environment on a fresh EC2 instance
  2. Installing the latest Node.js for backend development
  3. Writing a preflight script to check your environment
  4. Approaching scripts and workflows like a DevOps-aware backend engineer

🔹 Step 0: Check Your Environment

Commands

whoami
pwd
uname -a
Enter fullscreen mode Exit fullscreen mode

Explanation

  • whoami → “Which user am I logged in as?”

  • pwd → “What is my current directory?”

  • uname -a → “Show OS and kernel info”

Why: Before doing anything, confirm you’re in the right place, with the right user and OS. Prevents mistakes.

🔹 Step 1: Update the System

Command

sudo yum update -y
Enter fullscreen mode Exit fullscreen mode

Explanation

  • sudo → run as administrator

  • yum update → update all installed packages

  • -y → auto-confirm prompts

Why: Ensures the system is secure, stable, and ready for software installation.

🔹 Step 2: Install Dependencies for nvm

Command

sudo yum install -y git curl
Enter fullscreen mode Exit fullscreen mode

Explanation

  • git → needed for downloading nvm

  • curl → needed for fetching files from the internet

Why: These are foundational tools on nearly every Linux server.

🔹 Step 3: Download nvm Installer

Command

curl -o install.sh https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh
Enter fullscreen mode Exit fullscreen mode

Explanation

  • curl → downloads content from a URL

  • -o install.sh → save it as a file

  • URL → nvm installation script

Why: Safer than curl | bash. We download first, inspect later.

🔹 Step 4: Run the Installer

Command

bash install.sh
Enter fullscreen mode Exit fullscreen mode

Explanation

  • Run the downloaded script using bash

  • Clones nvm to ~/.nvm

  • Adds lines to .bashrc to load nvm automatically

Why: Sets up Node Version Manager safely, without root.

🔹 Step 5: Load nvm into the Current Shell

Commands

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
Enter fullscreen mode Exit fullscreen mode

Explanation

  1. export NVM_DIR="$HOME/.nvm" → remember where nvm is installed

  2. [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" → if nvm exists, load it now

  3. [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" → if tab-completion exists, load it

Why: Makes nvm available immediately, without logging out.

🔹 Step 6: Verify nvm

Command

nvm --version
Enter fullscreen mode Exit fullscreen mode

Explanation

  • Checks that nvm is installed and working

🔹 Step 7: Install Latest Node.js

Commands

nvm install node
nvm use node
nvm alias default node
Enter fullscreen mode Exit fullscreen mode

Explanation

  • nvm install node → installs the latest Node.js

  • nvm use node → use it now

  • nvm alias default node → make it default for future shells

Why: Isolates Node versions, avoids system pollution.

🔹 Step 8: Verify Node

Commands

node -v
npm -v
Enter fullscreen mode Exit fullscreen mode

Explanation

  • Confirms Node.js and npm are installed

🔹 Step 9: Sanity Test Node

Command

node -e "console.log('Node works 🚀')"
Enter fullscreen mode Exit fullscreen mode

Explanation

  • Runs a one-line Node program to verify runtime works

Why: Quick check before writing real apps.

🔹 Step 10: Create Preflight Script

Initial file content

#!/usr/bin/bash
whoami
pwd
uname -a
Enter fullscreen mode Exit fullscreen mode

Explanation

  • #!/usr/bin/bash → tells Linux which shell to use

  • whoami, pwd, uname -a → print user, working directory, and system
    info

Why: Scripted check instead of manual commands.

🔹 Step 11: Make It DevOps-Aware

Add Strict Mode

set -euo pipefail
Enter fullscreen mode Exit fullscreen mode

Explanation

  • -e → exit if any command fails

  • -u → error on undefined variables

  • -o pipefail → error if any part of a pipeline fails

Why: Prevents hidden errors and makes script predictable and safe.

Label Output

echo "=== Preflight Check ==="
echo "User: $(whoami)"
echo "Working directory: $(pwd)"
echo "System info:"
uname -a
echo "Preflight check completed successfully."
Enter fullscreen mode Exit fullscreen mode

Why: Makes logs human-readable, communicates intent.

🔹 Step 12: Insert Shebang Safely

Command

sed -i '1i #!/usr/bin/bash' preflight.sh
Enter fullscreen mode Exit fullscreen mode

Explanation

  • Inserts shebang at line 1 without opening an editor

🔹 Step 13: Verify First Lines

Command

head -n 3 preflight.sh
Enter fullscreen mode Exit fullscreen mode

Explanation

  • Shows the first 3 lines to confirm shebang and commands

🔹 Step 14: Make Script Executable

Command

chmod +x preflight.sh
Enter fullscreen mode Exit fullscreen mode

Explanation

  • Adds execute permission so you can run it

🔹 Step 15: Run Script

Command

./preflight.sh
Enter fullscreen mode Exit fullscreen mode

Explanation

  • Executes preflight script safely

✅ Optional DevOps Enhancements

  • Check required commands:
command -v git >/dev/null || { echo "git not installed"; exit 1; }
Enter fullscreen mode Exit fullscreen mode
  • Check OS type:
grep -qi "amazon linux" /etc/os-release || echo "Warning: Not Amazon Linux"
Enter fullscreen mode Exit fullscreen mode
  • Colorful output (optional)

  • Logging to a file

🧠 Key Takeaways

By following this:

  • You learned DevOps mindset: safety, verification, predictability

  • You installed Node safely: latest version, user-level, isolated

  • You wrote a DevOps-aware script: clear, fail-fast, automation-ready

  • You verified each step: human-readable logs + sanity checks

This is now a professional starting point for backend + DevOps work

Top comments (0)