Military organization
History: The use of formalized ranks in a hierarchical structure came into widespread use with the Roman Army.
In modern times, executive control, management and administration of military organization is typically undertaken by governments through a government department within the structure of public administration, often known as a  ministry of defence or department of defense. These in turn manage military branches that themselves command formations and units specialising in combat, combat support and combat-service support.

Executive control, management and administration: The usually civilian or partly civilian executive control over the national military organization is exercised in democracies by an elected political leader as a member of the government's cabinet, usually known as a minister of defence. In presidential systems, such as the United States, the president is the commander-in-chief, and the cabinet-level defense minister is second in command. Subordinated to that position are often secretaries for specific major operational divisions of the armed forces as a whole, such as those that provide general support services to the military, including their dependants.
Then there are the heads of specific departmental agencies responsible for the provision and management of specific skill- and knowledge-based services such as strategic advice, capability development assessment, or military science provision of research, and design and development of technologies. Within each departmental agency will be found administrative branches responsible for further agency business specialization work.

Military branches: In most countries, the armed forces are divided into three military branches (also service, armed service, or military service): army, navy, and air force.
Many countries have a variation on the standard model of three basic military branches. Some nations also organize their cyber force, emergencies service, medical service, military logistics, space force, marines, and special forces such as commandos or airborne forces as independent armed services. A nation's border guard or coast guard may also be an independent branch of its military, although in many nations border guard or coast guard is a civil law enforcement agency. A number of countries have no navy, for geographical reasons.
In larger armed forces, the cultures between the different branches of the armed forces can be quite different.
Most smaller countries have a single organization that encompasses all armed forces employed by the country in question. Armies of developing countries tend to consist primarily of infantry, while developed countries armies tend to have larger units manning expensive equipment and only a fraction of personnel in infantry units.
In western militaries, a joint force is defined as a unit or formation comprising representation of combat power from two or more branches of the military.

Internal security forces: Gendarmeries, military police and security forces, including equivalents such as paramilitary forces, militia, internal troops and police tactical unit, are an internal security service common in most of the world, but uncommon in countries with English common law histories where civil police are employed to enforce the law, and there are tight restrictions on how the armed forces may be used to assist.

Commands, formations, and units: It is common, at least in the European and North American militaries, to refer to the building blocks of a military as commands, formations, and units.
In a military context, a command is a collection of units and formations under the control of a single officer, although during World War II a command was also a name given to a battlegroup in the United States Army. In general, it is an administrative and executive strategic headquarters that is responsible to the national government or the national military headquarters. It is not uncommon for a nation's services to each consist of their own command (such as Land Component, Air Component, Naval Component, and Medical Component in the Belgian Army), but this does not preclude the existence of commands that are not service-based.
A formation is defined by the U.S. Department of Defense as "two or more aircraft, ships, or units proceeding together under a commander". Fomin in the Great Soviet Encyclopedia emphasised its combined-arms nature: "Formations are those military organisations which are formed from different speciality Arms and Services troop units to create a balanced, combined combat force. The formations only differ in their ability to achieve different scales of application of force to achieve different strategic, operational and tactical goals and mission objectives." It is a composite military organization that includes a mixture of integrated and operationally attached sub-units, and is usually combat-capable. Examples of formations include divisions, brigades, battalions, wings, etc. Formation may also refer to tactical formation, the physical arrangement or disposition of troops and weapons. Examples of formation in such usage include pakfront, panzerkeil, testudo formation, etc.
A typical unit is a homogeneous military organization (either combat, combat-support or non-combat in capability) that includes service personnel predominantly from a single arm of service, or a branch of service, and its administrative and command functions are self-contained. Any unit subordinate to another unit is considered its sub-unit or minor unit. It is not uncommon in the United States for unit and formation to be used synonymously. In Commonwealth practice, formation is not used for smaller organizations such as battalions, which are instead called "units", and their constituent platoons or companies are referred to as sub-units. In the Commonwealth, formations are divisions, brigades, etc.
Different armed forces, and even different branches of service of the armed forces, may use the same name to denote different types of organizations. An example is the "squadron". In most navies a squadron is a formation of several ships; in most air forces it is a unit; in the U.S. Army it is a battalion-sized cavalry unit; and in Commonwealth armies a squadron is a company-sized sub-unit.

Table of organization and equipment: A table of organization and equipment (TOE or TO&E) is a document published by the U.S. Army Force Management Support Agency that prescribes the organization, manning, and equipage of units from divisional size and down, but also including the headquarters of Corps and Armies.
It also provides information on the mission and capabilities of a unit as well as the unit's current status. A general TOE is applicable to a type of unit (for instance, infantry) rather than a specific unit (the 3rd Infantry Division). In this way, all units of the same branch (such as infantry) follow the same structural guidelines.

Modern hierarchy: 

Army: The following table gives an overview of some of the terms used to describe army hierarchy in armed forces across the world. Whilst it is recognized that there are differences between armies of different nations, many are modeled on the British or American models, or both. However, many military units and formations go back in history for a long time, and were devised by various military thinkers throughout European history.
For example, the modern Corps was first introduced in France about 1805 by Napoleon as a more flexible tactical grouping of two or more divisions during the Napoleonic Wars.

Rungs may be skipped in this ladder: for example, typically NATO forces skip from battalion to brigade. Likewise, only large military powers may have organizations at the top levels and different armies and countries may also use traditional names, creating considerable confusion: for example, a British or Canadian armored regiment (battalion) is divided into squadrons (companies) and troops (platoons), whereas an American cavalry squadron (battalion) is divided into troops (companies) and platoons. In the French system (used by many African countries) the company is divided into sections (platoons) composed of 3 x "groupes de combat" of 7 soldiers, plus a group of vehicle crews and a HQ that includes 2 x snipers.
Army, army group, region, and theatre are all large formations that vary significantly between armed forces in size and hierarchy position.  While divisions were the traditional level at which support elements (field artillery, hospital, logistics and maintenance, etc.) were added to the unit structure, since World War II, many brigades now have such support units, and since the 1980s, regiments also have been receiving support elements.  A regiment with such support elements is called a regimental combat team in US military parlance, or a battlegroup in the UK and other forces. Canadian Army doctrine also includes the combat team which is a company of infantry augmented with tanks, or a squadron of tanks augmented with infantry, or the combination of a full company of infantry with a full squadron of tanks.
During World War II the Red Army used the same basic organizational structure.  However, in the beginning many units were greatly underpowered and their size was actually one level below on the ladder that is usually used elsewhere; for example, a division in the early-WWII Red Army would have been about the size of most nations' regiments or brigades. At the top of the ladder, what other nations would call an army group, the Red Army called a front. By contrast, during the same period the German Wehrmacht army groups, particularly on the Eastern Front, such as Army Group Centre significantly exceeded the above numbers, and were more cognate with the Soviet Strategic Directions.

Navy: Naval organization at the flotilla level and higher is less commonly abided by, as ships operate in smaller or larger groups in various situations that may change at a moment's notice.  However, there is some common terminology used throughout navies to communicate the general concept of how many vessels might be in a unit.
Navies are generally organized into groups for a specific purpose, usually strategic, and these organizational groupings appear and disappear frequently based on the conditions and demands placed upon a navy.  This contrasts with army organization where units remain static, with the same men and equipment, over long periods of time.