For medical diagnoses and treatments, it is often desirable to wirelessly trace an object that moves inside the human body. A magnetic tracing technique suggested for such applications uses a small magnet as the excitation source, which does not require the power supply and connection wire. It provides good tracing accuracy and can be easily implemented. As the magnet moves, it establishes around the human body a static magnetic field, whose intensity is related to the magnet's 3-D position and 2-D orientation parameters. With magnetic sensors, these magnetic intensities can be detected in some predetermined spatial points, and the position and orientation parameters can be computed. Typically, a nonlinear optimization algorithm is applied to such a problem, but a linear algorithm is preferable for faster, more reliable computation, and lower complexity. In this paper, we propose a linear algorithm to determine the 5-D magnet's position and orientation parameters. With the data from five (or more) three-axis magnetic sensors, this algorithm results in a solution by the matrix and algebra computations. We applied this linear algorithm on the real localization system, and the results of simulations and real experiments show that satisfactory tracing accuracy can be achieved by using a sensor array with enough three-axis magnetic sensors.