Carbon monoxide is composed of one carbon and one oxygen. We have to first determine the type of bonding, as well as the number of electron pairs in the molecule.
To do this, we need to count the number of valence electrons involved in the bonding. Carbon has 4 valence electrons, while oxygen has 6 valence electrons.
First, we connect the two atoms (C-O; from this point on, the number of dashes [-] will represent the kind of bond, [--] means double bond, etc.). Hence, we have C-O. This means that we have already used up 2 electrons, so we have 8 more left (6 + 4 - 2). We use the 8 to complete the octet on both C and O -- which is not possible since we would need 12 electrons to do so. Hence, we form a multiple bond: C -- O. Again, we try to complete the octet by using the remaining 6 electrons (4 + 6 - 4). This is again impossible since we need 8 to do so. We form another bond: C --- O (C triple bond O). We have 4 electrons left, which we can use to complete the octet on both. We can do this by placing two electrons on C and two electrons on O (giving C a -1 formal charge, and O a +1 formal charge).
:C---O: would be the structure of carbon monoxide.
The molecule is linear (only two atoms). Considering, now, the electron geometry, note that on each atom we only have two electron domains -- the triple bond, and the lone electron pair. Multiple bonds count as single electron domains. iHence, the electron geometry is also linear.
(This is so, because by the VSEPR theory, electron domains must be as far away from each other as possible.)
Think of the Lewis Dot structure of a carbon monoxide molecule. Carbon and oxygen are bonded through a triple bond. Carbon also has one lone pair of electrons. Therefore, there are a total of two electron domains in the CO molecule. The molecular shape and geometry of the molecule would thus be linear.