This network connection priotity, as said in most of the other answers, is set via the metric.
You can see this via routes command; here's mine for example:
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 100 0 0 enxdeb70e78396c
default tomoya 0.0.0.0 UG 101 0 0 enx2225cf7cf844
default _gateway 0.0.0.0 UG 600 0 0 wlp0s20f3
Here i have three network connections enxdeb70e78396c is my cable connection, enx2225cf7cf844 is my tethered phone and wlp0s20f3 is my wifi connection
so in my case it will first use the cable connection.
on Ubuntu you can change the metric using network-manager. But to do this you'll need the connection name, this can be found using the nmcli tool as follows:
$ nmcli connection show
NAME UUID TYPE DEVICE
Wired connection 1 d1e5e9af-06b5-3d49-a773-e80748773ed8 ethernet enxdeb70e78396c
myWifi f6dad8c9-e1ca-4018-a22b-890c0fbe257a wifi wlp0s20f3
Wired connection 2 0c4c49b8-4881-307f-ac0d-10e9f3f74de1 ethernet enx2225cf7cf844
as you can see my cable connection is called Wired connection 1
to use my tethered phone instead i'll have to increase the metric of my cable connection to be higher than my tethered phone. This can be done with the following command:
nmcli connection modify "Wired connection 1" ipv4.route-metric 102
to apply the change i have to bring the connection down and back up as follows:
nmcli connection down "Wired connection 1"
nmcli connection up "Wired connection 1"
now if i check my routes again i get
Destination Gateway Genmask Flags Metric Ref Use Iface
default tomoya 0.0.0.0 UG 101 0 0 enx2225cf7cf844
default _gateway 0.0.0.0 UG 102 0 0 enx4467522ea5c9
default _gateway 0.0.0.0 UG 600 0 0 wlp0s20f3
so now my all my traffic go through my tethered phone