A bar magnet is the simplest form of magnets which is rectangular in shape and has a magnetic field around it. It is usually made of ferromagnetic materials (elements that have naturally magnetic fields like cobalt, iron and nickel). The bar magnet is also known as Permanent Magnet because it can retain its magnetic field for some time in the absence of any magnetic field.
Before understanding how a bar magnet works we need to understand the concept of magnetic field lines.
Magnetic field lines Magnetic field lines are created by moving point charges in an electric charge carrying conductor. They are imaginary line of force around a magnet that attract or repel other ferromagnetic materials. When a ferromagnetic material is placed inside a magnetic field, they are heated to a certain temperature after which they are permanently magnetized. A magnet has normally two poles (a) North Pole and (b) South pole. By convention it is believed that magnetic field lines flow from North Pole to South Pole.