Navigation & File Management

Learn how to navigate Linux systems, manage files and directories, and work efficiently from the terminal.

Learn how to move through the Linux filesystem, manage files and directories, and understand how file operations actually work.


Difficulty: Beginner
Estimated reading time: 35 min


Introduction

Now that you understand how the Linux filesystem is structured, it is time to actually work with it.

One of the most important Linux skills is becoming comfortable with:

  • navigating directories
  • creating files
  • copying data
  • moving files
  • deleting content
  • locating resources quickly

At first, working in the terminal can feel strange compared to graphical file explorers.

But once you understand the workflow, terminal-based file management becomes:

  • faster
  • more precise
  • easier to automate
  • extremely powerful

Understanding the Current Working Directory

Every shell process operates inside a directory called:

The current working directory.

When you execute commands, they usually operate relative to your current location.

You can display your current directory using:

pwd

Example output:

/home/john/projects

pwd stands for:

Print Working Directory

Understanding Paths

Linux uses paths to locate files and directories.

There are two main types:

Type Example
Absolute path /home/john/project/app.js
Relative path ./app.js

Absolute Paths

Absolute paths always begin from:

/

Example:

/home/john/documents/report.txt

This path always points to the same location regardless of your current directory.


Relative Paths

Relative paths depend on where you currently are.

Examples:

./file.txt
../notes.txt

Symbols:

Symbol Meaning
. Current directory
.. Parent directory
~ Home directory

Example:

cd ..

moves one directory upward.


The cd Command

The cd command changes the current directory.

Example:

cd /home/john/projects

Now your shell operates inside that directory.


Common cd Examples

Go into a directory:

cd projects

Go one level up:

cd ..

Go to the home directory:

cd ~

Go to the previous directory:

cd -

This is extremely useful when switching between two locations repeatedly.


Understanding Relative Navigation

Imagine your current location is:

/home/john/projects

Then:

cd ..

moves to:

/home/john

And:

cd ../..

moves to:

/home

Relative navigation becomes incredibly useful once you understand filesystem hierarchy.


Listing Files with ls

The ls command lists files and directories.

Basic usage:

ls

Example output:

app
notes.txt
docker-compose.yml

Detailed Listing

ls -l

Example:

-rw-r--r-- 1 john john 1200 May 13 notes.txt

This output contains:

Part Meaning
-rw-r--r-- Permissions
john Owner
john Group
1200 File size
May 13 Modification date
notes.txt Filename

Hidden Files

Files beginning with . are hidden.

Example:

.bashrc
.env
.gitignore

To display hidden files:

ls -a

Combine with long listing:

ls -la

This is one of the most commonly used Linux commands.


Creating Directories with mkdir

Create a new directory:

mkdir project

Create nested directories:

mkdir -p projects/api/src

Without -p, Linux expects parent directories to already exist.


Creating Files with touch

Create an empty file:

touch app.js

Multiple files:

touch index.html style.css app.js

touch can also update file timestamps.


Viewing File Contents

Several commands can display file contents.


cat

Displays the full contents of a file.

cat notes.txt

Example:

Hello Linux

Useful for small files.


less

Better for large files.

less logs.txt

Navigation:

Key Action
q Quit
Space Next page
/ Search

Displays the first lines of a file.

head logs.txt

Default:

First 10 lines

Custom amount:

head -20 logs.txt

tail

Displays the last lines of a file.

tail logs.txt

Extremely useful for logs.

Real-time log monitoring:

tail -f app.log

This continuously displays new log entries as they appear.

Very common in DevOps workflows.


Copying Files with cp

Copy a file:

cp file.txt backup.txt

Copy into another directory:

cp file.txt /home/john/backups

Copying Directories

Directories require recursive copying:

cp -r project backup-project

-r means:

recursive

Without it, Linux refuses to copy directories.


Moving Files with mv

Move a file:

mv file.txt documents/

Rename a file:

mv old.txt new.txt

Linux uses the same command for:

  • moving
  • renaming

because renaming is technically just moving within the filesystem.


Deleting Files with rm

Delete a file:

rm notes.txt

Delete directories recursively:

rm -r project

Force deletion:

rm -rf project

Breakdown:

Option Meaning
-r Recursive
-f Force

Why rm Is Dangerous

Unlike Windows:

Linux usually does not have a recycle bin in the terminal.

Once deleted:

rm file.txt

the file is often permanently gone.

This makes Linux extremely powerful — but also dangerous.


The Famous Dangerous Command

You may sometimes see:

rm -rf /

This attempts to recursively delete the entire filesystem.

Modern Linux systems include protections against this, but historically this command could completely destroy a system.

This demonstrates an important Linux concept:

Linux trusts the user.

With enough permissions, you can modify almost anything.


Wildcards

Wildcards allow pattern matching.

Example:

*.txt

matches:

notes.txt
report.txt
todo.txt

Common Wildcard Examples

Delete all log files:

rm *.log

List all JavaScript files:

ls *.js

Copy all text files:

cp *.txt backup/

Wildcards become extremely useful for automation.


Searching for Files with find

The find command searches the filesystem.

Example:

find /home -name notes.txt

Search for all log files:

find /var/log -name "*.log"

Search directories only:

find . -type d

Search files only:

find . -type f

Finding Executables with which

Displays the executable location of a command.

Example:

which docker

Output:

/usr/bin/docker

This helps explain how commands are discovered through the PATH variable.


File Permissions Preview

You already saw outputs like:

-rw-r--r--

These are Linux permissions.

They control:

  • who can read files
  • who can modify files
  • who can execute files

We will explore permissions deeply in the next chapter.


Understanding Ownership

Every Linux file belongs to:

  • a user
  • a group

Example:

-rw-r--r-- 1 john developers 1200 app.js
Part Meaning
john Owner
developers Group

Linux was designed as a multi-user operating system from the beginning.

Ownership is fundamental to system security.


Tab Completion

One of the most important terminal productivity features is:

Tab completion.

Example:

cd Doc[TAB]

may automatically complete:

cd Documents

This saves time and reduces typing errors.

Modern shells provide extremely advanced autocomplete systems.


Command History

Linux shells remember previously executed commands.

Use arrow keys:

↑ ↓

Search history:

history

Search interactively:

Ctrl + r

This becomes incredibly useful over time.


Real-World Example Workflow

Imagine creating a new project.


Create Project Structure

mkdir myapp
cd myapp
mkdir src
touch README.md
touch src/app.js

Result:

myapp/
├── README.md
└── src/
    └── app.js

Copy Files

cp README.md backup.md

Rename Files

mv backup.md old-readme.md

View Project Files

ls -la

Why Terminal File Management Matters

GUI file explorers are useful.

But terminal-based workflows become superior when:

  • managing servers
  • working remotely
  • automating tasks
  • handling large projects
  • writing scripts
  • working with DevOps tools

This is why Linux professionals spend so much time in the terminal.


The Bigger Picture

Commands like:

  • cd
  • ls
  • cp
  • mv
  • rm

may look simple.

But together they form the foundation of almost every Linux workflow.

Whether you are:

  • managing servers
  • deploying Docker containers
  • debugging infrastructure
  • writing automation scripts

you constantly interact with the filesystem.

Mastering navigation and file management is one of the most important Linux skills.


What Comes Next

In the next chapter, we will explore:

  • users
  • groups
  • file permissions
  • chmod
  • chown
  • sudo
  • Linux security basics

This is where Linux starts becoming much more powerful — and much more dangerous.