You can reset your device to factory settings via terminal (CLI) by executing the firstboot command. After the command has been entered it'll prompt you for confirmation before erasing all settings and reverting to default configuration. Make sure to restart your device after successful confirmation by using the reboot command. The device should be up and running with default configuration after it restarts.
More information regarding the process is available on our wiki page here.