The equation of a line of the shortest distance between the given lines will be along the perpendicular to both the lines.
A line perpendicular to L1:1x=−1y=1z and L2:0x−1=−2y+1=1z is,
∣i^10j^−1−2k^11∣=i^(−1+2)−j^(1−0)+k^(−2+0)
=i^−j^−2k^
Let, 1x=−1y=1z=α
⇒x=α,y=−α,z=α
Thus, a point on the line L1 is P(α,−α,α)
Similarly, let 0x−1=−2y+1=1z=λ
⇒x=1,y=−2λ−1,z=λ
Thus, a point on the line L2 is Q(1,−1−2λ,λ)
Now, a vector joining the points P&Q is (α−1)i^+(2λ−α+1)j^+(α−λ)k^
Let, the vector joining the points P&Q is along perpendicular to the two lines.
Hence, (α−1)i^+(2λ−α+1)j^+(α−λ)k^ and i^−j^−2k^ are
proportional and hence on comparing, 1α−1=1α−2λ−1=2λ−α
⇒α−1=α−2λ−1
⇒λ=0
Hence, point Q is (1,−1,0)
The equation of a line passing through a point (x1,y1,z1) and parallel to a vector ai^+bj^+ck^ is ax−x1=by−y1=cz−z1
So, the equation of required line is 1x−1=−1y+1=−2z.