Table of contents:
Get the ID of the device:
~> xinput list ⎡ Virtual core pointer id=2 [master pointer (3)] | ... ⎜ ↳ Logitech M705 id=10 [slave pointer (2)]
Mouse button mapping is normally:
1 = left button 2 = middle button (pressing the scroll wheel) 3 = right button 4 = turn scroll wheel up 5 = turn scroll wheel down 6 = push scroll wheel left 7 = push scroll wheel right 8 = 4th button (aka browser backward button) 9 = 5th button (aka browser forward button)
So swap the buttons you'd like to. For me it was side buttons' back/forward feature. So it was only swapping 8 and 9 in the order:
xinput set-button-map 10 1 2 3 4 5 6 7 9 8 10 ^- This is device id