Terminal and commandsUnit 2 of 2
Beginner20 minIn reviewreview

Navigate and change virtual state

Use the current directory, paths and small reversible changes inside the safe simulator.

What you will learn
  • Use observation before modification.
  • Create a directory and file, then verify the changed virtual state.
Know this first
  • Terminal
  • Command
  • File
  • Folder
Start this unit
Last verifiedReview every 365 days
On this page

The safe command loop

Use the same loop whenever you meet a new command:

  1. Read the command name and arguments.
  2. Predict what it should observe or change.
  3. Run it in the intended location.
  4. Read the output.
  5. Verify the resulting state with another observation.

Current directory and relative path

The shell keeps a current directory. pwd prints it in this Linux-style exercise. ls lists names inside it. cd lab changes the current directory to a child named lab.

The command touch note.txt uses a relative path. It creates the file inside whichever directory is current at that moment.

Try the complete loop

TRY IT HERE

Create a folder, enter it and create one file.

Deterministic simulator: no real shell, network or access to your files.

Suggested sequence

$ …

What happened: The current directory changed; the file exists only inside the virtual filesystem.

What happened

mkdir lab changed virtual state by creating a directory. cd lab changed the shell's current location. touch note.txt created a file there. The final ls verified the result instead of assuming success.

Common mistakes

  • Reading output but not checking the resulting state.
  • Forgetting that a relative path depends on the current directory.
  • Treating clear as deletion; it clears the screen, not files or command history.

Mini challenge

Reset the practice. Create a directory named evidence, enter it and create first.txt. Predict the final path before running pwd.

Next stepContinue to Network foundations

You can now issue and verify a command; next you will use that skill to inspect how computers connect.