Buying the large economy toothpaste is a mistake for travelers and tourist, a small one is less likely to break in your bag and last a long time.
Photo of the best size, please do not buy ones that open easily, they will open easily inside your bag.
Small tubes are also easy to refill. Once empty, roll the tube up, apply the mouth of it to the mouth of a larger tube. Gently squeeze the larger tube and watch the smaller tube fill.
I do not like Hostels, and sharing showers, but when I have been in them, many people leave their shampoo, creme rinse, toothpaste sitting around. I can see people refilling their small ones, and for sure people are using the other peoples shampoo. I have a special shower bag, that hangs up.