Command Line Booting a Raspberry Pi

Raspberry Pi Logo

The Raspberry Pi is a remarkable little computer with numerous uses. They can be used for embedded applications or as a DNS, DHCP, Samba (File), Firewall, or other server. When using the Raspberry Pi in this way, you may want your Raspberry Pi to boot directly to a Command Line Interface (CLI) instead of to a Graphical User Interface (GUI). Although the Raspbian LXDE user interface is quick and light weight, it does consume memory and other resources. If you are not actively using the GUI, it makes good sense to have your Raspberry Pi boot to a Command Line Interface and save those resources for other tasks. If you need the GUI later, you can start it manually or switch back to GUI booting later.

Set Up Command Line Booting

Open an LXTerminal and run the program raspi-config to change the default Raspberry Pi boot behavior.

sudo raspi-config

Raspi-config runs as a textual user interface (TUI). Use your down arrow keys to go down to line 3, “Enable Boot to Desktop/Scratch”.Raspi-ConfigClick enter on that line to edit this setting.

The next TUI screen allows you to choose your boot option.

Text console

Use the arrow keys on your keyboard to select the first line, “Console Text console, requiring login (default)”. Click enter on that line to select this setting. Now your Raspberry Pi will boot to a command line interface. The raspi-config TUI takes you back to the main screen. Click Tab, Tab, Enter to finish your raspi-config session so your changes can take effect.

Before raspi-config exits, it asks if you want to reboot. For this particular change, it does not matter. Selecting Yes or No here is your choice.

Starting the GUI from the Command Line

You do not have to give up the GUI if you choose to boot into the CLI. Just use following command from the CLI.

startx

Your familiar LXDE GUI is back again for the rest of your session.

Boot to Graphical User Interface

It is easy to change your settings back from Command Line to booting into the GUI.

sudo raspi-config

Repeat what you did above, but change your selection to “Desktop Log in as user ‘pi’ at the graphical desktop”.

Text console

Click enter on that line to select this setting. Now your Raspberry Pi will boot to a GUI instead of the CLI. The raspi-config TUI takes you back to the main screen. Click Tab, Tab, Enter to finish your raspi-config session so your changes can take effect, just as before.

Changing the boot behavior from GUI to command line is easy with raspi-config.