[Intro music]
Command syntax. Every time you run a command, you
have the option, and you have argument. Command
typically have the syntax like command, like as if
you are running command, let's say ls, it's a
listing command, the option is going to be the
-l or ltr, whatever we use in argument if
you are looking for a specific file. Now, what are
the options again? It modifies the way that a
command works. It usually consist of a hyphen or a
dash, followed by a single letter. Sometimes some
commands accept multiple options, which can
usually be grouped together for a single hyphen.
And what are the arguments? Most commands are used
together with one or more arguments. Some commands
assume a default argument if none is supplied, and
arguments are optional for some commands and
required by others. Let's look at our Linux
machine and I will explain you exactly how the
command syntax works.
[No audio]
So we are in this Linux
machine. Again, the first thing you always have to
do is find out who are you or which user
are you logged in as. So you do whoami, you are
yourself. Second thing, which directory you are in?
you are in slash home and slash your user. This is
your home directory. And by the way, every time
you start to type cd, no matter which directory you
are in, you're always going to come back to your
home directory. Now when I mean by command, so the
first, when we run command ls in your directory,
you will see all the directories and files it has,
without other details that you get. So when you
use the option, so you do ls -l, this will
list everything that you have in your home
directory. And then it will also give you all the
details whether it's a directory,
file, size, who owns it, and all the bunch of
stuff. So you adding the option with the
-l. So options can also be grouped. When
I'm meant the group, it means ls -l, and you
could add another option to it, which is t. So you
see, it will let list all the contents of your
directory by the time they were created. Then when
you do another option with that ls -ltr, it
will still give you the all the listing, but it
will list all the newest files or directories
starting at the bottom and the oldest one from the
top. So that covers our ls as a command. And then
the second one is the option which we use ls -ltr.
And what do we mean by argument? Let's look
at the argument again.
[No audio]
Argument can be used to be
more specific, meaning let's say if you wanted to
know just a file, bart, so you do ls -l bart.
This is going to only list the file bart. If
you want to know the details about the file bart,
who owns it, was a permission on it, you could just
use that argument to list this. Now you have
command, you have option, and you have argument. If
you wanted to, let's say delete a directory, which
is by the way the command to delete is rm, remove, -f,
which is to remove without asking you
whether they should delete it or not, so you could
just do rm -f.
And then let's say I want to remove seinfeld. And
when you hit Enter, it's gonna say cannot remove
seinfeld, Is a directory. So we have to use an
option to remove it and to remove a directory
with an option, it is, so let's say if this time we
will take out f, and we just do r. So r is an option
to remove a directory, so when you hit enter, it
will remove the seinfeld. And how do you validate
that? You do ls -ltr, and you're going to
see in your listing seinfeld directory is gone.
And I want you to recreate it again, it's mkdir
[No author]
seinfeld, you do ls -ltr, and there you go.
This has at the bottom, it has your new directory
seinfeld. So again, to wrap up this lesson, we
covered the command, the option, and argument. And
the best way to find out which options you have
available with the command you always run man,
which is stands for manual, and ls, which is the
command. When you hit enter, it will give you a
user command, a manual, which will give you all the
options like if you run -a, it will ignore
entry starting with dot, if you uppercase, A, B,
and C, and so on, and you could just hit space to
go down and see other option. Keep hitting space,
keep hitting space, keep hitting space, and you'll
see all the different options, and by the time you
get to the bottom and you cannot hit the base
anymore, you could just hit Q to get your prompt
back. You could also run a man ls, hit enter. And
if you just want to view the first page without
going any further, you could just simply quit out
of it right away instead of just hitting space,
space and go to the end, so you hit Q. So this is
what primarily we covered in this lesson. Again,
command, option, and argument.
[No audio]