Excalibur's Sheath

Command-Line Deep Dive: Mastering Shell and Utilities

Oct 26, 2025 By: Jordan McGilvrayhomelab,linux,automation,ansible,ssh,sysadmin,package-management,networking,bash

Advanced Linux Administration for Homelabs: Part 1 of 1

Linux is a powerful platform, but the real strength lies in the command line. While graphical tools can make basic tasks easier, they often hide what’s happening behind the scenes. In a homelab with multiple systems, relying only on a GUI limits your understanding and control. The terminal lets you see everything happening and gives you full control to inspect, manipulate, and automate your environment.

For a quick reference to essential commands, see Essential Linux Commands.

We’ll take a hands-on, project-based approach. Instead of listing commands in isolation, we’ll build a working Ansible setup from the ground up. You’ll learn practical Linux administration skills while configuring a control node capable of managing multiple hosts.

Along the way, we cover package management, SSH configuration, inventory setup, and basic automation in a real project context.

By the end, you’ll have a system you can expand and adapt for future homelab projects. You may also find Package Management useful for background on installing and updating software.

Before diving into Ansible, it’s important to understand the environment you’re working in. Checking your current user, exploring directories, and viewing file permissions gives you the context you need. Without this knowledge, it’s easy to misconfigure hosts or break scripts that rely on predictable paths and permissions.

Keeping systems updated and consistent is also critical. Outdated software can cause security issues, break Ansible compatibility, and make troubleshooting harder.

This guide walks you through updating systems, installing Ansible, configuring SSH access, and verifying connectivity, all while explaining why each step matters.

Exploring the Filesystem

Before configuring SSH or installing software, take a moment to inspect your environment. Knowing where you are and what files exist is fundamental.

whoami

whoami shows your current username. This helps prevent accidental file changes or running commands with insufficient privileges.

pwd

pwd prints the current working directory. Being aware of your location prevents unintended changes and helps when specifying paths for scripts or configuration files.

ls -lhad *

ls -lhad * lists all items, including hidden files, showing permissions, ownership, size, and last modification date.

Examining these details is important when editing SSH keys or configuration files. Incorrect permissions can prevent remote login or break scripts.

For more on command-line tools, see Unix and Linux Command-Line Commands.

Updating Your Systems

Keeping systems current helps avoid errors and reduce security risks.

Debian/Ubuntu

sudo apt update

apt update refreshes the package database, so your system knows about the latest software. Always run this before installing new packages.

sudo apt upgrade -y

apt upgrade installs updates. The -y flag confirms prompts automatically, ensuring dependencies are met and avoiding conflicts.

RedHat/Fedora

sudo dnf update -y

dnf update synchronizes and upgrades packages. Keeping systems current is important, especially when managing multiple hosts, because package mismatches can break automation.

Regular updates reduce the chance of encountering unexpected errors.
For more on updates and script maintenance, see Why Update Scripts.

Installing Ansible

Ansible is the automation engine for this project. Installation depends on your Linux distribution.

Debian/Ubuntu

sudo apt install ansible -y

This installs Ansible from the official repository for stability. After installation, confirm the version:

ansible --version

Verifying the installation ensures you have the correct setup for running playbooks and modules.

RedHat/Fedora

sudo dnf install epel-release -y

epel-release enables extra packages not included in the base system, including Ansible.

sudo dnf install ansible -y

Confirm the installation:

ansible --version

Checking versions is a good habit, especially with multiple hosts. Differences in software versions can cause subtle issues.
For more reference, see Ultimate Linux Cheat Sheet.

Configuring SSH Access

SSH provides secure communication between the control node and managed hosts, forming the backbone of Ansible automation.

Enabling SSH

Debian/Ubuntu

sudo systemctl enable --now ssh

Starts SSH immediately and enables it at boot.

RedHat/Fedora

sudo systemctl enable --now sshd

On RedHat-based systems, the SSH daemon is sshd. Enabling it ensures remote hosts are accessible.

Generating and Deploying SSH Keys

Passwordless SSH is key for automation. Generate a secure key pair:

ssh-keygen -t ed25519

Copy the public key to each host:

ssh-copy-id username@host1
ssh-copy-id username@host2
ssh-copy-id username@host3

Test connectivity:

ssh username@host1

Successful login without a password confirms proper key setup.
If SSH fails, check .ssh directory and authorized_keys permissions. For more guidance, see SSH Banners and MOTD.

Creating the Ansible Inventory

The inventory lists all hosts Ansible can manage. Edit /etc/ansible/hosts:

[homelab]
host1 ansible_host=192.168.1.101 ansible_user=username
host2 ansible_host=192.168.1.102 ansible_user=username
host3 ansible_host=192.168.1.103 ansible_user=username

Test connectivity:

ansible -m ping homelab

A successful ping confirms communication with all hosts.
For extra network tools, see Mastering Network Tools.

Running Commands Across Hosts

Retrieve system information:

ansible homelab -m shell -a "uname -a"

Update Debian/Ubuntu hosts:

ansible homelab -m shell -a "sudo apt update && sudo apt upgrade -y"

Update RedHat/Fedora hosts:

ansible homelab -m shell -a "sudo dnf update -y"

One terminal can now manage multiple systems at once, saving time and avoiding mistakes.

Reinforcing Bash Concepts

As you set up Ansible, practice general Bash skills:

  • Tab completion – speeds up typing and reduces errors.
  • Command history – recall previous commands with arrow keys.
  • man pages and --help – explore command options.
  • Quoting and escaping – avoid errors with paths containing spaces.
  • Redirecting output – save logs using > or append with >>.
  • Pipes (|) – chain commands efficiently.
  • Environment variables – use echo $PATH or export VAR=value.

Practicing Bash now makes automation scripts easier to follow and troubleshoot later.

Conclusion

Throughout this article, you have built a foundation for managing multiple Linux systems using Ansible. By installing Ansible, configuring SSH keys, and creating an inventory file, you’ve taken the first steps toward centralizing control over your homelab environment. These tasks not only prepare your systems for automation but also reinforce essential command-line concepts that underpin all Linux administration.

In the process, you’ve practiced navigating the filesystem, inspecting file permissions, and understanding ownership and hidden files. You’ve also explored process monitoring, environment variables, and the nuances of package management across different distributions. These skills are not just for Ansible — they form the backbone of effective Linux system administration.

The command-line examples throughout this guide demonstrate how one terminal can perform tasks across multiple machines simultaneously. You’ve seen how updating packages, retrieving system information, and running shell commands on remote hosts becomes efficient and repeatable. This practical experience strengthens both your technical knowledge and your confidence in managing multiple systems at once.

Finally, by combining theory with hands-on execution, you’ve learned to think like a system administrator. You’ve gained insight into why commands behave the way they do, how to troubleshoot basic connectivity issues, and how to structure your systems for secure and efficient automation. This foundation equips you to approach more complex tasks with clarity and control, making the Linux command line a powerful ally in your homelab endeavors.

Understanding not just how, but why commands are run helps you troubleshoot, adapt, and expand your automation projects with confidence

More from the "Advanced Linux Administration for Homelabs" Series:

  • Command-Line Deep Dive: Mastering Shell and Utilities