By inserting the steel bar inside the solenoid and switching on electric current. Once the current starts flowing, it undergoes re-arrangement at molecular level and gets magnetized.