When I use the command sudo -i and input the password, and then input ls, I found that I can only see the Desktop folder and packages in terminal.

But when I came back to normal mode, all the folder showed up.

I don't know what cause this problem...Can someone help me ?

  • 1
    If you want your home directory while root you have to do cd /home/user/Desktop – troylatroy Oct 31 '13 at 17:15
  • Oh my god...Thanks! Your answer solve my problem! – brandboat Nov 1 '13 at 1:03

The sudo -i command gives you a shell as root, and you will be in the root user's home directory, not your own. As root is not generally a user you should use normally, only very few files will exist in the home directory for that user, particularly the skeleton directory structure for any new user.


It is because when you are in root mode you are in root's home directory. Try this:

sudo -i

You will see the directory change


this was troubling me too much also, so I made this script:

params="$@";sudo -i bash -c "cd \"`pwd`\";$params"

pwd will be run with your normal user, before the command you want

put it on a script file which is root:root rw-r--r-- on a folder full hierarchy owned by root too like /MyScripts (create it) to be safer..

the flaw on it is if you have a parameter with a space in-between like ls -1 a "b c", would require to be ls -1 a "b\ c", but this can be worked out later when you improve the script :)

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.