Skip to content
Laviyx Learn

Try

Linux and Bash course menu

Basic Linux Commands: pwd, ls, cd and Getting Help

Learn your first Linux commands: pwd, ls, cd, how commands, options and arguments work, listing hidden files, and getting help with man and --help.

Beginner6 min readUpdated
On this page

Where am I?#

pwd (print working directory) shows the folder you are in:

Terminal
pwd
Output
/home/asha

When you open a terminal, you start in your home folder.

What is here?#

ls lists the contents of a folder:

Terminal
ls
Output
docs
notes.txt
projects

Commands, options and arguments#

Most commands follow one pattern:

Text
command  -options  arguments
ls       -l        docs

An option changes how the command behaves, and an argument says what to work on.

Terminal
ls -l docs
Output
total 4
-rw-rw-r-- 1 asha asha 5 Nov  5 06:26 plan.txt

-l means the long format. The columns are the permissions, link count, owner, group, size in bytes, modification date, and name.

Options can be combined. -a also shows hidden files, whose names start with a dot, and -h prints sizes in a readable form:

Terminal
ls -lah
Output
total 36K
drwxr-x--- 4 asha asha 4.0K Nov  5 06:26 .
drwxr-xr-x 6 root root 4.0K Nov  5 06:22 ..
-rw-r--r-- 1 asha asha  220 Nov  5 06:26 .bash_logout
-rw-r--r-- 1 asha asha 3.7K Nov  5 06:26 .bashrc
-rw-rw-r-- 1 asha asha    7 Nov  5 06:26 .hidden
-rw-r--r-- 1 asha asha  807 Nov  5 06:26 .profile
drwxrwxr-x 2 asha asha 4.0K Nov  5 06:26 docs
-rw-rw-r-- 1 asha asha    6 Nov  5 06:26 notes.txt
drwxrwxr-x 4 asha asha 4.0K Nov  5 06:26 projects

. means the current folder, and .. means the parent folder.

CommandShows
ls -aHidden files too
ls -lDetails
ls -lhDetails with readable sizes
ls -tNewest first
ls -SLargest first
ls -RFolders inside folders

Moving around#

cd (change directory) moves you to another folder:

Terminal
cd projects/site
pwd
cd ..
pwd
cd ~
pwd
Output
/home/asha/projects/site
/home/asha/projects
/home/asha
CommandGoes to
cd folderA folder inside this one
cd ..The parent folder
cd ~ or just cdYour home folder
cd -The previous folder
cd /etcAn exact location

Getting help#

Nearly every command explains itself with --help:

Terminal
ls --help | head -n 4
Output
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

For the full manual, use man. Press q to leave, Space to go down a page, and / to search.

Terminal
man ls

type tells you what a name really is, and which shows where a program lives:

Terminal
type cd
which ls
Output
cd is a shell builtin
/usr/bin/ls

cd is built in to the shell, while ls is a program stored in a file.

A few useful commands#

Terminal
echo "Today is a good day"
date +%Y
uname -sm
Output
Today is a good day
2026
Linux x86_64

clear clears the screen, and history lists the commands you have typed.

Common mistakes#

Practice#

Practice exercise

From your home folder, go into docs, print the location, list the files, and go back.

Show solution
Terminal
cd docs
pwd
ls
cd -
Output
/home/asha/docs
plan.txt
/home/asha

cd - prints the folder it returns to.

Key takeaway#

Next: The Linux File System.

Finished this lesson?