Set-up Raspberry Pi headlessly in Laptop, no HDMI no Monitor.
- RASPBIAN STRETCH ISO file
- Etcher
- Advance IP scanner
- MobaXterm - By Choosing it
- Using Etcher, Write Image File On SD Card (Must Be FAT32)
- Connect Raspbery and Laptop/PC via Ethernet and Get Gatway IP address
- Get IP Address Used By Rapberry - Typically Find It Using Advance IP Scanner
- Log In To Pi Using MobaXterm & (Optional) Set WiFi Configuration & Get A New IP Address (If We Don't Want To Use Ethernet Cable Further)
✔ Boot: First download RASPBIAN STRETCH ISO file, but don't use Noobs for the sake of full headless implementation. However, Rasbian Stretch is almost 5GB image file.
After booting, then we need to create an empty file and name it ssh
(with no extension - preferred) and put into the SD card. However, to do this, we may need to eject and re-enter our SD card into PC/Laptop.
✔ Laptop/PC Config:
Go to Control Panel - > Network and Internet -> Network and Sharing Center
Enable Interet Connection Sharing. We'll see following section appear.
Now, Power On Rapberry Pi. Connect it to Laptop/PC via Ethenet Cable. We'll see a new public unidentified network available. Click the Ethernet option. Double click on Internet Protocol V4 and We'll get the new Gatway IP address. For example: It's 192.168.137.1
.
OK, just remember it.
✔ Advance IP Scanner:
Here we'll use a tools that will find all the possible IP address from this Gatway address. We'll use
Advance IP scanner to find it. After opening this tools type
following IP address range: 192.168.137.1-192.168.137.254
. And after scanning hopely we'll find the host IP address of our Pi. Let's say, it appears something like 192.168.137.49
. Save it.
✔ MobaXterm:
Download MobaXterm and Using host IP address (here it is 192.168.137.49
), log in to pi.
✔ Needy Task:
After log in, type following commands: sudo raspi-config
and navigate same as following. Run: sudo raspi-config
> Advanced Option
> Expand Filesystem
- Press OK and Finish. Reboot Necessary. After rebooting, run following command. This may take some time, couple of hours (perhaps). It's necessary.
sudo apt-get update && sudo apt-get upgrade
✔ GUI Desktop: Without using VNC or Windows Remote Desktop, we can able to open GUI of our Ras Pi. To do this, Go the Advanced SSH settings tab of the Session Settings in MobaXterm. And choose Remote Environment LXDE Desktop from the dropdown menu. By default, it's Interactive Shell. However, X11-Forwarding in MobaXterm is enable by default. So we can bring GUI application from our Pi OS to Remote Desktop. We'll also perform it up next.
After finishing, Open a new session. We'll see something following:
Normally we can do almost everything. It's something like an another desktop. By this, we invoke Ras OS in GUI mode without VNC or XRDP. However, MobaXterm has VNC option too.
✔ X11 Forwarding Not a serious feature, just fancy. We can invoke some Pi application to our Remote desktop from PuTTY/Interactive Shell terminal. Type following command:
xclock &
# For opening xclocklibreoffice &
# For opening libreofficethonny &
# For opening thonny Python IDE
✔ WiFi Configuration
We can do this from Interactive Terminal but let's open it now via LXDE Desktop. Then go to Preference -> Raspberry Pi Configuration
. Set country zone to BD. And Go to WiFi settings and enter the SSID and WiFi Password. Same thing we can do simply by using Interactive Shell or PuTTy. Type:
sudo raspi-config > Network Option > Wi-Fi > SSID > Password
Now, typically we create two IP addresses - via Ethernet and WiFi. Type following command to see them:
ifconfig
From Ethernet: 192.168.137.49
From Wi-Fi: 192.168.0.102
Now, Poweroff the Pi, command: sudo poweroff
. Change IP address in MobaXterm session settings. Like following:
A security alert may pop up, just say yes/OK.
✔ Copy-Paste: Previously It's a backpain to send and receive files between Pi and Remote Desktop. But now it's super easy. Just play around with following option.
✔ Set Static IP Address: By default, Pi set dynamic IP address. So, everytime we boot our pi, it may change its IP address. To resolve this, we can set static IP address for our pi. Check out this blog post to achieve this.
Some Basic Commands: Few commands required Super User Do or sudo to perform.
📖
ls -l
: Lists files in the current directory, along with file size, date modified, and permissions.cd /abc/xyz
: Changes the current directory to the /abc/xyz directory.mkdir example_directory
: Creates a new directory named example_directory inside the current directory.
📖
ifconfig
: To check the status of the wireless connection we are using (to see if wlan0 has acquired an IP address).ping
: Tests connectivity between two devices connected on a network.
📖
df -h
: Shows information about the available disk space.df /
: Shows how much free disk space is available.free
: Shows how much free memory is available.hostname -I
: Shows the IP address of your Raspberry Pi.dpkg ––get–selections
: Shows all of the installed packages.lsusb
: Lists USB hardware connected to your Raspberry Pi.
📖
apt-get update
: Synchronizes the list of packages on your system to the list in the repositories.apt-get upgrade
: Upgrades all of the software packages you have installed.clear
: Clears previously run commands and text from the terminal screen.poweroff
: To shutdown immediatelyreboot
: To reboot immediately.raspi-config
: Opens the configuration settings menu.
See More.