This note summarizes the first layer of Linux shell fluency: locating yourself, moving through directories, listing files, and reading small text files.
Most command-line work starts with three questions:
- Where am I?
- What is here?
- What do I want to inspect or change?
The basic loop is:
pwd
ls
cd /path/to/directoryUse pwd to print the current working directory.
pwdThis is useful before running commands that read or write relative paths.
Common cd forms:
cd /absolute/path
cd relative/path
cd ..
cd ~
cd -Notes:
/absolute/pathstarts from the filesystem root.relative/pathstarts from the current directory...moves to the parent directory.~expands to the current user's home directory.-returns to the previous directory.
Common ls forms:
ls
ls -l
ls -a
ls -lh
ls -RUseful reading:
-lshows permissions, owner, group, size, and modification time.-aincludes dotfiles.-hmakes sizes human-readable when paired with-l.-Rrecursively lists subdirectories.
Use cat for short files:
cat notes.txtUse less for files that may be longer than the terminal:
less system.logInside less, /pattern searches forward and q quits.
Use more only when it is already available in a simple environment. less is usually the more practical pager.
Before changing files, run a quick context check:
pwd
ls -lahThis prevents many mistakes caused by assuming the wrong working directory.