04. The Linux File System pwd, ls, cd

What is a File System?

Computers organize their files using a tree-like structure known as a file system.

Linux has a single file tree system, which starts with the root directory (/). On a Windows, the "root" would be something like C:\.

The following image shows what a Linux File System would look like.

UNIX file structure
The Linux file system

Everything in Linux is a file

In Linux, almost everything is represented as a file (or directory) on the File System. This includes USB devices and hard disks, which are stored under /dev.

Naming files

A filename can contain uppercase or lowercase letters, numbers and most punctuation characters. Note that filenames are case sensitive!

Special characters

Some files begin with a dot (.) and are used for configuration settings. Others can end with a tilden (~), denoting that it is a backup file. Furthermore, we'll see how we can use ? and * to denote special cases when we learn about wildcards and globbing. Although you can name your files with these symbols, it's highly not recommended.

Checking your Current Directory

You can check to see where you are along this file system with the pwd command (short for "print working directory").

$ pwd
/home/JohnDoe/Dropbox/FunStuff

Here, we can see that we are in our FunStuff directory, which is within our Dropbox folder.

Take your Linux skills to the next level!

Command Line Kung Fu

Take your Linux skills to the next level! Try Linux & UNIX

Command Line Kung Fu is packed with dozens of tips and practical real-world examples. You won't find theoretical examples in this book. The examples demonstrate how to solve actual problems. The tactics are easy to find, too. Each chapter covers a specific topic and groups related tips and examples together.

$ Check price
14.9914.99Amazon 4.5 logo(27+ reviews)

More Linux & UNIX resources

Aching back from coding all day?

Acupressure Mat & Pillow

Aching back from coding all day? Try Back Problems

Relieve your stress, back, neck and sciatic pain through 1,782 acupuncture points for immediate neck pain relief. Made for lower, upper and mid chronic back pain treatment, and improves circulation, sleep, digestion and quality of life.

$$ Check price
144.87144.87Amazon 4.5 logo(1,890+ reviews)

More Back Problems resources

Ad