Hack Like a Pro: Linux Basics for the Aspiring Hacker, Part 4 (Finding Files) « Null Byte :: WonderHowTo

Welcome back, my budding hackers!I began this series on Linux basics because several of you have expressed befuddlement at working withBackTrackon Linux. As a hacker, there is no substitute for Linux skills.Linux beginners are often faced with the issue of how to find files and programs, especially considering the radically different directory structure as compared to Mac OS or Windows. Beginners sometimes get frustrated trying to find the necessary files or binaries, so I'm dedicating this tutorial to finding stuff in Linux.Before we dive in, make sure to check out my previous guides on Linux basics (1,2, and3) to get current on our lessons.Step 1: Finding Files in a Directory (Find)The first command I want to show you isfind. As you probably guessed,findis able to find stuff by looking in a directory for the file you're hunting for. By default, it's recursive, which means it will look in all sub-directories and display a list of everywhere it finds the file. For instance, if we are looking foraircrack-ng, we could type:bt > find -name aircarck-ngNote that we need to tell Linux that we want to search by name (-name) and then the name of the file we're searching for.It then returns the full path of every place where it findsaircrack-ng. We can be more specific and ask Linux to only tell us where it findsaircrack-ngin the/pentestdirectory. We can do this by typing:bt > find /pentest -name aircrack-ngThis command says, "look in the pentest directory and all its sub-directories and tell me where you find something called aircrack-ng".Now, Linux only returns those paths to files that are in the directory/pentestor its sub-directories, such as/pentest/wireless/aircrack-ngand the others.Step 2: Finding Binaries in Path Variables (Which)The next searching command we want to look at iswhich. This command allows us to search for binaries that are in our path variable. Hmm...even I think that's a lot of techo-googlygoop. Let's try to make some sense of it.Binaries are the files that are the equivalent of executables in Windows. These are files that do something likeecho,ls,cd,mv, etc. Our path variable is the variable that keeps the directory path to our binaries. Usually, our binaries are in the/bin(bin is short for binaries) or/sbindirectory and that's reflected in our path variable. Our path variable setting can be checked by asking Linux toechothe value in the variable. We do this by typing:bt > echo $PATHLinux responds with the value in our path variable. These are the places thatwhichwill search for binaries. So when we type:bt > which lsIt returns the path to that binary. If we usewhichto search foraircrack-ng:bt > which aircrack-ngThen we can see that Linux returns/usr/local/bin/aircrack-ng. Ifaircrack-ngwere not in a directory that was in our path, it would not be able to help us.Step 3: Finding Any File in Any Directory (Whereis)Unlikewhich,whereisis not limited to finding binaries in our path. It can locate files in any directory, and in addition, it also locates the files manual ormanpages. So, when we type:bt > whereis aircrack-ngWe can see thatwhereisreturns the path to multiple locations ofaircrack-ngincluding themanpages.Step 4: Finding Files Using the Database (Locate)Thelocatecommand can also be used to find files and usually is much faster than eitherwhichorwhereis. The difference is thatlocateuses a database of all the files in the file system and searches therefore take place much faster.The drawback to locate is thatnewfiles will NOT be found bylocateas the database is typically only updated daily, usually scheduled in the middle of the night when activity on the system is light as updating this database can be CPU intensive.locate aircrack-ngYou can see in the screenshot above that locate returns a path every time it encounters any file withaircrack-ngin it, binary or not.Hope this helps you in finding what you need in BackTrack Linux, therefore making you a better hacker. Make sure to check out the first three parts of this series (1,2, and3), and if you have any questions, ask away in the comments below or hit up theNull Byte forumfor more help.Come back for my next Linux basics tutorial, and we'll look at how to install new software!Penguinphotosby Liam QuinnWant to start making money as a white hat hacker?Jump-start your hacking career with our2020 Premium Ethical Hacking Certification Training Bundlefrom the newNull Byte Shopand get over 60 hours of training from cybersecurity professionals.Buy Now (90% off) >Other worthwhile deals to check out:97% off The Ultimate 2021 White Hat Hacker Certification Bundle99% off The 2021 All-in-One Data Scientist Mega Bundle98% off The 2021 Premium Learn To Code Certification Bundle62% off MindMaster Mind Mapping Software: Perpetual LicenseRelatedNews:How to Study for the White Hat Hacker Associate Certification (CWA)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 11 (Apache Web Servers)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 1 (Getting Started)How To:The Essential Skills to Becoming a Master HackerHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 6 (Networking Basics)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 21 (GRUB Bootloader)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 5 (Installing New Software)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 12 (Loadable Kernel Modules)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 2 (Creating Directories & Files)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 13 (Mounting Drives & Devices)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 17 (Client DNS)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 22 (Samba)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 10 (Manipulating Text)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 25 (Inetd, the Super Daemon)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 9 (Managing Environmental Variables)Hack Like a Pro:Windows CMD Remote Commands for the Aspiring Hacker, Part 1How to Hack Like a Pro:Getting Started with MetasploitHow To:Linux Basics for the Aspiring Hacker: Managing Hard DrivesHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 24 (The Linux Philosophy)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 23 (Logging)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 16 (Stdin, Stdout, & Stderror)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 3 (Managing Directories & Files)Goodnight Byte:HackThisSite Walkthrough, Part 6 - Legal Hacker TrainingGoodnight Byte:HackThisSite Walkthrough, Part 8 - Legal Hacker TrainingGoodnight Byte:HackThisSite, Realistic 3 - Real Hacking SimulationsCommunity Byte:HackThisSite Walkthrough, Part 6 - Legal Hacker TrainingGoodnight Byte:HackThisSite Walkthrough, Part 10 - Legal Hacker TrainingGoodnight Byte:HackThisSite Walkthrough, Part 7 - Legal HackerHack Like a Pro:Hacking Samba on Ubuntu and Installing the MeterpreterCommunity Byte:HackThisSite Walkthrough, Part 1 - Legal Hacker TrainingCommunity Byte:HackThisSite Walkthrough, Part 10 - Legal Hacker TrainingGoodnight Byte:HackThisSite Walkthrough, Part 9 - Legal Hacker TrainingHow To:How Hackers Take Your Encrypted Passwords & Crack ThemCommunity Byte:HackThisSite Walkthrough, Part 2 - Legal Hacker TrainingGoodnight Byte:HackThisSite Walkthrough, Part 4 - Legal Hacker TrainingNews:Let Me Introduce MyselfCommunity Byte:HackThisSite, Realistic 2 - Real Hacking Simulations