Actually, there is one way to knit a closed end tube on straight needles. It's going to be a pain to keep the stitches on the needle though!
You need to know the circumference of your head, and the gauge you get with that yarn and those needles. Subtract two inches from the circumference and multiply it by the number of stitches per inch. Cast on half that number. On the first row, knit in the front and back of every stitch.
Now you're going to have to do something called double knitting. On every row, knit the first stitch. Bring the yarn to the front of your work and slip the next with the yarn in front of the needle. Take the yarn to the back and knit the next stitch. Continue in this way across, alternating knitting and slipping and ending with a slip stitch. Turn and repeat. Continue until the tube is as long as you want the hat to be. BE VERY CAREFUL TO SLIP EVERY OTHER STITCH, otherwise, you will close your tube off at that point. When the tube is long enough, get a third needle (a size or two bigger than the ones you knit with) and slip the stitches alternately onto two needles, then use your third needle to do the normal bindoff.
Yes, it's very complicated! Actually, using a circular needle or double pointed needlesto knit an actual tube is much easier. The other alternative, already mentioned, is to knit the hat flat and sew up the back seam.