There is a method by which I can open any folder (or execute any operation) as root (using sudo). Is there any method I can use to open a folder or execute any operation as some other user on the system. I need this because I have two users on the system. Sometimes; I need to use stuff from other user's home folder.

1 Answer 1


sudo is a commad that might be best read as "SetUser Do" command:

The command can also be executed as

sudo -u username docommand.foo

see man sudo

  • sudo -u username cd /home/username doesn't work though Aug 12, 2020 at 20:16
  • You'd have to be smarter than I to figure out why. I suspect that it has to do with the fact that cd is one of the built-in commands. Aug 13, 2020 at 14:31
  • What is meant by "built-in" commands, and why is it that we can't run cd after running sudo ? I solved the problem by signing into the other account and doing chmod 777 /home/username/ so that other users can cd into the first user's /home directory, but this is not an ideal solution. Aug 13, 2020 at 16:42
  • Several commands are part of the shell that you are running, typically Bash. Others as Sh, and Csh, Zsh... A more suitable solution for your situation may be to assign yourself to a group, and give that group permissions to the directory, rather than assign local permissions. Another alternative if you are looking for access on an occasional basis, might be to execute sudo -i -u <username> which would leave you as that user until you execute exit Aug 14, 2020 at 16:03
  • It's unfortunate that one would need to "become" the user, and then remember to press "exit" afterwards. Sure I can make a group and give permissions to the group, but if I'm an administrator, why can't I just cd into my own directory on a different account? I have the sudo password for both the current account and the other account. Aug 14, 2020 at 16:43

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.