In order to probe the ability of ions to enter and leave a nanotube, ab initio calculations were made of the energetics of direct diffusion pathways for H+, Li+, Na+ or K+ cations moving through (3,3), (4,4) and (5,5) open-ended single-walled carbon nanotubes. For the three nanotubes, there was no energy barrier for the Li+ ions to enter the open tubes. There was instead a net decrease in the energy of the system, showing that the nanotubes actually acted as an attractor for the Li+ ions. Similar results also held for the H+ and Na+ ions in (4,4) nanotubes. These ions could easily diffuse and leave the nanotube from the other side. The H+ was strongly attracted to the (3,3) nanotube, but could not diffuse and was trapped. The results showed that entry of K+ and Na+ ions into the (3,3) nanotube was forbidden. In contrast, (4,4) and (5,5) nanotubes with regard to H+ and K+ ions, and (5,5) nanotubes with regard to Na+, acted as ion channels which conducted those ions. In all nanotube-H systems and the (3,3) nanotube-Li system, the charge transferred between the ion and the nanotube and the nanotube acquired a positive charge.