There is a ready-made package for samtools, simply do
apt install samtools
Also, your screenshot shows you are using the root account. You should not do that, especially if you are not very sure about the commands you are issuing or are copy-pasting commands from the internet into your console. After you installed the package, the samtools index command will be available for a normal user on the machine.