You have to come in contact with one of the viruses.
There are essentially two ways in which the virus gets transmitted from person to person:
1. Through the air: If a person with a cold sneezes or coughs, the virus travels with the small mucous droplets ready to infect those who inhale it.
2. Direct contact: Touching an infected person or an object that the infected person has come into contact with.
Although cold viruses can survive outside the body for about seven days, their ability to infect reduces after about 24 hours.
References:
Hopkinsmedicine
Jamaicahospital