5 Must-Know Linux Commands for Embedded Developers (with Examples)

If you’re starting out with Embedded Linux, mastering a few essential commands can make your development and debugging process much easier. Whether you’re working on a Raspberry Pi, BeagleBone, or a custom ARM board, these Linux commands help you peek under the hood and interact with the system confidently.

In this post, we’ll walk through 5 must-know Linux commands every embedded developer should know — with simple, practical examples.

1. dmesg – View Kernel Messages

The dmesg command shows messages from the kernel ring buffer. It’s extremely helpful for checking hardware initialization, driver logs, and boot issues.

USE CASE:

  • Check if a USB device or driver was detected.
  • Debug kernel boot sequence.

eXAMPLE:

$ dmesg | tail -20

Shows the last 20 kernel messages.

$ dmesg | grep tty

Lists serial ports (useful for debugging UART).

2. lsmod – List Loaded Kernel Modules

This command lists all currently loaded kernel modules (drivers). It’s useful for verifying if a driver for your hardware is active.

uSE CASE:

  • Check if your Wi-Fi or SPI driver is loaded.
  • Debug missing hardware functionality.

eXAMPLE:

$ lsmod

You might see something like:

spi_bcm2835    16384  0

Which means the SPI driver is loaded on a device.

3. top – Monitor CPU and Memory Usage

top gives you a live, real-time view of processes and resource usage. It’s perfect for tracking down performance issues in embedded systems.

Use case:

  • Identify CPU-heavy processes.
  • Check RAM usage on limited-resource systems.

example:

$ top

Press q to quit. Press Shift + M to sort by memory usage.

4. free – Show Memory Usage Summary

While top is interactive, free gives a quick snapshot of memory usage, which is useful for embedded systems with limited RAM.

Use case:

  • Monitor memory usage in scripts.
  • Check for memory leaks or insufficient RAM.

example:

$ free -h

The -h flag shows memory in a human-readable format like MB or GB.

5. strace – Trace System Calls

strace helps you see what a program is doing behind the scenes by tracing system calls. It’s invaluable when debugging file access errors or unexpected behavior in embedded applications.

Use case:

  • See if your application is trying to open a missing file.
  • Trace execution of a malfunctioning process.

example:

$ strace ./my_app

You’ll see logs like:

open("/etc/myconfig.conf", O_RDONLY) = -1 ENOENT (No such file or directory)

That’s a clue that the app is looking for a config file that doesn’t exist!

Nice is it ?!

As an embedded developer, your job doesn’t stop at writing C/C++ code. You also need to understand how your software behaves in a Linux environment. These commands are like your first-aid toolkit — helping you debug, optimize, and understand the system better.

If you’re new, start by running these commands on your development board. Observe how they behave, and make them part of your daily routine.

Happy hacking!

Leave a comment