Context. As the 4th most abundant element in the universe, carbon (C) is widespread in the interstellar medium (ISM) in various allotropic forms (e.g., fullerenes have been identified unambiguously in many astronomical environments, the presence of polycyclic aromatic hydrocarbon molecules in space has been commonly admitted, and presolar graphite as well as nanodiamonds have been identified in meteorites). As stable allotropes of these species, whether carbon nanotubes (CNTs) and their hydrogenated counterparts are also present in the ISM or not is unknown. Aims. We explore the possible routes for the formation of CNTs in the ISM and calculate their fingerprint vibrational spectral features in the infrared (IR). Methods. We study the hydrogen-abstraction/acetylene-addition (HACA) mechanism and investigate the synthesis of nanotubes using density functional theory (DFT). The IR vibrational spectra of CNTs and hydrogenated nanotubes (HNTs), as well as their cations, have also been obtained with DFT. Results. We find that CNTs could be synthesized in space through a feasible formation pathway. CNTs and cationic CNTs, as well as their hydrogenated counterparts, exhibit intense vibrational transitions in the IR. Their possible presence in the ISM could be investigated by comparing the calculated vibrational spectra with astronomical observations made by the Infrared Space Observatory, Spitzer Space Telescope, and particularly the upcoming James Webb Space Telescope.