SkillSprout
Chapter 1 · Lesson 2
Beginner
2 min read

Filesystem Navigation and Absolute Paths

Overview

Linux stores files in one directory tree rooted at /. There is no C:; every disk, directory and device is reachable below that root. A path may start at the root (absolute) or from the current directory (relative).

Detailed Notes

The current directory

Every process has a current working directory. It is not the same as the terminal display. pwd prints the process's current location.

bash
pwd
ls
ls -l
ls -la
  • ls lists entries.
  • ls -l prints details.
  • ls -la includes hidden entries and details.

Hidden names begin with .. The two special entries are:

  • . means the current directory.
  • .. means the parent directory.

Change directory

bash
cd /
pwd
cd /var/log
pwd
cd ..
pwd
cd ~
pwd

An absolute path starts with /. A relative path does not:

bash
cd linux-practice
cd ../documents
cd ~/linux-practice

~ expands to the current user's home directory. ~other-user refers to another user's home if permissions allow.

Directory tree

Common top-level directories:

PathPurpose
/Root of the filesystem
/homeNormal users' home directories
/rootRoot user's home
/etcSystem configuration
/varLogs, caches and changing application data
/tmpTemporary files
/usrMost installed programs and libraries
/optOptional third-party software

Practice

  1. Print your current location.
  2. Enter /etc, list it and return home.
  3. Create a directory with mkdir ~/linux-practice/navigation.
  4. Enter it using an absolute path.
  5. Enter .., then .. and check pwd.
Absolute and Relative Paths
Architecture
Root `/`top of treeHome/home/learnerPractice/home/learner/linux-practiceCurrentDirectoryprinted by pwdabsolute path../navigation
Key point. Use `pwd` before a relative path if you are unsure where the shell currently is.

Absolute paths begin at `/`; relative paths begin at the current directory.

Common Interview Questions

Finished this lesson?

0 of 25 lessons done · 0% of the course