Pages - Menu

Wednesday, August 23, 2017

Simple Guide for Raspberry Pi Newbies

Installing RASPBIAN Images Using Windows
  • Insert the SD card into your SD card reader and check which drive letter was assigned. You can easily see the drive letter, such as G:, by looking in the left column of Windows Explorer. You can use the SD card slot if you have one, or a cheap SD adapter in a USB port.
  • Download the Win32DiskImager utility from the Sourceforge Project page as a zip file; you can run this from a USB drive.
  • Extract the executable from the zip file and run the Win32DiskImager utility; you may need to run this as administrator. Right-click on the file, and selectRun as administrator.
  • Select the image file you extracted earlier.
  • Select the drive letter of the SD card in the device box. Be careful to select the correct drive; if you get the wrong one you can destroy the data on your computer's hard disk! If you are using an SD card slot in your computer and can't see the drive in the Win32DiskImager window, try using an external SD adapter.
  • Click Write and wait for the write to complete.
  • Exit the imager and eject the SD card.





Disable Raspbian Desktop
With the Rasbian image, you can re-run the initial start up script using:
sudo raspi-config

  1. Entering your sudo password.
  2. This will bring up the same menu options that you got after first boot.
  3. You do not need to remake all your first boot choices, just use the arrow keys to move to the menu options you want to change.
  4. In your case, selecting:
  5. Start X-server after boot?
  6. and choosing:
  7. no or disable
  8. will sort you out.





Change the Password!

The default login for Raspbian is pi with the password raspberry. But you can change it as you wish.

Type the following command:
sudo raspi-config

in the terminal, then navigate to ssh, hit Enter and select Enable or disable ssh server.

reboot

After Pi is restarted check ip-address with the command
ifconfig

Note the inet addr!

It is a good idea to change password. This is done with the command:
sudo -i
passwd pi

Remember the new password!




Enable/Disable SSH (Secure Shell)

You can remotely gain access to the command line of a Raspberry Pi from another computer on the same network using ssh. Note you only have access to the command line, not the full desktop environment. For full remote desktop see VNC.

You can enable or disable the SSH server on your Raspberry Pi (it is enabled by default). This is done using raspi-config. Enter sudo raspi-config in the terminal, then navigate to ssh, hit Enter and select Enable or disable ssh server.




Connect to your RasPi via SSH (in Windows)

On Windows you will need to download an SSH client. The most commonly used one is called PuTTY and can be downloaded from greenend.org.uk

Look for putty.exe under the heading For Windows on Intel x86.

It doesn't have an installer package, it's just a standalone .exe file. When you run it you'll see the configuration screen below:

PuTTY configuration

Type the IP address of the Pi into the Host Name field and click the Openbutton. If nothing happens for a while when you click the Open button and eventually see a message saying Network error: Connection timed out it's likely that you've entered the wrong IP address for the Pi.

If you don't know the IP address just type hostname -I in the Raspberry Pi command line. See more methods of finding your IP address.

When the connection works you'll see this security warning (below), you can safely ignore it and click the Yes button. You'll only see this warning the first time when PuTTY connects to a Pi that it has never seen before.

PuTTY warning

You'll now have the usual login prompt, login with the same username and password as you would use on the Pi itself. The default login for Raspbian is piwith the password raspberry.

You should now have the Raspberry Pi prompt which will be identical to the one found on the Raspberry Pi itself.
pi@raspberrypi ~ $

PuTTY window

You can type exit to close the PuTTY window.

The next time you use PuTTY look for the Saved Sessions section on the bottom half of the configuration screen. If you use this I recommend switching to the Connection page in the left hand tree and setting the Seconds between keepalives value to 30. Then switch back to the Session page in the tree before you click Save. Using this setting allows you to leave a PuTTY window open for long periods of time with no activity and the Pi will not time out and disconnect you.




 Make Static IP

Having a static IP isn't essential, however it will make repeated access to the Raspberry Pi via SSH much simpler, as you'll always know that the Raspberry Pi has the same address. Imagine how much trouble your postman would have if your house constantly changed location.

Checking Set Up

First, we need to list the network interface we currently have available:
cat /etc/network/interfaces



The line . . . .

iface eth0 inet dhcp

Implies that we're currently getting out IP address via DHCP, meaning it's being dynamically registered by the router. This is what we want to change!

Gathering Information

Fist of all we need to grab some information from our router and Pi. There's a couple of command we need to run to get this info. Have a pen and paper handy! . . .
ifconfig



This reveals your router information, the bit you want is after eth0 (the ethernet connection). . . .

eth0      Link encap:Ethernet  HWaddr b8:27:eb:b3:fc:2c

               inet addr:192.168.1.81  Bcast:192.168.1.255  Mask:255.255.255.0

Write down the following information. . .

inet addr – 192.168.1.81 (Pi's Current IP Address)

Bcast –  192.168.1.255 (The Broadcast IP Range)

Mask –  255.255.255.0 (Subnet Mask Address)

We need a little more information before we proceed. Use the command. . .
netstat -nr

(route -n will give you the same info.)



We need:

'Gateway' Address – 192.168.1.254

'Destination' Address – 192.168.1.0

Editing Network Configuration

We now need to plug this information into the Pi's network configuration file using a text editor. I always use nano text editor. . .
sudo nano /etc/network/interfaces



Simply change the line that reads:

iface eth0 inet dhcp

to

iface eth0 inet static

Then directly below this line enter the following (Please Note. You will need your own addresses we gathered in Part B, more details below). . . .

address 192.168.1.81

netmask 255.255.255.0

network 192.168.1.0

broadcast 192.168.1.255

gateway 192.168.1.254

To clarify what each part means. . . .

address – The address you want to give your Pi, this can be any IP in the network range, but it's usually advisable to go higher rather than lower, or you could end up logging different devices to the same IP! I've selected 192.168.1.81, as we're already registered to that address (denoted by 'inet addr'), but this can be any IP address from the range192.168.1.1 to 192.168.1.255.

netmask – The 'Mask' address we wrote down earlier.

network – The router IP address, this is the 'Destination' Address was found earlier. You can also grab this off your router, it will say on the side somewhere.

broadcast – The 'Bcast' address we wrote down earlier.

gateway – This is the 'Gateway' address we found earlier.



So, it should look something like the above, but with your values! Remember to save before exit, CTRL+X (exit) then yes to save changes!

Re-check Static IP Configuration

UPDATE: Remove any existing leases
sudo rm /var/lib/dhcp/*

Then we'll need to reboot and check your changes. . .
sudo reboot

Log back in and run
ifconfig

Which should reveal your new settings. .



To double checks all is working as it should, ping your 'Gateway' Address. . .
ping 192.168.1.254 -c 10

(the -c 10 command simply denotes that you want to ping it 10 times, if you forget to add this, it will ping the address continuosly. To stop it press CTRL+C)



This should ping successfully and all packets should be recieved. If something's not right double check through all your IP addresses, and make sure you're pinging the right address too. Remember you can always revert back to DHCP by reversing the steps. The 'network' router IP address is sometimes a little fiddly, so check that if you're still having issues!

Source :

  • www.raspberrypi.org

  • www.modmypi.com

1 comment:

  1. Air Jordan 20 Retro Game - Air Jordan 20 Retro
    This product is made in Israel. Air bj 사이트 Jordan 20 replica air jordan 18 retro red Retro Game If you have air jordan 18 retro men red for sale an alternative version, Type: Game 파워볼 돈버는법 벳무브 CartridgeColor: AirColor: AirRotation: air jordan 18 stockx discount 90 Degrees

    ReplyDelete