5. Open Bash Shell in Raspberry Pi

Share for us

Bash is a command processor that normally runs in a text window. It can run the commands users input. Bash can also read commands from a file, or more precisely, a script. Like other Unix shells, it supports filename replacing (wildcard matching), piping, here files, command substitution, variables and structure control statements like condition ones and loop iterations.

5.1 Open Bash directly

For users with a screen display, you only need to click Terminal on the desktop to open the Bash shell.

Then a windows will pop up as follows:

For those without one, you need to open the Bash shell remotely.

5.2 Remotely open Bash

When using the Raspberry Pi, most of the time we do not connect it to piles of peripherals like keyboard and mouse; instead, we’d like to use the Raspberry Pi remotely in the PC with better functions and configurations for programing and development. In this way you won’t need to prepare several displays and mice. You can use the serial port, ssh and rdp or VNC as long as you have already known the address of the Raspberry Pi.

Note: For the 2016-11-25 release or above, SSH is Disabled by default. Therefore, when you need to log in remotely, you need to create a file named “ssh” under /boot/ to enable it.

5.2.1 IP Address of the Raspberry Pi

There are two situations for acquiring the IP address of a Raspberry Pi.

Scenario A: The Raspberry Pi has been connected with an HDMI display.

Hover the cursor on the Wi-Fi icon at the top right corner on the desktop and you will see the connection status of the Wi-Fi including the information about the IP address a few seconds later.

Scenario B: Without an HDMI display

Method a: Checking via the router

If you have the privilege to log into the router (like of the home network), you can check the IP address that the router has distributed to the Raspberry Pi in the management interface of the router.

The default hostname of the Raspbian system is raspberrypi, so just find it out.

(If you are using the ArchLinuxARM system, go to find alarmpi. If the hostname has been changed before, find whatever you’ve changed to.)

If you cannot log into the router and have no display, you can try the following method.

Method b: Network Segment Scanning

There are many network scanners available, and here we recommend the Advanced IP scanner.

This software will detect the network segment of the computer and decide the scan range automatically. For example, when the IP is 192.168.1.101 of the computer, its scan range is 192.168.1.*

Click Start to start the scanning and you will see a computer list within the same network segment.

One advantage of this software is that it can find out the manufacturer of the network devices.

The device whose manufacturer is Raspberry Pi Foundation is the Raspberry Pi. Also, the IP address is helpful when you log into the Raspberry Pi remotely later.

5.2.2 For Linux or Mac OS X Users

For Linux and Mac OS X users, you can only open the Bash shell via ssh.  

Go to Applications->Utilities, find the Terminal, and open it.

Type in ssh pi@ip_address – ssh is the tool for remote login, pi, the user name, and ip_address, as the name suggests, your Pi’s IP address. For example:

ssh pi@192.168.0.101

Press Enter to confirm. If you get a prompt that no ssh is found, you need to install an ssh tool like Ubuntu and Debian by yourself:

sudo apt-get install ssh 

For other Linux platforms, please contact your supplier.

5.2.3 For Windows Users

If your computer runs on Windows, you need to pen the Bash shell with the help of some software. Here we recommend a tool PuTTY.

  1. Download PuTTY
  2. Open PuTTY and click Session on the left tree-alike structure (generally it’s collapsed upon PuTTY startup).Enter the IP address of the RPi you just got in the textbox under Host Name (or IP address) and 22 under Port (by default it is 22)
  1. Click Open. Note that when you first log in to the Raspberry Pi with the IP address, you’ll be prompted with a security reminder. Just click Yes. When the PuTTY window prompts login as: type in the user name of the RPi: pi, and password: raspberry (the default one, if you haven’t changed it).

Note: When you’re typing the password in, the window shows nothing just null, but you’re in fact is typing things in. So just focus on typing it right and press Enter. After you log in the RPi successfully, the window will display as follows.

If you have a module for shifting the USB to the serial port such as the FTDI, you can use the serial port to open the bash shell. According to the pin figure of the Raspberry Pi, you only need to connect the TX and RX of the module to those of the Raspberry Pi, VCC to 5V, and GND to GND respectively.

Find the port number in the Computer Management of the computer and fill in the corresponding port number and correct baud rate in PuTTY; the baud rate of the Raspberry Pi is 115200.

After click Open, the operation is almost the same with ssh. There is no need to connect the Raspberry Pi with the Internet, but an external USB-to-serial module is needed.

5.3 Remote Desktop

5.3.1 Enable the VNC

If you do not have a display, you can use the remote desktop connection of the Windows to remotely access the Raspberry Pi desktop. The service VNC has been installed in the system. By default, VNC is disabled. You need to enable it in config.

sudo raspi-config

On the config interface, select 9 Advanced Options by the forward and backward keys.

Select A5 VNC.

Select Yes

5.3.2 Install the VNC on Windows

Then you need to install the VNC software on Windows. After the installation is done, open it.

Select New connection:

Enter the IP address of the Raspberry Pi behind VNC Server, and anything for Name.

Double click the connection just created:

Enter Username (pi) and Password (raspberry by default):

Now you can see the desktop of the Raspberry Pi:

This is a method without the display and what’s shown is just the same with using one. But the frames may not be so smoothly shown.