-   Linux - Newbie (
-   -   "Permission denied" and "recursive directory loop" when searching for string in files (

mack1e 06-09-2008 03:29 PM

"Permission denied" and "recursive directory loop" when searching for string in files
I am trying to find which file contains the line "GLOBAL_BIN" in the body. Im using RHEL AS 4 and used these commands to do so but kept getting the "grep:....Permission denied" and "grep:....recursive directory loop" messages for all the output lines.

1)find / -type f | xargs grep -l GLOBAL_BIN
2)grep -r -I -D skip "GLOBAL_BIN" /

Can anyone shed light? maybe a syntax tweak? I am wondering why "permission denied" and "recursive directory loop" is returned here...yes Im green at this :P

lwasserm 06-09-2008 04:12 PM

Try running the grep -r command as root. The permission denied message is just when you try to access a file that you don't have permission to read as a normal user.

mack1e 06-10-2008 09:35 AM

thanks for your reply but I am running as root:

[root@redbox ~]# grep -r -I -D skip "GLOBAL_BIN" / | less
grep: /root/.kde/socket-redbox: No such file or directory
grep: /root/.kde/tmp-redbox: No such file or directory
grep: /sys/module/dm_mirror/dm_mirror_error_on_log_failure: Permission denied
grep: warning: /sys/block/hdc/device/block: recursive directory loop

...thats why this threw me even more because if Im getting perms denied for root

lwasserm 06-10-2008 10:31 AM

For the purpose of your search you can probably ignore these errors. My guess would be that the files with redbox in the name are broken symbolic links. The files in the /sys directory are not permanent files, they are created by the kernel to make access to various internal states available. Some of them are write-only and this is probably what is causing the permission error. Hope this helps.

chrism01 06-10-2008 07:41 PM

Try redirecting stderr to null eg

grep -r -I -D skip "GLOBAL_BIN" / 2>/dev/null

mack1e 06-12-2008 08:38 AM

maybe i needed sleep....came back and did a : "locate Bastille" (the program I am actually trying to get working) and observed all the paths that came out. I then cd'd into those paths (i.e. /usr/lib/Bastille, usr/sbin, etc) and did: grep GLOBAL_BIN* and voila, the file I was looking for with that entry is ""...but now Im past that im getting a different error :(

All times are GMT -5. The time now is 03:44 PM.