LARP it
Mission. The files you’re after are somewhere on this machine. Search the folders one by one, read what’s inside, and get back to where you started without getting lost.
ls
cd Desktop
pwd
ls -la
cd ..
pwd
cd ~
If Desktop doesn’t exist on your machine, pick any folder name that ls showed you.
Learn it
ls lists what’s in the current folder. Add flags after a dash to change how it works:
| Command | Shows |
|---|---|
ls |
names of files and folders |
ls -l |
a long list: permissions, owner, size, date changed |
ls -a |
all, including hidden files whose names start with . |
ls -la |
both at once: flags can be combined |
cd means change directory. It moves the shell into another folder. It prints
nothing when it works; run pwd to see where you landed.
A few names have special meanings:
.is the folder you’re in...is the folder one level up (the parent).~is your home folder.cdwith nothing after it also takes you home.
Paths. Desktop is a relative path: it’s looked up from where you are now. /Users/you/Desktop
(or /home/you/Desktop) is an absolute path: it starts at /, the top of the whole file
system, and works from anywhere.
If a folder name has a space in it, wrap it in quotes:
cd "My Projects". Or type the start and press Tab, and the shell adds the escaping for you.
Check it
- From your home folder, go into a folder, then into a folder inside it. Now get back home in one command.
- What’s the difference between
cd Desktopandcd /Desktop? (Try both.) - Run
ls -ain your home folder. Name one hidden file you didn’t know was there.