Codecademy Logo

File Systems

Filesystem

The filesystem is the data structure used by the operating system to store and retrieve data.

Filesystem File

A file is a unit of storage used to describe a self-contained piece of data and can have a variety of possible formats based on what that file contains.

Filesystem Directory

A directory is a data structure that contains references to files and other directories. They are typically organized in a hierarchical tree structure called a directory tree.

Working Directory

A working directory, also called a current directory, is the directory associated with the execution of a process.

File Attributes

File attributes are a collection of metadata that determine how files behave, such as if they are hidden or compressed.

File Permissions

File permissions determine which users and groups can read, write, and execute the file.

Terminal output of file permissions in a Linux operating system

File Control Block

A file control block contains the metadata for a file, such as permissions and access times.

Filesystem Layers

The filesystem has multiple layers of abstraction: The applications, logical file system, File-organization module, basic file system, IO control, and devices.

The layers of the filesystem shown as a stack: The applications, logical file system, File-organization module, basic file system, IO control, and devices.

File and Directory Operations

Both files and directories can be created, opened, read, written, deleted, closed, linked, unlinked, listed and truncated. It is possible to move across directories as well as find files within directories.

// Create a file named lunch
touch lunch
// Write a list of foods to the lunch file
echo "burger, salad, and sandwich" > lunch
// Read the file
cat lunch
// Delete the file
rm lunch
// Make a directory named dinner
mkdir dinner
// List the files in the dinner directory
ls dinner
// Delete the directory
rm -r dinner
0