โ† Operating System Basics: From Zero to Hero
Level 1 ยท Zero: Getting Started

Hardware and Software: Ask Your Computer

Lesson 3 of 14 ยท โฑ 10 min

A computer has hardware (the parts you can touch) and software (the instructions). Linux can tell you about your own hardware, if you know how to ask. Let's go on a hardware hunt! ๐Ÿ•ต๏ธ

An operating system banner on top connected to five hardware parts: input, CPU, output, RAM and storage.

Part Body idea What it does
CPU Your brain Follows instructions, billions of times a second
RAM Your desk Quick workspace for what you're using now
Storage Your cabinet Keeps your files, even when the power is off
Input / Output Ears, hands, eyes, voice Keyboard, mouse, screen, speakers

๐Ÿงช Lab 1: meet the brain (CPU)

lscpu | head -20

lscpu lists the CPU. The | head -20 part means "show me only the first 20 lines" (we'll learn the | in a later lesson). Look for:

  • Architecture: the type of CPU (for example x86_64 on many PCs or aarch64 on a Raspberry Pi)
  • Model name: the name of your CPU
  • CPU(s): how many cores (little brains) you have
nproc

nproc prints just the number of processing units. Every core can work on one thing at the same moment.

๐Ÿงช Lab 2: meet the desk (RAM)

free -h

free shows memory. The -h means human-friendly, so it uses GB and MB instead of giant numbers. You'll see a table like this (your numbers will be different):

               total        used        free      shared  buff/cache   available
Mem:           3.8Gi       612Mi       2.4Gi        22Mi       860Mi       3.2Gi
Swap:          1.0Gi          0B       1.0Gi
  • total: how big the desk is
  • used: how much of the desk is covered
  • available: how much room is still free for new things

๐Ÿงช Lab 3: meet the cabinet (storage)

lsblk

lsblk lists block devices, which are the storage drives, like SD cards, SSDs or hard drives, and how they are split into partitions.

df -h

df means disk free. It shows each storage area, its size, how much is used, and where it is mounted (attached to the folder tree).

๐Ÿ’ก Find the line that ends with /. That's your main drive, and it's where Linux itself lives!

๐Ÿงช Lab 4: write a hardware card

Let's save what you found in a file. Run these one by one (change the words in quotes to match what you saw):

cd ~/MagiLab
echo "Computer name: $(hostname)" > hardware.txt
echo "CPU cores: $(nproc)" >> hardware.txt
echo "Disk usage:" >> hardware.txt
df -h / >> hardware.txt
cat hardware.txt
  • > writes output into a file (it replaces what was there).
  • >> adds to the end of a file.
  • $(...) runs a command and puts its answer right into the text.

You just made a report with Linux's help!

What is the OS doing here?

When you ran free, lscpu and df, those programs asked the OS for the facts. The OS keeps track of every part of the hardware, and it shares that information with anyone who asks. That's the OS doing its job as manager!

Words to know

Word What it means
Core One processing unit inside a CPU
Partition A section of a storage drive
Mounted Attached to the folder tree so you can use it
Redirect (>) Sending a command's output into a file

๐ŸŽฏ Quiz time!

1. Which command shows how much memory (RAM) you have?
2. What does nproc print?
3. What does >> do in echo hi >> notes.txt?
4. Which part is like the desk: fast but forgets when the power goes off?