How to Use FIND Command to Search for a File or a Directory in Linux

DaRecordon

Well-known member
Registered
Joined
Oct 7, 2016
Messages
242
Points
18
I want to find a file in my VPS linux and I read web hosting guides on a web hosting blog, they presented using find command but I tried to run it on my SSH console but I could not run this command. Does it require me to install somethings to run the find command? What are exact commands to find a File or a Directory in Linux with find?
 

LJSHost

Well-known member
Hosting Provider
Registered
Joined
Jul 5, 2016
Messages
1,031
Points
63
What error are you getting when running the find command ?

Find should already be installed.
 

Optimidia

Member
Registered
Joined
Oct 5, 2016
Messages
42
Points
8
Try something like
Code:
cd /;
find | grep FileYouAreLookingFor
and let us know what the output is. Also make sure you are logged in with the right privileges and account to SSH.
 

UnderHost

Member
Registered
Joined
Sep 5, 2016
Messages
42
Points
8
For your current folder use . or remplace /home for the location you are searching from.

Folders only:

find /home -type d -name 'searchfolders'

Files:

find /home -type f -name searchfiles.php
 

UWH-David

Member
Registered
Joined
Jan 18, 2016
Messages
45
Points
8
I want to find a file in my VPS linux and I read web hosting guides on a web hosting blog, they presented using find command but I tried to run it on my SSH console but I could not run this command. Does it require me to install somethings to run the find command? What are exact commands to find a File or a Directory in Linux with find?
That is odd, find is a default command. Try the following command
Code:
/usr/bin/find . -type f -name thefilename
You may be in a pretty jailed out ssh session or not in a shell like bash. You might want to verify your profile is set to bash in /etc/profile and your path setting is in place. You could always try the "locate" command.


If you have the ability to install, you could run:

CenOS/RedHat/Fedora/Scientific

Code:
sudo su
yum install mlocate
updatedb
locate "yourfile"

Debian/Mint/Ubuntu

Code:
sudo su
apt-get install mlocate
updatedb
locate "yourfile"
 

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top