[deleted]
In general, they stayed well behind the front lines. Division command post would be behind brigade CP, battalion CP, etc. Company CP would be right up at the front line near the foxholes and firing positions. So a high ranking officer like a general would usually have layers of fighting troops and "rear echelon" troops (logistics, medical, etc) between him and the front line.