Used bikes are a great idea, if you know what you're looking for and looking at, and have it checked by a good bike mechanic. But as has been said, for around $500 you should be able to get a decent entry level mountain bike if that's what you're set on.
I'll echo, however, the issue with knobby MTB tires on roads and commuting. I'd seriously getting some commuter tires instead of riding with the knobbies. You can swap out tires when you're trail riding.
And as far as the 12 mile distance ... honestly I think between 10-15 miles one way is an ideal commute. Mine is 12 miles each way. Currently I'm riding three days a week, but looking to increase that to four days a week and do a few five day/week commutes over the summer. That said, if you're new to this, you'll need to work up to it. It can take quite a bit out of you, especially in the beginning.