What is the difference between der Zug and die Bahn (besides the gender of course)? When should one be used and not the other?
There are plenty of situations where Bahn and Zug can be used interchangeably:
- Both words can denote a concrete track-based vehicle ("Meine Bahn kommt."/"Mein Zug kommt.").
- Both words can denote the concept of a train ("Ich fahre mit der Bahn nach München."/"Ich fahre mit dem Zug nach München.").
When they are not interchangeable, though, or when both words are used together, Bahn leans towards describing the infrastructure or network, whereas Zug rather denotes the concrete vehicle, which is either track-based or composed of several connected vehicles:
- Railway companies or systems will usually call themselves ...bahn, hardly ever ...zug.
- Railway companies will call their vehicles exclusively Zug, especially when it gets more technical/internal ("Zugschluss", "Zugnummer", ...), but also when talking about the vehicles towards customers ("Zugdurchfahrt", "Zug fällt aus.", "Zug wird abgestellt.", "Zug wird in ... geteilt.", ...).
- Even some vehicles (or other moving things) that do not run on a track are sometimes called Zug. For instance, this can be the case for large trucks with heavy trailers ("Sattelzug"), but also for parades that move through a town ("Faschingszug").
- The word Bahn is also used for some non-track-based systems, such as aerial cable cars ("Gondelbahn").
Lastly, note that using either word (in particular Zug) to describe a concrete vehicle is reserved to track-based means of transportation. While aerial lifts are called Bahn such as "Gondelbahn", the vehicles/transport cabins are never called Zug or Bahn.
Bahn (which means something like "track") in general is anything that runs on rails or is otherwise bound to a track. For instance Straßenbahn, U-Bahn, S-Bahn, Seilbahn, Magnetschwebebahn, Eisenbahn These words are used when talking about the type of transport in general, e.g.: "die Berliner S-Bahn...", "Ich nehme die S-Bahn und nicht das Auto"... Also, as a general term it can be used to refer to the railway network (Bahn=railway) and also to "Deutsche Bahn", the german railway company.
Zug (from ziehen, to pull) refers to the train (locomotive plus coaches/wagons). Typically long distance trains are called Zug, while local trains are called S-Bahn, Regionalbahn, Stadtbahn, or similar. However Zug can also be used in the context of S-Bahn, U-Bahn, when referring to a specific train or to technical terms, e.g. "Zugnummer", "der Zug fährt ab", "die Züge der Berliner S-Bahn"
user1583209's answer is correct as to the concept of Bahn and Zug.
"Bahn" is more general and denotes the mode transport (using some sort of rail device) and also the company running the railway network. "Zug" is the physical object . My answer relates to the second question of usage:
Ich benutze die Bahn um zur Arbeit zu fahren. I commute by train. ("Bahn" by itself clearly implies the main railway network, not S-Bahn or U-Bahn or Seilbahn etc. Eisenbahn is a bit old fashioned but means the same thing as Bahn.)
Die Bahn hat ihre Preise um 6% erhöht. [this is the company]
Der Zug ist entgleist. The train is derailed. Ich steige in den Zug. I get on the train. [this is the actual train with locomotive and carriages attached. Trains carrying goods are called Güterzug.
And in reply to the comments to above answer: an "S-Bahn Zug" is the actual object, the city-rail-train that you step into but in common usage the word Zug is often omitted in this context. It is perfectly fine to say: Ich steige in die S-Bahn - as well as :Ich steige in die U-Bahn.
However to say: "Ich steige in die Bahn" sounds slightly odd to me. People will understand what you mean but "Zug" is definitely better in this context.