Most hackers don't smoke tobacco, and use alcohol in moderation if at all. However, there has been something of a trend towards exotic beers since about 1995, especially among younger Linux hackers apparently influenced by Linus Torvalds's fondness for Guinness.
Limited use of non-addictive psychedelic drugs, such as cannabis, LSD, psilocybin, nitrous oxide, etc., used to be relatively common and is still regarded with more tolerance than in the mainstream culture. Use of ‘downers’ and opiates, on the other hand, appears to be particularly rare; hackers seem in general to dislike drugs that make them stupid. But on the gripping hand, many hackers regularly wire up on caffeine and/or sugar for all-night hacking runs.