Hello, the beautiful people.
Now, in the last video, you learned how to search the Linux manual for specific keywords, open up
manual pages, and how to read them to learn how to use specific commands.
But there was quite a lot of stuff in that video and a lot to take in.
So in this video what we want to do is we want to give you some practice.
So in this video, we're going to take a look at a completely new command that we haven't seen before.
And we're going to learn how to use it.
We're going to search the manual for it.
We're going to learn how to use it.
Using the synopsis in the manual page.
We're going to read through its various options, and we're going to try some of them out and see how
you can customize commands and stuff like that.
And the idea is that this is going to show you how to independently search for stuff using the manual.
We're going to put the whole process together.
We're going to take everything we've learned, put it all together, and show you how you would learn
about a new command from scratch.
And the idea is you're going to have the independence to search for new stuff and learn how it works.
And that's really where the value comes from.
The manual, it's not having people randomly show you things that they find cool is being able to go
out there and find stuff that you find cool and learn how to use it independently.
And it's going to take your Linux abilities to a whole new level.
So let's go ahead and jump into it and start learning about our brand new command.
Okay.
So what we're going to do is we're going to look at a command that will allow us to list out what is
in a folder also known as a directory.
Okay.
So we want to command that will list out a directories contents.
So now that we've know that, let's go ahead and search for what might be available.
So the first step is to search for what might be available in the manual.
And you might have to try this multiple times.
You might not get the search terms available right away.
You might have to try different words and different keywords, but let's try that.
So let's try this type.
The Man Command, give it the K option, and now we tell what we want to search for.
Now I'm going to put in quotes list directory contents.
Now the reason I put it in quotes is because I want to search for this search term in one go.
I don't want to search for the word list, then the word directory, then the word contents.
I want to search for list directory contents in one go.
So once I do that, I press enter and here we go, we get some results.
Now they all seem to pretty much do what we want, right?
They all seem to say list directory contents.
But the one that I'm specifically looking for, I've heard about it online is the LS command.
Okay, now the RLS command is one that we will come onto as well in the later section of the course.
But we can see that it's a user command because it's in the first section of the manual, so we could
open it using.
Man one LS But because it's in the first section, we don't have to have it.
You can have the one, we can just type man L s and here we go.
We're in the manual page for the LS command.
So there we are now.
Right at the top we can see that we're in the LS command.
It's in the first section of the manual, which is apparently user commands and we can see that the
name of the command is LS and it lists directory contents and that's from the name section.
Now looking at the synopsis section, we can see that if you type LS, then you can have multiple optional
options.
We know they're optional because they're surrounded by square brackets and you can have multiple of
them because they've got the the ellipsis after it.
And then you can have multiple optional file names or paths to directories and can have multiple of
those because we can see the dot, dot, dot.
But the one thing that you might notice is because everything else is optional, right?
The only thing you actually need to enter is the RLS command itself and it will work.
So let's try that.
Okay, let's try and see that we don't even have to give the command any input.
So if we press lowercase Q to quit, we're back in our we're back in our terminal now.
As I said, the only thing we need to do is enter the LS command itself.
So if I just type ls and press enter.
We said that it has indeed listed out all the contents of our home directory, which is the directory
that we're currently in.
So how cool.
Now go back in the main page.
Let's go back in the main page and we can see in here that there's a whole bunch of options that we
can use.
We can look down in the description section.
Um, it says here that list information about the files, which is the current working directory by
default sorts entries alphabetically.
If none of these options or the sort option is is specified and mandatory arguments to long options
are mandatory for short options as well.
Okay, so that's fair enough.
Now we've got loads of different options in here.
Loads of them.
Let me just scroll through.
Loads of them guys.
Okay.
So memorizing all these, it's just not possible.
Just don't even don't even try.
You're not going to be able to do all that.
And even if you did, there are thousands and thousands of Linux commands.
So it's kind of a waste of time to do it all.
This is why you need to know how to use a manual page effectively.
There's a whole bunch of options.
One that I might like to show you, which is a good one, is the L option.
Now the of course, you can browse through these and have a look at what they do, but you've got the
L option here, which stands for long listing format.
So let's try.
That sounds pretty cool.
Let's see what that means.
So if I type LS and give it the l option, I press enter.
We now see that everything is kind of listed in a much more detailed fashion.
This was the output before and this is the output now.
So we've got much more detailed view of what's in our folder.
Now.
I'll explain what this means a bit later in the course, but for now I hope you can see that the process
that you might follow for discovering a new command, we've searched for it.
We're able to see manual pages.
We browsed a few of the options and we tried them out as well as seeing how to actually use the command
in the first place.
Now let's have another look in.
We can see that this is a bit it's a bit difficult to read.
Perhaps if we look at the RLS command again and we scroll down, we can see that there's another option
here called the H option, which stands for human readable.
So you can see here we've got a short form option, dash h or a long form option dash dash, human readable.
And this is how you can tell whether whether an option has a long form or not because it would be right
next to it in the manual page.
Remember when I said some options have long forms and some don't?
This is how you can tell.
And it says that with the L option and or the SE option, this will print human readable sizes of files.
So for example, one kilobyte, 284 megabytes, two gigabytes, etc..
Okay, so let's take a look at that here.
This column, this column here is actually all the file sizes and it just says 4096 or 8980 or whatever
it might be.
But to make that human readable, you can type ls dash l and then give it the option as well and we'll
see that.
Now it's telling us it's four kilobytes, 8.8 kilobytes and so on and so on.
But as well, because we have a long form option, we don't have to just type H, we might type H,
but we could also type dash, dash human, uh, readable.
I think it was like that.
Look, let me check, uh, if I type.
LS It's dash.
Dash human.
Human readable.
I apologize.
Human dash readable.
And there we go.
Now we've got exactly the same output that we had before, you see.
So you can see here the way we've used a long form option, which means now we, it's a bit easier to
read what.
H Well what that means than it is to just see what H means.
But it kind of makes the command a bit more difficult to type.
So there's a bit of a trade off there, but you get the same output.
So you can see just how useful reading the man pages actually is.
And if we just go back into the RLS command, let me clear the screen, go back into the RLS command
and scroll all the way down.
You will see a section if we if we keep scrolling down the long manual page much longer than the which
command.
Right, you'll see a section that says that is called see also.
So this section here that says see also it's got a hyperlink.
And you can click on this hyperlink or any hyperlink that's in a manual page by holding the control
key and left clicking.
Now if we control in left click what that's going to do.
If I if I clicked it right.
We have to wait, I think.
There we go.
It's opening up.
So I clicked it multiple times, but it's opened up in the Firefox browser, the link that was in there.
So it's going to give you more information about the command as long as you have Internet access.
So sometimes in manual pages, there are there are links that you can click on.
So there's another one here.
For example, another one here.
You can if you hold the control key and click them, then they will open up in your browser and you'll
be able to see what they're pointing at.
So that's very, very useful and that's something you'll definitely want to do if you want more information.
And there's a final note, although you can find pretty much information on pretty much all the commands
that you'll ever need using the main pages, you can't quite get all of them.
So some commands are defined directly in the shell and don't have man pages for them.
So to find those commands, you will need to use the help command instead of the man command.
Let me just show you what I mean.
So for example, one of them is the CD command.
Now the CD command is one you will use all the time.
Actually, it's used to change a directory.
You'll see this in the next section of the course.
All about navigating the file system.
But if I type man CD, you'll say there's no manual entry for the CD command.
But if I type the help command and then do CD, we then get something that's very similar to a man page
and we can see how to use it up here.
We get a description, we get the options and so on.
It's like, okay.
So it works pretty much just the same as a manual page.
It's just you have to use help instead now to find the commands that are that need the help command
abuse.
If you just type help and press enter, you get a big list and every single one of these in here is
need needs, the needs, the help command to see it.
So for example, here's CD the for example, p if we do p WD over here, if we do man P, that actually
is a main page for it.
But if for one of those commands it didn't come up with a man page, you would just type help pwt and
it will give you basically the same basic like a very similar kind of output.
So if man doesn't work and you know the command is correct, use the help command instead.
And there's a lot of other things in here like for example, doing wild loops in the in the shell for
loops and other things like that.
So it's, it's quite, it's quite an advanced thing more about the shell rather than about the programs
that are installed on your computer.
So that's just something to bear in mind.
Now, another thing that has actually come to my mind, um, when we're in the LZ command here, I'll
notice this is, this works for pretty much all commands notice when we've got a long form.
So for example, almost all or block size or ignore backups when you have a long form command like this,
they tend to break up the words with a dash.
So ignore dash backups, block dash size almost dash all or you know, down here full dash time group
dash directories, no dash group human dash readable.
So when you're making a long form option when if I wanted, you know, the, the the human readable
one instead of going human readable like the mistake I made before because human is one word and readable
is another word, it's going to be human dash readable and that gives us the output.
So that's just something to bear in mind with regards to spelling and things like that.
But the main thing to remember when you're reading these manual pages is each Linux command is designed
to do one thing and do it extremely well.
That's why you've got a the LZ command with so many different options.
Anything that you can possibly imagine to do with listing things out of directories, the LZ command
is going to be able to do it.
So that's why the manual pages have a lot of information to really get the information out of that.
Unfortunately, if you want to become a master of the LZ command or or, you know, even just start
using any new command, there's going to be no shortcut to reading, unfortunately.
I wish there was.
You can skim read and sometimes they give you quick intros and quick starts to commands and things like
that in the manual pages.
But for all these options, if you want to learn it, you're going to have to read it.
So there's no other way around that.
So that's how you will go through and you'll learn about a new command.
So let's do it really quick.
In quick succession, we wanted to learn about a command that shows you how to list directory content.
So we use man with the K option list directory contents.
It came up with some possible page names, the sections they were in and the explanations the LS command
core re.
We noticed it was in the first section, so we just typed man ls.
It gave us the manual page.
We saw that yes.
It lists directory contents.
We see a quick description and we saw how to use it.
You have to type the LS command.
The options are optional.
You can have multiple of those and the files are optional and you can have multiple of those.
So we saw that actually you can just type the LS command and you get some output, but there were plenty
of other options.
There's loads of things in here.
One thing that we liked was the idea that you could have a long form option.
Okay, so the long form option, we found it.
Where is it?
It's down here.
We found it under l use a long listing format so we had to look at that.
We do ls l.
We got that.
We also saw that you can have long form options as well.
Okay.
One other thing is that you can see here there's a lowercase a and which gives you one option and an
uppercase A, which gives you another option.
And here you got a lowercase B gives you one option and an uppercase B gives you another option that's
very common.
So you need to make sure that when you are spelling things in Linux, you get the case correct.
So for example ls dash l will give us that, but if I do ls dash capital l um.
It didn't even do anything.
But so you need to make sure that you get that stuff right.
And just, just for curiosity, what is the capital?
L So if there is a capital L option, um, yeah.
D reference when following, when showing file information for a symbolic link, show information for
the file in the link, showing information for the file.
The link reference is rather than for the link itself.
So there you go.
Um, okay.
So you need to make sure that you get your cases correct.
Things have to be spelled precisely.
You need to have a very sharp eye and not make mistakes and make sure you're doing stuff right.
Because the power of these commands are so, so powerful.
They can do so many different things, but you just need to make sure that you enter them correctly.
Okay.
So there we go.
That's a quick summary of this video.
What we're going to do in the next video is we're going to actually be moving on from the manual.
And what we're going to be showing you is how to how commands, take input and actually give output.
Because one of the most powerful things that Linux commands let you do is to chain different commands
together to make up super powerful command pipelines.
Now, because each command.
Is amazing at what it does when you can chain them together, chain these each of these separate commands
that is amazing at what it does, but chain them together.
You can create some incredibly powerful functionality with very little effort.
Okay, so I'm going to show you how to do that.
But first, we need to take a little bit of a look into how commands, take input and give output so
you can actually start building together these components, command pipelines.
You need to understand how they take input and give outputs.
So for all that good stuff, I'm going to see you in the next video.