Skip to content

Instantly share code, notes, and snippets.

@BaReinhard
Created December 3, 2017 04:20
Show Gist options
  • Save BaReinhard/2e104a2abf69c64d0166b8c5e8a062e1 to your computer and use it in GitHub Desktop.
Save BaReinhard/2e104a2abf69c64d0166b8c5e8a062e1 to your computer and use it in GitHub Desktop.
Intro to Linux

Introduction to the Basics of Linux and Connecting to your Raspberry Pi

In order to connect to the Raspberry Pi, it must be connected to the the network, either via Wifi or Ethernet. Wifi Should Already be Enabled on your device

To connect on a Windows machine you will need a 'ssh client' such as PuTTY. (Download here)

  1. Under hostname or ip input [email protected] , password is raspberry
  2. Then connect, it may ask you to accept the keys. Go ahead and do so.
  3. While you're logged in, its good practice to change your password since its the default and very unsecure.
  4. in the terminal type passwd, it will ask for current pass, then ask for your new pass twice. (Be sure to remember this, and change it in the configuration for PuTTy)
  5. Now we can start navigating files, for this cd aka change directory will be used to navigate locations.
  • cd requires another parameter to it to be on an use. For example for us to change to the local bin directory we would use cd /usr/local/bin, then if we wanted to navigate back to the home directory, we could use a special character to get us there easier cd ~.
  • Another important command when trying to figure out what directory we are in is pwd which "Prints the working directory"
  1. Initially when you are logged in it will take you to the home directory, typically /home/$USERNAME in this case it will be /home/pi.
  • Another word on directories, the characters . and .. are in reference to current directory and parent directory respectively. In other words, to reference a file in the current directory you can use ./file_in_cur_dir and referencing a file in the parent directory ../this_is_up_one_level
  1. Anther powerful tool in the CLI (command line interface) is ls, it is similar to dir in windows it will list all files in the current directory, or you can pass it a path and it will list files in the path.
  • ls -a will list all files in current directory 'including files starting with .', this is also syntactically the same as ls -a .
  • ls /usr/local/bin will list all files in the directory /usr/local/bin excluding friles starting with .
  1. Now that we can navigate the file system and see what is in each file we can now start to make changes to files. There are several CLI text editors, some are easier than others. A few popular ones are vim and nano. I will choose to use nano in this introduction. Vim isn't all that friendly to beginners. (There's a reason the question how to exit vim? is one of the most viewed question on Stackoverflow.
  2. Specifically for the project lightshowpi you will need to use the CLI to edit at least one file or two files to get things up and running.
  3. Lets begin by editing the defaults.cfg file,
# We will start in the home directory, use the following commands
cd lightshowpi
cd config
sudo nano defaults.cfg
  1. From there a text editor window will open and you will see a lot of different text, but mainly what you'll be looking for the lines containing:
# Using 8 pins of GPIO on the pi:
gpio_pins = 0,1,2,3,4,5,6,7
  • To close the editor without saving changes press ctrl + x then type n and then enter
  • To save the changes press ctrl + o then enter, then close ctrl + x
  • If you are fine using these pins, then great nothing needed to change, just make sure you plug your GPIO wires into the correct pins and you're all set.
  • You can find a pin out here.
  • It lists BCM $number and (Wiring Pi $number), for all intents and purposes go by the (Wiring Pi $number) as this project uses WiringPi. Those numbers will correspond to the numbers gpio_pins= above.
  1. Once they are all hooked up properly you can start by testing out the hardware: You can check out some of the commands here.
  1. With at least the basics covered as far as navigating and editing you can start taking a look at the getting started guide: http://lightshowpi.org/getting-started/

To sum up the commands:

  1. cd - change directory e.g. cd ~ - navigates to home directory
  2. ls - list files e.g. ls -a /home/pi/ - lists files in the home directory, including files start with .
  3. pwd - lists the file path of your current location in the file system. e.g. cd ~ then pwd will output /home/pi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment