I want to use the file manager to copy a directory from my Desktop to the /opt directory. When I run gksudo nautilus, I do not see anything in the Desktop directory.

If I open Nautilus normally from the taskbar, it shows the lampp directory along with other existing ones.

So how do I get to view this directory so I can cut and paste it into /opt directory?


You are seeing an empty desktop because it is root's desktop directory since you use gksudo to open Nautilus. So, when you open Nautilus just follow this path from the left sidebar:

--> File system --> home --> your_user_name --> your_desktop

Then copy whatever you want. For an alternative way, you can use terminal for this:

sudo cp -r ~/Desktop/directory_that_will_be_copied /opt/where_to_copy

When you run Nautilus as root (with gksu nautilus or gksudo nautilus), it considers root's home directory (/root) as the pertinent home directory, instead of your own home directory (/home/shawn, where shawn is replaced by your actual username, if different).

That sort of thing does not happen when you run nongraphical commands as root in the usual way (i.e., with sudo). This is the main difference between the default behaviors of sudo and its graphical frontends like gksu and gksudo, and it is for good reason, since it is common for graphical programs to create and maintain configuration files in the home directory (which would either be rendered unchangeable by the non-root user and/or would provide a way for programs run as the non-root user to create and modify configuration data altering the behavior of programs run as root, both of which would be undesirable).

As mentioned above, if your username is shawn, your home directory's full path is /home/shawn. Your desktop folder is then /home/shawn/Desktop. If you run Nautilus as root and navigate to that folder, you'll see (and be able to access and manipulate) the files on your desktop.

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.