The invention discloses a single-cylinder opposed double-piston free-piston linear generator and a double-piston free-piston linear generator, including a generator, two sets of two-stroke engines, a first auxiliary motor, a second auxiliary motor, a first auxiliary motor, and a second auxiliary motor Symmetrically arranged on both sides of the generator axis, the auxiliary motor 1 and the auxiliary motor 2 are connected to the generator, the auxiliary motor 1 and the auxiliary motor 2 are connected to the two-stroke engine, and the two-stroke engine includes a cylinder block, a cylinder head, a spark plug, and a fuel injector , piston, crankcase kit, connecting rod, auxiliary motor 1, auxiliary motor 2 are set coaxially with the generator, the generator is connected with auxiliary motor 1 and auxiliary motor 2, the stator of the generator is connected with the auxiliary motor 1 stator, and the auxiliary motor 2 stator is the most A predetermined axial distance is respectively set between two adjacent windings. The invention solves the problem of long response time for the switching of the working mode of the motor, ensures that the piston reaches the designated position smoothly, and enables the free-piston linear generator to run stably.