1

I am trying to use nmcli to edit an existing connection and I would like to remove completely some properties (as opposed to just modifying their value).

Specifically the properties are wifi-sec.key-mgmt and wifi-sec.psk and the use case is because the network has been switched to open mode from wpa-psk mode.

I can't seem to find a way to delete these properties, and the nmcli help seems to point to the command nmcli connection modify but it doesn't seem to have the ability to delete entire properties, just delete some items in multi-value properties, which is not the case for the ones I want.

Usage: nmcli connection modify { ARGUMENTS | help }

ARGUMENTS := [id | uuid | path] <ID> ([+|-]<setting>.<property> <value>)+

Modify one or more properties of the connection profile.
The profile is identified by its name, UUID or D-Bus path. For multi-valued
properties you can use optional '+' or '-' prefix to the property name.
The '+' sign allows appending items instead of overwriting the whole value.
The '-' sign allows removing selected items instead of the whole value.

Is there any way to completely remove a property via nmcli or do I have to delete the whole connection and then re-create it without these properties ?

Note that this needs to be invoked from another program, so interactive mode commands are not suitable.

2 Answers 2

2

Provided the property is not a flag or container-type (if it is, use the nmcli c modify conid -setting.property value syntax you describe) then the nmcli man page specifies to set the property value to an empty string to reset it to defaults:

nmcli con modify id setting.property ""

You can also use the 'remove' keyword to unset a whole setting section on the connection instead of a specific property via:

nmcli con modify [--temporary] [id | uuid | path] ID remove setting
0

Information from nmcli manual:

  1. First you need to identify the connection you want to edit with the following command:

    nmcli connection show

  2. Then, assuming you have a connection named 'Ethernet' (used here just as an example) use this command:

    nmcli connection edit Ethernet

It starts the ===| nmcli interactive connection editor |===, which can remove properties of a connection.

1
  • Thank you, but unfortunately this does not work for me because nmcli is invoked by another program, thus I can't go into interactive mode. I updated the original question. Commented Jan 12, 2021 at 9:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .