Linux Basics

The File System

Unlike Windows, which uses drive letters like C:\ and D:\, Linux uses a single, unified tree structure. Everything starts at the "root".


The Root Directory /

The forward slash / represents the very bottom of the file system tree. Every file, folder, and even hardware device on your computer lives somewhere under /.

Important Directories

  • /home/: This is where your personal files live. If your username is rajath, your home folder is /home/rajath/. (Often abbreviated as ~).
  • /dev/ (Devices): This is crucial for embedded developers. In Linux, hardware devices are represented as files here. When you plug in an ESP32, it usually appears as /dev/ttyUSB0.
  • /etc/: System-wide configuration files live here.
  • /bin/ & /usr/bin/: This is where the actual programs (binaries) you run are stored, like ls, python3, or git.

To move around this file system, you need to learn a few essential commands. Open your terminal and try these out.

Tells you exactly where you are right now.

bash
pwd
# Output: /home/rajath

ls (List)

Shows you the files and folders inside your current directory.

bash
ls

# Use -l to see detailed information (permissions, size)
ls -l

# Use -a to see hidden files (files that start with a dot, like .bashrc)
ls -la

cd (Change Directory)

Moves you into a different folder.

bash
# Move into the Documents folder
cd Documents

# Move UP one level (the two dots mean "parent directory")
cd ..

# Go straight back to your home folder (the tilde shortcut)
cd ~

# Go to the absolute root of the file system
cd /

File Operations

Creating and moving files from the terminal is much faster than dragging and dropping in a GUI.

mkdir (Make Directory)

Creates a new folder.

bash
mkdir esp_projects

cp (Copy)

Copies a file. The syntax is cp [source] [destination].

bash
cp main.c backup_main.c

mv (Move / Rename)

Moves a file, or renames it if you move it to the same folder with a new name.

bash
# Rename the file
mv backup_main.c old_main.c

# Move the file into a folder
mv old_main.c esp_projects/

rm (Remove)

Deletes a file.

There is no recycle bin!

When you use rm, the file is gone forever. Be very careful.

bash
# Delete a file
rm old_main.c

# Delete a folder and everything inside it (Recursive and Force)
rm -rf esp_projects/

In the next section, we'll look at the permission system, which dictates who is allowed to read, write, or execute these files.

Previous
What is Linux?