Day 16 of My DevOps Journey — Practical Linux Administration for DevOps

Linux is the backbone of DevOps, and today I focused on applying fundamentals in a way that mirrors real-world tasks. I worked hands-on with EC2 Ubuntu instances, covering user management, permissions, environment setup, inter-server communication, and automation with shell scripting.
Instead of treating them as isolated exercises, I approached each task as if I were managing servers in production.
Task 1: Secure User & SSH Setup
Problem: In real-world environments, giving every engineer direct root access is a security risk. The correct approach is to create dedicated users with SSH keys.
Steps I took:
# Create a new user
sudo adduser devopsuser
# Create SSH directory for the user
sudo mkdir /home/devopsuser/.ssh
# Add the public key for secure access
sudo nano /home/devopsuser/.ssh/authorized_keys
# Set correct permissions
sudo chown -R devopsuser:devopsuser /home/devopsuser/.ssh
sudo chmod 600 /home/devopsuser/.ssh/authorized_keys
Learning: Permissions and ownership are crucial. Without correct chmod 600
, SSH will reject the key for being insecure.
Task 2: File & Directory Permissions
Problem: On shared servers, we need to ensure files and directories are owned and accessible only by intended users or groups.
Steps I took:
# Create files and directories
sudo touch project.txt
sudo mkdir project_dir
# Assign ownership to the new user
sudo chown devopsuser:devopsuser project.txt project_dir
# Restrict access to owner and group
sudo chmod 770 project_dir
Learning: A single misconfigured permission can cause unauthorized access or, worse, expose sensitive files. Practicing this taught me how least privilege access works in Linux.
Task 3: Environment Setup — JDK Installation
Problem: Many applications require Java. Without setting JAVA_HOME
, build tools like Maven won’t work properly.
Steps I took:
# Install JDK
sudo apt update -y
sudo apt install -y openjdk-11-jdk
# Set JAVA_HOME and persist it
echo "export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64" >> ~/.bashrc
source ~/.bashrc
# Verify installation
java -version
Challenge: JAVA_HOME
worked in the current session but disappeared after reboot. I solved this by exporting it permanently in .bashrc
.
Task 4: Instance-to-Instance Communication
Problem: In a real deployment, multiple servers need to exchange data securely. Testing this with two EC2 instances gave me hands-on exposure.
Steps I took:
# Copy file securely from Instance A to Instance B
scp -i key.pem file.txt ubuntu@<instance-b-ip>:/home/ubuntu/
Learning: SCP is the simplest way to test secure data transfer. For large-scale systems, we would use more advanced tools, but this was a strong foundation.
Task 5: Automation with Shell Scripting
Problem: Manually installing dependencies wastes time and creates inconsistency. Automation ensures uniform setups across servers.
Solution Script:
#!/bin/bash
echo "Updating Ubuntu packages..."
sudo apt update -y
echo "Installing Git..."
sudo apt install git -y
echo "Installing Java JDK 11..."
sudo apt install -y openjdk-11-jdk
echo "Installing Maven..."
sudo apt install -y maven
echo "Installation Complete!"
echo "Installed Versions:"
git --version
java --version
mvn --version
Challenge: The script initially failed because I typed mvn--version
(without a space). Debugging line-by-line helped me fix it.
Learning: Small syntax issues can break automation. Testing scripts step by step is critical.
Challenges I Faced
Permission Errors: Forgot to use
sudo
→ Solved by re-running with elevated privileges.JAVA_HOME Persistence: Variable disappeared → Fixed by adding it to
.bashrc
.SSH Rejection: Public key not set up → Solved by placing the key in
authorized_keys
.Script Debugging: Wrong syntax caused failure → Debugged carefully and fixed.
Key Takeaways
Linux administration is about security, automation, and precision.
Debugging small mistakes builds problem-solving skills that scale up to complex systems.
Every command connects back to real DevOps practices — user management, secure transfers, environment setup, and automation.
Subscribe to my newsletter
Read articles from Akanksha directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
