In an international armed conflict, civilians are generally protected by international humanitarian law from being harmed except:[1]
Nationals under their own state authority except for refugees of the occupying power living in occupied territory prior to hostilities as long they don't commit crimes after hostilities or that violate their own laws which are also ordinary criminal offenses under the law of the occupied state.
Nationals of a neutral state who find themselves in a recognized territory of a belligerent nation as long their state maintains diplomatic relations with a belligerent country
Nationals of a co-belligerent (i.e., allied) state as long their state maintains diplomatic relations with a belligerent nation
In an international armed conflict, protected civilians have the right to defend themselves. If they participate in other fighting, they are usually called partisans, and they can be tried for war crimes.
In a non-international armed conflict, Common Article 3 of the Geneva Conventions and their Additional Protocol II protect civilians regardless of nationality from the harmful effects of war. They can also be tried for harboring non-state armed groups since rebellion is a crime under the domestic law of most nations.
Many modern wars are civil wars. In a civil war, it can be difficult to make the distinction between the different parties at war, and it can also be difficult to make a difference between a civilian and a soldier.
Guerilla warfare and terrorism rely on the fact that the people taking part cannot be distinguished from civilians; they look like civilians, and not like soldiers.
Depleting the resources of the enemy has long been a method of war. Crops are burned and supplies blockaded so all, including enemy troops, will starve. In modern times strategic bombing may attack weapons factories, transport, and cities.