— Until last month, Ayman Faraj Hasan al-Barady, a ship captain’s assistant, had never handled a weapon. But when the uprising against Libyan leader Moammar Gaddafi began and soldiers abandoned a large army base here, he went in and picked up an AK-47.

“All I knew,” he said, “is that you just need to slide the handle back and then pull the trigger.” He knew this “from what I saw in the movies. And also from PlayStation.”

As Gaddafi’s forces moved toward his home town, Barady, 30, volunteered at an opposition base, but there was no time for training. When government forces launched a fierce attack on Benghazi, he recalled, “the commander said, ‘Empty the base, go to the streets and hide yourselves — and if you want to fight, you can.’ ”

Such is the state of the rebels’ ragtag army, which has plenty of heart but not much organization, training or chain of command. A few seasoned officers, defectors from Gaddafi’s army, have stepped in to help, but with no command structure and a hodgepodge of weapons, rebel leaders acknowledge that it has been as hard to train a new army during wartime as it has been to restrain eager fighters from charging off to the battlefield.

“In a revolution, it’s very hard to control patriotic, excited young men,” said Mustafa Gheriani, an opposition spokesman. “If you come in and say, ‘I would like to volunteer,’ there is no system to receive you.”

Eastern Libya is on an adrenaline high, as people revel in a Gaddafi-free existence for the first time in 41 years. In these heady days, the fever of war has burned more clearly than the means of waging it.

Throughout the region, young men in mismatched fatigues and camouflage have set up checkpoints and installed themselves on street corners, with assault rifles and bayonets slung over their shoulders, handcuffs and knives shoved into pants pockets, cigarettes dangling from their lips.

They are students and engineers, bakers and plumbers whom circumstance has turned into soldiers. They have learned to jerry-rig antiaircraft artillery onto the backs of pickup trucks. They have packed into cars and driven to wherever the fighting was taking place. They lack communication equipment and, in many cases, have no idea with whom to communicate. Some arrive at the front unarmed, confident they can poach a weapon from a dead soldier.

But on the battlefield, enthusiasm only gets you so far. With nearly 8,000 rebels killed, by their own count, the movement’s leaders are struggling to impose structure and discipline onto an army that has existed only for a month and, if not for the airstrikes by the international coalition, probably would have been demolished by now.

Since the airstrikes, the movement’s leaders said, they have taken a more measured approach.

“We are preparing ourselves, and we are trying to hold ourselves back a little bit,” Mustafa Abdel Jalil, president of the interim government, said last week. “When the heavy military machinery of Gaddafi becomes weak, we’ll be able to move.”

That movement appears to be underway, with rebels recapturing Ajdabiya after coalition airstrikes there and pushing west into the oil ports of Brega and Ras Lanuf and the coastal town of Bin Jawwad on Saturday and Sunday.

The rebels have also installed a new army commander, a former Libyan officer who is widely respected. But one of the opposition’s most urgent needs is arms and ammunition, and their representatives abroad are pressing foreign governments to provide them, Jalil said.

Rebel officials are candid about the military’s weaknesses. For years, the Libyan military has been plagued by dysfunction, with a weakened national army that is inferior to the special militias that are overseen by each of Gaddafi’s sons. These militias have worked independently of one another and employed foreign fighters.

When the Libyan uprising began, there was no centralized army to throw its support behind the protesters, as had happened in Egypt. “No one expected that military special forces were going to come and wage a war on us,” Gheriani said. “We never expected to be commanders in the field. Now, all of a sudden, we’re saying, ‘Let’s build a military.’ ”

That will not be fully possible until after the war, said Col. Ahmed Bani, a spokesman for the rebel military who was an air force officer under Gaddafi. “Before there was no army, but now, inshallah [God willing], there is an idea for a new army,” he said. “We will start from scratch.”

The military is not the opposition’s only fragile point. The interim government, new and inexperienced, is on high alert for Gaddafi loyalists trying to infiltrate the area.

Jalil, upon whom Gaddafi put a $400,000 bounty this month, is shuttled from house to house in his home town of Baida, with young revolutionaries camped out in the street to protect him. Last week, at an opposition training base in western Benghazi, a colonel was killed by a volunteer who turned out to be a Gaddafi loyalist.

Living in a state of chaos is not new for Libyans. Their government has for years been subjected to the whims of one man, and their cities are littered with unfinished construction projects, some going back decades. Now, although it is split off from its capital, eastern Libya is remarkably functional. There is electricity, gas stations are open and banks are running, as is one of the country’s two cellphone services.

Still, opposition leaders recognize the urgent need for a viable and better-organized military.

“There are no privates,” said Ibrahim Hadia, who is helping to coordinate communication between the interim government and the rebel military. “In one site where I’m working, there are 60 colonels and about 100 privates, and half of them are not paid.”

For the time being, though, there are small improvements. In pushing west now, the rebels say they will ensure each town is secure before moving ahead and plan more strategically for battles in challenging areas.

Experienced soldiers are also taking more of a lead in battle, pushing novices toward the back. And fighters are getting a little more training.

“We need even one or two hours,” said Mohammad Nuri, a colonel who left Gaddafi’s navy to join the rebels. “Just to train them to learn how to use this gun and to go on.”