LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Can't access /root/.local as normal user (https://www.linuxquestions.org/questions/linux-general-1/cant-access-root-local-as-normal-user-718486/)

dodle 04-11-2009 03:51 PM

Can't access /root/.local as normal user
 
I am trying to create a script to empty the root's Trash, but am coming up with permission issues. If I am logged in as root, I can use the following command to empty the trash:

Code:

rm -r /root/.local/share/Trash/files/* /root/.local/share/Trash/info/*
But, if I try it as a sudoer I get the following output:

Code:

rm: cannot remove `/root/.local/share/Trash/files/*': No such file or directory
rm: cannot remove `/root/.local/share/Trash/info/*': No such file or directory

I tried accessing /root/.local as a normal user with nautilus, but it says that I do not have permission to view the folder (in the shell it just says that the folder does not exist). Is there some way to empty root's Trash using "sudo", so that I can finish my script?

SciYro 04-11-2009 04:56 PM

It appears that your script is telling 'rm' to remove the file "/root/.local/share/Trash/files/*", the star ('*') is not acting as a glob, but instead being taken as the name of a file (which of course does not exist).

I dont know why your script would act that way, so a quick fix would be to tell 'rm' the name of a actual directory to remove.

dodle 04-11-2009 09:39 PM

Thanks for the reply. I found an answer at ubuntuforums.org:

Code:

sudo bash -c "exec rm -r /root/.local/share/Trash/{files,info}/*"


All times are GMT -5. The time now is 10:32 PM.