PROJECT 1

Linux Server Setup & Automation

Prepare the daily shell environment, establish standardized project folders, configure custom terminal aliases, and write automated workstation bootstrap scripts.

Environment
Ubuntu / CLI Terminal
Difficulty
Beginner
Course Module
Chapters 1–2: Linux
Deliverables
Bootstrap Script & Key Pairs
1. System Architecture & Workflow

The diagram below maps the structure of directories created inside the user home folder, along with the login configuration timeline of the bash environment lifecycle.

/home/devops/ ├── Projects/ ├── Scripts/ ├── Backups/ ├── Logs/ └── .bashrc Shell Initialization Flow 1. Login trigger -> Read /etc/profile 2. User home -> Execute ~/.bashrc 3. Apply Aliases, Prompts & Paths
2. Part 1: Step-by-Step Action Items & Key Execution Steps
STEP 1

Standardize the Directory Hierarchy

Organize your home folder with separated, structured workspaces dedicated to coding projects, server automation scripts, download caches, backup archives, and application logs.

$ mkdir -p ~/Projects ~/Scripts ~/Downloads ~/Backups ~/Logs
This command creates a set of project folders, using the -p flag to build missing directories and resolve issues.
$ ls -lh ~/
This command displays directory attributes, permissions, file size metrics, ownership states, and last modification timelines for all objects in the home location.
STEP 2

Install Essential Utilities & Monitoring Packages

Prepare standard package systems with primary command-line monitoring interfaces, file management suites, and network statistics utilities.

$ sudo apt update && sudo apt install -y curl wget git unzip zip net-tools tree htop
This command fetches packages indexing info, then installs network requestors (curl, wget), git VCS, compression engines (unzip, zip), network sockets viewer (net-tools), directory view (tree), and interactive process table (htop).
STEP 3

Configure Bash Profiles and Custom Environment Aliases

Define permanent command-line shortcuts and performance alias definitions inside the bash profile config file.

$ echo "alias ll='ls -laF'" >> ~/.bashrc
This command appends a persistent command alias definition to the user's .bashrc profile, mapping "ll" to present long-format directory inventories with classifications.
$ echo "alias checksys='df -h && free -m && htop'" >> ~/.bashrc
This command adds a customized multi-command shell alias to inspect disk allocations, physical memory values, and launch the real-time process monitoring interface.
$ echo "alias project_backup='tar -czf ~/Backups/projects_\$(date +%F).tar.gz -C ~/ Projects'" >> ~/.bashrc
This command constructs an automated compression backup alias that captures directories under ~/Projects, compresses them, and writes a dated tarball archive inside ~/Backups.
$ source ~/.bashrc
This command reloads your .bashrc profile, activating new configurations without needing to restart your terminal.
STEP 4

Generate Secure Cryptographic Key Pairs for Remote SSH

Construct secure public/private keys used to authenticate with remote Git codebases, virtual machine hosts, and CI deployment nodes without plain-text password prompts.

$ ssh-keygen -t ed25519 -b 4096 -C "student@devops-node" -N "" -f ~/.ssh/id_ed25519
This command generates a secure ED25519 key pair with a comment, disables the passphrase prompt for automation, and writes the keys to the .ssh directory.
$ cat ~/.ssh/id_ed25519.pub
This command outputs the public key contents, allowing the student to copy the public key and paste it into GitHub or other authorized hosts.
3. Automation Architecture

The flowchart below outlines the bootstrap shell script logic. The script automates folder generation, validates software packages, modifies files, reloads variables, and validates environment outputs.

1. Dir Verification Create standard home folders mkdir -p 2. Package Install Verify/install git, curl, htop, tree apt-get install 3. Config Injection Write aliases to .bashrc profile cat <<EOF 4. Verification Run diagnostic test and write reports env_setup.log
4. Part 2: Complete Deliverable Assets & Production Templates

To automate the configuration of a fresh user workstation, we will write a bootstrap initialization script. Below is a step-by-step breakdown of how this script is assembled, followed by the complete unified script template.

Step-by-Step Script Construction

Step 1

Declare Safety Flags & Log Paths

Setup standard shell flags to prevent error leakage and specify where logs will be captured.

#!/usr/bin/env bash set -euo pipefail LOG_FILE="${HOME}/Logs/bootstrap_setup.log"
This boots the bash shell interpreter, enables strict error checking, and defines the destination file path variable to redirect installation output streams.
Step 2

Loop to Create Work Directories

Create all standard project, script, and backup directories in the user home folder.

for dir in Projects Scripts Downloads Backups Logs; do if [ ! -d "${HOME}/${dir}" ]; then mkdir -p "${HOME}/${dir}" echo "Created directory: ${HOME}/${dir}" | tee -a "${LOG_FILE}" fi done
This checks the presence of each folder in the list and creates it if it is missing, writing confirmation messages to both the terminal and the log file.
Step 3

Automate Package Installations

Check and install necessary tools using apt-get package manager.

REQUIRED_PACKAGES=(curl wget git unzip zip net-tools tree htop) sudo apt-get update -qq for pkg in "${REQUIRED_PACKAGES[@]}"; do if ! dpkg -s "${pkg}" &>/dev/null; then sudo apt-get install -y -qq "${pkg}" >> "${LOG_FILE}" 2>&1 fi done
This updates local apt listings, checks if each required tool is already installed using dpkg -s, and installs missing packages silently, appending all outputs to the log file.
Step 4

Inject Custom Shell Aliases

Check `.bashrc` and inject command aliases for administrative efficiency.

BASHRC_CONFIG="${HOME}/.bashrc" ALIASES=( "alias ll='ls -laF'" "alias checksys='df -h && free -m && htop'" "alias project_backup='tar -czf ~/Backups/projects_\$(date +%F).tar.gz -C ~/ Projects'" ) for val in "${ALIASES[@]}"; do if ! grep -Fq "${val}" "${BASHRC_CONFIG}"; then echo "${val}" >> "${BASHRC_CONFIG}" fi done
This iterates over custom aliases, searches `.bashrc` for duplicates, and appends missing entries to the file.
Step 5

Generate SSH Key Pair

Create secure cryptographic credentials for remote GitHub authentication.

if [ ! -f "${HOME}/.ssh/id_ed25519" ]; then ssh-keygen -t ed25519 -C "student@devops-node" -N "" -f "${HOME}/.ssh/id_ed25519" >> "${LOG_FILE}" 2>&1 fi
This verifies if an ED25519 private key is already present in the `.ssh` folder, and generates a new key pair with no passphrase if the key is missing.

Combined Automated Script

Save the consolidated blocks above as ~/Scripts/bootstrap_linux.sh, make it executable with chmod +x bootstrap_linux.sh, and run it:

#!/usr/bin/env bash # bootstrap_linux.sh - Automation System Setup Script set -euo pipefail LOG_FILE="${HOME}/Logs/bootstrap_setup.log" echo "=== DevOps Environment Bootstrap Initiated ===" | tee -a "${LOG_FILE}" # 1. Directory Structure Creation for dir in Projects Scripts Downloads Backups Logs; do if [ ! -d "${HOME}/${dir}" ]; then mkdir -p "${HOME}/${dir}" echo "Created directory: ${HOME}/${dir}" | tee -a "${LOG_FILE}" else echo "Directory already exists: ${HOME}/${dir}" | tee -a "${LOG_FILE}" fi done # 2. Package Installation REQUIRED_PACKAGES=(curl wget git unzip zip net-tools tree htop) echo "Updating apt caches..." | tee -a "${LOG_FILE}" sudo apt-get update -qq for pkg in "${REQUIRED_PACKAGES[@]}"; do if dpkg -s "${pkg}" &>/dev/null; then echo "Package already installed: ${pkg}" | tee -a "${LOG_FILE}" else echo "Installing Package: ${pkg}..." | tee -a "${LOG_FILE}" sudo apt-get install -y -qq "${pkg}" >> "${LOG_FILE}" 2>&1 fi done # 3. Inject Alias Configurations BASHRC_CONFIG="${HOME}/.bashrc" ALIASES=( "alias ll='ls -laF'" "alias checksys='df -h && free -m && htop'" "alias project_backup='tar -czf ~/Backups/projects_\$(date +%F).tar.gz -C ~/ Projects'" ) echo "Injecting configuration aliases..." | tee -a "${LOG_FILE}" for val in "${ALIASES[@]}"; do if ! grep -Fq "${val}" "${BASHRC_CONFIG}"; then echo "${val}" >> "${BASHRC_CONFIG}" echo "Added alias: ${val}" | tee -a "${LOG_FILE}" fi done # 4. Generate SSH Key pairs if not exists if [ ! -f "${HOME}/.ssh/id_ed25519" ]; then echo "Generating cryptographic ED25519 identity key..." | tee -a "${LOG_FILE}" ssh-keygen -t ed25519 -C "student@devops-node" -N "" -f "${HOME}/.ssh/id_ed25519" >> "${LOG_FILE}" 2>&1 else echo "SSH identity keys already present." | tee -a "${LOG_FILE}" fi echo "=== DevOps Environment Bootstrap Completed ===" | tee -a "${LOG_FILE}"
5. Deliverables Summary

Verify that the following configurations and outputs exist inside your Linux workstation.

Created Files / Templates

  • /home/devops/Scripts/bootstrap_linux.sh - Automated bootstrap configuration script.
  • /home/devops/Logs/bootstrap_setup.log - Validation log output tracking shell configurations.
  • /home/devops/.ssh/id_ed25519.pub - Public ED25519 authentication SSH key.

Verification Artifacts / Execution Proof

  • Output of tree ~/ showing all standard directories are present.
  • Result of alias ll confirming successful integration of shell shortcuts.
  • Verification of installed tools (git, curl, zip, htop) using which [command].
6. Closing Explanation: Why We Did This & What It Accomplishes

Architectural Intent & Operational Impact

Why We Did This

What This Accomplishes