CodeTheRobot

Ubuntu Linux for Robotics · Lesson 01 of 96

What Linux is and why robotics uses it

The kernel, distributions, open source, and why ROS 2 and robot computers run Linux.

Estimated time · 30–45 min

Learning goals

What you will understand

  • Explain what linux is and why robotics uses it in your own words
  • Use it in a small workstation example
  • Verify the result instead of assuming it worked

Understand the idea first

The mental model

Linux is an operating system kernel: the part that manages the CPU, memory, disks and devices. A distribution such as Ubuntu adds the tools, libraries, package manager and desktop around it. Ubuntu is the most common Linux for robotics and is the primary platform for ROS 2.

Robotics uses Linux because it is free and open source, runs on everything from a Raspberry Pi to a server, lets you control every part of the system, has real-time and driver support for sensors, and is where the ROS 2 tools and community packages are tested first.

Guided lesson

Work through these steps

  1. 1.

    Open a terminal and record the current state before changing anything.

  2. 2.

    Read the what linux is and why robotics uses it commands and predict what each one does.

  3. 3.

    Run the commands one at a time and compare each output with your prediction.

  4. 4.

    Write the commands that worked in a setup note you can repeat later.

Worked example

Read it before you run it

uname -a
# Print the kernel name, version and architecture (x86_64 or aarch64).
cat /etc/os-release
# Print the distribution name and version.
lsb_release -a
# Show the Ubuntu release and its codename.
nproc
# Print the number of CPU cores.
free -h
# Show memory in human-readable units.
df -h /
# Show how full the main disk is.

What the example is doing

  1. 1.Lines without sudo only inspect or change files you own; sudo authorizes a system-wide change.
  2. 2.Read command output before moving to the next line. Stop if names, versions, disks, or paths differ from the lesson.
  3. 3.Comments beginning with # explain safety checks and are not executed by the shell.

Watch it run · The robot's computer

See what this code does

The terminal types this lesson's practice solution and runs it. The scene shows the kind of robot behaviour that code drives. It plays by itself and loops.

robot computercpumemdiskdriverstoppedplannerstoppedloggerstoppedsafetystoppedTHE ROBOT'S COMPUTER

Demo for What Linux is and why robotics uses it. Expected result: Linux

Practice code

Now type it yourself

Open a terminal, run the starter line by line (or save it as practice.sh and run bash practice.sh), and replace every TODO with your own command.

# Print the name of the kernel you are running
# TODO: use uname with the option that prints only the kernel name

Expected output

Linux
Stuck? Show the full solution (try it yourself first)
# Print the name of the kernel you are running
uname -s

Expected result

How you know it worked

  • Each command completes without an unexplained error.
  • Your notes contain the command, the important output, and what it proves.

Practical exercise

Apply the lesson

Open a terminal and write down your kernel version, Ubuntu release and codename, CPU core count, total memory and free disk space. Then explain in two sentences why a robot might use Linux instead of a phone operating system.

Before you continue

  • You recorded the starting state
  • Every command and output is understood
  • The change can be repeated from your notes

If something goes wrong

A command says permission denied.

Check ownership and permissions first. Do not add sudo unless the command changes a documented system location.

A command or package is not found.

Check spelling, Ubuntu version, enabled repositories, and whether the previous installation command succeeded.