Paths in Linux are used to navigate the file system. Here’s a structured explanation with a simple diagrammatic representation →
Key Definitions:
Root (/
):
/
.Absolute Path:
A complete path from the root (/
) to a specific file or directory.
Starts with a /
.
Example:
This command navigates directly to fo1
inside /bin
.
cd /bin/fo1
Relative Path:
A path relative to the current directory.
Does not start with /
.
Example:
This command navigates to fo2
relative to the current directory.
cd fo2
File System Example:
/
Contains directories like bin
, etc
, apps
, etc.File Structure Tree:
/ -> Root
|-- bin
| |-- f1
| |-- fo1
| |-- f2
| |-- fo2
Commands Example:
Absolute Path:
Navigate to fo1
from anywhere in the system:
cd /bin/fo1
Relative Path:
Navigate to fo2
when already inside /bin/fo1
:
cd fo2
Diagrammatic Representation:
Here’s a simple diagram for better visualization:
Root (/)
├── bin
│ ├── f1
│ ├── fo1
│ │ ├── f2
│ │ └── fo2
├── etc
└── apps
/bin/fo1