The Shell & Filesystem
Navigate directories and work with files using pwd, ls, cd, cat, mkdir, and touch.
The shell is a text interface to your computer: you type a command, it runs, and it prints the result. Bash is the most common one. Everything starts with moving around the filesystem — a tree of directories (folders) and files.
This is a real (simulated) shell running in your browser. Type commands, or click
an example. Start with ls and cat readme.txt.
cs shell — type "help" to see commands.
learner@cs:~$
A simulated shell — supports pipes ( | ) and redirection ( > , >> ). Use ↑/↓ for history.
Where am I, and what’s here
pwd— print working directory: where you currently are.ls— list the contents of a directory.ls -lshows one per line;ls datalists another directory.cd <dir>— change directory. Special targets:..(up one level),~(home),/(root). Trycd data, thenpwd, thencd ...
Paths are either absolute (start at /, e.g. /home/learner) or relative
to where you are (e.g. data/fruits.txt).
Reading and making files
cat <file>— print a file’s contents. Trycat data/fruits.txt.mkdir <name>— make a new directory.touch <name>— create an empty file (or update its timestamp).mv/cp/rm— move, copy, remove. (rm -rremoves a directory.)
Everything you create lives until you press reset.
Takeaways
- The shell is a read-eval-print loop: type a command, see its output.
- The filesystem is a tree;
pwd,ls, andcdare how you move through it. - Paths are absolute (from
/) or relative (from your current directory).