File system layout describes how an operating system organizes files, folders, devices, and user data. Students need this reference to understand paths, directory trees, permissions, and where important files usually belong. This cheat sheet helps connect programming, operating systems, command-line work, and cybersecurity basics.
It is especially useful when navigating Linux, macOS, Windows, or project folders.
Key Facts
- A file system is a method an operating system uses to name, store, organize, and retrieve files on a storage device.
- A directory tree starts at a root location, such as / on Linux and macOS or C:\ on Windows.
- An absolute path gives the full location from the root, such as /home/ana/report.txt or C:\Users\Ana\report.txt.
- A relative path gives a location from the current working directory, such as ../images/logo.png.
- The symbol . means the current directory, and .. means the parent directory one level above.
- Typical Linux folders include /home for users, /etc for configuration, /bin for essential programs, /var for changing data, and /tmp for temporary files.
- File permissions usually control read, write, and execute access for the owner, group, and others.
- A good project layout separates source code, tests, data, documentation, and build output into clearly named folders.
Vocabulary
- Root directory
- The top-level directory from which all other files and folders branch.
- Path
- A text address that identifies where a file or folder is located in a file system.
- Absolute path
- A complete path that starts at the root location and uniquely identifies a file or folder.
- Relative path
- A path written from the current working directory instead of from the root.
- Mount point
- A directory where another storage device or file system is attached and accessed.
- Permission
- A rule that determines who can read, modify, or execute a file or folder.
Common Mistakes to Avoid
- Confusing absolute and relative paths is wrong because an absolute path starts at the root, while a relative path depends on the current working directory.
- Using the wrong path separator is wrong because Windows commonly uses backslashes like C:\Users\Ana, while Linux and macOS use forward slashes like /home/ana.
- Deleting or editing system folders without understanding them is dangerous because folders such as /etc, /bin, C:\Windows, and Program Files contain files needed by the operating system.
- Assuming file extensions always prove file type is wrong because extensions are naming conventions, while the file contents and metadata may tell a different story.
- Giving everyone write or execute permission is unsafe because it can allow accidental changes, malware execution, or unauthorized access.
Practice Questions
- 1 In the path /home/student/projects/app/main.py, what is the root directory, and what is the file name?
- 2 If your current directory is /home/student/projects and a file is stored at /home/student/images/logo.png, write a relative path to the file.
- 3 A Windows file is located at C:\Users\Maya\Documents\essay.docx. Identify the drive, two folders, and the file name.
- 4 Why is it useful for an operating system to separate user files, system files, configuration files, and temporary files into different folders?
Understanding File System Layout Reference
A path is more than a label. It is a set of instructions that the operating system follows one folder at a time. When a program opens a file, the system checks each part of the path in order.
It must be allowed to pass through every directory on the route. This is why a file can have readable permission yet still be unreachable if a parent folder blocks access. Names can be misleading too.
A file ending in .txt is not automatically safe text, and a file named report may be any kind of data. The operating system stores extra information about files, such as size, owner, dates, location on storage, and access rules. On many systems, the displayed filename is only one part of that stored record.
The current working directory matters most when using a terminal, running a script, or testing a program. A relative path depends on where the command started. The same command may work in one folder and fail in another because its starting point changed.
This causes many beginner errors in Python, Java, web development, and data science projects. A reliable script often builds paths from its own location or accepts a path supplied by the user. Students should practise reading paths from right to left.
The final part is usually the target file or folder. Each earlier part describes the route used to reach it. Windows commonly accepts backslashes, while many programming tools use forward slashes even when they run on Windows.
Permissions are a practical security boundary, not just a set of letters shown by a command. Read permission for a file permits viewing its contents. Write permission permits changing or deleting its contents in many situations.
Execute permission permits running a program or script. For a directory, the meanings differ. Read permission can allow a list of names.
Write permission can allow creating or removing entries. Execute permission permits entering the directory and reaching items inside it. Ownership matters because the owner may change permissions, while ordinary users usually cannot.
Administrator accounts can bypass many restrictions, so they should be used carefully. Running a command with elevated privileges can place files in the wrong location or change files that the system needs to start correctly.
A clear project layout reduces mistakes because each type of work has an expected home. Source files should not be mixed with generated output, downloaded dependencies, private keys, or large experimental data files. Build folders can often be deleted and recreated, while source code cannot.
Version control tools usually track code and documentation but ignore temporary output, log files, passwords, and machine-specific settings. This separation makes it easier to share a project without exposing secrets. File names deserve care too.
Spaces, unusual symbols, and names that differ only by capital letters can behave differently across operating systems. Before moving or deleting anything, check the full path, confirm the current directory, and keep a backup of work that cannot be recreated.