Files, Folders, and Paths: How Computers Organize Stored Information
📑 On this page
- What a file contains
- Directories form a hierarchy
- Paths identify locations
- Absolute and relative paths
- Dot components
- A concrete example: opening a document
- Current working directory
- Case sensitivity
- Hidden files
- Links and shortcuts
- Permissions
- Paths and URLs are not the same
- Common misunderstandings
- "A folder physically contains file bytes"
- "A relative path always begins beside the program file"
- "Hidden files are secure"
- "Renaming a file copies all its data"
- Knowledge check
- The one idea to remember
A storage device presents blocks of bytes. People and applications want meaningful objects such as invoice.pdf, holiday-photo.jpg, and settings.json.
A file system creates that organized view.
A file is a named collection of data and metadata. A directory organizes names. A path describes how to reach an item through the directory hierarchy.
These are operating-system abstractions over physical storage.
What a file contains
A file has content, but the file system also tracks metadata:
- Name
- Size
- Type hints
- Timestamps
- Owner
- Permissions
- Storage locations
The name is not generally stored alongside every content byte. File-system structures connect a directory entry to internal metadata and data blocks.
This separation allows renaming a large file quickly. The system can update its directory entry without rewriting all content.
Directories form a hierarchy
A directory, commonly called a folder in graphical interfaces, maps names to files and other directories.
That creates a tree:
Documents
├── Invoices
│ ├── June.pdf
│ └── July.pdf
└── Notes
└── ideas.txtThe hierarchy lets the same filename appear in different locations. July.pdf in Invoices is distinct from a file with the same name in another directory.
A directory is not physically a paper-like container. It is a file-system structure used to resolve names.
Paths identify locations
A path lists components leading to an item.
Unix-like systems use forward slashes:
/home/dhayal/Documents/Notes/ideas.txtWindows commonly uses drive letters and backslashes:
C:\Users\dhayal\Documents\Notes\ideas.txtProgramming tools often accept or display forward slashes on Windows as well, but native conventions and escaping rules vary.
Path components are interpreted in order, narrowing from a starting point to the target.
Absolute and relative paths
An absolute path begins from a file-system root or drive and identifies a location independently of the current working directory.
A relative path begins from the current location.
Suppose the current directory is:
/home/dhayal/DocumentsThen:
Notes/ideas.txtrefers to:
/home/dhayal/Documents/Notes/ideas.txtRelative paths make projects portable because they do not embed one user's complete machine-specific location.
Dot components
Many systems use:
. current directory
.. parent directoryFrom /home/dhayal/Documents/Notes, the path:
../Invoices/July.pdfmoves to Documents, then into Invoices.
Tools normalize such components, but security-sensitive code must validate paths carefully. An uploaded filename containing repeated ../ components may attempt to escape the intended directory.
This is called a path-traversal attack.
A concrete example: opening a document
When an application opens:
Documents/Invoices/July.pdfthe operating system and file system:
- Choose the starting directory.
- Find the
Documentsentry. - Check access permissions.
- Find
Invoices. - Find
July.pdf. - Locate its metadata and data blocks.
- Return a file handle.
The application then reads through the handle. If the file moves or permissions change before opening, resolution can fail.
Current working directory
Every process has a current working directory used to resolve relative paths.
Command-line tools often display or change it:
pwd
cd DocumentsAn application launched from different locations can interpret the same relative path differently. This is a common source of "file not found" errors.
Robust applications distinguish:
- Application installation directory
- User data directory
- Temporary directory
- Current working directory
- Configuration directory
Assuming they are identical causes portability problems.
Case sensitivity
File-name rules vary.
Many Linux file systems treat these as distinct:
Report.txt
report.txtDefault Windows and macOS configurations often treat them as the same for lookup while preserving capitalization.
Software developed on a case-insensitive system can fail when deployed to a case-sensitive server if an import uses the wrong letter case.
Use consistent naming and test in the target environment.
Hidden files
Graphical tools may hide selected files to reduce clutter.
Unix-like systems conventionally treat names beginning with a dot as hidden:
.gitignore
.envWindows can store a hidden attribute in metadata.
Hidden does not mean encrypted or protected. Users and programs can reveal and read the file if permissions allow.
Sensitive information needs access control and often encryption, not merely a hidden flag.
Links and shortcuts
A symbolic link is a special file that points to another path. A hard link creates another directory entry for the same underlying file record.
These features allow flexible organization but introduce questions:
- What if the target moves?
- Can links create cycles?
- Should an operation follow a link?
- Does deleting one name delete the data?
A graphical shortcut may instead be an ordinary file interpreted by the desktop environment, not a file-system link.
The visible behavior can look similar while internal semantics differ.
Permissions
File systems store access rules.
Permissions may control:
- Reading
- Writing
- Execution
- Directory traversal
- Deletion
- Ownership changes
Directory permissions are especially important. Reading a directory lists names; traversing it allows resolving items inside; writing may allow creating or deleting entries.
Administrator access can override many rules, but encryption and remote policies can still require separate credentials.
Paths and URLs are not the same
A path identifies a resource within a local or mounted file-system namespace.
A URL identifies a resource through a scheme:
https://example.com/docs/page
file:///C:/Users/dhayal/notes.txtURL path components use encoding and web rules that differ from native file paths.
Treating one as the other can create errors or security vulnerabilities.
Common misunderstandings
"A folder physically contains file bytes"
A directory organizes names and references. File content may be stored in blocks elsewhere on the device.
"A relative path always begins beside the program file"
It begins from the process's current working directory unless the application defines another base.
"Hidden files are secure"
Hidden status affects normal display, not authorization or encryption.
"Renaming a file copies all its data"
Within one file system, renaming often changes metadata only. Moving across file systems may require copying and deletion.
Knowledge check
1. What is the difference between an absolute and relative path?
An absolute path starts from a root or drive. A relative path is interpreted from a current or specified base directory.
2. What does .. mean in a path?
It conventionally refers to the parent directory.
3. Why can filename capitalization break software after deployment?
The development system may be case-insensitive while the deployment file system treats differently capitalized names as distinct.
4. Why is path traversal dangerous?
Untrusted components such as ../ can escape the intended directory and access unauthorized files.
The one idea to remember
Folders organize names, paths resolve those names through a hierarchy, and the file system maps them to metadata and stored data.
Knowing the base directory, platform rules, permissions, and link behavior turns file-location problems into understandable questions.
Next, we will separate a file's name extension from its actual internal format.