I do in Posix find $HOME +perm 0666 -type f -exec grep -l "XSym" {} \;
but get this which I do not understand
find: ‘/home/masi/.dbus’: Permission denied
grep: /home/masi/.viminfo: Permission denied
grep: /home/masi/.cache/dconf/user: Permission denied
since
drwx------ 3 root root 4096 Jun 18 14:49 .dbus
-rw------- 1 root root 6266 Jun 18 13:24 .viminfo
-rw------- 1 root root 2 Jun 18 14:51 /home/masi/.cache/dconf/user
I do not like double negation structure and non-Posix things like ! -perm -g+r,u+r,o+r -prune
here which I think is equivalent to ! -perm 0444 -prune
.
Proposal after Kusalananda's fix
I do
# http://unix.stackexchange.com/a/121020/16920
find / -type d \! -perm 0666 -prune -o -type f -name '._*' -print
Output: no files. Expected output: many files with many appropriate files.
I run
find / -type d \! -perm +0666 -prune -o -type f -name '._*' -print
I get
find: invalid mode ‘+0666’
System: Ubuntu 16.04 64 bit
Grep: 2.25
Find: 4.7.0-git
Best Answer
Those files and directories do not belong to you, they belong to the
root
user, and have too restrictive access permissions forfind
andgrep
to work. Therefore,find
complains about not being able to enter the directory/home/masi/.dbus
(to do its job), andgrep
complains about not being able to read the files (to do its job).The files and directories do not belong to you, even though they are located in your home directory. The reason that they instead belong to the
root
user is likely that you have been running things (vim
and other things) asroot
and whatever programs these were have created the files and directories.You may change the ownership of these files and directories with
chown masi:masi
(masi:masi
should be replaced with your username and your default group name, see your other files), but you need to beroot
to do it, so usesudo chown ...
.If you want to make sure that all files and directories in your home directory belongs to you, do
sudo chown -R masi:masi $HOME
, but first be sure that this is really what you want.EDIT: To find all files and directories in
$HOME
that doesn't belong to usermasi
, do this: