Running Raspbian on RPi B+, I can sudo in command mode and do all operations like deleting a directory, etc. But when in GUI mode I get permession denied, although I am using the same user in both cases.
What's the solution?
The safe way to do this on raspbian is via gksudo in the gksu package.
Running GUI apps via sudo is possible but can create problems, e.g. see here; a graphical desktop is a complex thing and just plain sudo is a dumb mechanism -- if the app you want to run writes to some kind of status or lock file as root, it won't recognize the consequences for you, the normal user. And likely you won't either until you are mysteriously unable to use the desktop at all.
The rest of that Q&A may be of interest to you as well.
I'm not sure there is an appropriate solution (there are solutions which I'll leave to others as I don't think them sensible).
You should only run up against this problem when you want to do system administration. You shouldn't need to use sudo for general day to day work.
The system is blurred on the Pi as the normal user will almost invariably be the same person as the system administrator.
I'd spend some time examining why you need to use sudo. It shouldn't be needed for anything you do in your /home/user directory.
For the rest I'd just launch a command shell from the GUI and enter the needed sudo commands there.
pcmanfm, with (gk)sudo. – goldilocks Jan 04 '15 at 16:53