Yes. But...
I've done that journey, both ways, many times, in 2nd class & 3rd class (or whatever they call the classes these days)
Try to get a 1st class or 2nd class "coupe" which is a "half" cabin. In 1st class, that is two bunk beds and in 2nd, it is 3 bunk beds.
The alternative is sharing with 3 other (first class) or 5 other (2nd class) people in your cabin. If you are married or book with a male/female couple you have a better chance of getting into a 2 bed cabin.
I would not recommend 3rd class unless you are fairly brave, but it is cheap. And loud. And full of drunk people singing church songs.
The train stops everywhere, all the time. I'd suggest buying a chain and lock to secure your luggage in case someone gets off with it, while you are asleep.
Typically people get really drunk on the 26 hour trip. This is worse in 3rd class, but I've seen some bad **** in 2nd too. Take booze but don't get too drunk.
Keep your wits about you, it will be fine.