There are several different ways of magnetising a material, and several ways of demagnetising it.
A piece of steel can be permanently magnetized when
1) Placed near a magnet (producing a weak magnet), or more strongly by stroking with one end of a magnet.its magnetism is usually weak.
2. Placed inside a solenoid with a direct current moving through it.
3. Magnetic materials are often weakly magnetised because of the Earths own magnetic field.
A magnet may be demagnetised by
1. Hammering it repeatedly to disrupt the magnetic domain structure.
2. Heating it.
3. Place it inside a solenoid with ac current flowing through it.