working directory/home/sam$ pwd/home/sam$ lsnotes.txt projects$ cd projects$ cd ..$ cd /etc$ cd ~// (root)homeetcusrtmpsambinnotes.txtprojectsls//home/home/sam/home/sam/notes.txt
Right: the file tree. Khaki blocks are folders, violet blocks are files; traces join each folder to what is inside itLeft: the terminal card and the working-directory signMovers: the path pill, the you-are-here pin, and the envelope carrying ls's answerThe file tree on the right: the root folder / at the back, then /home, /etc, /usr and /tmp, then /home/sam and /usr/bin, then notes.txt, projects and the ls program in front. On the left, the terminal and the working-directory sign. A path pill walks from / down to notes.txt, spelling the path. The you-are-here pin stands on the working directory: pwd prints it, ls lists it, and each cd moves the pin: a relative path from where it stands, an absolute path from the root /. The user sam and the files notes.txt and projects are an example; your home folder is named after your own user name.

The tree

  1. Linux keeps every file in one tree of folders, also called directories. The tree starts at a single folder, the root, written as a slash: /. Even a USB stick you plug in is attached somewhere inside this one tree.

Where you are

Moving around

What happens

;; step 1/9 · tree
/                  the root: the top of the tree
├── home           folders hang under folders
├── etc
├── usr
│   └── bin
└── tmp
one tree for every disk: a USB stick is attached
(mounted) at a folder inside it, such as /media/...

The user sam and the files notes.txt and projects are an example; your home folder is named after your own user name. On Ubuntu, Debian and Fedora the old folder /bin is now a link to /usr/bin, so ls can be reached as /bin/ls or /usr/bin/ls: the same file. cd is built into the shell rather than being a separate program, because it must change the shell's own working directory (with the chdir system call). ls sorts names in the order of your language settings (the LC_COLLATE locale setting); for plain lower-case names like these that is A to Z.