Finding a specific text phrase in all system files

Trying to find a specific text phrase in all system files. A terrible way to debug but I have no clue where the mistake is and at this point I do not care whether it takes a day to debug.

I ran

grep -rnw /* -e _renderd 

And the error I got was

root@geocode:~# grep -rnw /* -e _renderd 
/etc/passwd:38:_renderd:x:115:124:renderd daemon,,,:/nonexistent:/usr/sbin/nologin
/etc/shadow:38:_renderd:*:18784:0:99999:7:::
/etc/passwd-:38:_renderd:x:115:124::/nonexistent:/usr/sbin/nologin
/etc/shadow-:38:_renderd:*:18784:0:99999:7:::
/etc/group:66:_renderd:x:124:
/etc/gshadow:66:_renderd:!::
/lib/systemd/system/renderd.service:8:User=_renderd
grep: /proc/sys/abi/vsyscall32: Cannot allocate memory
grep: /proc/sys/debug/exception-trace: Cannot allocate memory
grep: /proc/sys/debug/kprobes-optimization: Cannot allocate memory
grep: /proc/sys/dev/cdrom/autoclose: Cannot allocate memory
grep: /proc/sys/dev/cdrom/autoeject: Cannot allocate memory
grep: /proc/sys/dev/cdrom/check_media: Cannot allocate memory
grep: /proc/sys/dev/cdrom/debug: Cannot allocate memory
grep: /proc/sys/dev/cdrom/info: Cannot allocate memory
grep: /proc/sys/dev/cdrom/lock: Cannot allocate memory
grep: /proc/sys/dev/hpet/max-user-freq: Cannot allocate memory
grep: /proc/sys/dev/raid/speed_limit_max: Cannot allocate memory
grep: /proc/sys/dev/raid/speed_limit_min: Cannot allocate memory
grep: /proc/sys/dev/scsi/logging_level: Cannot allocate memory
grep: /proc/sys/dev/tty/ldisc_autoload: Cannot allocate memory
grep: /proc/sys/fs/aio-max-nr: Cannot allocate memory
grep: /proc/sys/fs/aio-nr: Cannot allocate memory
grep: /proc/sys/fs/binfmt_misc/register: Invalid argument
grep: /proc/sys/fs/dentry-state: Cannot allocate memory
grep: /proc/sys/fs/dir-notify-enable: Cannot allocate memory
grep: /proc/sys/fs/epoll/max_user_watches: Cannot allocate memory
grep: /proc/sys/fs/file-max: Cannot allocate memory
grep: /proc/sys/fs/file-nr: Cannot allocate memory
grep: /proc/sys/fs/inode-nr: Cannot allocate memory
grep: /proc/sys/fs/inode-state: Cannot allocate memory
grep: /proc/sys/fs/inotify/max_queued_events: Cannot allocate memory
grep: /proc/sys/fs/inotify/max_user_instances: Cannot allocate memory
grep: /proc/sys/fs/inotify/max_user_watches: Cannot allocate memory
grep: /proc/sys/fs/lease-break-time: Cannot allocate memory
grep: /proc/sys/fs/leases-enable: Cannot allocate memory
grep: /proc/sys/fs/mount-max: Cannot allocate memory
grep: /proc/sys/fs/mqueue/msg_default: Cannot allocate memory
grep: /proc/sys/fs/mqueue/msg_max: Cannot allocate memory
grep: /proc/sys/fs/mqueue/msgsize_default: Cannot allocate memory
grep: /proc/sys/fs/mqueue/msgsize_max: Cannot allocate memory
grep: /proc/sys/fs/mqueue/queues_max: Cannot allocate memory
grep: /proc/sys/fs/nr_open: Cannot allocate memory
grep: /proc/sys/fs/overflowgid: Cannot allocate memory
grep: /proc/sys/fs/overflowuid: Cannot allocate memory
grep: /proc/sys/fs/pipe-max-size: Cannot allocate memory
grep: /proc/sys/fs/pipe-user-pages-hard: Cannot allocate memory
grep: /proc/sys/fs/pipe-user-pages-soft: Cannot allocate memory
grep: /proc/sys/fs/protected_fifos: Cannot allocate memory
grep: /proc/sys/fs/protected_hardlinks: Cannot allocate memory
grep: /proc/sys/fs/protected_regular: Cannot allocate memory
grep: /proc/sys/fs/protected_symlinks: Cannot allocate memory
grep: /proc/sys/fs/quota/allocated_dquots: Cannot allocate memory

How do I limit the memory. Is it that I am running into files that are larger than 16 GB ram that I have or something else?


Solution 1:

Unless you specifically want to search ephemeral filesystem like /proc, /sys I'd suggest using find for the recursion + non-recursive grep so that you can prune them (and the block device tree /dev) from the search. You might want to add -I to the grep options to skip binary files:

find / \( -path /dev -o -path /proc -o -path /sys \) -prune -o -type f \
    -exec grep -Inw -e _renderd {} +

You may want to add -path /run to the list of pruned paths.