RedTeam Nexus Labs
Module 02 · Lesson 06 // Filesystem

files/directories

Filesystem · Linux

Freereading · 10 min
On this page
LESSON

Overview

Beyond ordinary files and folders, Linux has several file types, and it treats directories themselves as a special kind of file. Knowing the types you will encounter — and the basic operations on them — rounds out your understanding of the filesystem. This lesson covers files and directories in Linux.

Learning objectives

  • Identify the common Linux file types.
  • Distinguish files from directories structurally.
  • Use core file/directory operations safely.

Core concept

In Linux, directories are a special file type that contain references to other files. The ls -l listing shows a file's type in the first character:

  • - — a regular file (text, binary, image, etc.).
  • d — a directory.
  • l — a symbolic link.
  • c / b — character/block device files.
  • p, s — named pipes and sockets.

Filenames are case-sensitive (File and file differ), and files whose names begin with a dot (.bashrc) are hidden by default.

How it works

The first character of an ls -l line reveals the type, and the rest of the line shows permissions, owner, size, and modification time. Core operations apply across types: touch creates an empty file, mkdir creates a directory, cp copies, mv moves or renames, and rm removes (with rm -r for directories). Because removal is immediate and permanent, these operations — especially recursive rm — must be used carefully.

Practical example

$ ls -l
drwxr-xr-x 2 alice alice 4096 Sep 21 10:00 projects
-rw-r--r-- 1 alice alice  128 Sep 21 09:30 notes.txt
lrwxrwxrwx 1 alice alice    8 Sep 21 09:31 shortcut -> notes.txt

The leading d marks projects as a directory, - marks notes.txt as a regular file, and l marks shortcut as a symbolic link pointing to notes.txt. The type is readable at a glance from that first character.

Cybersecurity relevance

Recognizing file types is practical for security tasks: spotting a symbolic link matters because links can point elsewhere (relevant to certain attacks and to careful file handling), and identifying device or special files helps you understand a system. Hidden dotfiles frequently store configuration and secrets, so enumeration must include them (ls -a). Safe use of destructive operations (rm -r) prevents accidental loss during administration or testing.

Common mistakes

  • Overlooking file type — the first ls -l character tells you what you are dealing with.
  • Missing hidden dotfiles by not using ls -a.
  • Forgetting filenames are case-sensitive, and that rm -r is immediate and permanent.

Key takeaways

  • Directories are a special file type; ls -l's first character shows the type (- file, d directory, l symlink, c/b devices, etc.).
  • Filenames are case-sensitive, and dot-prefixed names are hidden by default (reveal with ls -a).
  • Core operations (touch, mkdir, cp, mv, rm) apply across types; recognizing types and using destructive commands carefully matter for both administration and security.

Check your understanding

  • In an ls -l listing, how do you tell a directory from a regular file from a symbolic link?
  • Why must enumeration include hidden files, and how do you list them?
FINISH THIS LESSON

Sign in to save your progress.