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.
A 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: 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:
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:
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.
Lesson 4 – VIM, and The Sense Hat!!!