In the summer of 2013, several science students at Cornell University in New York found themselves tasked with an unusual project. They were asked to go into subway stations and trains, and swab surfaces for no less than three minutes.

Christopher Mason, the Weill Cornell Medicine geneticist who devised the study, points out that three minutes is a long time when you are in the middle of a public place, swabbing away at a subway pole. Some bemused looks and questions from commuters later, though, the team amassed a comprehensive collection of samples from 468 stations.

The point of the exercise? To investigate the microbes that share our environments, riding the same subway trains that millions of New Yorkers use daily. These microscopic urban commuters vastly outnumber humans but we still know little about them. The project is one of many now underway to explore the urban "microbiome" – the localised population of microorganisms – and its influence on human health.

The work is at an early stage. But the initial results suggest we might want to nurture the urban microbiome, rather than fight to remove the microbes from our cities.

Back in the lab, Mason and his colleagues analysed their subway samples for viral and bacterial DNA. A huge range of microbes showed up. For example, there was heaps of Pseudomonas stutzeri, which is quite common in soils, and lots of Acinetobacter radioresistens, a radiation-resistant bacterium found on human skin.

Even a year later, microbes likely brought in by the weather had persisted there

There were also many potentially pathogenic – illness-causing – microbes. But it was not clear that they were actually causing any illnesses.

For instance, they seemed to lack many of the specific chunks of DNA that trigger human disease. And, obviously, people who ride the subway are not as a rule in a constant state of poor health.

"I'm extraordinarily confident in knowing that I can grab the pole and it's probably fine," says Mason. "I have more confidence [in that] than I did before, I would say."

The researchers also found that one subway station, which had been flooded during Hurricane Sandy the year before, still bore a microbial fingerprint of the event. The station's microbiome included ten species associated with marine life, like Shewanella putrefaciens. This suggested that, even a year later, microbes likely brought in by the weather had persisted there.

It is these sorts of studies that are finally revealing to us the microbes with which we share our city spaces.

The US recently launched a new initiative to better document these invisible species in our midst. Meanwhile, Mason and colleagues are now examining the microbiomes of mass transit systems in many places around the world.

But our co-existence with urban microbes is not always a happy one.

Humans have a combative relationship with their microscopic neighbours. Even now, with increasing awareness that many microbes in the human body are "friendly" – or potentially beneficial to our health – Western societies are at war with the bacteria and viruses that occupy the environment.

Cleaning products boast about the 99.99% of bacteria to which they will lay waste, and entrepreneurs are even developing devices to extend this reach. For example, a start-up called Bio-Smart is hoping to market an ultraviolet light that will indiscriminately vaporise bacteria within its range. In general, we are paranoid about pathogens.

The urban environment, by its very nature, is not always home-sweet-home to microbial life

"The fear-mongering is not warranted, because most of the bugs that we encounter on a daily basis are either good in terms of immune development, or good in terms of the whole barrier effect," says Klas Udekwu, a microbiologist at Stockholm University in Sweden.

The barrier effect Udekwu mentions refers to the process by which microbes on and within our bodies are able to fend off would-be pathogens. For example, bacteriophages are viruses that live on us but are sometimes good for us – they can help to prevent infections by infecting and replicating inside bacteria.

Of course, this does not mean that all of the microbes we encounter in the built environment are beneficial – but neither are they all detrimental to our health. The research efforts of Mason and others aim to explore where the balance lies.

How dangerous are the potentially pathogenic strains? What locations and surfaces support microbes better than others? And, living in these urban jungles, are we missing out on helpful microbes more commonly found out in nature?

As far as that last question is concerned, there is certainly some evidence to show that the urban environment, by its very nature, is not always home-sweet-home to microbial life.

In a study published in April 2016, researchers placed tiles with swatches of plasterboard, ceiling tile and carpet on the floors, walls and ceilings of nine offices in three cities. Over a year, samples were collected every four to six weeks, and the DNA of collected microbes was later analysed.

Despite the harshness of our offices and homes, some special microbes do get along quite nicely

Microbes were there, certainly, but the data seemed to show that they were largely the result of human presence and activity in the area, even though workers in the offices did not touch the experiment tiles during the study.

"Surface microbial communities may behave similarly to those found in the soils of the Atacama Desert, waiting for liquid water to become active," the paper notes.

Sean Gibbons at the Massachusetts Institute of Technology argues this paints a picture of office spaces as "microbial wastelands": microorganisms may be regularly deposited in buildings, but are not always able to thrive there.

Mason makes a similar point with regard to his research on the subway, which he describes as a "high traffic area". The next question, he says, is to find out which of the deposited microbes are able to do well over time.

There is evidence that, despite the harshness of our offices and homes, some special microbes do get along quite nicely.

In a study published in June 2016, Rob Dunn, a microbiologist at North Carolina State University, investigated the ability of some of these organisms to thrive in extreme conditions. Some microbe species seem quite happy in hot water heaters, dishwashers or even the bleach tanks of washing machines.

It's kind of eye-opening to see how gross your pipes are

Some microbes could only handle certain kinds of extremes: for example, they survived extremely hot habitats but succumbed to high or low pH. But others, like the nitrogen-fixing bacteria Azospira, were found in places that had extremes of all three kinds.

In a 2015 study, Dunn and his colleagues analysed microbes found in the dust on the outside of around 1,200 homes across the US. There were geographic trends, but not such a stark difference between urban and rural locations. Dunn makes the point that people with dogs in their homes are more likely to come into contact with microbes found in soil, thanks to Rover's habit of garden hole-digging.

Besides environmental location and the presence of pets, there are all kinds of ways in which the introduction of microbes to our homes can vary. One of the most unexpected, for some, is tap water.

Although drinking water itself lacks certain nutrients, a wealth of microbes can be found there. Amy Pruden at Virginia Tech points out that our water pipes are not sterile inside. In fact, they have a thin biofilm into which nutrients – and microbes – can be deposited.

Some microbe species seem quite happy in hot water heaters, dishwashers or even the bleach tanks of washing machines

"I don't know if you've ever checked out your pipe when the plumber has come over, but it's kind of eye-opening to see how gross your pipes are," she says. "There's a lot of microbiology going on there."

In a 2015 study, Pruden and colleagues examined the microbiome of water systems. They developed a rig of pipes, which they installed at five water utility plants in the US. They found the plants contained potential pathogens like Mycobacterium and Legionella, which can cause Legionnaire's disease – although these particular strains of the bacteria will not necessarily trigger disease.

It was the way each utility processed its water that made the largest difference between the microbiomes. Two of the utilities even drew their water from the same source, but the microbiomes of the liquid they pumped out to homes were distinct – showing that it was their own process for treating the water that really mattered.

What effect could all of this be having on human health? Are there healthier microbiomes to live within?

Dunn says there is likely a "huge impact" on our wellbeing from the microbes we are exposed to. But he adds, "Do we understand which of these exposures matter? Not at all."

So basically it's a gland for feeding microbes

Still, there are interesting leads that deserve more research. In 2013, science journalist Ed Yong wrote about the work of Susan Lynch at the University of California, San Francisco. Lynch has shown how the extra microbial diversity of a home with a dog appeared to have a positive impact on health – at least in experiments using mice instead of humans.

Some of the mice ate dust from homes where dogs lived, and were then exposed to allergens. These mice had reduced asthma-associated inflammation in their lungs than mice exposed to dust from dog-free homes. One of the microbial species that had this effect was Lactobacillus johnsonii – one of many bacteria found in mothers' vaginas just before birth.

It is also possible that our modern ways of living hamper microbes that our bodies have evolved to support.

Another 2016 study by Dunn's team investigated the effect of antiperspirants and deodorants on armpit bacteria.

The armpits of volunteers were sampled during the course of an eight-day period. For the first day, participants kept to their normal hygiene habits, then spent five days not using odour-busting sprays at all. Finally, participants they began using them again on the last two days of the experiment.

Dunn says there is likely a "huge impact" on our wellbeing from the microbes we are exposed to

The results showed that one genus of bacteria, Corynebacterium, had dramatically reduced levels when the aerosols were being used. In one sense this is desirable – for it is Corynebacterium that produce the unpleasant odours in a sweaty armpit. But what you might not know is that our armpits' apocrine glands seem to want them there.

"What they're really doing is not producing sweat, they're actually producing a sebaceous, liquid-like substance that appears to serve no function other than to feed microbes," says Dunn. "So basically it's a gland for feeding microbes."

Again, it is not yet clear how negative the effects of displacing Corynebacterium may be. But Dunn notes that knocking it out allows other microbes to thrive in our armpits, which could be disadvantageous for us.

Is there any way we could use all this information to improve the microbial diversity of our surroundings?

Increasingly, microbiologists are thinking about ways in which the introduction of favourable bacteria to urban environments may be more beneficial than approaches that seek to sterilise those places of all microbial life – not least because, thanks to microbes that favour extremes, those approaches seldom work as advertised.

The microbes we need are sometimes hampered by the structures we have build around us

Pruden suggests that one way of displacing harmful bacteria like Legionella in water systems could be to encourage the growth of antagonistic bacteria. These bacteria produce chemicals that can inhibit the bloom of potentially pathogenic microbes. One such species is Bacillus subtilis, which can have an antagonistic effect on Legionella.

And then there is Jack Gilbert, a trail-blazing microbiologist who is hoping to develop materials for buildings that encourage the presence and persistence of microbes that can stop pathogens taking hold.

In the last few years alone, then, we have unearthed heaps of new knowledge about how rich our urban environment is with microbial life – but also how fragile an ecosystem it is, too. The microbes we need are sometimes hampered by the structures we have build around us, and it is still not clear exactly how our health may be affected as a result.

It seems certain, though, that as this understanding continues to evolve, we will become ever more cognizant of our microbial neighbours. We have long shared our cities with them. Perhaps it is time we thought about how to get along.

Join over five million BBC Earth fans by liking us on Facebook, or follow us on Twitter and Instagram.

If you liked this story, sign up for the weekly bbc.com features newsletter called "If You Only Read 6 Things This Week". A handpicked selection of stories from BBC Future, Earth, Culture, Capital, Travel and Autos, delivered to your inbox every Friday.