20

I am using Raspbian. I would like to make programatic changes to the WiFi settings. However, I can't find where they are located. Where are they? Any tips for editing them?

Also, in the "Manage Networks" of the WiFi Config, I am not able to remove old connections. Has anyone else had this problem? Is there a better way to config WiFi on the Raspberry Pi than this program?

0

4 Answers 4

9

If you are talking about NetworkManager settings, they are in:

/etc/NetworkManager/system-connections

If you do a ls -l you will see all your wireless networks there, one file per network.

If you want to delete a connection, you simply need to delete the corresponding file. If you give a sudo cat YourNetworkName.conf you will see something like this:

[connection]
id=YourNetworkName
uuid=929ceffc-8191-4dea-9a61-b4b174b9c910
type=802-11-wireless
timestamp=1218126248

[802-11-wireless]
ssid=YourNetworkName
mode=infrastructure
mac-address=00:28:F7:21:B1:19
security=802-11-wireless-security

[802-11-wireless-security]
key-mgmt=wpa-psk
psk=yourpasswordgoeshere

[ipv4]
method=manual
dns=192.168.10.1;8.8.8.8;
addresses1=192.168.10.100;24;192.168.10.1;

[ipv6]
method=auto

Everything is easily editable, provided that you know what these parameters mean.

For what concerns your last question:

Is there a better way to config WiFi on the Raspberry Pi than this program?

if you need a more reliable (and maybe scriptable) WPA/WPA2 connection I suggest to use WPA_Supplicant (or HostAP if you want your Raspberry Pi to become a wireless router) directly. I have to admit that NetworkManager is somehow practical, but it tends to take initiative too often for my taste, so I never use it when I need reliability.

4
  • Now, with Raspbian Jessie, you most definitely want to use wpa_supplicant. There are some odd initial issues, such as the OS swapping wlan0 and wlan1 - but once it is stable it is pretty reliable now.
    – SDsolar
    Commented Sep 30, 2017 at 4:19
  • i can't find /etc/NetworkManager ?
    – mrid
    Commented Jul 10, 2018 at 5:43
  • Do you have NetworkManager currently installed? What distro are you running? Both Ubuntu 16.04 and Debian/Raspbian Jessie have network-manager among their packages. You can install it with sudo apt install network-manager.
    – Avio
    Commented Jul 10, 2018 at 12:44
  • @Paul if you flash using Raspberry Pi Imager, and choose the operating system marked "recommended" (which is currently "Raspberry Pi OS 64 bit, Debian Bookworm released 2023-10-10"), then you get a popup to apply OS Customization Settings. These include the WiFi details. These get saved as a file under /etc/NetworkManager/system-connections
    – Bart Doe
    Commented Nov 28, 2023 at 13:43
26

Default behavior seems to consist in storing wifi settings in /etc/wpa_supplicant/wpa_supplicant.conf, just like @lucaslink mentionned. I'd like to provide a bit more details however. Here is how the wpa_supplicant.conf file is supposed to look like:

$ sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/Var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
        ssid="MyWiFi"
        psk="MyPassword"
        key_mgmt=WPA-PSK
}

I just removed the lines related to my WiFi, leaving the network section empty:

$ sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/Var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
}

And then I restarted the networking service:

sudo service networking restart
2
  • 3
    Still true in September 2017 with Raspbian Jessie.
    – SDsolar
    Commented Sep 30, 2017 at 4:16
  • How do you access this on the sdcard? I am trying to trouble shoot my Zero W and it's not visible on the network. Haven't had this problem with my other Pis. Commented Dec 20, 2023 at 22:20
5

I had the same issue, where WifiConfig GUI would not remember the deletion/removal of ssids in the Manage Networks tab. Raspbian doesn't have 'NetworkManager' settings but instead holds all network information (ssids, passwords, etc.) in

/etc/wpa_supplicant/wpa_supplicant.conf

to edit:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

it's contents will look something like:

network={
ssid="network name"
psk="wifi password"
}

Once the file has been edited and saved reboot your pi for changes to take effect. Your pi will no longer attempt connection to the forgotten networks.

IF this file is empty, but your raspberrypi is still connecting to rogue networks, your credentials are likely held in the interfaces file:

sudo nano /etc/network/interfaces

The entries for ssids and networks looks a little bit different in here, but same idea. You should see them at the end of the file. They will look something like:

wpa-ssid "network name"
wpa-psk "wifi password"

Delete/Add as you see fit.

4
  • How exactly should I edit wpa_supplicant.conf? Do I delete everything or just the network node or just what's between the curly brackets? Commented Jul 13, 2016 at 14:07
  • 2
    @Hand-E-Food Best case is to just remove whats between the curly brackets then restart the networking service: sudo service networking restart @Anto's answer below covers this too. Good luck!
    – lucaslink
    Commented Jul 14, 2016 at 14:39
  • In wpa_supplicant.conf you can remove the networks you want it to forget and leave the ones you think you want, with the SSID and password. It will connect to the first one that works. In my Raspian I haven't seen the wireless connections in interfaces by address. In there it says dhcp.
    – SDsolar
    Commented Dec 2, 2016 at 6:07
  • You can use your favorite editor, such as vi to edit the file, but of course you need to use sudo vi
    – SDsolar
    Commented Sep 30, 2017 at 4:21
0

I had this similar question some eleven years later. In my case, I have many similar devices and I want to automate cloning one to the next using the SD Card Copier utility provided with Raspberry pi O/S. I have two wifi devices, one internal and one an external usb plugin device. I found two files in /etc/NetworkManager/system-connections for the local SSID. The difference between the two files, other than the uuid value in the [Connections] section, is the mac-address value in the [wifi] section. These values will be wrong for the cloned device. To address this, I have a script to get the correct mac addresses using "ip -brief link show dev [wlan0|wlan1]", then I use sed on each file to replace the mac-address value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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