In linear solenoids the stroke from the initial position to the end of stroke is made by an electromagnetic force that is created when a voltage is applied to the solenoid.
To return to the initial position, external forces or a spring mounted in the solenoid are normally used.