| | |

LFCA 12 ๐Ÿง Basic Shell Navigation โ€” pwd, cd, ls

Three commands form the foundation of every Linux session: pwd tells you where you are, cd moves you somewhere else, and ls shows you what’s there. They’re the first commands anyone learns and the ones you’ll type most often. On their own they’re simple; with their options and combinations they cover the whole of interactive navigation. The LFCA exam expects you to know them cold โ€” the flags, the arguments, the special paths โ€” because everything else in a Linux system is reached by moving around with these three.

Key point: The Linux filesystem is a single tree. You are always at some directory, and pwd prints its absolute path. cd changes that location โ€” to a path, a parent, a home directory, or the previous directory. ls lists what’s inside the current or specified directory. Master these three and you can reach any file on the system; everything else โ€” finding, editing, running โ€” depends on getting there first.


pwd โ€” where am I

pwd prints the current working directory as an absolute path.

$ pwd
/home/alice

The output always starts with / โ€” it’s an absolute path from the root of the tree. That’s the location of your shell.

Why you need it: The shell tracks where you are, but the prompt doesn’t always show the full path. pwd tells you exactly.

Flags:

FlagMeaning
-LLogical โ€” use $PWD, following symlinks (default)
-PPhysical โ€” resolve all symlinks

The difference:

$ cd /var/log
$ pwd
/var/log

$ cd /tmp/link  # symlink to /var/log
$ pwd
/tmp/link        # logical

$ pwd -P
/var/log         # physical

-L reports the path you navigated; -P reports the real path after resolving symlinks. The default is -L.

Shell variables:

$ echo $PWD
/home/alice

$ echo $OLDPWD
/etc

$PWD tracks the current directory; $OLDPWD tracks the previous one. pwd and $PWD usually match, but pwd -P can differ.

Why the distinction matters: Symlinks make paths ambiguous. /tmp/link and /var/log might be the same directory. pwd -L reports what you typed; pwd -P reports the truth. For most purposes the default is fine; for scripts that must not be fooled, -P is safer.

Why pwd is a built-in: Every shell implements it internally. The directory is the shell’s own state โ€” only the shell knows where it is. An external pwd would report the directory where the process started, which is correct but slower and less consistent.


cd โ€” move around

cd changes the current working directory.

$ cd /etc
$ pwd
/etc

The shell updates its state and the next command runs from the new directory.

The forms of cd:

CommandGoes to
cdHome directory
cd ~Home directory
cd /etcAbsolute path
cd subdirRelative to current
cd ..Parent directory
cd ../..Two levels up
cd -Previous directory
cd ~aliceAlice’s home
cd -P /tmp/linkPhysical path

Absolute vs relative:

  • Absolute โ€” starts with /, from the root: cd /var/log
  • Relative โ€” starts with a name or ., from where you are: cd log, cd ./log, cd ../log
$ cd /home/alice       # absolute
$ cd Documents         # relative, from /home/alice
$ cd ..                # parent โ†’ /home/alice
$ cd ../bob            # sibling โ†’ /home/bob

Special directories:

  • . โ€” current directory
  • .. โ€” parent directory
  • ~ โ€” your home
  • ~user โ€” another user’s home
  • - โ€” previous directory

Using -:

$ cd /etc
$ cd /var/log
$ cd -
/etc

$ cd -
/var/log

cd - toggles between the current and previous directory. It also prints the path it switched to.

CDPATH: A variable that lists directories the shell checks for relative cd targets.

$ export CDPATH=/home:/etc
$ cd alice
/home/alice

Useful but rarely set. It can surprise you.

Failure:

$ cd /nonexistent
bash: cd: /nonexistent: No such file or directory

If the target doesn’t exist or isn’t a directory, cd fails and stays put.

Permissions: You need execute (x) permission on a directory to enter it. Read (r) permission to list its contents. Both to navigate and see what’s inside.

Why cd is a built-in: It changes the shell’s own state. An external cd would change the directory of a child process, which exits immediately โ€” the shell would be unaffected. The directory is per-process; only the shell can change its own.

Why cd without arguments goes home: It’s the most common destination. cd alone is a shortcut for cd ~. The designers assumed you’d want to go home more than anywhere else.


ls โ€” what’s here

ls lists directory contents.

$ ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos

The output is a set of names, sorted alphabetically, with columns if the terminal is wide enough.

Common flags:

FlagEffect
-lLong format
-aShow hidden files
-hHuman-readable sizes
-AHidden but not . and ..
-RRecursive
-rReverse sort
-tSort by modification time
-SSort by size
-iShow inode numbers
-dShow directory itself, not contents
-1One per line
-FAppend type indicators
-nNumeric UID/GID

The long format:

$ ls -l
total 48
drwxr-xr-x  2 alice alice 4096 Sep 22 10:30 Documents
-rw-r--r--  1 alice alice 1234 Sep 22 09:15 notes.txt
lrwxrwxrwx  1 alice alice    7 Sep 20 14:00 link -> /etc

Each line:

drwxr-xr-x  2 alice alice 4096 Sep 22 10:30 Documents
โ”‚โ””โ”ฌโ”˜โ””โ”ฌโ”˜โ””โ”ฌโ”˜  โ”‚  โ”‚    โ”‚     โ”‚    โ”‚         โ”‚
โ”‚ โ”‚  โ”‚  โ”‚   โ”‚  โ”‚    โ”‚     โ”‚    โ”‚         โ”” name
โ”‚ โ”‚  โ”‚  โ”‚   โ”‚  โ”‚    โ”‚     โ”‚    โ”” modification time
โ”‚ โ”‚  โ”‚  โ”‚   โ”‚  โ”‚    โ”‚     โ”” size in bytes
โ”‚ โ”‚  โ”‚  โ”‚   โ”‚  โ”‚    โ”” group
โ”‚ โ”‚  โ”‚  โ”‚   โ”‚  โ”” owner
โ”‚ โ”‚  โ”‚  โ”‚   โ”” hard link count
โ”‚ โ”‚  โ”‚  โ”” others' permissions
โ”‚ โ”‚  โ”” group's permissions
โ”‚ โ”” owner's permissions
โ”” type: d=dir, -=file, l=symlink, b=block, c=char

Permissions in the long format:

  • First character: file type
  • Next three: owner (rwx)
  • Next three: group (rwx)
  • Last three: others (rwx)

r = read, w = write, x = execute, - = not granted.

Hidden files: Files starting with . are hidden. Use -a to show them.

$ ls
Documents  notes.txt

$ ls -a
.  ..  .bashrc  .config  Documents  notes.txt

-a includes . and ... -A includes hidden files but excludes those two.

Combining flags:

$ ls -lah
drwxr-xr-x  5 alice alice 4.0K Sep 22 10:30 .
drwxr-xr-x 20 root  root  4.0K Sep 22 09:00 ..
-rw-r--r--  1 alice alice  123 Sep 22 09:15 notes.txt

The most common combination is ls -lah โ€” long, all, human-readable.

Sorting:

$ ls -t        # newest first
$ ls -S        # largest first
$ ls -r        # reverse alphabetical
$ ls -lt       # long, by time
$ ls -lS       # long, by size

Listing a specific directory:

$ ls /etc
$ ls ~/Documents
$ ls ../other

Without an argument, ls lists the current directory.

Multiple directories:

$ ls /etc /var
/etc:
...

/var:
...

ls groups the output by directory.

The type indicator โ€” -F:

SuffixType
/Directory
*Executable
@Symlink
|FIFO
=Socket
$ ls -F
Documents/  script.sh*  link@  notes.txt

Why ls matters: It’s how you see what’s on the system. Every task โ€” reading a file, running a program, finding a directory โ€” starts with knowing what’s there. The flags cover every way you might want to look: sorted, filtered, detailed, or compact.

Why ls isn’t a built-in on most shells: It doesn’t change shell state, so it can be a standalone program. Making it external means one canonical implementation, and scripts behave the same across shells. pwd and cd are built-ins because the directory is the shell’s own state; ls reads the filesystem and exits.


Combining navigation

The three commands work together.

Moving and checking:

$ cd /var/log
$ pwd
/var/log
$ ls
apt  auth.log  dpkg.log  syslog

Jumping around and going back:

$ cd /etc
$ cd /var/log
$ cd -
/etc
$ cd -
/var/log

Going up multiple levels:

$ pwd
/home/alice/projects/web/src
$ cd ../../..
$ pwd
/home

Using .. in commands:

$ ls ../sibling
$ cat ../../notes.txt

Relative paths work in any command, not just cd.

One-liners:

$ cd /etc && pwd && ls
/etc
adduser.conf  apt  bash.bashrc  ...

&& chains commands โ€” run the next only if the previous succeeded.

Why the combination matters: Navigation isn’t just moving โ€” it’s moving and verifying and seeing. cd to a directory, pwd to confirm, ls to inspect. That loop is the foundation of every session.

Why learn the flags: The bare commands are simple. The flags are what make them useful โ€” ls -lah shows everything you want to know about a directory at a glance. Knowing the flags is the difference between typing ls and re-typing it four times, and typing ls -lah once.


A full example

A session navigating the filesystem.

# ============================================
# PART 1: START
# ============================================

pwd
# /home/alice

ls
# Desktop  Documents  Downloads  Music  Pictures

# ============================================
# PART 2: GO SOMEWHERE
# ============================================

cd /etc
pwd
# /etc

ls | head -5
# adduser.conf
# alternatives
# apt
# bash.bashrc
# bindresvport.blacklist

# ============================================
# PART 3: GO BACK
# ============================================

cd -
# /home/alice

# ============================================
# PART 4: HIDDEN FILES
# ============================================

ls
# Desktop  Documents  Downloads

ls -a
# .  ..  .bash_history  .bashrc  .config  Desktop  Documents  Downloads

# ============================================
# PART 5: LONG FORMAT
# ============================================

ls -l
# total 32
# drwxr-xr-x 2 alice alice 4096 Sep 22 10:30 Desktop
# drwxr-xr-x 2 alice alice 4096 Sep 22 10:30 Documents
# drwxr-xr-x 2 alice alice 4096 Sep 22 10:30 Downloads

ls -lah
# total 64K
# drwxr-xr-x 8 alice alice 4.0K Sep 22 10:30 .
# drwxr-xr-x 3 root  root  4.0K Sep 20 09:00 ..
# -rw-r--r-- 1 alice alice  220 Sep 20 09:00 .bash_logout
# -rw-r--r-- 1 alice alice 3.7K Sep 20 09:00 .bashrc
# drwxr-xr-x 2 alice alice 4.0K Sep 22 10:30 Desktop
# ...

# ============================================
# PART 6: SPECIFIC DIRECTORIES
# ============================================

ls /var/log
# apt  auth.log  dpkg.log  syslog

ls ~/Documents
# report.pdf  notes.txt

ls /etc/passwd
# /etc/passwd
# (a file, not a directory)

# ============================================
# PART 7: SORTING
# ============================================

ls -lt /etc | head -5
# (newest files first)

ls -lS /var/log | head -5
# (largest first)

# ============================================
# PART 8: RECURSIVE
# ============================================

ls -R /etc/apt
# /etc/apt:
# apt.conf.d  preferences.d  sources.list  sources.list.d  trusted.gpg.d
#
# /etc/apt/apt.conf.d:
# 01autoremove  20packagekit  70debconf  ...
#
# /etc/apt/sources.list.d:
# ...

# ============================================
# PART 9: TYPE INDICATORS
# ============================================

ls -F /usr/bin | head -5
# 2to3*  aclocal*  addpart*  ...
#       โ†‘ executables

ls -F /etc | head -5
# adduser.conf  alternatives/  apt/  ...
#                             โ†‘ directories

# ============================================
# PART 10: PATH NAVIGATION
# ============================================

cd /var/log
cd ../..
pwd
# /var

cd ../home
pwd
# /home

cd alice
pwd
# /home/alice

cd ~
pwd
# /home/alice

Each part exercises a different aspect: pwd, cd, ls with flags, sorting, recursion, type indicators, and path navigation.

Why this session: It’s the workflow you’ll run constantly โ€” checking where you are, moving, listing, listing in detail, sorting. Once these are muscle memory, every other Linux command has context.


Complete Example Session

# ============================================
# PART 1: INITIAL STATE
# ============================================

whoami
# [ alice ]

pwd
# [ /home/alice ]

echo $HOME
# [ /home/alice ]

echo $PWD
# [ /home/alice ]

echo $OLDPWD
# [ (empty on first session) ]

# ============================================
# PART 2: BASIC LS
# ============================================

ls
# [ Desktop  Documents  Downloads  Music  Pictures ]

ls -1
# [ Desktop ]
# [ Documents ]
# [ Downloads ]
# [ Music ]
# [ Pictures ]

ls -F
# [ Desktop/  Documents/  Downloads/  Music/  Pictures/ ]

# ============================================
# PART 3: HIDDEN AND LONG
# ============================================

ls -a
# [ .  ..  .bash_history  .bashrc  .config ]
# [ .local  .profile  Desktop  Documents  Downloads ]

ls -l
# [ total 32 ]
# [ drwxr-xr-x 2 alice alice 4096 Sep 22 10:30 Desktop ]
# [ drwxr-xr-x 2 alice alice 4096 Sep 22 10:30 Documents ]
# [ ... ]

ls -lah
# [ total 64K ]
# [ drwxr-xr-x 8 alice alice 4.0K Sep 22 10:30 . ]
# [ drwxr-xr-x 3 root  root  4.0K Sep 20 09:00 .. ]
# [ -rw-r--r-- 1 alice alice  220 Sep 20 09:00 .bash_logout ]
# [ -rw-r--r-- 1 alice alice 3.7K Sep 20 09:00 .bashrc ]

# ============================================
# PART 4: CD BASICS
# ============================================

cd /etc
pwd
# [ /etc ]

cd /var/log
pwd
# [ /var/log ]

cd -
# [ /etc ]

cd -
# [ /var/log ]

# ============================================
# PART 5: RELATIVE PATHS
# ============================================

pwd
# [ /var/log ]

cd ..
pwd
# [ /var ]

cd ..
pwd
# [ / ]

cd home
pwd
# [ /home ]

cd alice
pwd
# [ /home/alice ]

# ============================================
# PART 6: SPECIAL PATHS
# ============================================

cd ~
pwd
# [ /home/alice ]

cd ~root
pwd
# [ /root ]

cd
pwd
# [ /home/alice ]

cd /tmp
cd ..
pwd
# [ / ]

# ============================================
# PART 7: LS ON DIRECTORIES
# ============================================

ls /etc
# [ adduser.conf  alternatives  apt  bash.bashrc  ... ]

ls -l /var/log | head -5
# [ total 1234 ]
# [ drwxr-xr-x 2 root root 4096 Sep 20 09:00 apt ]
# [ -rw-r----- 1 root adm  1234 Sep 22 10:30 auth.log ]

ls /etc/passwd
# [ /etc/passwd ]

ls -lh /etc/passwd
# [ -rw-r--r-- 1 root root 3.1K Sep 15 14:22 /etc/passwd ]

# ============================================
# PART 8: SORTING AND FILTERING
# ============================================

ls -lt /var/log | head -5
# (newest first)

ls -lS /var/log | head -5
# (largest first)

ls -1 /etc | wc -l
# [ (number of entries) ]

# ============================================
# PART 9: TYPE INDICATORS
# ============================================

ls -F /usr/bin | head -3
# [ 2to3*  aclocal*  addpart* ]
#    โ†‘ executables

ls -F /etc | head -3
# [ adduser.conf  alternatives/  apt/ ]
#                             โ†‘ directories

# ============================================
# PART 10: LS SPECIFIC PATTERNS
# ============================================

ls /etc/*.conf
# [ adduser.conf  ca-certificates.conf  ... ]

ls ~/.[a-z]*
# (hidden files starting with a letter)

ls -d /etc/apt
# [ /etc/apt ]
# (directory itself, not contents)

# ============================================
# PART 11: COMBINED
# ============================================

cd /var/log && pwd && ls -lah | head -5
# [ /var/log ]
# [ total 1234K ]
# [ drwxr-xr-x  8 root root 4.0K Sep 22 10:30 . ]
# [ ... ]

# ============================================
# PART 12: RECAP
# ============================================

cd ~
pwd
# [ /home/alice ]

ls -la
# (full listing of home)

Every part exercises a navigation concept. Together they cover the full range of pwd, cd, and ls.


Quick Reference

pwd

CommandOutput
pwdCurrent directory (logical)
pwd -LLogical path
pwd -PPhysical path (symlinks resolved)

cd

CommandGoes to
cdHome
cd ~Home
cd ~userUser’s home
cd /pathAbsolute path
cd pathRelative path
cd ..Parent
cd ../..Two levels up
cd -Previous
cd -P pathPhysical path

cd Variables

VariableMeaning
$PWDCurrent directory
$OLDPWDPrevious directory
$HOMEHome directory
$CDPATHExtra search paths

ls Common Flags

FlagEffect
-lLong format
-aAll files (including . ..)
-AAll except . ..
-hHuman-readable sizes
-RRecursive
-rReverse sort
-tSort by time
-SSort by size
-1One per line
-FType indicators
-dDirectory itself
-iInode numbers
-nNumeric IDs

ls -l Columns

PositionField
1Type + permissions
2Hard link count
3Owner
4Group
5Size
6โ€“8Modification time
9Name

File Type Characters

CharType
-Regular file
dDirectory
lSymlink
bBlock device
cCharacter device
sSocket
pFIFO (pipe)

Permission Triples

PositionApplies to
1โ€“3Owner
4โ€“6Group
7โ€“9Others

Within each: r, w, x, -.

Type Indicators (-F)

IndicatorType
/Directory
*Executable
@Symlink
|FIFO
=Socket

Combined Flags

FlagMeaning
-lahLong + all + human
-ltrLong + by time + reverse
-lShLong + by size + human
-RFRecursive + type indicators

Special Path Names

NameMeaning
.Current directory
..Parent directory
~Home directory
~userAnother user’s home
-Previous directory
/Root

Path Forms

FormExampleMeaning
Absolute/etcFrom root
RelativeetcFrom current
Home~/xFrom home
Parent../xFrom parent
Current./xFrom current (explicit)

Symbolic vs Hard Links

Typels -lBehavior
Symlinkl...Points to another file
Hard link-...Another name for the same inode
Directoryd...Contains other entries

Permissions

SymbolNumericMeaning
rwx7Full
rw-6Read/write
r-x5Read/execute
r--4Read only
-wx3Write/execute
-w-2Write only
--x1Execute only
---0None

Common Errors

ErrorCauseFix
No such file or directoryPath doesn’t existCheck spelling
Not a directorycd into a fileUse a directory
Permission deniedNo x on directoryCheck perms
Too many levels of symbolic linksCircular symlinksUse -P

When to Use Which ls

NeedCommand
Basic listls
See hiddenls -a
Detailsls -l
Human sizesls -lh
Sort by timels -lt
Sort by sizels -lS
Recursivels -R
One per linels -1
Type marksls -F
A file, not contentsls -l FILE

Useful Combinations

CommandEffect
cd /etc && pwd && lsMove, check, list
cd - && pwdToggle and verify
ls -lah ~Home in full detail
ls -lt /var/log | headRecent files
ls -R /etc | head -20Recursive preview
find . -type f(alternative to ls -R)

Best Practices

โœ… Do This:

# Check where you are before acting
pwd                                               # โœ…

# Use absolute paths in scripts
cd /var/log                                       # โœ…

# Use ~ for home
cd ~/projects                                     # โœ…

# Use cd - to toggle
cd /etc
cd -
cd -                                              # โœ…

# Use ls -lah as your default detailed view
ls -lah                                           # โœ…

# Use -t to see recently modified
ls -lt | head                                     # โœ…

# Quote paths with spaces
cd "My Documents"                                 # โœ…

# Use tab completion
cd /u<Tab>/l<Tab>                                 # โœ…

# Verify with pwd after a cd
cd /var
pwd                                               # โœ…

# Use -1 for scripting
ls -1 | while read f; do ...; done                # โœ…

โŒ Don’t Do This:

# Don't use ls to find files in scripts
for f in $(ls); do ...; done  # use globs             # โš ๏ธ

# Don't parse ls output
ls | grep ...  # filenames with spaces break           # โš ๏ธ

# Don't cd without checking
cd /path/to/something  # if it fails, you stay put     # โš ๏ธ

# Don't rely on cd affect caller in scripts
# Script runs in a subshell                            # โŒ

# Don't assume ls is sorted by name
ls  # locale-dependent                                  # โš ๏ธ

# Don't use ls -a in scripts without accounting for . and ..
# Use -A instead                                          # โš ๏ธ

# Don't forget . for current directory
./script.sh  # needed to run from current dir          # โœ…

# Don't use .. without care in scripts
cd .. # context-dependent                               # โš ๏ธ

# Don't ignore permissions
ls -l # read the permissions                            # โœ…

Common Pitfalls

PitfallProblemSolution
Forgetting ./script.sh not found./script.sh
cd fails silentlyStay in old directoryCheck $? or use &&
Hidden files missed. files not shownls -a
Parsing ls outputBreaks on spacesUse globs or find
Symlink confusionpwd vs pwd -PKnow which you need
cd - surprisingToggles both waysUse consciously
Tab completion wrongAmbiguous prefixPress Tab twice
Wrong directoryrm in wrong placepwd first
Permission deniedNo x on directoryls -ld to check
Locale sortingUnexpected orderSet LC_ALL=C

Real-World Examples

1. Where am I?

pwd

2. What’s here?

ls

3. Detailed listing

ls -lah

4. Hidden files

ls -a

5. Go home

cd

6. Go to a specific path

cd /etc/nginx

7. Go up one level

cd ..

8. Go up several

cd ../../..

9. Toggle back

cd -

10. Go to another user’s home

cd ~alice

11. List a directory

ls /var/log

12. Sort by time

ls -lt

13. Sort by size

ls -lS

14. Recursive

ls -R /etc/apt

15. Type indicators

ls -F

16. One per line

ls -1

17. Info about a file

ls -lh /etc/passwd

18. Directory itself

ls -ld /var/log

19. Combine and chain

cd /var && pwd && ls -lah

20. Recent files in a directory

ls -lt /var/log | head -10

Visual: The Path

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  /                                           โ”‚
โ”‚  โ”œโ”€โ”€ home/                                   โ”‚
โ”‚  โ”‚   โ”œโ”€โ”€ alice/    โ† $HOME for alice         โ”‚
โ”‚  โ”‚   โ”‚   โ”œโ”€โ”€ Documents/                      โ”‚
โ”‚  โ”‚   โ”‚   โ””โ”€โ”€ Downloads/                      โ”‚
โ”‚  โ”‚   โ””โ”€โ”€ bob/                                โ”‚
โ”‚  โ”œโ”€โ”€ etc/                                    โ”‚
โ”‚  โ”‚   โ”œโ”€โ”€ passwd                              โ”‚
โ”‚  โ”‚   โ””โ”€โ”€ hosts                               โ”‚
โ”‚  โ””โ”€โ”€ var/                                    โ”‚
โ”‚      โ””โ”€โ”€ log/                                โ”‚
โ”‚          โ”œโ”€โ”€ syslog                          โ”‚
โ”‚          โ””โ”€โ”€ auth.log                        โ”‚
โ”‚                                              โ”‚
โ”‚  From /home/alice:                           โ”‚
โ”‚  โ”œโ”€โ”€ pwd โ†’ /home/alice                       โ”‚
โ”‚  โ”œโ”€โ”€ cd .. โ†’ /home                           โ”‚
โ”‚  โ”œโ”€โ”€ cd ~/Documents โ†’ /home/alice/Documents  โ”‚
โ”‚  โ”œโ”€โ”€ cd /var/log โ†’ /var/log                  โ”‚
โ”‚  โ””โ”€โ”€ cd - โ†’ /home/alice/Documents            โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Visual: ls -l Breakdown

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  drwxr-xr-x  2 alice alice 4096 Sep 22 10:30 Documentsโ”‚
โ”‚  โ”‚โ””โ”€โ”ฌโ”˜โ””โ”€โ”ฌโ”˜โ””โ”€โ”ฌโ”˜ โ”‚  โ”‚    โ”‚     โ”‚    โ”‚         โ”‚        โ”‚
โ”‚  โ”‚  โ”‚   โ”‚   โ”‚  โ”‚  โ”‚    โ”‚     โ”‚    โ”‚         โ”‚        โ”‚
โ”‚  โ”‚  โ”‚   โ”‚   โ”‚  โ”‚  โ”‚    โ”‚     โ”‚    โ”‚         โ”‚        โ”‚
โ”‚  โ”‚  โ”‚   โ”‚   โ”‚  โ”‚  โ”‚    โ”‚     โ”‚    โ”‚         โ”” name   โ”‚
โ”‚  โ”‚  โ”‚   โ”‚   โ”‚  โ”‚  โ”‚    โ”‚     โ”‚    โ”” mtime           โ”‚
โ”‚  โ”‚  โ”‚   โ”‚   โ”‚  โ”‚  โ”‚    โ”‚     โ”” size                โ”‚
โ”‚  โ”‚  โ”‚   โ”‚   โ”‚  โ”‚  โ”‚    โ”” group                     โ”‚
โ”‚  โ”‚  โ”‚   โ”‚   โ”‚  โ”‚  โ”” owner                          โ”‚
โ”‚  โ”‚  โ”‚   โ”‚   โ”‚  โ”” links                             โ”‚
โ”‚  โ”‚  โ”‚   โ”‚   โ”” others                              โ”‚
โ”‚  โ”‚  โ”‚   โ”” group                                   โ”‚
โ”‚  โ”‚  โ”” owner                                       โ”‚
โ”‚  โ”” type                                            โ”‚
โ”‚                                                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Visual: Permissions

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  rwxr-xr-x                                   โ”‚
โ”‚  โ”€โ”ฌโ”€โ”€โ”ฌโ”€โ”€โ”ฌโ”€                                   โ”‚
โ”‚   โ”‚  โ”‚  โ”‚                                    โ”‚
โ”‚   โ”‚  โ”‚  โ”” others                             โ”‚
โ”‚   โ”‚  โ”‚     r-x โ†’ read + execute              โ”‚
โ”‚   โ”‚  โ”‚                                        โ”‚
โ”‚   โ”‚  โ”” group                                 โ”‚
โ”‚   โ”‚     r-x โ†’ read + execute                 โ”‚
โ”‚   โ”‚                                          โ”‚
โ”‚   โ”” owner                                    โ”‚
โ”‚      rwx โ†’ read + write + execute            โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Octal:  r=4  w=2  x=1                       โ”‚
โ”‚                                              โ”‚
โ”‚  rwx = 4+2+1 = 7                             โ”‚
โ”‚  r-x = 4+0+1 = 5                             โ”‚
โ”‚  r-- = 4+0+0 = 4                             โ”‚
โ”‚  --- = 0                                     โ”‚
โ”‚                                              โ”‚
โ”‚  rwxr-xr-x = 755                             โ”‚
โ”‚  rw-r--r-- = 644                             โ”‚
โ”‚  rwx------ = 700                             โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Visual: Path Forms

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Absolute       /var/log/syslog              โ”‚
โ”‚                 โ”” starts from /              โ”‚
โ”‚                                              โ”‚
โ”‚  Relative       logs/syslog                  โ”‚
โ”‚                 โ”” from current directory     โ”‚
โ”‚                                              โ”‚
โ”‚  Home           ~/projects                   โ”‚
โ”‚                 โ”” from $HOME                 โ”‚
โ”‚                                              โ”‚
โ”‚  Current        ./script.sh                  โ”‚
โ”‚                 โ”” from current directory     โ”‚
โ”‚                                              โ”‚
โ”‚  Parent         ../sibling/file              โ”‚
โ”‚                 โ”” up one, then down          โ”‚
โ”‚                                              โ”‚
โ”‚  Previous       -                            โ”‚
โ”‚                 โ”” cd - only                  โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Visual: cd - Toggle

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  $ cd /etc                                   โ”‚
โ”‚  $ cd /var/log                               โ”‚
โ”‚                                              โ”‚
โ”‚  Current:  /var/log                          โ”‚
โ”‚  Previous: /etc                              โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ”‚
                  โ”‚  cd -
                  โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Current:  /etc                              โ”‚
โ”‚  Previous: /var/log                          โ”‚
โ”‚                                              โ”‚
โ”‚  (swapped)                                   โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ”‚
                  โ”‚  cd -
                  โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Current:  /var/log                          โ”‚
โ”‚  Previous: /etc                              โ”‚
โ”‚                                              โ”‚
โ”‚  (back to the start)                         โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Visual: Symlinks and pwd

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  /tmp/link  โ”€โ”€โ–บ /var/log                     โ”‚
โ”‚                                              โ”‚
โ”‚  $ cd /tmp/link                              โ”‚
โ”‚  $ pwd                                       โ”‚
โ”‚  /tmp/link      (logical)                    โ”‚
โ”‚                                              โ”‚
โ”‚  $ pwd -P                                    โ”‚
โ”‚  /var/log       (physical)                   โ”‚
โ”‚                                              โ”‚
โ”‚  $ ls                                        โ”‚
โ”‚  (contents of /var/log)                      โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Visual: ls -a vs ls -A

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  $ ls                                        โ”‚
โ”‚  Documents  Downloads  notes.txt             โ”‚
โ”‚  (no hidden files)                           โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  $ ls -a                                     โ”‚
โ”‚  .  ..  .bashrc  .config  Documents  notes.txtโ”‚
โ”‚  (includes . and ..)                         โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  $ ls -A                                     โ”‚
โ”‚  .bashrc  .config  Documents  notes.txt      โ”‚
โ”‚  (hidden files, no . or ..)                  โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Visual: ls -F Markers

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Documents/    โ† directory                   โ”‚
โ”‚  script.sh*    โ† executable                  โ”‚
โ”‚  link@         โ† symlink                     โ”‚
โ”‚  notes.txt     โ† regular file                โ”‚
โ”‚  socket=       โ† socket                      โ”‚
โ”‚  pipe|         โ† FIFO                        โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Visual: Where pwd, cd, ls Fit

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  You are here โ”€โ”€โ–บ pwd                        โ”‚
โ”‚                                              โ”‚
โ”‚  Move to โ”€โ”€โ–บ cd PATH                         โ”‚
โ”‚                                              โ”‚
โ”‚  Look around โ”€โ”€โ–บ ls [PATH]                   โ”‚
โ”‚                                              โ”‚
โ”‚  Loop:                                       โ”‚
โ”‚    pwd โ†’ where am I?                         โ”‚
โ”‚    cd โ†’ go somewhere                         โ”‚
โ”‚    ls โ†’ what's here?                         โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Visual: Decision Flow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Need to know where you are?                 โ”‚
โ”‚       โ””โ”€โ”€ pwd                                โ”‚
โ”‚                                              โ”‚
โ”‚  Need to move?                               โ”‚
โ”‚       โ”œโ”€โ”€ Home โ”€โ”€โ–บ cd                        โ”‚
โ”‚       โ”œโ”€โ”€ Specific path โ”€โ”€โ–บ cd PATH          โ”‚
โ”‚       โ”œโ”€โ”€ Parent โ”€โ”€โ–บ cd ..                   โ”‚
โ”‚       โ”œโ”€โ”€ Previous โ”€โ”€โ–บ cd -                  โ”‚
โ”‚       โ””โ”€โ”€ User home โ”€โ”€โ–บ cd ~user             โ”‚
โ”‚                                              โ”‚
โ”‚  Need to see files?                          โ”‚
โ”‚       โ”œโ”€โ”€ Basic โ”€โ”€โ–บ ls                       โ”‚
โ”‚       โ”œโ”€โ”€ Hidden โ”€โ”€โ–บ ls -a                   โ”‚
โ”‚       โ”œโ”€โ”€ Detail โ”€โ”€โ–บ ls -l                   โ”‚
โ”‚       โ”œโ”€โ”€ By time โ”€โ”€โ–บ ls -lt                 โ”‚
โ”‚       โ”œโ”€โ”€ By size โ”€โ”€โ–บ ls -lS                 โ”‚
โ”‚       โ””โ”€โ”€ Recursive โ”€โ”€โ–บ ls -R                โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Summary

CommandPurpose
pwdPrint current directory
cdChange directory
lsList directory contents
cd -Toggle to previous
cd ~Go home
cd ..Go to parent
ls -lLong format
ls -aShow hidden files
ls -lahLong + all + human

Key takeaways:

  • pwd prints the current working directory as an absolute path
  • pwd -P resolves symlinks; the default -L reports the logical path
  • cd changes the current directory โ€” to absolute or relative paths
  • cd with no arguments goes home; cd - toggles to the previous directory
  • cd ~user goes to another user’s home
  • ls lists directory contents; with a path argument, it lists that directory
  • ls -l shows the long format โ€” permissions, owner, group, size, mtime, name
  • ls -a shows hidden files (including . and ..); -A excludes those two
  • ls -h makes sizes human-readable
  • ls -t sorts by modification time; ls -S by size
  • ls -R lists recursively
  • ls -F appends type indicators (/, *, @)
  • Special paths โ€” ., .., ~, -, /
  • Absolute paths start with /; relative paths don’t
  • cd and pwd are built-ins โ€” they change shell state
  • ls is an external command โ€” it reads the filesystem and exits

Remember: pwd, cd, and ls are the first three commands anyone learns and the ones you’ll use for the rest of your career. pwd answers “where am I?” cd answers “how do I get there?” ls answers “what’s here?” With their flags they cover every interactive navigation need. Learn them cold โ€” the options, the special paths, the difference between -a and -A, between absolute and relative โ€” and every other Linux command becomes reachable. These three are the entry point to the entire filesystem.


Stop using slow, ad-bloated tool sites! ๐Ÿคฎ

๐Ÿ”Ž Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
โœ… Finance (Mortgage, Interest, Inflation)
โœ… Tech (Base64, JSON, Dev Suite, IP)
โœ… Health (BMI, BMR, TDEE)
โœ… Productivity (Timer, Workspace, QR)

โšก๏ธ Fast & Private
๐Ÿ”’ No data leaves your device
๐Ÿ’Ž 100% Free

๐Ÿ”— Use it now: https://tools.kandz.me
๐Ÿ”– Bookmark itโ€”youโ€™ll need it later!