Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm finding that a script is getting started twice, so I want to search for the script name in any file anywhere, to see where its getting called.

So I did this...

cd /
sudo grep -r autostart *

But that gives me the error..

boot/ t autostart_arrays
grep: dev/vsock: Invalid argument
share|improve this question
sudo grep -rl autostart /*. Does that work? – andy Sep 26 '13 at 14:52

This is not an error. Grep just reported its failure to search through a special file (probably a socket), and was already working on the next. If you don't want to see grep's error messages, you can send them to the bitbucket:

fgrep -r autostart * 2> /dev/null

Note that fgrep will likely be much faster in your case because you are searching for a string, not for a regular expression.

Contrary to what you it looked like, grep hadn't crashed. Technically, it wasn't hung either. Maybe it was searching /dev/random for the string. Eventually it would find it there, though this might take an astronomical amount of time. Sadly, soon after grep would have found the string in /dev/random, it would encounter /dev/zero where it would certainly spend an infinity of time looking for the string. Logically therefore, your command was guaranteed to not terminate.

If you wish to prevent fgrep from searching special files, combine it with find:

find / -type f -exec fgrep -l autostart {} \;

And since you're looking for a script, skipping all all non-executables on the file system will save a lot of time:

find / -type f -executable -exec fgrep -l autostart {} \;

In fact, I would focus my search first on the usual suspects:

find {,/usr}/{,s}bin /etc -type f -executable -exec fgrep -l autostart {} \;

Particularly so if you have some remote file systems mounted, which grep would dutifully search as well.

share|improve this answer
Thanks. Are you saying that it hadnt crashed but had just printed out a message and was continuing to search in the background? – spiderplant0 Sep 26 '13 at 15:22
Thanks, I tried find / -type x -exec fgrep -l autostart {} \; but it came back with find: Unknown argument to -type: x – spiderplant0 Sep 26 '13 at 15:23
also should I add sudo before these commands? – spiderplant0 Sep 26 '13 at 15:32
No, grep didn't technically crash. It was guaranteed to run forever though. Added the explanation for this to the answer. You should need to sudo these commands only if the string could be in a non-world-readable (and therefore non-world-executable) file. – zwets Sep 26 '13 at 20:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.