Gavin Long, the man identified on Sunday as the deadly shooter of police officers in Baton Rouge, left behind an online trail to web pages featuring complaints about the treatment of African Americans by police.

Using the pseudonym “Cosmo Setepenra”, Long, 29, railed in a series of videos, photographs and online writings at perceived injustices against black people.

“You gotta fight back,” he urged viewers in a video recorded a week ago.

Styling himself as a life coach and “spiritual advisor”, Long distanced himself, however, from well-known groups campaigning for African American rights.

“I thought my own thoughts, I made my own decisions – I’m the one who’s gotta listen to the judgment,” he said in another clip.

Long was shot dead by responding officers on Sunday, his 29th birthday, after allegedly shooting three officers dead and wounding three others, one critically.

His history of rambling postings indicated that the attack was motivated at least in part by killings by police of black Americans in recent years and the resulting unrest. In one recent clip, he expressed disgust over the arrest of protesters demonstrating in Baton Rouge over the fatal shooting of Alton Sterling earlier this month.

But they also pointed to apparent paranoia and mental instability. Long complained last year to likeminded message board users that he was a long-term victim of “gang-stalking”, a supposedly intense form of government and corporate surveillance covering every aspect of a subject’s life.

An image of ‘Cosmo Setepenra’ taken from Facebook. Photograph: Facebook

Claiming to be a round-the-clock “TI” – targeted individual – Long urged others in his situation to wear body cameras to monitor such surveillance and to warn companies involved in harassment “that we are going to expose your involvement and rate your poor performances & games on the internet”.

The US marines confirmed on Sunday that Long was honorably discharged in 2010 after five years of military service, including a year in Iraq. He reached the rank of sergeant. Long’s attack in Baton Rouge followed the Dallas attack by Micah Johnson, a US army veteran who served in Afghanistan.

In 2011 Long divorced his wife, Aireyona Hill, according to Missouri court filings, which said they did not have children. The Kansas City Star reported that it had published the couple’s marriage announcement in July 2009. Online postings indicated that Long had spent a prolonged period in Africa in 2015, apparently spending time in Ethiopia, Uganda, Kenya and Egypt.

Appearing to pre-empt public questions about his motivations, Long told viewers in one video clip that “if anything happens to me”, he should not be viewed as affiliated with organized groups despite past membership of the Nation of Islam and others.

“I’m affiliated with the spirit of justice,” he said. “Nothing else.”

Sorry, your browser is unable to play this video.Please upgrade to a modern browser and try again.

Connections between Long and his alter-ego Setepenra were revealed through registration logs underpinning a series of websites. A site was registered earlier this year by someone using Long’s name and home address inKansas City, Missouri, and an email address that has also been used by Setepenra. Law enforcement converged on an address in the city on Sunday.

A Facebook page in the name of Cosmo Setepenra was taken down late on Sunday afternoon, following the shootings in Louisiana. It was unclear why the page was taken down.

A recent posting had stated: “Violence is not THE answer (it is a answer), but at what point do you stand up so that you and your people dont become the Native Americans...EXTINCT?”

Two photographs posted on the page featured black children holding a piece of paper reading: “JUSTICE FOR ALL THE BLACK AMERICANS”.

A picture taken from a Facebook page in the name of Cosmo Setepenra. Photograph: Facebook

On a Twitter page using the Setepenra identity, Long in the early hours of Sunday stated: “Just [because] you wake up every morning doesn’t mean that you’re living. And just [because] you shed your physical body doesn’t mean that you’re dead.”

Video footage posted on the Setepenra Facebook page earlier this month appeared to show Long in Dallas, Texas, where five police officers had been killed by a gunman at the end of a protest against the excessive use of force by law enforcement.

In a video separately posted to YouTube on 10 July, Long said he was in Dallas. In a frequently incoherent rant, he compared the fighting of oppression by black people today to the efforts of American revolutionaries.

“But when an African fights back, it’s wrong,” according to mainstream thought, he said. “You gotta fight back – that’s the only way a bully knows to quit.”

In another video, Long embarked on racially charged rants against white and Asian people, accusing “Arabs and Indians” of exploiting black Americans for money.

According to public domain records, the website convoswithcosmo.club was registered in April this year in Gavin Long’s name and home address in Kansas City, along with a cellphone number and email address that have been posted online as being used by Cosmo Setepenra. The title of the site, Convos With Cosmo, is the title of an existing website and online radio show by “Cosmo Setepenra”.

Around the same time in April this year a second website, hambam.net, was registered using the same home address, email address and cellphone number but this time in the name of Cosmo Setepenra, according to a registration history for the domain that was purchased by the Guardian. Details of the ownership of the site have since been shielded.

A second email address used in past online message board postings by someone calling themselves “Cosmo Setepenra” and complaining about government surveillance was tied to Long’s home address in Kansas City by commercial public records databases.