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:
| Flag | Meaning |
|---|---|
-L | Logical โ use $PWD, following symlinks (default) |
-P | Physical โ 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
pwdis a built-in: Every shell implements it internally. The directory is the shell’s own state โ only the shell knows where it is. An externalpwdwould 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:
| Command | Goes to |
|---|---|
cd | Home directory |
cd ~ | Home directory |
cd /etc | Absolute path |
cd subdir | Relative to current |
cd .. | Parent directory |
cd ../.. | Two levels up |
cd - | Previous directory |
cd ~alice | Alice’s home |
cd -P /tmp/link | Physical 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
cdwithout arguments goes home: It’s the most common destination.cdalone is a shortcut forcd ~. 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:
| Flag | Effect |
|---|---|
-l | Long format |
-a | Show hidden files |
-h | Human-readable sizes |
-A | Hidden but not . and .. |
-R | Recursive |
-r | Reverse sort |
-t | Sort by modification time |
-S | Sort by size |
-i | Show inode numbers |
-d | Show directory itself, not contents |
-1 | One per line |
-F | Append type indicators |
-n | Numeric 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:
| Suffix | Type |
|---|---|
/ | 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
lsisn’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.pwdandcdare built-ins because the directory is the shell’s own state;lsreads 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 -lahshows everything you want to know about a directory at a glance. Knowing the flags is the difference between typinglsand re-typing it four times, and typingls -lahonce.
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
| Command | Output |
|---|---|
pwd | Current directory (logical) |
pwd -L | Logical path |
pwd -P | Physical path (symlinks resolved) |
cd
| Command | Goes to |
|---|---|
cd | Home |
cd ~ | Home |
cd ~user | User’s home |
cd /path | Absolute path |
cd path | Relative path |
cd .. | Parent |
cd ../.. | Two levels up |
cd - | Previous |
cd -P path | Physical path |
cd Variables
| Variable | Meaning |
|---|---|
$PWD | Current directory |
$OLDPWD | Previous directory |
$HOME | Home directory |
$CDPATH | Extra search paths |
ls Common Flags
| Flag | Effect |
|---|---|
-l | Long format |
-a | All files (including . ..) |
-A | All except . .. |
-h | Human-readable sizes |
-R | Recursive |
-r | Reverse sort |
-t | Sort by time |
-S | Sort by size |
-1 | One per line |
-F | Type indicators |
-d | Directory itself |
-i | Inode numbers |
-n | Numeric IDs |
ls -l Columns
| Position | Field |
|---|---|
| 1 | Type + permissions |
| 2 | Hard link count |
| 3 | Owner |
| 4 | Group |
| 5 | Size |
| 6โ8 | Modification time |
| 9 | Name |
File Type Characters
| Char | Type |
|---|---|
- | Regular file |
d | Directory |
l | Symlink |
b | Block device |
c | Character device |
s | Socket |
p | FIFO (pipe) |
Permission Triples
| Position | Applies to |
|---|---|
| 1โ3 | Owner |
| 4โ6 | Group |
| 7โ9 | Others |
Within each: r, w, x, -.
Type Indicators (-F)
| Indicator | Type |
|---|---|
/ | Directory |
* | Executable |
@ | Symlink |
| | FIFO |
= | Socket |
Combined Flags
| Flag | Meaning |
|---|---|
-lah | Long + all + human |
-ltr | Long + by time + reverse |
-lSh | Long + by size + human |
-RF | Recursive + type indicators |
Special Path Names
| Name | Meaning |
|---|---|
. | Current directory |
.. | Parent directory |
~ | Home directory |
~user | Another user’s home |
- | Previous directory |
/ | Root |
Path Forms
| Form | Example | Meaning |
|---|---|---|
| Absolute | /etc | From root |
| Relative | etc | From current |
| Home | ~/x | From home |
| Parent | ../x | From parent |
| Current | ./x | From current (explicit) |
Symbolic vs Hard Links
| Type | ls -l | Behavior |
|---|---|---|
| Symlink | l... | Points to another file |
| Hard link | -... | Another name for the same inode |
| Directory | d... | Contains other entries |
Permissions
| Symbol | Numeric | Meaning |
|---|---|---|
rwx | 7 | Full |
rw- | 6 | Read/write |
r-x | 5 | Read/execute |
r-- | 4 | Read only |
-wx | 3 | Write/execute |
-w- | 2 | Write only |
--x | 1 | Execute only |
--- | 0 | None |
Common Errors
| Error | Cause | Fix |
|---|---|---|
No such file or directory | Path doesn’t exist | Check spelling |
Not a directory | cd into a file | Use a directory |
Permission denied | No x on directory | Check perms |
Too many levels of symbolic links | Circular symlinks | Use -P |
When to Use Which ls
| Need | Command |
|---|---|
| Basic list | ls |
| See hidden | ls -a |
| Details | ls -l |
| Human sizes | ls -lh |
| Sort by time | ls -lt |
| Sort by size | ls -lS |
| Recursive | ls -R |
| One per line | ls -1 |
| Type marks | ls -F |
| A file, not contents | ls -l FILE |
Useful Combinations
| Command | Effect |
|---|---|
cd /etc && pwd && ls | Move, check, list |
cd - && pwd | Toggle and verify |
ls -lah ~ | Home in full detail |
ls -lt /var/log | head | Recent files |
ls -R /etc | head -20 | Recursive 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
| Pitfall | Problem | Solution |
|---|---|---|
Forgetting ./ | script.sh not found | ./script.sh |
cd fails silently | Stay in old directory | Check $? or use && |
| Hidden files missed | . files not shown | ls -a |
Parsing ls output | Breaks on spaces | Use globs or find |
| Symlink confusion | pwd vs pwd -P | Know which you need |
cd - surprising | Toggles both ways | Use consciously |
| Tab completion wrong | Ambiguous prefix | Press Tab twice |
| Wrong directory | rm in wrong place | pwd first |
| Permission denied | No x on directory | ls -ld to check |
| Locale sorting | Unexpected order | Set 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
| Command | Purpose |
|---|---|
pwd | Print current directory |
cd | Change directory |
ls | List directory contents |
cd - | Toggle to previous |
cd ~ | Go home |
cd .. | Go to parent |
ls -l | Long format |
ls -a | Show hidden files |
ls -lah | Long + all + human |
Key takeaways:
pwdprints the current working directory as an absolute pathpwd -Presolves symlinks; the default-Lreports the logical pathcdchanges the current directory โ to absolute or relative pathscdwith no arguments goes home;cd -toggles to the previous directorycd ~usergoes to another user’s homelslists directory contents; with a path argument, it lists that directoryls -lshows the long format โ permissions, owner, group, size, mtime, namels -ashows hidden files (including.and..);-Aexcludes those twols -hmakes sizes human-readablels -tsorts by modification time;ls -Sby sizels -Rlists recursivelyls -Fappends type indicators (/,*,@)- Special paths โ
.,..,~,-,/ - Absolute paths start with
/; relative paths don’t cdandpwdare built-ins โ they change shell statelsis 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!