How can I restore iPhone 6 to factory settings on Ubuntu? I need to restore it to main settings, remove I cloud and password
Firstly, restoring an iPhone that is logged into iCloud will turn on iCloud Lock, which is impossible to bypass. If you already have a locked phone, I suggest you return it to where you bought/stole/found it.
Secondly, restoring is impossible from Ubuntu. Apple has not provided drivers for Linux, nor will iTunes work (yes, there's WINE, but that doesn't support USB communication). There's no way to restore an iPhone from Ubuntu.
Thirdly, if the phone isn't locked, just reset from Settings. It'll iCloud Lock it if iCloud is logged in.