lessons · raspberry pi · Websites

Lessons on PI – Lesson 3: Getting around (ls, cd, rm, mkdir, touch, pwd, less…)


The Linux operating system and specifically the terminal, can feel like a maze when trying to find your way around.  If you haven’t yet, check out Lesson 1, and Lesson 2.

The file and directory



There are a couple of concepts you will have to hold in your head as you get started.  The first is the idea of a file.  Files are the objects that can be edited or run.  They are stored inside a directory.


directory is a place to store files or other directories.  Its there for your convenience, allowing you to create a hierarchy that makes sense to you.  When you have a hierarchy of directories its called a “path”.  Like a path to a file.

To find your current path, or the current directory you are in type pwd:



The output above shows that you are in the “root” directory of “home”, and inside of that you are in “pi”.  This happens to be the place you are always dropped when you login to the “pi” account.  It’s your “home” where all the files here are likely to be owned by you.

Together they make… The Filesystem


The combination of these makes up something called the filesystem.  Lets run through that picture up at the top:


Your computer – the thing at the top of the picture – contains hard-drives… or a flashdrive as the case with the raspberry pi.  This thing: 414hz2dzvil is your computer’s drive, the equivalent of “Local Disk(c:)” in that picture.  To get to the very root of your system you will “change directory to it”. Like this:

cd /

Now that might seem odd given that picture.  I’ve tricked you though… that picture is actually of the filesystem seen in “Windows OS”.  The directory structure in Linux actually looks like this:


But the idea of files and directories has better “imagery” in the windows world.  So, when you said:

cd /

You “changed directory”(cd) to the root folder.  If you do “ls” you’ll list the items within that folder.  Try it in your terminal.  It should look something like this:


Now that you have that in structure in your head.  Check this out…  it’s a little game that will help you explore some of the other magical commands available to you in the filesystem.

Terminus… an adventure


Play the game… save the girl and you will have the power of the Linux OS!

A cheat sheet of the commands…

The game above will take you through each of these… but in case you couldn’t make it through, here is the list.

ls – List files

cd – Change directory

rm – Remove file

less – Show the contents of the file

mkdir – Make directory

touch – Create empty file

vim – Edit file using the VIM editor

pwd – Print working directory – answers the question, “Where am I?”

history – What did I type?  Shows you the commands you’ve recently used.


Lessons on PI – Lesson 3 (cont.): A little programming…


3 thoughts on “Lessons on PI – Lesson 3: Getting around (ls, cd, rm, mkdir, touch, pwd, less…)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.