Should you come across a locked door you will, of course, need the correct key with which to unlock it. Typing OPEN DOOR <direction> will attempt to open it without a key; if you own the necessary key then UNLOCK DOOR <direction> will both unlock the door and open it for you. You will then be able to pass through without further ado, and perhaps LOCK the door behind you. Type DOORS in any location to review all doors (and gates, etc) nearby and their state of repair.
Syntax: CONSTRUCT DOOR <direction>.
Doors are constructed using the labours "crafting" skill, if one is desired - since buildings, for instance, are doorless immediately after construction - and must then be transported to the desired destination. Carts and wagons tend to be used for this purpose. Once on the ground at the desired spot one may CONSTRUCT DOOR <direction> to fit the basic door into an appropriately prepared locale. For further information on construction see HELP CONSTRUCTION and related helpfiles.
There are other forms of barrier, some behaving in a similar fashion to doors (like gates and windows, while others require a little guile to operate. The drawbridge for instance is occasionally found. To operate them, one must find the location containing its mechanism. Therein one may issue the RAISE DRAWBRIDGE or LOWER DRAWBRIDGE commands to exact control over this most comprehensive of barricades. City gatehouses, barbicans, portals and all manner of magical door-simalcrums exist in the land; phenomena to be explored and experienced with as and when time permits.