Super User is a question and answer site for computer enthusiasts and power users. 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

How to find file with name="php.ini" on linux using grep command ? Can anybody show me ?

share|improve this question
up vote 17 down vote accepted

You would normally use find not grep to find files by name.

find / -name php.ini

If you must use grep

cd /; ls -lR | grep php.ini

In both cases replace "/" with the absolute or relative path for the directory you wish to start the search in.

Note that linux also has a locate command that relies on indexing - check it's man page for details. This is fastest if the right locations are indexed.

share|improve this answer
To search within the current directory, use find . -name php.ini. To ignore case, use find . -iname php.ini. To search for directory names, use find . -iname bin -type d. – Dave Kennedy Mar 6 '14 at 20:59

Just to add some more information...

find / -name php.ini
cd /; ls -lR  | grep php.ini

of course do work, but you could be better served with

locate php.ini

which uses the indexed filesystem database to locate the file. It is considerably faster. To update the filesystem index, the command is:


These however required root as far as I remember.

disclaimer: I have not used linux for years for anything meaningful... I learnt these back then when the predominant distribution was slackware, and debian potato was not even out...

share|improve this answer
I think you were writing this at the same time I was updating my answer with the same idea :-) – RedGrittyBrick Jun 14 '11 at 10:14
Yes, Heh, I beat you by 3 minutes. +1 to you for the same great idea :P – bubu Jun 14 '11 at 10:18

fs all | filter "php.ini" or fs "**/php.ini"

when you install npm install nixar More docs:

share|improve this answer
Please read the question again carefully. Your answer does not answer the original question, which was asking about using grep. In addition your link is broken (it returns a blank page). – DavidPostill Oct 19 '15 at 11:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .