How to Programatically change the Wifi settings in Arduino Yun from Linino

A copy of the credentials is available in file /etc/config/arduino.
In order to programmatically reset wifi, use command wifi-reset-and-reboot