Finding of Directory/Path in Linux
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 fileiname name of the searched file - case insensitivetype Type of searched file
f : regular file
d : directory
b : block file
c : character file
l : symbolic linkcnewer 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❗️🥂