TITLE: Classify groups of order 27
QUESTION [9 upvotes]: Let $|G|=27$. Prove that all subgroups of index $3$ are normal. Classify all groups of order $27$.

I can do the first one, but the classification is overwhelming. I don't even know where to start. 
Any help appreciated.

REPLY [8 votes]: Alexander's answer is excellent, but I wanted to come at this from a slightly different point of view, avoiding presentations.
Let $G$ be a group of order $27$.  Now $G$ has a subgroup of order $9$, let's call it $H$; note that $H$ is normal in $G$.
First, assume that there is a $g\in G-H$ with $g^3=1$. Then, things are easy: $G$ is the semidirect product $H\rtimes\langle g\rangle$. Now there are two isomorphism choices for the order $9$ group $H$, and $g$ can act trivially or non-trivially, so that makes $4$ total possible groups for $G$. [I am glossing over some facts, most notably that $C_3\times C_3$ is completely reducible.]
Now assume that there are no order $3$ elements in $G-H$; I want to show $G$ is cyclic. We can assume that replacing $H$ with any other maximal subgroup doesn't put us in the context of the previous paragraph. If $[G:Z(G)]\le3$, then we will be done, so we can assume that $[G:Z(G)]=9$, and reach a contradiction. Note that $[G:Z(G)]=9$ means two things right away: $G/Z(G)$ is abelian, so $G'=Z(G)$, and $|Z(G)|=3$, so $Z(G)\subset H$. The map $f:\ G\rightarrow G$, given by $f(g)=g^3$, is actually a homomorphism:
$$ \begin{align*}
   x^3y^3&= x(yx)[x,y](yx)[x,y]^2y\\
         &= (xy)^3[x,y]^3\\
         &= (xy)^3.
\end{align*}$$
The second equality follows from $G'\subset Z(G)$, and the third from $|Z(G)|=3$.
Assuming $G$ is non-cyclic, every element $g\in G-H$ has order $9$.  Thus $g^3\in H$ is centralized by both $g$ and $H$, so $g^3\in Z(G)$. This also allows us to assume that $H$ is cyclic (why?). Thus, we must have $f(G)\subset Z(G)$.  Then $\ker(f)$ has order at least $[G:Z(G)]=9$. But $\ker(f)=\lbrace g\in G\mid g^3=1\rbrace$ is a subset of $Z(G)$, which has order $3$; this is our contradiction.
The same argument above, with $3$ replaced by any odd prime $p$, gives the same classification of the five groups of order $p^3$.
Finally, let me mention that the step where we showed $G$ is cyclic generalizes quite a bit for odd primes $p$; namely, any finite $p$-group with a unique subgroup of order $p$ is cyclic.  The proof follows from the homomorphism $f$, some counting $\pmod{p}$, and induction.