learn/phase-2/p2-w4/lesson 01
Week 4 · lesson 1

Linux: Files, Folders & Navigation

Hands-on. Live every command in the terminal beside you.

What you'll learn

  • Find out who and where you are: whoami, id, hostname, pwd.
  • List, read, and move around files: ls, cat, ~, cd.
  • Create and manage files: touch, cp, mv, rm, echo.

Linux: Files, Folders & Navigation

Almost every security tool runs on Linux, so being comfortable at the shell is non-negotiable. This lesson is pure muscle memory, run each command in the terminal on the right as you read.

Who and where am I?

whoami      # your username
id          # your user id, group id, and group memberships
hostname    # the machine's name
pwd         # print working directory (where you are now)

whoami answers "which account am I?". id goes further: it shows your numeric uid, your gid, and every group you belong to (groups decide what you can access).

Looking around

ls          # list files in the current folder
ls -la      # long format: permissions, owner, size, date  (and hidden files)
cat notes.md   # print a file's contents

The ~ symbol is shorthand for your home directory (/home/learner). cd ~ always takes you home.

Creating and managing files

touch report.txt          # create an empty file
echo "hello" > report.txt # write text into a file
cp report.txt copy.txt    # copy
mv copy.txt archive.txt   # move or rename
rm archive.txt            # remove (careful, there is no recycle bin)

echo simply prints its argument; combined with > it becomes a quick way to put text in a file.

A word of caution

rm deletes immediately and permanently, there is no "trash". In this sandbox nothing real is harmed, but build the habit now of reading an rm line twice before you run it.

Try it

Work top to bottom: whoami, id, pwd, ls, ls -la, cat readme.txt, then touch test.txt and rm test.txt. Every one responds in the terminal beside this lesson.

Check your understanding

3 questions

Type an answer and press Check. Grading is keyword-based and forgiving, so short answers are fine.

  1. 1

    Which single command creates an empty file called notes.txt?

  2. 2

    After running cp report.txt backup.txt, which new file exists in the directory?

  3. 3

    Which command prints the contents of readme.txt to the screen?