I've been reading about WWI recently and trench warfare sounds absolutely terrible. Even going to the bathroom was a difficult task. Yet, in all the pictures I see of the time, the soldiers managed to stay clean shaven (presumably so they could wear gas masks when necessary). How were the soldiers able to do this? I don't even know how they'd be able to get a hold of a semi-clean razor to be able to shave. Did they just use bayonets?
I'll speak from the point of view of the British Expeditionary Force.
There are two points to note here.
The first is the system of rotation that was in place. A Division with 3 Brigades would normally have 1 Brigade out of the line for rest and recovery, and 2 up in the line, while each Brigade would usually have 1 Battalion up, 2 in the secondary lines conducting duties like carry food and water up, repairing fortifications, burying telegraph cables etc. and one to the rear.
Even when a Battalion was up, it would normally only have 2 Companies up with 2 in support.
One young Subaltern remarking that a Division would normally have about 1,000 bayonets in the front line out of its nominal strength of ~10,000.
It was therefore unusual to spend more than 2 or 3 days in a row in a front line trench, and you'd be unlucky indeed to spend more than a 7 days continuously in the line.
Add into this occasions where the entire Division would be taken out of the line en bloc and you can see that there was ample time away from the front line trenches for men to maintain themselves.
In rear areas, troops were usually provided with baths and clean uniforms, and had the opportunity to spend their pay on food, drink, or more vicious entertainment amongst the local fleshpots.
The second point is that hygiene was taken extremely seriously. Even in the most exposed front line trench, latrines would be located in saps dug a short way back from the line. These would either be buckets or 'long drop' type latrines.
Each company would have a corporal in charge of sanitation (or NCO i/c Shit Wallers, as they were known to the troops), and latrines were subject to frequent inspections by commanding officers and medical staff, the latter making recommendations for improvements in sanitary arrangements.
Measures to combat trench foot included issuing whale oil to troops to keep their feet dry, and foot inspections were a regular occurrence - failing to take care of your feet was a serious disciplinary offence that many judged to be the mark of a poor or green unit.
Shaving was just one additional aspect of trench hygiene and not too onerous to accomplish, a razor and bit of water being all that was required.