How I Built My Own Linux Command Using Python (Beginner-Friendly, Real-World)

Published: (January 7, 2026 at 11:40 PM EST)
3 min read
Source: Dev.to

Source: Dev.to

Why build your own command?

Because it teaches you three important things at once:

  • How Linux commands really work
  • How Python packages are structured
  • How real tools get published to PyPI

And most importantly, it changes your mindset from “I use tools” to “I can build tools”.

The idea (keep it simple)

I wanted a command that does one small but useful thing: syscheck.

CPU Usage: 21.4%
Memory Usage: 40.7%
Disk Usage: 16.99%

That’s it. No dashboards.

Before writing code, understand this: a Linux command is just an executable file in your PATH. When you run ls, Linux searches the directories listed in $PATH and runs the first ls it finds.

Our goal is to:

  1. Create a Python program.
  2. Tell Python: “Expose this as a command”.

Project structure (this part matters more than code)

syscheck/
├── pyproject.toml
├── README.md
├── LICENSE
└── syscheck/
    ├── __init__.py
    └── main.py

Why a folder inside a folder?
The outer syscheck/ is the project root, while the inner syscheck/ is the actual Python package. Python only imports packages, not arbitrary folders—this is where most beginners get stuck.

Writing the actual logic (keep it boring)

syscheck/main.py

import shutil
import psutil

def main():
    cpu = psutil.cpu_percent(interval=1)
    memory = psutil.virtual_memory().percent
    disk = shutil.disk_usage("/")

    disk_percent = (disk.used / disk.total) * 100

    print(f"CPU Usage: {cpu}%")
    print(f"Memory Usage: {memory}%")
    print(f"Disk Usage: {disk_percent:.2f}%")

Nothing fancy here. The key idea is don’t reinvent system logic—use existing libraries (psutil) and focus on clean output, just like real production tools.

Turning Python into a command

pyproject.toml

[project.scripts]
syscheck = "syscheck.main:main"

Plain English: create a command called syscheck. No magic.

Installing it locally (production mindset)

  • For development

    pip install -e .
  • For production testing

    pip install .

Once installed, Linux creates a wrapper script (e.g., ~/.local/bin/syscheck) that simply calls your Python function. So when you type syscheck, the flow is:

Linux → Python → your code

Why this matters (career perspective)

At 1–2 years of experience, this demonstrates that you:

  • Understand Linux internals
  • Understand Python packaging
  • Think like a tool builder, not just a user

In interviews you can say:

“I built a small Python‑based CLI tool and exposed it as a Linux command using Python’s packaging system.”

That sentence alone makes a strong impression.

Publishing to PyPI (optional but powerful)

When everything works locally, publishing is straightforward:

python -m build
twine upload dist/*

After that, anyone can install it with:

pip install syscheck

At that moment, you’re no longer just learning Python—you’re delivering a reusable tool.

What I learned from this

  • Commands are simpler than they look
  • Packaging matters more than the core logic
  • Clean output matters in real tools
  • Understanding beats memorization
  • Building small things builds confidence

Final advice to beginners

Don’t try to build massive tools like kubectl, aws cli, or full monitoring systems right away. Build small, boring, useful tools—that’s how real engineers grow.

Back to Blog

Related posts

Read more »

Lyra: The Command line Assistant

I coded the skeleton and the main loop for the assistant. The reason to choose a CLI assistant over a voice or AI assistant is due to my hardware limitations. I...