Why won't "sudo cd" work?
Solution 1:
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.
Solution 2:
Instead try using sudo -s
to start a root shell and then simply cd
into the directory.
When you're done as root, press CtrlD or type exit
.
As Arjan hints at in his comment below, it is important to note that as root, one can easily do damage to essential system components. Use with care!
Solution 3:
You can simply su
to become root and then cd
all you want... I know an answer has already been accepted, but if one is not on the sudoers list then this is the only option.