Finding of Directory/Path in Linux

Burcu YARAR
InfoSec Write-ups
Published in
3 min readOct 5, 2022

--

Hi everyone❗️

I have prepared this short article, which is like a cheat sheet, for those who are just starting out in the field of cyber security and who want to improve themselves.👩🏻‍💻📝 Pathfinding commands in Linux; penetration tests, CTF solutions or OSCP etc. it is very important for us pentesters when preparing for certification exams.🎃 I hope you find it useful.🌟😌

locate

  • The related command searches from a constantly updated database.
  • The “locate” command searches on the database file “/var/cache/locate/locatedb”.
  • That’s why we should always update the database before using it.
  • The command we should use to update the database is the “updatedb” command.
  • The “locate” command searches on the custom database in all possible locations.

which

  • The related command indicates in which directory the executable file belonging to a command or program is located.
  • It searches for directories defined in the $PATH environment variable for this operation and returns the full path if it finds a match.

find

  • It performs file and directory searches on the specified criteria.
  • It does this recursively.
Syntax:

find <directory> <parameter> <searched file/statement>
  • Some parameters that can be used with the related command and their explanations are as follows.
Parameter:        Description:

name name of searched file
iname name of the searched file - case insensitivetype Type of searched file

f : regular file
d : directory
b : block file
c : character file
l : symbolic link
cnewer files modified after the given dateamin files accessed n minutes agocmin file status changed n minutes agoatime files accessed "n*24 hours" agomtime files processed in n daysctime files modified in n days
  • Case insensitive search for all files with filename “asd.txt” in the /root directory:
  • Searching for all files with “777” permission under the /sbin directory:
  • Finding and deleting “asd.txt” files under /root directory:
  • { } : The found files and directories will be placed between these brackets as parameters and the program specified immediately after exec will be run accordingly.

Happy hunting❗️🥂

From Infosec Writeups: A lot is coming up in the Infosec every day that it’s hard to keep up with. Join our weekly newsletter to get all the latest Infosec trends in the form of 5 articles, 4 Threads, 3 videos, 2 GitHub Repos and tools, and 1 job alert for FREE!

--

--

Passionate Cyber Security Expert #member @SynackRedTeam #pentesting #cybersecurity #offensivesecurity #applicationsecurity | https://www.linkedin.com/in/brcyrr/