my contents of .sh file are

sudo -i
cd /home/madhu131313/Documents/

I run it ,then it asked for root password, it changed to root, but it doesn't execute the changing directory


Changing directory affects the current process. It does not affect the parent process; that would be a huge security hole. Please see http://mywiki.wooledge.org/BashFAQ/060

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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