Nation rises up in support for liberty but leaders acknowledge sweeping changes need to follow massacres.

France has responded to the murderous assaults on journalists, police and Jews with an outpouring of grief and national unity, yet once the emotions recede it faces the harder task of neutralising violent Islamists and the conditions that allow them to spread.

The country has mobilised as never before in its postwar history, with millions joining rallies and commemorations for the 17 people killed last week by three gunmen who claimed allegiance to al-Qaeda or Isis (Islamic State).

The dead include the editor and cartoonists of a satirical magazine that had lampooned the Prophet Muhammad, three police officers - one of Arab origin and another of African background - and people at a kosher grocery in eastern Paris.

Watch: Raw: French police storm market, people flee


Their brutal deaths have sparked solidarity, a revival of nationhood and a sense of mission described in French as "un sursaut republicain", meaning a surge in support for the liberties on which the republic was founded.

Beyond the immediate reflex, though, lie challenges requiring unity and purpose for years to come.

They start with the immediate problem of stopping the radicalised-in-waiting and progress to the longer job of changing the social and economic conditions that help to transform alienated young French Muslims into ruthless jihadists.

Priority No1 will be to overhaul domestic intelligence, strengthen protection of Islamists' targets and beef up international security co-operation.

Brothers Cherif and Said Kouachi, suspected of carrying out the attack on Charlie Hebdo magazine in central Paris, and an associate, Amedy Coulibaly, who attacked the grocery store, were able to go to the Middle East for training, return home, acquire assault rifles, a rocket launcher and explosives and plot their attacks.

None of this was apparently spotted by the security services, even though two of the three had criminal records and were known radicals, and Charlie Hebdo and its editor had received death threats from Islamist groups and were under police protection. "There were flaws, that's obvious," Prime Minister Manuel Valls said after the three were shot dead by police, ending a twin hostage drama at the kosher store and a village northeast of the capital.

"This is why we have to learn from what happened. We owe this duty in truth to the victims, their families and our fellow citizens."

The authorities must also reform France's prisons, where Cherif Kouachi and Coulibaly became radicalised through contact with an Islamist fellow inmate.

Experts consider the transformation a classic process: companionship, mentoring and jihadist instruction give a delinquent or lost soul an identity and holy mission.

The orphaned Kouachi brothers were brought up in state institutions and were known to the police for delinquency.

France was reminded of the prison problem through Mohammed Merah, who in 2012 killed seven people, including three children and a teacher at a Jewish school in Toulouse, and Mehdi Nemmouche, who is suspected of murdering three people at the Jewish Museum in Brussels last June.

It is now bound to get closer attention. Potential solutions include smarter monitoring of extremists in penitentiaries, better facilities in prison and support for those behind bars or returning to civilian life, including spiritual backing.

"There aren't enough [Muslim] prison chaplains," said Yaniss Warrach, who visits inmates at Alencon-Conde in Normandy, one of France's bleakest prisons.

"Inmates who have a spiritual void end up in the orbit of inmates who grow a beard and practise sectarian beliefs."

There are only 132 chaplains for a nationwide prison population of 67,000, although this compares with just 32 chaplains in 2012, Warrach told AFP. Then there is the longer need of integration. France has more than five million Muslims, the most of any country in Europe, in a population of 65 million.

Most of them are immigrants, or their descendants, from the country's former colonies in North and West Africa and Lebanon.

Despite the avowed "republican" goal of equality, the incomes, housing, educational and professional attainment of Muslims clearly fall far below the national average.

But data on the basis of ethnic or religious background is absent in French statistics.

Apart from football and music, there are few examples of success by this group, and they have a particularly dismal lack of role models in the media and politics.

"The challenges of integration persist," the Organisation for Economic Co-operation and Development (OECD) said last month.

Changing this so Muslims feel more of a stake, a greater ownership in the republic will require resources, a willingness on both sides to communicate and share, according to Max Gallo, a historian and former minister. "We have to consider members of the Muslim community to be fully fledged French citizens, to integrate them as we have done in the past with Italians or other French people of different origins," Gallo told Le Parisien.

"It also requires efforts on [Muslims'] part. Muslims need to speak out clearly whether they wish to be assimilated and what this will imply in terms of their religion."

But reaching out is a big ask at a time of cripplingly high unemployment, shrinking budgets and deep anxiety after extremists claiming to act in the name of Islam carried out a double massacre.

An Ifop poll at the weekend suggests most French people do not view Muslim fellow citizens as a danger - but many think otherwise of their religion. Sixty-six per cent agreed with the statement "no link should be made between Muslims living peacefully in France and radical Islamists" while 29 per cent agreed with the statement, "Islam represents a threat".

Trail of clues led police to suspects

A fingerprint smudged on a Molotov cocktail, an identity card left in a getaway car and DNA found in a balaclava all helped French police piece together the identity of the jihadist gunmen who held the country in a three-day grip of terror.

A few crucial mistakes would allow police to quickly identify them in a colossal manhunt that would culminate in a dramatic showdown leaving all three dead.

The grisly scene inside the Charlie Hebdo building where eight journalists, a police guard and a visitor were killed revealed 31 Kalashnikov bullet casings, said Paris prosecutor Francois Molins.

Outside, some 25 bullet casings from a 9-millimetre handgun were scattered around as the brothers Cherif and Said Kouachi climbed into their parked Citroen and fled to the north of Paris. But an accident forced them to abandon their car, giving investigators crucial information, such as Said's identity card.

A hooded police officer approaches the market where Amedy Coulibaly held hostages. Photo/ AP

Cherif's fingerprint was found on one of 10 Molotov cocktails, while Molins revealed police had also found a "jihadist flag" of the type used by al-Qaeda in the Arabian Peninsula and Isis (Islamic State).

That same afternoon police issued arrest warrants for the brothers and took Cherif's wife into custody.

Enter Amedy Coulibaly. The petty criminal believed to have become radicalised in prison was armed to the teeth when he was involved in a car accident before sunrise the next morning in Montrouge south of Paris.

Masked and wearing a bullet-proof vest, he fired on police coming to investigate with a Kalashnikov and handgun, killing a policewoman and injuring a municipal worker. He hijacked a car, dropping his balaclava as he fled.

Within two hours police were able to match DNA from the balaclava with that of Coulibaly. Cherif's wife confirmed to police the two men knew each other "very well" and she and Coulibaly's wife were found to have spoken by phone more than 500 times in the past year.