Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Raspberry Pi 3 Home Automation Projects

You're reading from   Raspberry Pi 3 Home Automation Projects Bringing your home to life using Raspberry Pi 3, Arduino, and ESP8266

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781783283873
Length 226 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Shantanu Bhadoria Shantanu Bhadoria
Author Profile Icon Shantanu Bhadoria
Shantanu Bhadoria
Ruben Oliva Ramos Ruben Oliva Ramos
Author Profile Icon Ruben Oliva Ramos
Ruben Oliva Ramos
Arrow right icon
View More author details
Toc

Table of Contents (7) Chapters Close

Moving on to the LXTerminal

While the Raspberry Pi has a healthy variety of applications and programs for our consumption, we’re going to be primarily using the LXTerminal to download and interact with the Magic Mirror program. For those of you unfamiliar with the Terminal, it’s essentially a program that allows a user to directly manipulate their computer system through the use of commands. As we move through the text, when I refer to the command line, I’m talking about the Terminal and the location where a user will input the commands.

Understanding how the Terminal works and being able to use the command line is a very powerful tool when working to manipulate files on the Raspberry Pi. Commands can be strung together and input in order to efficiently carry out tasks that other applications cannot. When you initially open LXTerminal, you will see a screen with a blinking cursor. On the left-hand side, there will be a prompt that shows your current username and the hostname of the Pi. Both the username and hostname can be changed later on in settings if you’d like to tailor the Pi further for your uses:

Basic Linux commands

There are basic Linux commands that are going to be very useful in your navigation through your filesystems through the Terminal. In this section, I want to list some essential commands that will help you when building the Magic Mirror. With each command, I’ll provide a brief explanation. As with anything, the best way to learn how to successfully use these commands is with practice. Also, note that syntax is important when working with the command line. The computer interprets capitalized and uncapitalized letters as two different symbols, so we have to make sure we type our commands as they are shown. A good rule of thumb is that if something doesn’t work the first time, go back and proofread what you have typed.

Helpful commands

Here are some helpful Linux or NOOBS commands that will come in handy when you work on your Raspberry Pi:

  • sudo: Short for super user do, this command is powerful and necessary. When used before any others in the command line, you're telling the computer that you are running the command as the root user. This gives you the ability to alter files that may be unalterable to the regular user on the computer. When first working with the Terminal, I suggest you use sudo primarily, as opposed to su (though su is needed for particular actions). This will curtail your use of the super user command, putting a slight speed bump between you and any commands that may unintentionally delete necessary files from your system.
  • su: While similar to sudo, instead of running a command as root, su makes you root. As I said earlier, sudo is useful for targeted commands, but if you’re working extensively as root, su may be the better option. Just make sure you stay aware that you're working as a root user, as you do not want to delete anything necessary in your Raspberry Pi system files.
  • cd: This changes your location to a directory of your choosing. Remember, a directory is essentially a folder, and this allows you to navigate to a specific folder as long as you know the pathway. Furthermore, if you are in a specific directory and want to return to your /home directory, typing in cd will bring you immediately back to /home.
  • cd –: To build on the cd command, a useful command is to add the dash after the space after cd. This will allow you to immediately return to the previous directory in your pathway, for example, cd /MagicMirror/modules/. This will bring you to the modules folder within the MagicMirror folder. If you want to go back to the MagicMirror folder, you would then type cd –.

  • ls: When you're in a directory and wish to know the folder's contents, typing in this command will list the files within the folder.

  • pwd: This stands for print working directory. It is very useful if you’ve forgotten your current pathway or need to access that information.

  • mkdir: This command enables you to create a directory with a name of your choosing.

  • cp: This is the copy function. It allows you to copy a file from its source destination to another destination of your choosing.

  • nano: This command calls upon the Terminal’s nano text editor, enabling you to access and modify the contents of the file from within the Terminal emulator. This is very useful for quick changes to files on the Pi, and I will be using this as the command-line editor for this text.

Let's move forward. I find these to be the most useful commands for this project; however, there is a vast array of commands that will make your navigation more efficient. As you learn more with the Pi, it’s encouraged that you research more commands and how they work in order to maximize your experience in LXTerminal.

You have been reading a chapter from
Raspberry Pi 3 Home Automation Projects
Published in: Nov 2017
Publisher: Packt
ISBN-13: 9781783283873
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime