Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

I found the strangest thing

sudo cd $pwd
sudo: cd: command not found

I am able to cd as a normal user.It seems that PATH is not set properly for su.

How do I fix that?

share|improve this question

marked as duplicate by Avinash Raj, Ask, chronitis, Jorge Castro, falconer Feb 11 at 16:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
cd is not a program but an in-built command and sudo only applies to programs –  Avinash Raj Feb 11 at 6:34
add comment

3 Answers 3

You can't do cd like below,

sudo cd $pwd

But you can do,

sudo su
cd $pwd
share|improve this answer
    
sudo -i is the cleaner way of doing it. –  frlan Feb 11 at 8:12
add comment

You don't change directory as sudo.

sudo = Superuser Do [something]

what you can do is login as a superUser

sudo su

do what you want (change directory, execute, edite file, etc). eg:

cd [the_directory]

when you are done. logout superUser:

exit

share|improve this answer
    
i think sudo means substitute user(rather than super user) –  Meow Feb 11 at 6:26
    
Instead of sudo su you should do sudo -i –  frlan Feb 11 at 8:11
add comment

thats because "cd" is a shell bullitin

don't worry it doesn't work for anyone

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.