How to find a directory on linux?
I have a VPS with Suse Linux 10.3.
I've logged in via SSH/putty and am trying to find where my web files are located.
Since I'm uploading via FTP in a directory called httpdocs, I assume that this directory exists somewhere.
My google searches have taught me to do this, go to my root directory and type:
find httpdocs -type d
but it says "No such file or directory".
How can I find this directory?
It is:
find / -type d -name 'httpdocs'
the first parameter "/" is where to look, in this case "/" it's the entire system.
-name could be -iname to ignore case
also -type is not mandatory
use : man find for more options
this command should get you what you are looking for:
find / -type d -name httpdocs
that will search from the root of your server for directories with the name of httpdocs or if you just want to search from the current directory replace the '/' with a '.'
Another command you can try is locate you would do something like:
locate httpdocs
find / -type d -name httpdocs 2> /dev/null
This will eliminate all the error messages you'll likely (read, always) get when not doing this as the root user. Would recommend doing it this way.
It's important to know the parameter -iname to search "case insensitive" patterns and the use of wildcards: *, ?, etc..
Two examples:
Search all files from /root that contains the string "Linux", case insensitive:
find /root -type f -iname "*linux*"
Search all directories from /root that contains the string "Linux", case insensitive:
find /root -type d -iname "*linux*"
Extracted from here:
http://www.sysadmit.com/2015/12/linux-buscar-ficheros-directorios-con-find.html