Linux - Finding files in linux
12K views
Nov 28, 2024
Linux - Finding files in linux
View Video Transcript
0:00
now into previous video we have seen how
0:02
we can use the grep command to find a
0:04
particular word into the globus Linux
0:07
operating system now if I want to find a
0:09
particular file for an example if I'm
0:12
using a particular service and I want to
0:14
check where the service files are
0:15
located and I don't know in the service
0:17
file name I can just give the command
0:19
and I can check what are the files which
0:21
are dependent on this particular service
0:23
or which the services are depending on
0:25
which particular files and where they
0:27
are located I can use find and special
0:30
commands let us check how you can use
0:31
file and filter commands and what are
0:33
the commands we generally use it so for
0:35
the commands we have very first called
0:38
as a variance now if suppose I want to
0:40
find a file and I know I want to see
0:42
where this file is located I can give
0:44
the command wellis so it will check the
0:46
file the binary files the source files
0:49
as well as the manual pages for this
0:51
first so wherever that particular file
0:53
name is located it will show me all the
0:55
entries of those particular files
0:57
wherever the services are running on
0:59
that name but the files are located on
1:01
that name as well as the binary files
1:03
which are used for that particular file
1:05
so basically I can say any services if
1:09
you want to check their dependent first
1:10
you can go for various command the next
1:13
is a find find is for particular file
1:17
name you can find where it is located
1:19
but when you are using the file name so
1:22
file name will be searching the complete
1:25
file into a particular location where
1:27
you are going to give define this file
1:28
command so we can say it is not a global
1:30
search but it is a search from Bury or
1:33
do you need to define the destination
1:35
where you want to search your file so
1:37
you can find a file by the name or by
1:39
the extension into that particular
1:41
destination now if I'm thinking about
1:43
the various parameters into various we
1:47
also have different parameters which we
1:49
can specify while defining the command -
1:51
B we can use both along with the
1:53
variants so that we can check for the
1:55
binary files we can use - M for only the
1:59
manual section or the manual pages of
2:01
those particular service or the file we
2:04
can use - s for looking at this source
2:06
of the file or source of the command
2:08
which we have run - you unusual entries
2:12
all those particular for
2:14
- capital B we can use to search wealthy
2:17
binary files are located and what are
2:19
the limited places where we generally
2:21
stole our minor refunds
2:22
then - capital M we can use for
2:25
searching searching for your manual
2:27
sections were generally you store your
2:29
manual files - s we can use for looking
2:33
out delimited sources where we can keep
2:35
our files so this are the parameters
2:38
which we use with the variants there are
2:40
again more parameters which we can check
2:42
by using the man commands again for fine
2:44
commands we also have some parameters
2:46
which is generally we can use while you
2:49
are creating or finding a particular
2:51
file in to a particular destination we
2:53
can use - one which is a by default if
2:56
you do not define any parameters it will
2:58
take by default - one which will be the
3:01
filter or we can say search for a file
3:04
with the files first name so if you have
3:07
a file with multiple name multiple words
3:10
like for example I give important data
3:12
that is a directory name so important
3:15
and data so first wireless the name is
3:18
important the second word is data so if
3:21
I don't define anything by Devon it will
3:23
check for the first name of a file then
3:26
- - parameter we can define which will
3:29
take the first name first and then the
3:32
file system type which kind of file
3:34
system do you have like for example I
3:36
want to search for all the documents or
3:38
all the documents which is having a
3:40
particular dohc extensions or all the
3:43
document which is having jpg extension
3:45
so we can define the extensions of the
3:48
file system of the file as / - 3 again
3:52
we can use which find the file
3:54
automatically and reorders and source
3:56
based on the resources or likelihood of
3:59
the success we can say it will check for
4:02
each and every resources origin of
4:04
resource as well generally we can get
4:06
this particular file so automatically it
4:08
will set the destination of your file
4:10
where you can find it then we have
4:12
maximum depth like what are the sub
4:14
directories you have for example I have
4:16
created a sub directories which is at
4:19
5th level of my parent rectory 1st 2nd
4:23
3rd 4th and so so v is my fifth level of
4:26
my sub
4:27
directory into all the paren directories
4:28
we can also set the limit because I know
4:31
either uma file is located into the
4:33
first three sub directories or not if it
4:36
is in the first two third sub
4:37
directories I can set a limit for those
4:39
paths so what it will do while finding
4:41
the file it won't go into the depth but
4:43
in spite of that it will find all those
4:45
particular directly only in the first
4:47
three sub directories that the limit we
4:50
can define for the sub directories then
4:52
we have I name it can also check with
4:55
the file name with a case-sensitive so
4:58
if I do not want to search my file
5:00
without a case-sensitive I can directly
5:02
go for - I I named because whenever the
5:06
fine command works and all we know the
5:08
Linux contains all these case sensitive
5:10
data so here if I want to exclude that
5:13
because I don't remember the file name
5:15
which I have created whether it is in
5:16
capital case or it is in small case I
5:19
can give - i name so the case sensitive
5:22
won't be happening over here then we
5:25
have - not so if suppose I have created
5:28
a file and the result of the file does
5:30
not match the text which I have added so
5:33
I can go for - not then - type F we can
5:37
search for a particular file so we can
5:40
go for type F then if I want to check
5:43
for the directories I can give type - D
5:46
for finding out the directories so these
5:49
are the parameters we generally have for
5:51
finding a particular file as well as to
5:54
check where this particular service or
5:55
files are located in two different
5:57
locations for using the appearance so
6:00
let us check how we can use this various
6:02
and twine command into our terminal so
6:05
we can use the find command to file a
6:08
directory or a file into the same
6:10
current directory with the name we can
6:12
define what you name you require or
6:14
which name of the file directory require
6:16
so for example I'm searching for fruits
6:19
whether do you have fruits over here so
6:21
it's showing you we have fruits located
6:23
over here right same way if suppose I
6:25
have created I create directory mkdir
6:29
data to data if I move when I quit
6:35
rectory called us
6:36
ABC and I'm out of it and I'm going to
6:41
give the command the same come on just I
6:43
want to define that I want to search for
6:47
ABC so it's showing me this contained in
6:50
data and then they busy now for example
6:53
I'm on the home directory and I want to
6:56
search in which directory I have located
6:58
my file or directory I do not know the
7:00
exact path we can search with find
7:03
command so I can check though ABC was
7:05
created in dokie data and found it over
7:07
here right same way if I want to check a
7:11
particular file which is completely
7:12
empty so I can check for for example I'm
7:15
going to create a touch file right now
7:16
touch
7:19
21 okay so I wanted to charge for your
7:23
test file which is completely empty so
7:26
find that and we need to define the type
7:30
of your file
7:35
and that is empty
7:45
you
8:00
that you show me the current type of
8:03
your father is empty
8:14
check for searching for the empty files
8:22
. - type of your fun
8:37
you
8:47
okay so we just need to define - empty
8:52
so it will show you all the files which
8:54
are by default empty right now so this
8:56
is default which is empty which doesn't
8:57
contain anything file - doesn't contain
9:00
anything which is again located here so
9:01
we can check for file - it doesn't
9:04
contain anything we can check for the
9:08
type of the file which is again and
9:11
doesn't contain anything so although
9:13
this particular thing we can check
9:14
further by using the find commands I can
9:16
check the kamar which I have used for
9:18
empty just a - I have missed so you can
9:21
check into the parameters like how we
9:22
can use it so I've used like the front
9:29
into the current directory they typed
9:32
off as your file and that should be
9:36
empty so this is how it shows you same
9:40
way we can also check for defaults which
9:42
we have modified 1j prayer right so we
9:46
can also check into the you notice
9:48
parent location and I want that this
9:51
particular file was created by the user
9:53
called as trainer itself and I want to
9:56
check for a minimum time of this
9:58
particular file that is one day so I can
10:02
check like this so it will show me all
10:04
the files which was created one day ago
10:07
there are a number of us we have
10:11
same way we can also export those
10:13
particular files into the minimum time
10:16
of the day the number of days we
10:18
generally have to find like seven days
10:19
ago so it will show me all the time you
10:21
know file which was created seven days
10:23
ago but we haven't installed the machine
10:28
seven days ago that's reason it's not
10:29
showing me anything so the last machine
10:32
which I have created that was yesterday
10:34
so I can also define the one day ago
10:36
itself so this a tiff file generally
10:38
which we have so this is how we can
10:40
generally find a file as party-type
10:44
okay just you need to define the time
10:46
and the user who has created if you want
10:49
you can otherwise it is optional again
10:51
same way if I want to find all the files
10:54
which is having an you know extension as
10:57
jpg so we do not have any file as such
11:01
but still if I I want to find it I can
11:03
also define it by using JP G
11:10
let's showing you there is no such file
11:12
or directory into the concert okay so
11:16
this is how generally we use to find
11:18
come on but your important is your
11:20
various command now for example I want
11:23
to get the documents for configuring a
11:25
particular service I want to check where
11:28
these services are located where these
11:29
services on which services they are
11:31
depended on so we can use it like for
11:33
example I want to check and these
11:36
services for who so I'll just use where
11:39
is who so it is showing me the who
11:42
command has the file located at us Orban
11:46
us our share man manual pages we have
11:49
that is for who and that is a diesel
11:52
file and again we have worthy share man
11:55
man won who won P dot G's at file these
11:59
are the location of your who come on
12:02
same way if I want to check for my cat
12:04
come on I can also check for my cat come
12:06
on
12:06
so where is God which was very helpful
12:10
for you for if you are going for any
12:12
particular services and you want to
12:13
check where their files are located so
12:16
generally like if I'm configuring a
12:17
particular you know server so basically
12:20
what happens your sample file of
12:22
configurable configuring those servers
12:24
that get located in to thee us our share
12:27
itself so you can get the complete path
12:29
from there and it can copy your sample
12:32
file and reconfigure your complete
12:34
service so this is how we generally
12:36
search by using your find command and
12:38
various commands so where does command
12:40
can locate your dependent files or the
12:43
file with the same name wherever it is
12:44
located and fine command is on
12:46
particular location you can find for so
12:50
this is what the differences generally
12:51
we have in both defined and where is
12:53
command which both are used for
12:55
filtering and you know getting the
12:57
finding defaults so this is what we have
13:00
seen into this video into next video I'm
13:02
coming up with more administration and
13:05
more commands into Linux operating
13:06
system so keep watching
#Directories & Listings
#Programming