HCN is linear because carbon forms a single bond with H and a triple bond with N. So carbon is sp hybridized with ZERO lone pairs, thus, it is linear shape.
In C2H6, if you draw it out, you all the carbon atoms are single bonded to 4 different atoms, making it sp3 hybridized, thus tetrahedral shape.
👍 Nice first post ever, way to pitch in.
These are important to remember. Generally speaking,
4 "neighbors" - sp3 hybridized, tetrahedral, 109 degree bond angles
3 "neighbors" - sp2 hybridized, trigonal planar, 120 degree bond angles
2 "neighbors" - sp hyridized, linear, 180 degree bond angles
"neighbors" includes any lone pairs! which brings up another important point to keep in mind:
H2O and NH3 are common exceptions to the bond angles. In H2O, the O is sp3 hybridized, but the bond angles are more like 104 degrees, because of the electron repulsion from the lone pairs. Same goes for NH3. It isn't necessary to remember exact bond angles, just know that despite being sp3 hybridized, the angles are <109 degrees. Hope this helped!
You may also want to brush up on what the hybridization means in terms of bond strength (s character %age), bond length, and acidity.