Airlocks and Hatches are used to leave and enter a vessel. The difference between them is that an airlock is a pressurized corridor connection between two objects, and a hatch is a sealed ramp or door that opens out into the vessel's location. Also, an airlock can be independently depressurized and the outer door opened, allowing personnel with EVAs (or otherwise, perhaps) to leave the ship while it is in space.
To board a vessel when it is landed, simply type 'board <ship name>'.
openhatch -- Opens the hatch door/ramp.
closehatch -- Closes and seals the hatch/ramp.
al-open <outer/inner> -- Opens outer or inner pressure lock doors.
al-closee <outer/inner> -- Closes outer or inner pressure lock doors.
al-depressurize -- Depressurizes the airlock. (Airlock must be sealed before this can happen.)
al-pressurize -- Pressurizes the airlock. (Airlock must be sealed before this can happen.)
go-eva -- If outer door is open, this command lets you jump into space.
NOTE: When you're outside the ship in space, to re-enter, simply 'board <contact>' and you will go into the airlock (as long as it's open).