Find the shortest distance between the lines
$\vec{r}=(\hat{i}+2 \hat{j}+\hat{k})+\lambda(\hat{i}-\hat{j}+\hat{k})$ and
$\vec{r}=2 \hat{i}-\hat{j}-\hat{k}+\mu(2 \hat{i}+\hat{j}+2 \hat{k})$
The equations of the given lines are
$\vec{r}=(\hat{i}+2 \hat{j}+\hat{k})+\lambda(\hat{i}-\hat{j}+\hat{k})$
$\vec{r}=2 \hat{i}-\hat{j}-\hat{k}+\mu(2 \hat{i}+\hat{j}+2 \hat{k})$
It is known that the shortest distance between the lines, $\vec{r}=\vec{a}_{1}+\lambda \vec{b}_{1}$ and $\vec{r}=\vec{a}_{2}+\mu \vec{b}_{2}$, is given by,
$d=\left|\frac{\left(\overrightarrow{b_{1}} \times \overrightarrow{b_{2}}\right) \cdot\left(\overrightarrow{a_{2}}-\overrightarrow{a_{1}}\right)}{\left|\overrightarrow{b_{1}} \times \overrightarrow{b_{2}}\right|}\right|$
Comparing the given equations, we obtain
$\vec{a}_{1}=\hat{i}+2 \hat{j}+\hat{k}$
$\vec{b}_{1}=\hat{i}-\hat{j}+\hat{k}$
$\vec{a}_{2}=2 \hat{i}-\hat{j}-\hat{k}$
$\vec{b}_{2}=2 \hat{i}+\hat{j}+2 \hat{k}$
$\vec{a}_{2}-\vec{a}_{1}=(2 \hat{i}-\hat{j}-\hat{k})-(\hat{i}+2 \hat{j}+\hat{k})=\hat{i}-3 \hat{j}-2 \hat{k}$
$\vec{b}_{1} \times \vec{b}_{2}=\left|\begin{array}{ccc}\hat{i} & \hat{j} & \hat{k} \\ 1 & -1 & 1 \\ 2 & 1 & 2\end{array}\right|$
$\vec{b}_{1} \times \vec{b}_{2}=(-2-1) \hat{i}-(2-2) \hat{j}+(1+2) \hat{k}=-3 \hat{i}+3 \hat{k}$
$\Rightarrow\left|\vec{b}_{1} \times \vec{b}_{2}\right|=\sqrt{(-3)^{2}+(3)^{2}}=\sqrt{9+9}=\sqrt{18}=3 \sqrt{2}$
Substituting all the values in equation (1), we obtain
$d=\left|\frac{(-3 \hat{i}+3 \hat{k}) \cdot(\hat{i}-3 \hat{j}-2 \hat{k})}{3 \sqrt{2}}\right|$
$\Rightarrow d=\left|\frac{-3.1+3(-2)}{3 \sqrt{2}}\right|$
$\Rightarrow d=\left|\frac{-9}{3 \sqrt{2}}\right|$
$\Rightarrow d=\frac{3}{\sqrt{2}}=\frac{3 \times \sqrt{2}}{\sqrt{2} \times \sqrt{2}}=\frac{3 \sqrt{2}}{2}$
Therefore, the shortest distance between the two lines is $\frac{3 \sqrt{2}}{2}$ units.