Learn basics of Linux hacking for hacking aspirants Part 4

Hello friends, last part was written for the directory commands, there was one networking command too. In this article we are going to tell you about linux find command which will help you to find a file or directory in the computer.

Linux Find Command , Grep Find Exec

There are thousands of files which are used in the Linux file system. You can’t use ls-l command to see & find a single file from it. You can use linux find command some more commands that will help you to find a file from the disk.

Find a file in a directory

Linux find command is used to find a file in a directory. It is a recursive command which will search every file & folder to search for the filename we have given. Suppose we are going to find a file named hack. Then the command will be
find -name hack
This filter -name will tell the command to find the files whose name is hack. It will then return the path of all the directories where the file named hack is present. If we want to search in a specific directory then you can use the command like this.
find /Directory -name file-name
The above command will search all the directories & sub- directories in the specified directory for the name of file given. Output will show the path of all directory which contains that file.
Also ReadLearn basics of Linux hacking for hacking aspirants Part 2

Find binary files in the path

Binary files can be found by using which command. This command will let us finding binary files in the path given. You don’t know what a binary file is, a binary file is a file which is like .exe file in windows OS. It is programs in Linux. These files are stored in bin directory (remember the file structure of linux).

linux find command
linux find command

Use these commands in the given sequence as follows
echo $path
which ls
First command will give you the path variable. Second command will search for binaries , it will return a path to the binary file.
which binaryfilename
This will show you the path where the file is stored.
Finding a file in any directory
Whereis is a command used to find a file of any type in every directory. This will show you multiple path of the file of specified name in output. It also shows the manual files path in the output.
whereis filename
This command will display all the paths in the disk where the given file name is found including the man pages

Find a file using database of file system

This task is done by a special command called Locate. Now if you want to search a file in the disk, then it will take some time, when which or Whereis command is used. Locate command will search the filename in the file system. A file system is log where the database of all the files are stored in the table. When the Locate command will search a file by its name it will check the filesystem to see whether file is found or not. It can’t find a file which is created in few hours. As the new file details are updated in the filesystem in the night hours when the system is on rest.
locate filename
This is the syntax of the command to be used. The output of the command will show multiple paths of the file. The file can be in the multiple location of disk. There can be multiple directories where file of same name exists.
This article was based in search commands that will let you find any file from the terminal. You will use these commands in linux when we will be installing servers in the computer. Remember all these commands for being an advance user.
Also ReadLearn basics of Linux hacking for hacking aspirants Part 3
If you have any question regarding this please tell us in the comment box. Like our Facebook page for more updates. Thank You.

Leave a Comment