I had recently tried to move a file to overwrite /dev/null
and had encountered a Permission denied
Error. From using Ubuntu for the last couple of years, I know that if I get this error, I need to be sudo
to invoke the command and then it would succeed. This is what I did to overwrite /dev/null
as well.
However, artbristol posted a comment over there saying that blindly invoking sudo
to run a command is not a good habit and we should know why we are being denied the permission to run that command before proceeding further. I tend to agree with him along with all the people who have heavily upvoted that comment. But I don't know how to proceed to know the "why".
Recently, I came across this answer and tried to run the command as mentioned (393222
is the inode of examples.desktop
file in ~
):
$ find . -inum 393222 -exec nano {} \;
find: `./.gvfs': Permission denied
find: `./.cache/dconf': Permission denied
Running the above command did open examples.desktop
file in nano
, but also gave Permission denied
for the two folders. Following are the attributes of the two folders (truncated output of ls -la
):
drwx------ 2 root root 4096 Mar 11 21:04 .gvfs
drwx------ 2 root root 4096 Mar 11 21:04 dconf
Is there any general guideline to follow in order to know "why" I get a Permission Denied error while running a particular command?
sudo
, I do remember that I did open Gedit usingsudo
by mistake while opening one of the files in dconf folder. That explains the situation... However,gksu
andgksudo
are no longer available by-default since Ubuntu 13.04 :) – Aditya Mar 20 '14 at 16:58