>What is an IMU sensor?
>and what is the purpose of using magnetometer?
Sense the Earth's magnetic field. ("A compass.")
>What do they measure?
>do they measure the angular velocity and acceleration or the linear acceleration or give the orientation?
You get what you pay for. The IMUs in the DIY Drones store report position and orientation.
A gyro reports orientation and/or rotation rate. An accelerometer reports linear acceleration. These are parts of an IMU.
Do we use the IMU in navigation or in stabilizing the airplane? I mean in APM2.
The position of the airplane is detected by GPS only or by using the IMU also ? in APM2.