Everything in Linux is organized as one big tree of files and folders. Learning to move around it quickly is the first skill you need before you can secure a machine. Practice every command in this course on your own practice VM, and take a snapshot first so you can roll back.

The directory tree

Linux has a single root, written /. Everything hangs off it. Unlike Windows there are no drive letters; extra disks are attached (“mounted”) somewhere inside the tree.

  • / is the root of the whole filesystem.
  • /home holds each regular user’s personal files, such as /home/alex.
  • /root is the home folder of the administrator account (root).
  • /etc holds system configuration files. In CyberPatriot you will edit files here constantly.
  • /var holds data that changes, especially logs in /var/log.
  • /bin, /usr/bin and /sbin hold programs.
  • /tmp is scratch space that anyone can write to.
  • /dev and /proc are special folders that represent hardware and running processes.

Paths come in two kinds. An absolute path starts at the root, like /etc/passwd. A relative path starts from where you are now, like Documents/notes.txt. Special shortcuts help: . means the current folder, .. means the parent folder, and ~ means your home folder.

Moving around and looking

These commands are the core of navigation. Try them in a terminal on your practice VM.

pwd              # print working directory: where am I?
ls               # list files here
ls -la           # long list, including hidden files, with permissions
cd /etc          # go to /etc
cd ..            # go up one level
cd ~             # go home
cd -             # go back to the previous folder

Files whose names begin with a dot, like .bashrc, are hidden. Plain ls will not show them, but ls -a will. Attackers and mistakes both like to hide in hidden files, so get used to checking.

Linux is case sensitive: Notes.txt and notes.txt are different files. Tab completion saves typing and mistakes: type the first few letters of a name and press Tab.

Working with files and finding things

mkdir projects            # make a folder
touch note.txt            # create an empty file
cp note.txt backup.txt    # copy
mv backup.txt old.txt     # move or rename
rm old.txt                # delete (there is no recycle bin!)
cat /etc/hostname         # show a file
less /var/log/syslog      # page through a long file (q to quit)

Be careful with rm: deleted files do not go to a trash can. Never run rm -r on a path you have not double-checked.

To find files, use find and grep:

find /home -name "*.mp3"          # find media files in home folders
find / -type f -size +100M 2>/dev/null   # find large files
grep -i "password" /etc/ssh/sshd_config  # search inside a file

CyberPatriot images often contain prohibited files such as unauthorized media or hacking tools in user folders. Knowing how to search the tree is how you find them. Always read your competition README first to learn what is allowed.

Getting help

Every command has a manual. Type man ls to read it (press q to quit), or run a command with --help. Reading the manual is a real skill, not a sign of weakness.

Check your understanding

1. Which directory mostly holds system configuration files?

  • /home
  • /etc
  • /tmp
  • /dev

Answer: /etc Configuration files for the system and most services live in /etc.

2. What does the command cd .. do?

  • Goes to your home folder
  • Goes to the root folder
  • Goes up one level to the parent folder
  • Lists hidden files

Answer: Goes up one level to the parent folder The .. shortcut always means the parent of the current directory.

3. Why does plain ls not show a file named .secret?

  • The file is encrypted
  • Names starting with a dot are hidden
  • You need root access
  • The file is empty

Answer: Names starting with a dot are hidden Use ls -a or ls -la to include hidden files.

4. Which is an absolute path?

  • Documents/notes.txt
  • ../notes.txt
  • /var/log/syslog
  • ~notes

Answer: /var/log/syslog Absolute paths begin at the root /, so they work from any location.