For two nights preceding Uganda's 21st independence anniversary celebration here on Oct. 9, Army soldiers rampaged through the townships around this government center, brutally clubbing men and women with their rifle butts.

Many of the injured suffered cranial concussions, skull fractures and broken limbs, according to a western diplomat who had an employe badly beaten during the clash.

Such unprovoked cruelty, first fostered among the armed forces by military ruler Idi Amin, has continued as a pattern of behavior more than four years after the dictator's downfall.

"It's been almost standard practice that before big events, the soldiers behave as if they have been let loose," said the main political opposition leader, Paul Ssemogerere, who also talked about the attack here.

Since its hasty formation in 1979, the Uganda National Liberation Army has conducted mass executions of unarmed men, women and children in retaliation for antigovernment guerrilla attacks, according to western diplomats and human-rights organizations. According to these western accounts, the Army conducts massive sweeps of youths in Kampala and illegally detains thousands of civilians accused of being antigovernment insurgents. The reports say soldiers torture the detainees, rape young female prisoners rounded up as suspected guerrilla collaborators and murder prisoners by clubbing them, bayoneting them or leaving them in their cells to starve to death.

Of the prisoners who survive, a large number are freed after their families have paid large ransoms. Ordinary soldiers extort money at rural military roadblocks, such as the one all persons leaving Uganda by airplane must go through when driving the 25 miles from the capital of Kampala to the airport here.

"People have appealed to President Milton Obote to stop the bloodletting but he's got an army he did not form," said one sympathetic senior western diplomat. "No one is sure who controls it."

"The government has no control over the Army at the local level," said one western relief official working with the tens of thousands of peasants who have been displaced by the past two years' fighting between the Army and guerrillas in Luwero, Mpigi and Mubende districts.

"The military roadblocks are revenue collection points" for an army that the government rarely pays or feeds, he said. "If there is pressure to remove a certain roadblock, the Army gathers up several local men, shoots them and claims they were terrorists so the roadblock will not be removed," the official added.

On Oct. 27, Ugandan soldiers at the third Army roadblock, 25 miles west of Kampala on the road to Mubende, were collecting at gunpoint 100 shillings from each adult male on a bus and 50 shillings for each adult female on the road.

"That is every day at every roadblock," said a Ugandan relief worker taking a reporter through Mubende district. The soldiers waved the officially marked relief car through. "You begin to understand the impact of the extortion when you consider that 100 shillings about 33 cents is the average Ugandan civil servant's daily wage," he added.

Even at independence under Obote's first government, the 9,000-man Ugandan Army was a fragile institution. Obote relied on the Army's soldiers from the northern Nilotic tribes, like his own Langi people and the related Acholi.

In 1966 Obote ordered his deputy Army commander, Idi Amin, to storm the Kampala palace of the leader of the Baganda people. The Baganda leader managed to escape, but died in exile in London. Many Baganda since then have been opposed to Obote.

When Amin overthrew Obote five years later, he ordered the mass slaying of Langi and Acholi soldiers in the Army and replaced them with, among others, people from his West Nile Province. After Amin fell, Ugandan military leaders who had fought alongside the Tanzanians against the dictator, like current Langi Army commander Maj. Gen. David Oyite Ojok, recruited mostly Acholi and Langi into the new Army, which was hastily recruited and commanded by officers who were often inept.

The two groups, that had suffered years of persecution under Amin, took their revenge, in part, on Amin's compatriots from the West Nile. Next, they were unleashed on the guerrillas and the Baganda people in the southern coffee-growing districts around Kampala and Entebbe. With the guerrillas on the run in the past few months, the fighting has tapered off.

The reduced levels of conflict have resulted in an equal drop in reports of Army atrocities against civilians, but western diplomats cautioned that the Army is still barely under control. Moreover, some regional commanders have recruited many soldiers themselves and practically turned their divisions into private armies. No one even knows how many soldiers are in the Army; estimates vary from 40,000 to 25,000.

For his part, Obote has long disclaimed responsibility for the Army's indiscriminate violence, saying the force was recruited under trying circumstances in 1979 when Amin was fleeing. Obote did not return from his nine-year exile until May 1980.

Since the chaos after Amin's fall, the Army and police have been "undergoing a serious training program," he said.

A 35-man Commonwealth military team has trained about 1,500 Ugandan Army middle-level and noncommissioned officers in the past 18 months, but the impact on discipline is only slightly noticeable, a western diplomat said.

"It is a worry on how this training will filter down to the rank and file," said the diplomat. "A number of officers are afraid of their men, many of whom are unruly and often drunk and are not above threatening their officers."

Obote, moreover, has denied that any civilian detainees are being kept in military barracks. Yet he has not allowed officials of the International Committee of the Red Cross to inspect the suspected military barracks.

"There are no detainees in military barracks," Obote said in an interview. "There are no detainees who are tortured or murdered or killed in any way in government custody."

A 1982 report by the human rights group Amnesty International and a U.S. State Deparment report released earlier this year support allegations of civilian detentions, widespread abuses of human rights and killings carried out by soldiers in the military barracks. Well-informed western diplomats, one Ugandan government official who declined to be identified and political opposition leader Ssemogerere said abuses directed at civilian detainees is continuing in the Army's barracks.

"There are still large numbers of people who are arbitrarily arrested, detained and tortured and who are even killed violently, under physical torture or by starvation," said Ssemogerere. "One such torture place is Nile Mansions," the government hostel next to Kampala's conference center.

Amnesty International has identified Nile Mansions as a place where torture is used against suspected political opponents of Obote's government. It is also the place where several of the half dozen people who have disappeared here were last seen entering, according to Amnesty.

Ssemogerere also charges that in the past month Ugandan soldiers have begun a harassment campaign in his Mpigi constituency, which stretches from Entebbe to Kampala. He says soldiers are forcing people to leave their homes because the government says there is a danger of guerrilla operations. But Ssemogerere says no antigovernment activity has been recorded in the area.

Obote "has been complaining that this is not his army, that he found the soldiers already recruited," Ssemogerere said. "If Obote does not have control of the Army , why is he president?"

Obote angrily rejects Ssemogerere's charges about the abuse of civilians.

"You would not hear that type of statement from any other mouth, even members of Ssemogerere's Democratic Party. . . . He is not living in reality. The situation is improving," Obote said.

"There are an awful lot of renegade Ugandan soldiers, poorly trained, ill-paid and rarely fed," said a senior western diplomat. "After the decade they have just gone through under Amin , Ugandans are a dehumanized and brutalized people."