Basic Linux Navigation and Commands for Raspberry Pi

Basic Linux Navigation and Commands for Raspberry Pi

Navigating the Raspberry Pi’s interface and knowing the commands can be quite daunting, it is very different to using arrows, hotkeys and mouse clicks on Windows; but no worries, I am here to hopefully clear it up!

This guide is for the Raspberry Pi, but it should work for other Linux platforms.

 

Basic Linux commands for Raspberry Pi

To achieve most actions, you would have to enter commands rather than clicking on things. Not all commands are very memorable, and some are quite long.

Each command is followed by hitting enter.

Feel free to copy each command until you are comfortable in typing it out yourself.

I highly recommend you save or bookmark this page so you can reference this in the future.

Some more notes, the examples given below are for you to try out, you need to replace my examples with your own names and paths, as every system is different.

Also, you will notice sometimes I will have put in a full path (/home/pi/downloads/example.mp3) and other times I just type the file name (example.mp3), this is to give you a diverse set of scenarios, the times where you have to specify the full path, you are likely not in that directory, but if you are in the directory already you don’t have to do the whole path.

 

Show What is in the Current Directory (list)

using the ls command will show you the current active directory, including any files or directories inside.

Copy

 

Where Am I? (print the current directory)

at any point you’re  not sure on which directory you are at, use the pwd command to find out.

Copy

 

How much Space Do I Have?

use the df to see how much space have you used and how much space is available, use the -h flag at the end to simplify the information into GB and MB.

Copy

Move Around and Navigate using CD

the CD command allows you to jump around the Linux system, all you need to know is where you want to go. we will look more into CD in the navigation part further on.

Copy

Create a New Directory

the MKDIR command allows you to create a new directory in the active directory, you can also type a path if you are not currently in that directory. type the command followed by the name you want your directory to be.

Copy

Delete/Remove Files and Directories

Removing a folder is not as straight forward as Windows, the rm command only works on single files, to delete a directory you would have to include a -r which stands for recursive, that will delete everything within a directory, including sub directories. There are also prompts asking you if you are sure or not, you can use a -f to force the remove without it prompting you.

Copy

Copy a File or Directory

The CP command will make a copy in the same directory or another path, you would first specify what you wanted copied and then the destination.

Copy

Move a File

just like the CP command, the MV command is the same, but this time we will move it instead of copying it.

Copy

Renaming a File

There isn’t actually a command to rename a file, you would have to use the previous move command to do this, you just need to specify the new name in the last part and it will move and rename it.

Copy

Search for Files

The Locate command acts like the search function on Windows, if you know the name of a file but don’t know where it is, use this. it is case sensitive, so you can use an -i to ignore this.

Copy

 

Learn More About Each Command

use the MAN command to learn more about  the commands we learned.

Copy

If you want to learn even more commands, check out this article.

 

Basic Linux navigation for Raspberry Pi

As we won’t be using a graphical interface in our SSH setup, the layout of Linux on our Raspberry Pi is quite basic.

When you first log in, you are in your user’s directory, a bit like the My Documents folder on Windows. And depending on what you have in here, you can navigate around by using the CD command.

Before we see what’s here, let’s take a few steps back to the Root directory.

This Root directory is the main folder, everything on your Raspberry Pi is here a bit like your C drive on Windows.

It is also known as the ‘/’ directory as this is the start of any path.

your / Directory contains a few important directories, there is the home directory, which is where all your users directories are, the usr directory where is all your important files are located, a bit like your System32 folder.

you will spend most of your time in the /home Directory, and in particular the /home/pi Directory.

To navigate back to your user’s home directory just enter cd with no arguments and it will take you back to the directory of your user, in our case Pi.

if you want to go back a directory instead of remembering and typing out the path, just use Copy

You can also make good use of your tab key to navigate, if you know what a file or directory begins with, just enter one or two characters and hit tab, it will autocomplete it for you.

For example if I know that within my pi directory there is a directory called 2020 Summer Holiday Photos, I can just type cd /home/pi/2020 and hit tab to let Linux to autocomplete the directory. this is also very handy when the file has a long name.

 

Conclusion

I understand it is a steep learning curve, and we have been through a lot, but if you could practice what I shown you here you would be up and running in no time; and once you are ready you can jump right to the fun parts!

Sharing is caring, tell more people about this by sharing it!
Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp
Share on email

Leave a Comment

Your email address will not be published. Required fields are marked *