Essential Commands to Learn for Your Raspberry Pi Projects

, Essential Commands to Learn for Your Raspberry Pi Projects

If you find yourself SSH-ing into your Pi and need to browse the file system, a few key commands can help you out.

For starters, to navigate to a specific folder, use the “change directory” command:

cd ~/Documents/Screenshots

Unlike Windows, Linux directories just start with a slash—for example, /home/pi/Documents. The tilde (~) is a shortcut that represents your home folder, though, so it can be handy if you’re navigating through user files.

Once you’ve entered a specific directory, you’ll see it listed in the next terminal prompt, and you can use the ls command to see the files in that folder:


Or, if you want more details about those files and view hidden files, you can run the ls command with these flags appended:

ls -l -a

To create a new folder in the current directory, you can use mkdir in the following way:

mkdir MyNewFolder

And to move or copy files, you can use mv and cp in this fashion:

mv ~/Documents/mydoc.txt ~/Desktop/mydoc.txt

In this example, the first path is the file’s current location, while the second file path is where you want to move it. To copy a file, you would just replace mv with cp.

Finally, to delete a file, use the rm command:

rm ~/Documents/Important/mydoc.txt

You can delete an entire folder and its files by adding the -r flag, like so:

rm -r ~/Documents/Important/

Be careful with the rm command in particular, as it cannot be undone! These commands may seem a bit confusing and esoteric at first, but as you use them more and more, they’ll become second nature.

Source link

Leave a Reply

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