What is the difference between ‘who’ or ‘whom’?

What is the difference between ‘who’ or ‘whom’?

If you can substitute him, use whom. If you can substitute he, use who. You want to give the job to whom? (to him?) Who would do the best job? (He would do the best job?)

-Jane