Table of Contents
Introduction
Working with files and directories is at the heart of using Linux from the command line. Almost everything you do will involve locating files, changing where you are in the filesystem, and creating, copying, moving, or removing things. This chapter gives you a practical, high level understanding of how files and directories behave on a Linux system, without yet diving into specific commands. Later chapters such as “Listing files” and “Navigating directories” will teach the exact commands and options.
The Idea of a Filesystem Tree
Linux organizes data in a single hierarchical structure that starts at the root directory, written as /. From this root, every other directory and file branches out, forming what is often called the filesystem tree.
Think of / as the trunk of a tree. Directories are branches, and files are leaves. There is only one root of this tree, and every path to a file or directory begins from it, either explicitly or implicitly.
A directory can contain other directories and files. There is no technical difference between how the system treats a directory named Documents and a directory named bin at this level. Each is simply an entry in some parent directory. What makes them special is how the system and applications use them, which you will explore in later chapters such as “Linux Filesystem Hierarchy”.
Paths to Files and Directories
To refer to a specific file or directory, Linux uses paths. A path is a text description of how to reach that object inside the filesystem tree. The separator between levels of the tree is a forward slash, /.
For example, a path like /home/alex/notes.txt describes a route from the root directory /, then into home, then into alex, and finally to the file notes.txt.
You will later see how to use paths in commands such as cd and ls, but for now it is enough to understand that a path is the address of a file or directory inside the tree.
Important rule: In Linux, / is the single root of the filesystem tree, and / is also used as the separator between directory levels in a path.
Where You Are: The Current Working Directory
Whenever you are using a terminal, the shell keeps track of your current working directory. This is the location in the tree where you are considered to be “standing” at any given moment. Many commands behave relative to this current directory.
If you run a program and tell it to operate on notes.txt without specifying a full path, it will look for notes.txt inside your current working directory. If you change your working directory, the same filename may now refer to an entirely different file, or no file at all.
The concept of a working directory is central to navigation and file operations. The “Navigating directories” chapter will show how to change and inspect it. For now, you should remember that the shell always has a notion of “here,” and many operations depend on it.
Files vs Directories
A file represents data. This data might be text, an image, executable program code, or any other kind of content. The system does not inherently care what is inside, it simply stores bytes and exposes them as files. Applications interpret the contents.
A directory is a special type of object that stores a list of names and the references to the objects they represent. Those objects can be other directories or regular files, and also other types that you will learn about later such as symbolic links or device files.
You can think of a directory as a table of contents that maps names to items, while a file contains the actual content. Accessing a file always involves first navigating through one or more directories.
Hidden Files and Directories
In Linux, certain files and directories are considered hidden. This is done by convention, not by special permissions. A name that begins with a dot is treated as hidden. For example, .bashrc or .config are hidden.
Hidden items are usually configuration files or directories that the system or a program uses and that ordinary users do not need to see all the time. Many tools will not display hidden names by default, but you can usually enable them with an option when listing directories.
Convention: Any filename or directory name that begins with . is hidden by default in most tools.
Hidden status does not mean the file is protected or secure. It is only a way to reduce clutter and prevent accidental modification.
Special Names: `.` and `..`
Inside every directory there are two special entries. The first is . which refers to the directory itself. The second is .. which refers to the parent directory.
These names are part of the filesystem structure. They are regular entries with special meaning and are available in almost every directory.
Using . allows commands to explicitly refer to “right here.” Using .. lets you move or refer “one step up” in the tree. Combinations such as ../.. mean “go up two levels,” and so on.
You will work with these special names frequently when navigating and when specifying relative paths.
Case Sensitivity in Names
Linux filesystems are typically case sensitive. This means that Notes.txt, notes.txt, and NOTES.TXT are treated as three completely different names, and they can all exist in the same directory without conflict.
This behavior is different from some other operating systems that ignore case in names. On Linux, you must type file and directory names with the exact case they were created with.
Important: On Linux, filenames and directory names are case sensitive. File, file, and FILE are distinct and may refer to different objects.
Being precise about case avoids confusion when working with multiple similar names and when writing scripts that operate on specific files.
Naming Rules and Conventions
Linux is flexible about what characters can appear in a filename. In most cases, you can use letters, digits, spaces, and many symbols. However, certain characters have special meanings in the shell or create practical problems.
The forward slash / is reserved as the directory separator and cannot appear inside a filename. The null character, which is an internal terminator, also cannot be part of a name.
Other characters, such as spaces, quotes, $, *, and ?, are allowed but can be inconvenient. They often require quoting or escaping when used at a shell prompt. For this reason, many users prefer simple names that only use letters, digits, underscores, and hyphens.
There is no requirement to use file extensions like .txt or .sh, and the operating system does not rely on them to understand file types. Extensions are still helpful as a human convention and for some programs that look at them.
Hierarchical Organization and Structure
Because the filesystem is a tree, your data can be organized hierarchically in a way that mirrors how you think about it. For example, you might store documents under /home/alex/Documents, with separate directories for work and personal inside.
Directories can nest to many levels. However, very deep or complex nesting can become hard to manage. Part of learning to work effectively with Linux is learning how to choose a meaningful structure for your own files, while respecting the system structure that is already in place.
Later chapters on the Linux filesystem hierarchy will explain how the top level of the tree is organized for system directories such as /etc, /usr, /var, and others. In your own home directory, you have freedom to create your own layout.
Operations on Files and Directories
Common actions you will perform include creating, copying, moving, renaming, and deleting files and directories. You will also read the contents of files, check file sizes, and ask for metadata such as modification time and permissions.
These operations are performed using specific commands like those you will learn in the “File operations” chapter. At a conceptual level, each operation interacts with the filesystem tree.
Creating a file means adding a new leaf under a directory. Creating a directory adds a new branch. Moving or renaming involves changing the directory entry that points to the object, which may also involve changing its parent directory. Deleting removes a directory entry and may free up storage space.
Most operations are subject to permissions and ownership, which determine who is allowed to perform them. The details of permissions are covered later in “Users, Permissions, and Ownership,” so here you only need to know that you might sometimes be prevented from changing or removing certain files.
Relative and Absolute Thinking
Whenever you deal with files and directories, it helps to think in two ways at the same time. One is absolute thinking: where an object sits in relation to the root, /. The other is relative thinking: where it sits in relation to your current working directory.
If you are in /home/alex and you think only about the full path /home/alex/notes.txt, you are using absolute thinking. If you instead think of the same file as simply notes.txt because you are already “standing” inside /home/alex, you are using relative thinking.
Later, when you learn the difference between absolute and relative paths, this mental model will make it straightforward to understand why some references start with / and others do not, and how patterns like ../project/report.txt are resolved.
Summary
Files and directories form a single unified tree that begins at /. The shell always has a current working directory inside this tree, and your commands interact with files and directories relative to that point or via full paths from the root.
Directories store names and connections to other objects. Files store data. Names can include many characters, are case sensitive, and follow conventions such as a leading dot for hidden items. Special entries like . and .. help you refer to your current and parent directories.
With these core ideas in mind, you are ready to learn concrete commands for listing files, moving around the tree, and manipulating data in the following chapters.