In military terminology, desertion is the abandonment of a "duty" or post without permission from one's Government or superior. The term AWOL is an acronym for "Absence Without Leave." Ultimate "duty" or "responsibility," however, under International Law, is not necessarily always to a "Government" nor to a "superior," as seen in the fourth of the Nuremberg Principles, which states:
"The fact that a person acted pursuant to order of his Government or of a superior does not relieve him from responsibility under international law, provided a moral choice was in fact possible to him."
"Under UN General Assembly Resolution 177 (II), paragraph (a), the International Law Commission was directed to 'formulate the principles of international law recognized in the Charter of the Nuremberg Tribunal and in the judgment of the Tribunal.'"
In 1998, the United Nations Office of the High Commissioner for Human Rights document called “Conscientious objection to military service, United Nations Commission on Human Rights resolution 1998/77” recognized that “persons [already] performing military service may develop conscientious objections” while performing military service. 
In the United Kingdom, United States and Canada, military personnel become AWOL (US: Absence Without Leave) or AWL (UK, Canada and Australia: Absent Without Leave), all of which are pronounced /ˈeɪwɔːl/, when they are absent from their post without a valid pass or leave. The United States Marine Corps and United States Navy generally refer to this as Unauthorized Absence, or "UA." Such people are dropped from their unit rolls after 30 days and then listed as deserters. However, as a matter of U.S. military law, desertion is not measured by time away from the unit, but rather:
People who are away for more than 30 days but return voluntarily or indicate a credible intent to return may still be considered AWOL, while those who are away for fewer than 30 days but can credibly be shown to have no intent to return (as by joining the armed forces of another country) may nevertheless be tried for desertion or in some rare occasions treason if enough evidence is found.
In the United States, before the Civil War, deserters from the Army were flogged, while after 1861 tattoos or branding were also adopted. The maximum U.S. penalty for desertion in wartime remains death, although this punishment was last applied to Eddie Slovik in 1945. No US serviceman has received more than 18 months imprisonment for desertion or missing movement during the Iraq war.
AWOL/UA may be punished with nonjudicial punishment (NJP; called "office hours" in the U.S. Marines Corps); and may punished by Court Martial under Article 86 of the Uniform Code of Military Justice for repeat or more severe offenses.
Also, "Missing Movement" is another term which is used to describe when a particular serviceman fails to arrive at the appointed time to deploy (or "move out") with his assigned unit, ship, or aircraft; in the United States military, it is a violation of the Article 87 of the Uniform Code of Military Justice. The offense is similar to AWOL, but considered more severe.
Less severe is "Failure to Repair," consisting of missing a formation, or failing to appear at an assigned place and time when so ordered.
Rogue military units are usually when an officer deserts with most or all troops under his command. This usually leads to a creation of a new faction. This is typically caused when their country is near defeat, during a Societal collapse, or following a mutiny. Examples include rogue armies during the Decline of the Roman Empire. During the Soviet advance toward Germany in World War II the Russian Liberation Army deserted, fighting German and Soviet forces.
The desertion rate for American soldiers in the War of 1812 was 12.7%, according to available service records. Desertion was especially common in 1814, when enlistment bonuses were increased from $16 to $124, inducing many men to desert one unit and enlist in another to get two bonuses.
In the Mexican–American War, high desertion rates were a major problem for the Mexican army, depleting forces on the eve of battle. Most of the soldiers were peasants who had a loyalty to their village and family but not to the generals who conscripted them. Often hungry and ill, never well paid, under-equipped and only partially trained, the soldiers were held in contempt by their officers and had little reason to fight the Americans. Looking for their opportunity, many slipped away from camp to find their way back to their home village.
The desertion rate in the U.S. army was 8.3% (9,200 out of 111,000), compared to 12.7% during the War of 1812 and usual peacetime rates of about 14.8% per year. Many men deserted in order to join another U.S. unit and get a second enlistment bonus. Others deserted because of the miserable conditions in camp, or were using the army to get free transportation to California, where they deserted to join the California gold rush.
Several hundred deserters went over to the Mexican side; nearly all were recent immigrants from Europe with weak ties to the U.S. The most famous group was the Saint Patrick's Battalion, about half of whom were Catholics from Ireland. The Mexicans issued broadsides and leaflets enticing U.S. soldiers with promises of money, land bounties, and officers' commissions. Mexican guerrillas shadowed the U.S. Army, and captured men who took unauthorized leave or fell out of the ranks. The guerrillas coerced these men to join the Mexican ranks—threatening to kill them if they failed to comply. The generous promises proved illusory for most deserters, who risked getting shot if captured by U.S. forces. About fifty of the San Patricios were tried and hanged following their capture at Churubusco in August 1847.
Desertion was a major factor for the Confederacy in the last two years of the war. According to Weitz (2000), Confederate soldiers fought to defend their families, not a nation. He argues that a hegemonic "planter class" brought Georgia into the war with "little support from non-slaveholders" (p. 12), and the ambivalence of non-slaveholders toward secession, he maintains, was the key to understanding desertion. The privations of the home front and camp life, combined with the terror of battle, undermined the weak attachment of southern soldiers to the Confederacy. For Georgia troops, Sherman's march through their home counties triggered the most desertions.
Adoption of a localist identity caused soldiers to desert as well. When soldiers implemented a local identity, they neglected to think of themselves as Southerners fighting a Southern cause. When they replaced their Southern identity with their previous local identity, they lost their motive to fight and, therefore, deserted the army.
One example of desertion in the Civil War was Confederate soldier Arthur Muntz, who was killed by his fellow soldiers after deserting at The First Battle of Bull Run. In many cases, in the early years of the war, the Confederate Home Guard dealt with deserters. For a time, the Confederate government offered a bounty to be paid for the capture and return of deserters. However as the war progressively got worse for the south, often Home Guard units would deal with desertion as they saw fit, whether that be by execution or imprisonment.
In Arkansas, many units deserted completely when rumors spread that local Indians had raided towns and scalped citizens, with the soldiers feeling their place was at home rather than fighting in the war. There were also instances across the southern states where whole units deserted together, banding together and living in the mountains, at times fighting against Union Army regulars if forced to do so, but also raiding civilian farms to obtain food or supplies.  The fictional story of a wounded Confederate deserter is told in the novel Cold Mountain, who at the end of the Civil War walks for months to return home to the love of his life after receiving her letters pleading him to come home. Many Confederate units had signed on, initially, for a one year service, and felt completely justified in walking away when they'd reached their breaking point. By the war's end, it was estimated that the Confederacy had lost 103,400 soldiers to desertion. 
The Union Army also faced large scale desertions. Confederate forces lost fewer to desertion than did the northern forces. This has been partly attributed to the southern soldiers fighting a defensive war, on their own ground, rather than an offensive war of invasion, which gave the southern soldiers a sense that they were defending their homeland which is always an advantage in any war. In addition up until late 1863 the South had many victories, in fact more than the North, and many northern soldiers felt the war was a lost cause. For example New York alone suffered 44,913 desertions by the war's end, with Pennsylvania having 24,050 and Ohio having 18,354, not to mention the desertions faced by the other northern states. 
"306 British and Commonwealth soldiers [were] executed for...desertion during World War I," records the Shot at Dawn Memorial. "During the period between August 1914 and March 1920 more than 20,000 servicemen were convicted by courts-martial of offences which carried the death sentence. Only 3,000 of those men were ordered to be put to death and of those just over 10% were executed...." 
Over 21,000 US military personnel were convicted and sentenced for desertion during the 3.5 years of American involvement in World War II. Of these, 49 were sentenced to death, but only one soldier, Eddie Slovik, was actually executed for desertion; he being the only one after the Philippine–American War.
Of the Germans who deserted the Wehrmacht, 15,000 men were executed. In June 1988 the Initiative for the Creation of a Memorial to Deserters came to life in Ulm. A central idea was, "Desertion is not reprehensible, war is".
Order No. 270, dated August 16, 1941, was issued by Joseph Stalin. The order required superiors to shoot deserters on the spot. Their family members were subjected to arrest. Order No. 227 directed that each Army must create "blocking detachments" (barrier troops) which would shoot "cowards" and fleeing panicked troops at the rear. The Soviets executed 158,000 soldiers for desertion.
Approximately 50,000 American servicemen deserted. Some of these migrated to Canada. Among those who deserted to Canada were Andy Barrie, host of Canadian Broadcasting Corporation Radio's Metro Morning, and Jack Todd, award-winning sports columnist for the Montreal Gazette.
According to the Pentagon, more than 5,500 military personnel deserted in 2003–2004, following the Iraq invasion and occupation. The number had reached about 8,000 by the first quarter of 2006. Another report stated that since 2000, about 40,000 troops from all branches of the military have deserted, also according to the Pentagon. More than half of these served in the US Army . Almost all of these soldiers deserted within the USA. There has only been one reported case of a desertion in Iraq. The Army, Navy and Air Force reported 7,978 desertions in 2001, compared with 3,456 in 2005. The Marine Corps showed 1,603 Marines in desertion status in 2001. That had declined by 148 in 2005.
As per media reports, as many as 1,700 personnel from Pakistan army, para-military and police have left the armed forces fearing militant attacks during the FATA and Swat operations(2009).The attack on the Police Training Centre (PTC) in Lahore is the final outcome of the terrorist's strategy to target the security personnel in Pakistan and thus isolate them as vulnerable targets,sitting ducks who can be targeted anytime, anywhere.The soldiers and cops who have deserted have adverted it through the local newspapers. "Many of them have published it in the local papers that they are no more in uniformed services. The idea is to safeguard themselves and their families from the militant groups.Pakistan government was more worried about the arms and ammunition that the soldiers have surrendered to the militant groups instead of depositing it with the government.Meanwhile, the steps taken by the Pakistan government to stop this gradual, but steady outflow of soldiers too have miserably failed. Some months back, the government decided to increase the insurance cover for the soldiers, but that too has failed to create a positive environment.
Acronym used in the United States Army: “Absent WithOut Leave”.