Time
8 hours 30 minutes
Difficulty
Beginner
CEU/CPE
10

Video Transcription

00:01
Hello.
00:03
Hello and welcome to the last section of Montreuil 1041 of 4.7.
00:09
We're gonna talk about the file system hierarchy standard
00:12
and how to use some of the built in features of the operating system too quickly. Locate items that were interested in.
00:20
We already used the fine command fair amount and, uh,
00:23
earlier sections, but I'll go over some more of the
00:26
features that supports.
00:28
Also, look at the locate command, which where is type
00:33
and we'll see how that database of searched files is updated by using update D B command.
00:39
I want to have a look at the config file for update TB.
00:45
So the file system hierarchy standard or F h s. As it's known.
00:50
The reason of standard was created because is because there was original flavors of linen is back in the eighties and nineties that eventually morphed into Lennox. That we have today
01:02
and a standard for the location of various different types of files and different components of the operating system was needed so that there was more compatibility among all these different fenders,
01:15
as we've been looking through.
01:17
But
01:18
examples of how to use the shell in different activities.
01:22
We're already familiar with the idea of directories and links.
01:26
Special files for storage devices block files, character files.
01:32
But there's also a domain sockets. So when programs are communicating with each other over the network, they could use a socket.
01:40
It's basically the equivalent of like an old phone operator that was taken a patch cable and punching one caller into another caller
01:48
named Pipe provides a similar functionality, but
01:51
locally on the system and not going across the network.
01:57
We'll talk about those items a little little bit, uh,
02:00
later in the course.
02:01
So we start off with our locate command.
02:05
And as it's as we can see here, there is a database called him Locate.
02:09
This contains
02:10
off the
02:13
commands that we would normally be searching for,
02:16
typically found within your current search path.
02:21
Well, let's have a look at the CONFIG file to show us some of the paths and some of the features that it contains
02:27
now. We were running located.
02:29
We have a few different options we can use a dash are for my gil expressions.
02:34
The reason we might want regular expressions because we might know part of the name we. Maybe we want to find a few different ones that have something in common. A few letters, a few characters.
02:44
Since you know some other characters and so on, you can see how that might.
02:50
It might be required to make it more complicated. Search at times.
02:53
If I use the locate command
02:57
with a string of characters, it treats it as if there were
03:01
wildcard characters before and after that command.
03:06
But I'll demonstrate that here shortly
03:07
I can. Also, instead of getting the actual listings, I can just count the number of listings with the dash C option.
03:15
The Dash E option shows me files that exist. This is important because
03:21
if files have been removed and the update D B command has not been run than the M locate, database will still have references to those files, which are no longer there.
03:30
So Dash, he helps to reduce the confusion
03:32
by only showing me files that actually exist.
03:36
And then I can ignore a case by using Dash I
03:39
and even specify the number of returned searches. But with Dash hen from finding something that's got dozens or hundreds of entries, maybe I don't want to see the 1st 10 for instance.
03:51
So we'll look at some of those examples,
03:53
and we have the where is command.
03:55
Now, this is a little bit different than locate because it's only looking for the binary programs.
04:02
So, uh,
04:03
we'll use, like, if configures an example,
04:06
I could look for source code and the manual page for that particular command.
04:14
And I can break that down with Dash B for binaries em from annual pages.
04:17
Esper sort sources. And then there's this dash you for unusual injuries
04:23
and unusual means more than one
04:26
ah file will match with a given criteria.
04:30
All right, so let's have a look
04:39
to make my shelf full screen.
04:42
That dress is good enough to get enough room,
04:46
see what we're doing.
04:49
All right. So first I was gonna look for the If confed command. So if I run, locate
04:55
if config
04:58
it finds several instances, Looks like about eight of them.
05:02
I've got,
05:03
uh, one file here
05:08
that has a bunch of text before the word if config and I've got a p I
05:13
I've got pf config if config What's a man? Paige
05:17
countries. So this proves that it treats my
05:20
search string. Like what? He has wild cards before and after.
05:25
Because I confined things that just contain that string itself within the name of a file.
05:31
Maybe I, uh
05:33
I also want to do something like this.
05:36
I don't even need to type the whole game. I should get the same list.
05:40
Dash, I ignores the case. So I put it all on upper case and I got that same list of about eight files
05:46
I can count to make sure that it's actually eat files
05:48
by running
05:50
the dash C option.
05:56
I'm not typing the whole thing because I don't need to. I know that it's gonna match those eight files.
06:01
So there's my count. There might be a good reasons why we want to know
06:08
only a certain number of returned entries.
06:13
And if I run it with the dash and
06:15
four, I only see the 1st 4 entries that have returned.
06:19
So maybe I know that there's a bunch of other ones I don't really care so much about. So I can strip those out by by running it with that dash. An option?
06:30
No, let's look at where is
06:31
for a convict.
06:33
I can't type today.
06:36
Now, this, as I said, only shows the binaries and man pages. So first we see the binary. That's where the
06:43
command action runs from user s been. And then there's the path to the man. Paige,
06:48
I can
06:49
I run this? Show me on Lee the binary with the dash B
06:55
Here it is.
06:56
And then dash
06:59
for the man. Paige
07:01
pretty handy.
07:04
And it's a good idea. Also to, as I've been doing, any time you're running a command that you're not too familiar with,
07:11
see if there is a help screen for it.
07:14
I usually pipe it two more, because frequently it'll go off the screen
07:17
because he has a few other options here to look at
07:20
for locate.
07:25
Same thing with where is
07:30
help for where is a little bit shorter,
07:31
but there's are binary manual page and
07:34
sources.
07:38
All right, so I talked a little bit about the, uh, m locate database,
07:44
so let's have a look.
07:53
Oops.
08:03
Uh,
08:09
okay. So I talked a little bit about the update. D b uh, command. Now this will update the locate database, and we can
08:20
look at the configuration file underneath that. See? So it's update d b dot com
08:26
and there's a bunch of settings in here that basically tell
08:31
the update or the M locate database. Which folders are we interested in? In which
08:37
aspects of paths are important for the database to catalog all of the available commands.
08:43
I can see you've got a bunch of different past. They're being pruned out because these are probably not system commands
08:52
and a bunch of other items within the file system
08:56
types that we are not gonna also cattle a catalogue for commands.
09:01
You probably won't end up changing this file at any time, but it's good to know where it is. In case you do have some specific parameters, maybe you need to
09:09
add something to remove something from the file system types or the paths that you are interested in.
09:16
The command is just up TB,
09:20
and we probably only run this if we did some work on a system and removed some of the components that we're currently in the M locate database.
09:26
But when you run up tbe again
09:30
in order to
09:31
refresh that content,
09:39
the next two commands are which and type
09:43
no. In my command path,
09:46
I can only if I run a command without specifying it's absolute path name,
09:52
but it has to be in my search path.
09:54
The which command will only look in my search path.
09:58
And if the command I'm trying to run is not in my search path, and I need to specify its absolute path name
10:07
and I can we look at some examples of using the Dash A Options Mothers.
10:11
Then there's also the type command.
10:13
Now we've already seen examples where the bass shell
10:16
gives us some color coded examples of what type of file or directory we're looking at.
10:24
But often there's
10:26
other reasons to actually look at
10:30
commands that are components of the operating system to find out what they actually are.
10:35
Is it a aliases in the shallows, that reserved word,
10:39
uh, a little bit similar to the file command, which could be used to see what type of file we're dealing with.
10:46
So let's look at a couple of examples here,
10:50
and we'll start with
10:54
the which command.
10:56
So if I look for if config
10:58
just keep using the same example,
11:01
it tells me that it's located underneath Espen.
11:05
I can verify this is in my search path by echoing my dollar path environment variable
11:15
and
11:16
has been is right there.
11:18
So it's going to search all of these paths in order
11:22
looking for the the command that I just gave to which
11:28
no,
11:30
it's possible that my current search path needs to be updated, and I briefly covered that in earlier section. All we have to do is
11:37
modify the appropriate user profile where where the path is set
11:43
and we just upend
11:45
the new paths that we want to add to the existing path.
11:48
And then we export that variable that becomes
11:52
available to the show.
11:56
Now let's look at a
11:58
help screen for which,
12:01
which does give us mother nice options.
12:05
I can, uh,
12:07
print all the matches in my path, not just the 1st 1
12:11
for if configured probably won't give me
12:13
junior. Anything different
12:18
actually does have another one. So user aspen if config also exists.
12:22
So I was wrong about that
12:24
of these. That's the most common option that you're probably going to to use with which
12:30
that we have the type command
12:35
that does not have help. So where will
12:37
a man paid for that?
12:39
Some comedians are a group together, as you see here, underneath bash built ins.
12:46
These are all part of bash.
12:48
So I can do a search for Titan by type, by hitting this Lasky.
12:54
And for next.
13:01
There we go.
13:03
All right, so here we have our little extra information. If I use dash T,
13:09
this tells me whether it's an alias keyword function built in or a file.
13:15
Then I have the
13:18
Where is it? The dash p option?
13:20
This returns name of a disk file that might be executed.
13:24
So it looks basically for binaries.
13:28
And then lastly, we have the dash, a option
13:31
which prints off the places which contained
13:35
this particular execute herbal.
13:39
So sometimes the man pages are a little bit less useful than others in this example, that's a pretty pretty
13:46
kind of densely packed, a little bit of information,
13:48
but we know we can find it when we need it.
13:52
All right, so here we have our little extra information. If I use dash T,
13:58
this tells me whether it's an alias keyword function built in or a file.
14:03
Then I have the
14:05
Where is it? The dash p option?
14:09
This returns name of a disk file that might be executed,
14:13
so it looks basically for binaries.
14:18
And then lastly, we have the dash, a option
14:20
which prints off the places which contained
14:24
this particular execute herbal.
14:28
So sometimes the man pages are a little bit less useful than others. In this example, that's a pretty pretty
14:33
kind of densely packed, a little bit of information.
14:37
But we know we can find it when we need it.
14:39
All right, So for the type command,
14:43
let's try it with the dash K option for the command echo
14:48
shows me all of the available entries. I can see that echo is built into the shell.
14:54
There's also a binary
14:56
and slash been and a 2nd 1 and user bed.
14:58
So a for all shows me all that information.
15:03
Now, what if I change this too?
15:05
The dash p option
15:13
dash p for echo because shell is a built in resentment because echo was a shell built in didn't show me anything, but now the date command.
15:22
This shows me that
15:24
the binary for
15:26
date has under the slash Ben
15:28
so I could get a similar output from the type command that I would get from the
15:33
thiab,
15:35
which command or where is.
15:41
And then there's also the dash t to show me
15:46
whether or not aliases exist for
15:48
some of my commands.
15:50
So it's pretty useful, pretty useful overall for those different features that it gives us.
16:00
Now, we got a lot of options here for the find command. I've already demonstrated a few of these, but we can talk about a few more,
16:07
and you could try these a lab on your own.
16:11
The print option, uh, generally is implied. I don't always need to specify this. Usually I get my output to standard out.
16:19
I can also execute a command based on the results of the fine command.
16:25
Very handy.
16:26
I can do things. I delete the list of files that return from a find.
16:30
I can also specify
16:33
numeric arguments. So
16:36
if I'm looking for a size of a file like and say is show me all files that are greater than 10 megabytes, show me all files that are smaller than five kilobytes, for instance,
16:45
again, with the delete option, I can run that here.
16:49
F print is also handy because Aiken, instead of redirecting the output of the fine command, I can just tell it directly to save to a file and just specify that in the command line,
17:00
one of the most frequent options that will use nor were running find is the Dash name,
17:07
because generally that's what I'm looking for. A file based on its name
17:10
and the last section I demonstrated the
17:14
the Einem Dash Einem for the I Know number.
17:18
I can also use Dash I name to ignore Case What? I'm searching for a name. I can look for the user
17:23
and the group. I can even search by permissions or by the access time when the file was created. There's a lot of different options here,
17:32
which will be covered
17:33
when we're going through some examples for find.
17:37
So let's have a look at that.
17:41
All right, so let's run through some handful of examples for fine.
17:45
This is a incredibly powerful command. You'll probably use it a lot when you're going through your various administrative tasks. There's just so many things that you need to do
17:53
where you need to get some information quickly.
17:57
First, let's look at the help.
18:02
This isn't too detailed. As you can tell, Scott breaks it down into it. Some groups that we can
18:07
take a peek at here.
18:11
We need a path.
18:12
We need some sort of a operator
18:17
to tell it what we're What we're looking for is that we're gonna search by name in a search by and I know number. We're going to search by permissions.
18:26
I have a bunch of different
18:29
items here. We can tell it
18:32
Searched the deepest directors first because in the depth command, maybe
18:36
we want a Traverse Mount points with the Mount option.
18:40
We could do all kinds of tests
18:42
access, time, creation time.
18:45
We can
18:47
do things like find a follow that was created within the last three minutes or find files that are older than six days
18:53
doing searches by user, by group, by the size of the file. But the type of the file
18:59
and then we have actions as well. I can delete when I find I can run commands against the list.
19:07
The man pages a lot more detailed,
19:10
and you're probably gonna wanna peruse this a little bit,
19:18
but let's just go ahead and jump in and do some examples.
19:22
So in my current director, I've got a bunch of files that were here from earlier activities in the course,
19:30
so But let's say I don't know where these files are. I know that they're in my current directory,
19:34
but they could be anywhere. Current directory. My path would be dot
19:41
Let's say I want to find everything that starts with the word file.
19:45
Well, you notice that it gave me
19:48
a air message saying Past must proceed Except expression.
19:52
Sometimes find gets a little bit picky.
19:55
Wild cards work in certain cases. Sometimes we need to deal with double quotes.
20:00
So if I use double quotes,
20:03
I get the results I'm looking for. It's probably best to just be in the habit of using the double quotes,
20:08
since there may be times where,
20:11
where that's just what you need to do anyway.
20:15
Now I've got a list of files, but I maybe I want to know a little bit more about them.
20:19
So what I could do
20:22
is run the exact command.
20:26
Now, this is a little bit tricky. The syntax a little strange.
20:30
Maybe I want to do a long listing on these files. So I'll say exactly l s dash held.
20:36
But the way the fine command works, I need to have a pair of curly braces,
20:38
which is a back reference to the output of the fine command.
20:44
And then I need to backslash escape
20:45
a semi colon character in order to get this to work correctly. It's just a quirk of the syntax. Once you type this in a few times, you get used to it. It's not that big of a deal,
20:56
but here we can see that the fine command
20:59
gave me what I was looking for. I've got
21:02
I matched on file with a wild card and then I did a long list so I can see what these things are.
21:10
Maybe I decide that I don't like these files and I want to get rid of them.
21:14
I could
21:15
change this to just r M for remove that would work.
21:21
Or I could just
21:23
do a different way
21:26
and just run the delete command.
21:32
Now, if I run the fine command again,
21:37
it doesn't get anything because those files have been deleted. They're no longer there.
21:41
So deletes a lot easier if that's your specific goal. Otherwise, you just use exactly
21:47
to run.
21:48
Uh,
21:48
whatever command you wish
21:51
now, I can also search for
21:55
anything on my system would say that's owned by
21:57
user User one.
22:02
So I found a few items.
22:04
I'm not I'm not doing a long listing, but you get the idea. I can also change this to the group.
22:14
So this is probably gonna be the same list of files because that
22:17
when you create a new user by default, the group name that they belong to is also that same new user name. So I created user one,
22:25
and by default, it's group is user one.
22:29
Maybe I want to search for a file, but I'm not sure about its name.
22:36
So
22:38
let's pick one here.
22:44
I've got a file called out dot text.
22:47
I'm gonna search from route because normally, if I don't know where something is, I'm probably gonna search from route just to make sure I get everything.
22:53
If I think that it's under a director that I'm already in, I can use dot or I can specify something else like slash users. Last local.
23:02
It's an optimization that we could
23:04
consider.
23:06
So it's not dash. I know moustache I name,
23:10
and I know that it's maybe it's called out dot text
23:15
so I can put it in caps and maybe I wasn't sure. And sure enough it finds the lower case version, so that's that's a pretty nice little feature.
23:22
I could also do searches based on the size of the files. So in my current directory,
23:29
show me all files that are larger than 100 kilobytes.
23:33
But there's a list.
23:34
This is really handy. There are many times when
23:38
you'll be working with a system and you're running out of space. You're not sure exactly where the big files are, where you got problems
23:45
so I can run a fun and come in
23:48
and just keep on
23:49
changing this value. Me, I'm looking for files. They're bigger than one megabyte. I have a couple of those two.
23:57
Maybe I'm looking for files. They're bigger than 100 megabytes or a gigabyte. Whatever it is, I can specify kilobytes, megabytes getting gigabytes and I think even terabytes
24:08
my iris. That option should be supported,
24:15
so it's pretty handy. I can also look for files based on their type.
24:19
So if I type,
24:22
uh, if I used the type option
24:25
with Dash D, that shows me all directories.
24:27
So underneath my current directory,
24:30
these are all the other directories that exist.
24:34
Some of these are hidden. They have the dot in front of them so that we only see them. If I run the l s dash L A
24:41
l a option.
24:45
So there's all my some hidden directories dot cash doc config
24:52
dot Debus
24:52
But it also found directors they're not hidden like collector one
24:57
and links
25:00
other file types. I can use a B for block file, see for character files
25:06
l for links. If I want to search for links,
25:08
I could do that.
25:11
Uh, speaking of links, find also has an option
25:15
to follow
25:17
or not follow siblings.
25:21
So if I use the dash p,
25:27
I remind myself what this file is called.
25:33
Here we go. So I have to symbolic links underneath my data.
25:36
I'm gonna search model starts my search there because they'll be faster. So my data
25:45
dash capital p
25:48
you know, he's my double quotes.
25:53
I didn't like Dash P there. I might have it in the wrong position,
25:57
but regardless, I can search.
26:00
I can exclude or include If I want to include, I would use dash capital l to follow siblings So dash capital p
26:07
good.
26:08
I should have given me an air saying that I can't find the file, right? What? Actually, I don't give anything back
26:14
Dash capital. L should have found the files that are underneath my data.
26:18
I can also search by access time in minutes or days, creation time and miniter minutes for days.
26:27
So I'll go back to my current list.
26:30
Find from here. I'll say
26:33
amen.
26:36
Anything that was modified, uh, within three minutes
26:40
or more than three minutes ago. Sorry. So there's plenty of files there.
26:45
Maybe I want
26:47
300 minutes ago. These were some files have been around for a few days, so obviously they're gonna still match
26:52
now. I can also show me files that are newer than three days from now
26:59
or they were created or after I used eight times. So it's access within three days.
27:03
I can also use the negative option
27:07
Go.
27:08
This shows me files having access time. That's three days going back,
27:15
see time and see Men work the same way. Creation time. So
27:19
if I weren't Ellis Dash l rt that puts my newest files the bottom of the list.
27:25
So I've got several that were there here from today
27:27
My file on the links Director was created today,
27:32
so I can find that
27:34
if I didn't know where it was.
27:37
Dash C time
27:42
less than one day ago.
27:45
And so it finds
27:47
links
27:48
and all the contents inside. These other hidden directories have some content that was created in the last day as well.
27:56
So very useful.
27:57
Ah, few other things I can run.
28:02
Oops,
28:04
the dash empty option. This shows me files that heavy zero length
28:07
and we can see I've got several of those in my list,
28:11
so that's handy. Sometimes files get created with zero length
28:15
because the program needs a reference file for a flag or something like that. So it's gonna be ableto locate those when we need to.
28:22
And I can't even find files that are executed.
28:26
This would be a big list if I
28:33
I'll put that to more.
28:34
So these are all the executed all binary programs on my entire system. Like of course, narrow that down
28:41
and search on Lee those areas where
28:45
where I have
28:47
a little bit more interest.
28:49
All right, so lots of options here on dhe, you can mess around with a little bit more
28:55
with the online lab.
28:59
All right, so let's move on to the file Hurricane
29:02
Standard.
29:03
Here we can see several different standard directory names, which every limits administration needs to know.
29:11
I need to be able Thio verify that if I've got to try to find certain kind of information, I know where to look. One area that we've spent a lot of time and is the ETC. Folder.
29:22
That's all your configuration files.
29:23
We spent a little bit of time poke around the Death folder as well. Software
29:27
drivers, all of your character and block devices for your storage. But I'll be here,
29:33
everything to boot. The system is underneath slash boot. That's a pretty obvious one. Binaries under slash been libraries under stash, slash, live or live
29:44
Espen is ah, little bit different then than regular Been. This is Maura about
29:48
Byner is needed during booting,
29:52
but that's why we have the witch command, the wearer's command, the locate command. If we're not sure, we can always reference those commands to have to do the search for US
30:02
user accessible programs. Wonder slash user.
30:06
Most of our logs and other
30:08
out
30:11
configuration output from
30:12
programs and installed software will go under slash bar
30:17
slash 10. Pretty self explanatory.
30:19
If we install third party software, typically it goes under slash opt
30:23
as an optional.
30:26
That's a pretty good standard, because that way we can keep operating system programs separate from anything. That's third party.
30:33
It's kind of like Windows where you have your your programs or your programs. X 86 folder.
30:38
That's for installed software, not for the operating system
30:42
and then slash Media is a frequently use standard for removable media.
30:47
Pretty self explanatory as well.
30:49
Okay, we finally get to the end of the
30:52
104 module. We talked about the fine command
30:56
just recently, many different options. You're gonna get a chance to practice more. With that.
31:00
We looked at which and where is and locate.
31:03
We also covered the type command and the M locate database, which is updated by update D. B,
31:10
uh, update. DBS probably run as a daily crown job. I probably didn't mention that earlier, but it's not something you should have to do manually to off unless you just want up
31:19
updated within the day, and you don't want to wait till the next crown. John rolls around
31:26
all right. So we are. At the end of next, we will cover shell scripting and a little bit about data management.
31:32
See you then. Thank you.

CompTIA Linux+

Our self-paced online CompTIA Linux+ course prepares students with the knowledge to become a certified Linux+ expert, spanning a curriculum that covers Linux maintenance tasks, user assistance and installation and configuration.

Instructed By

Instructor Profile Image
Dean Pompilio
CEO of SteppingStone Solutions
Instructor