pwd, ls, and cd are the three commands you’ll type more than any others, ever.
The three you’ll never stop typing #
Think of these as one loop you run constantly:
pwdWhere am I?
↓
lsWhat’s here?
↓
cdTake me somewhere else.
pwd # print working directory
ls # list what's in it
ls -la # include hidden files + details
cd projects # move into a folder
cd .. # move up one level
cd ~ # jump home
cd - # jump back to the previous directory
Special paths worth memorizing #
| Symbol | Means |
|---|---|
. | Current directory |
.. | Parent directory |
~ | Home directory |
/ | Root directory |
Creating, copying, moving, deleting #
mkdir projects # create a directory
mkdir -p projects/app/config # -p creates any missing parents too
touch notes.txt # create an empty file (or bump its timestamp)
cp file.txt backup.txt # copy a file
cp -r project project-backup # copy a whole directory
mv file.txt documents/ # move a file
mv oldname.txt newname.txt # mv is also how you rename
rm notes.txt # delete a file
rm -rf projects # forcefully delete a folder + everything in it
Handle with care: Linux has no recycle bin for
rm. rm -rf / with the right (wrong) privileges is genuinely catastrophic. There is no “are you sure?” prompt coming to save you.