Skip to content

Navigate the Linux Shell and Work with Files: A Beginner Guide

Admin
October 4, 2026
6 min read
Beginner
💻 Target OS: Ubuntu 24.04+ / Debian 12+ / RHEL 9+

Before you begin

  • Applies to:Linux terminal basics for navigating directories and working with files.
  • Where to start:Open a terminal under your regular account. Start in the practice directory under your home folder.
  • What you need:Have write access to your home directory so you can create and edit the sample files.
Guide tools
Guide tools
0/0 Steps (0%)

The shell is a text interface for exploring and managing a Linux filesystem. A few commands—pwd, ls, and cd—help you understand where you are before you work with files. This tutorial uses a practice directory in your home folder so the examples do not alter system files.

Commands are case-sensitive. A path beginning with / starts at the filesystem root; a path beginning with ~ starts in your home directory. When a name contains spaces, put it in quotes.


01

Print the Working Directory and List Its Contents

Orientation

Use pwd to print the full path of the current directory. Use ls -lah to show normal and hidden entries, readable sizes, permissions, and ownership. Listing a path such as /etc does not change it.

Terminal window
pwd
ls -lah
ls -lah /etc
❯ Illustrative Output (Results Vary)
/home/sam
drwxr-x--- 8 sam sam 4.0K Oct 4 09:15 .
drwxr-xr-x 1 root root 4.0K Oct 1 08:00 ..

02

Use Absolute and Relative Paths

Navigation

cd changes the shell’s current directory. Use cd ~ to return to your home folder, cd .. to move up one level, and cd - to return to the previous location. A relative path is interpreted from the current directory.

Terminal window
cd /var/log &&
pwd &&
cd - &&
pwd &&
cd ~ &&
pwd
❯ Illustrative Output (Results Vary)
/var/log
/home/sam
/home/sam

03

Create Directories and Write a Small Text File

File Basics

Create a workspace under your home directory. The -p option makes any missing parent directories and does not complain if they already exist. printf writes the sample text into the file, replacing its contents if the file already exists.

Terminal window
mkdir -p ~/linux-basics-lab/reports
printf 'Daily report\nStatus: ready\n' > ~/linux-basics-lab/reports/status.txt
touch "$HOME/linux-basics-lab/project notes.txt"
❯ Illustrative Output (Results Vary)
The reports directory and status.txt are created under ~/linux-basics-lab.

04

Inspect Files Before and After a Copy or Move

File Operations

Use cp to make a copy and mv to rename or move an entry. Read a short file with cat; use less for longer files and press q to exit. List the directory after each operation to confirm the result.

Terminal window
cp ~/linux-basics-lab/reports/status.txt ~/linux-basics-lab/status-copy.txt
mv ~/linux-basics-lab/status-copy.txt ~/linux-basics-lab/status-final.txt
cat ~/linux-basics-lab/status-final.txt
ls -lah ~/linux-basics-lab ~/linux-basics-lab/reports
❯ Illustrative Output (Results Vary)
Daily report
Status: ready

Comments