I have the Raspberry Pi 4 Model B and my choice of RAM was the 4GB. i don't have internet via the gigabit ethernet at the moment, all i have is my smartphone to share internet via a hotspot (wifi).

i have installed Ubuntu Server 64-bit on the Raspberry 4 following the instructions on the ubuntu official webpage by flashing Ubuntu onto a 128GB samsung microSD card.

The installation went good, but now i want to connect the Raspberry to the internet via the command line to fetch some packages and install the desktop.

How can i setup the wifi via the command line on the Raspberry 4B 4GBRAM?


To be able to setup Wifi on Raspberry Pi 4 B+ 4GB on Ubuntu server 18 TLS, you first need to get the name of the wifi card by showing physical components using the following command:

 $ sudo lshw

in my case it was wlan0

Then navigate to /etc/netplan/ using the cd command the hit Enter

$ cd /etc/netplan/

use the command lsto list the files and directories under the folder then you now have to edit the .yaml file:

$ sudo nano 50-cloud-init.yaml

finally add the following lines to the 50-cloud-init file:

                      optional: true
        Password: “WIFI-PASSORD”
   Dhcp4: true

NOTE: make sure not to use tab for space, use the spacebar to create the blank.

here is the final file code:

# this file generated from information provided by the datasource. Changes
             # to it will not persist across an instance reboot. To disable cloud-init’s
             # network configuration capabilities, write a file 
             # /etc/cloud/cloud.cfg.d/99-disable-network-config-cfg with the following:
             # network:{config: disabled}

                                     dhcp4: true
                                     optional: true
                   version: 2

              # Adding wifi informations

                              optional: true
                Password: “WIFI-PASSORD”
           Dhcp4: true

Change the SSID-NAMEand the WIFI-PASSORD they have to be in quotes.

Close and save the file using ctrl+x and yes by tipping the letter y

finally you need to do some debugs

$ sudo netplan –debug try 
$ sudo netplan –debug generate 
$ sudo netplan –debug apply 

then reboot the pi

$ sudo reboot

Install ubuntu desktop with the following commad:

$ sudo apt-get install ubuntu-desktop


The above link provides further information on setting up the yaml file for those who have difficulty still.

New contributor
Scottc2789 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    You're expected to post essential information in your answer. As of now, your answer is meaningless should the link stop working. – Dmitry Grigoryev 14 hours ago
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review – Milliways 10 hours ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.