A solenoid is an electromagnet made of a wire in the form of a spiral whose length is larger than its diameter.

The word solenoid literally means ‘pipe-thing‘ since it comes from the Greek word ‘solen‘ for ‘pipe’ and ‘-oid‘ for ‘thing’.
And they are such an all-embracingly useful bit of kit that one might imagine an alternate universe where The Troggs might have sang:
Pipe-thing! You make my heart sing!
You make everything groovy, pipe-thing!
And pipe-things do indeed make everything groovy: solenoids are at the heart of the magnetic pickups that capture the magnificent guitar riffs of The Troggs at their finest.
The Butterfly Field
Very few minerals are naturally magnetised. Lodestones are pieces of the ore magnetite that can attract iron. (The origin of the name is probably not what you think — it’s named after the region, Magnesia, where it was first found). In ancient times, lodestones were so rare and precious that they were worth more than their weight in gold.
Over many centuries, by patient trial-and-error, humans learned how to magnetise a piece of iron to make a permanent magnet. Permanent magnets now became as cheap as chips.
A permanent bar magnet is wrapped in an invisible evanescent magnetic field that, given sufficient poetic license, can remind one of the soft gossamery wings of a butterfly…

The field lines seem to begin at the north pole and end at the south pole. ‘Seem to’ because magnetic field lines always form closed loops.
This is a consequence of Maxwell’s second equation of Electromagnetism (one of a system of four equations developed by James Clark Maxwell in 1873 that summarise our current understanding of electromagnetism).
Using the elegant differential notation, Maxwell’s second equation is written like this:

It could be read aloud as ‘del dot B equals zero’ where B is the magnetic field and del (the inverted delta symbol) does not represent a quantity but is the differential operator which describes how the field lines curl in three dimensional space.
This also tells us that magnetic monopoles (that is to say, isolated N and S poles) are impossible. A north-seeking pole is always paired with a south-seeking pole.
Magnetising a solenoid
A current-carrying coil will create a magnetic field as shown below.

The wire is usually insulated (often with a tough, transparent and nearly invisible enamel coating for commercial solenoids), but doesn’t have to be. Insulation prevents annoying ‘short circuits’ if the coils touch. At first sight, we see the familiar ‘butterfly field’ pattern, but we also see a very intense magnetic field in the centre of the solenoid,
For a typical air-cored solenoid used in a school laboratory carrying one ampere of current, the magnetic field in the centre would have a strength of about 84 microtesla. This is of the same order as the Earth’s magnetic field (which has a typical value of about 50 microtesla). This is just strong enough to deflect the needle of a magnetic compass placed a few centimetres away and (probably) make iron filings align to show the magnetic field pattern around the solenoid, but not strong enough to attract even a small steel paper clip. For reference, the strength of a typical school bar magnet is about 10 000 microtesla, so our solenoid is over one hundred times weaker than a bar magnet.
However, we can ‘boost’ the magnetic field by adding an iron core. The relative permeability of a material is a measurement of how ‘transparent’ it is to magnetic field lines. The relative permeability of pure iron is about 1500 (no units since it’s relative permeability and we are comparing its magnetic properties with that of empty space). However, the core material used in the school laboratory is more likely to be steel rather than iron, which has a much more modest relative permeability of 100.
So placing a steel nail in the centre of a solenoid boosts its magnetic field strength by a factor of 100 — which would make the solenoid roughly as strong as a typical bar magnet.
But which end is north…?
The N and S-poles of a solenoid can change depending on the direction of current flow and the geometry of the loops.
The typical methods used to identify the N and S poles are shown below.

To go in reverse order for no particular reason, I don’t like using the second method because it involves a tricky mental rotation of the plane of view by 90 degrees to imagine the current direction as viewed when looking directly at the ends of the magnet. Most students, understandably in my opinion, find this hard.
The first method I dislike because it creates confusion with the ‘proper’ right hand grip rule which tells us the direction of the magnetic field lines around a long straight conductor and which I’ve written about before . . .

The direction of the current in the last diagram is shown using the ‘dot and cross’ convention which, by a strange coincidence, I have also written about before . . .

How a solenoid ‘makes’ its magnetic field . . .
To begin the analysis we imagine the solenoid cut in half: what biologists would call a longitudinal section. Then we show the current directions of each element using the dot and cross convention. Then we consider just two elements, say A and B as shown below.
Continuing this analysis below:
The region inside the solenoid has a very strong and nearly uniform magnetic field. By ‘uniform’ we mean that the field lines are nearly straight and equally spaced meaning that the magnetic field has the same strength at any point.
The region outside the solenoid has a magnetic field which gradually weakens as you move away from the solenoid (indicated by the increased spacing between the field lines); its shape is also nearly identical to the ‘butterfly field’ of a bar magnet as mentioned above.
Since the field lines are emerging from X, we can confidently assert that this is a north-seeking pole, while Y is a south-seeking pole.
Which end is north, using only the ‘proper’ right hand grip rule…
First, look very carefully at the geometry of current flow (1).
Secondly, isolate one current element, such as the one shown in picture (2) above.
Thirdly, establish the direction of the field lines using the standard right hand grip rule (3).
Since the field lines are heading into this end of the solenoid, we can conclude that the right hand side of this solenoid is, in fact, a south-seeking pole.
In my opinion, this is easier and more reliable than using any of the other alternative methods. I hope that readers that have read this far will (eventually) come to agree.