To figure out which lexical class ("part of speech") a word belongs to, we can look at several things:
- What sort of constituent does the word belong to?
- What is its function within that constituent?
- Does this word have a determiner, modifiers, or complements?
- Is this word marked morphologically as belonging to a specific class?
In other words, what does it mean for a word to be a noun, a verb, or anything else? It has to mean something, or we wouldn't bother labeling it. We put words into categories so we can say something useful about them, what they do, what other words do with them, or what shapes they have.
In this case, the word appears to belong to a noun phrase:
- A while is the complement of the preposition for, which commonly takes noun phrases as complements.
- A while has the shape of a noun phrase, with a determiner (a), and a head (while). Adverbs don't generally take determiners.
- A while can also take adjectival, but not adverbial, modification: a long while but not *a quickly while.
The shape of a word can also be useful. When you see a word ending in -ly, your first thought is probably that it's an adverb, particularly if it has an adjective as a base. Of course, this isn't always the case (lively), but that's why we try to look at as much as evidence as possible.
In English, word shape tends to be a less reliable indicator than in many languages, but it's still useful. For nouns, we want to focus on the inflections the word can take; while is rarely plural, but you will occasionally hear native speakers say things like "just a few whiles ago", so it's not entirely out of the question, either. Inflecting like a noun is another strong suggestion that while is a noun.
In this case, all the evidence points pretty strongly in the direction of while being a noun.