Make sure to buy some food before you go. My favourite train snack is pistachios, because they take a while to eat - chews up time ;) Also make sure you have plenty of refreshments, especially caffeine if you're the sort of person who needs a shot when you wake up! Some trains (Russia) let you get off at stations and there are dozens of people selling cheap food and drink, but this is less common in Europe. And DO share your food with others - it's a good bonding activity, and you get to try out some of their food too!
Firstly, if you're in a cabin/carriage with just seats, you'll want a window seat. If you're ok with being a jerk about it, when the adjacent seat becomes available, you could put your stuff on it. This gives you an extra seat to use when you sleep. However, this will depend on seating numbers and whether you can change or not as well. In a train from Berlin to Krakow, a Brazilian girl and myself hunted through the train until we found an empty cabin. It had 8 seats facing each other. We each stretched out on four seats, and went to sleep. This worked well except for a random period from 4-6am when some kids came in and used 3 of the seats for two hours, and then they were gone again.
If you're travelling alone, this is even harder, but make sure to keep your possessions close by, if at all possible. Keep you wallet in your clothes, and if you're comfortable doing so, perhaps use a daypack as your pillow, with your valuables inside. I try to lock my leg through a strap on my pack if possible, for extra security. Consider using one of those wire-mesh security wraps for your pack - makes it much harder for someone to get in while you're asleep.
If you're in a carriage with others, it's chatting time! Everyone you meet has a story, find out theirs! And this is the best part - even if they're speaking in a foreign language, make it a game to figure out words - even if it takes you an hour to work out where they're from, what does it matter - it's a LONG train ride! Perhaps get them to teach you some words in their language - count from 1 to 10 etc. If you have playing cards, these are fantastic to use, and cheap.
Also consider books, a Kindle, netbook - whatever you use to entertain yourself while others are busy, or if there are no others around. Quite often travellers are keen to see your photos, and if you're as snap-happy as me, you can easily spent a couple of hours looking at each others' photos. By the end of the ride, you may have made a friend, found accommodation, or know a lot more about your destination, including locals' secret tips!