How can I run the terminal command
sudo xinput set-button-map "Logitech Unifying Device. Wireless PID:101b" 1 10 3 4 5 6 7 8 9 2 at every startup?
This command affects the GUI, so it must be executed after the GUI is set up. If you can live without your custom mouse button assignment on the login screen, add the command to your startup applications. Don't use
With a Gnome interface, the startup applications are in "System > Preferences > Startup Applications". With the Unity interface, they are in "Applications > Other > Startup Applications". See Adding program to session startup in the Ubuntu community documentation for more details.
The script should be placed in /etc/init/logitech-unifying-device.conf You can use a different name as long as extension is .conf.
I assumed that it is wireless device. However you can exec command on any event you find to be suitable. For details see Upstart Cookbook.