For the sides and back
First part your hair on the top on both sides so you dont accidentally cut the hair on the top of your head. Now take a trimmer with a guard and go around the sides and back till it looks good. This part is easy and takes 2 minutes, and takes care of more than half your head. Start with a high guard number and go down, Nowadays, the shorter the better on the sides and back. Hard to mess this up if you use a good guard.
View attachment 144699
For where your hair meets your skin
Use the razor without a guard to create a defined line where your hair ends around your ear and down your neckline and at the bottom of the hair on your neck. This part is also hard to mess up, just do what looks good.
View attachment 144697
For the top follow this video
take a comb and split your hair into horizontal sections with a comb and cut off the hairs coming out the comb with a razor or scissors. Imitate what you remember barbers doing and what the guy in the video is doing. blend the top of your hair with the sides of your hair using a trimmer as much as you want, the less you blend the more it looks like an undercut. This part is the hardest and honestly I have not been able to to do this part good yet at all.
Voila an undercut