File Types & Paths
In Linux, a "File" is the basic unit of storage. Understanding the different types of files and how to locate them using paths is fundamental to working in a terminal.
1. Types of Files
Linux categorizes everything as a file, but there are three main types you will encounter:
📄 General Files
These are the most common files. They contain data, text, or programs.
- Examples: Text files (
.txt), source code (.js,.py), compiled binaries, and images.
📁 Directory Files
In Linux, a directory is also a file that contains information about other files and directories.
- Note: You navigate through directory files using the
cdcommand.
🔌 Device Files
These special files represent hardware components like hard drives, keyboards, or printers. They allow the OS to communicate with physical devices as if they were files.
- Location: Usually found in the
/devdirectory.
2. Understanding Paths
A "Path" is the address of a file or directory in the system. There are two ways to specify a path.
Absolute Path
An absolute path specifies the location from the root directory (/). It always starts with a forward slash.
- Example:
/home/user/documents/report.pdf - Analogy: Giving someone the full latitude and longitude of a location.
Relative Path
A relative path specifies the location relative to your current directory. It does not start with a /.
.: Represents the current directory...: Represents the parent directory (one level up).- Example:
docs/notes.txt(if you are already in the project folder). - Analogy: Telling someone to "go two blocks down and turn left."
[!TIP] Pro Tip Use the
pwdcommand anytime you are lost to see your current absolute path.