Why won’t “sudo cd” work?

Why typing sudo cd whatever won’t change the directory?

Answer

cd is a shell builtin. sudo only works with executables. You could do sudo sh -c 'cd dirname' but as soon as the shell exits, you’re returned to the directory you started from. If you say what it is you’re trying to accomplish then I can help you find a way to do that.

Attribution
Source : Link , Question Author : sri prasanna , Answer Author : Dennis Williamson

Leave a Comment