- [Voiceover] It you see a veteran Linux user
typing away at the command line
or you see a snippet of bash commands
in a tutorial online, it can seem like memorizing
the ins and outs of commands and options
is the only way to be productive
and understand what's going on.
But everybody starts somewhere
and even experienced command line users
don't memorize everything.
Albert Einstein is credited with saying
he didn't carry certain technical information
in his mind because it was readily available in books.
And as with so much information in programming
and the technical world, it's just not practical
to try to memorize all of the syntax and options
of command line tools.
Of course, it's important to remember the basics,
but while you're getting started,
you only need to remember a few commands.
The first one is man, which stands for the manual pages.
You can think of the man pages as a technical reference
book for your Linux distribution.
If you know the name of a command
you can find out a wealth of information about what it does,
what options it provides
and what arguments it takes.
To look up something in the man pages
type man followed by the command.
Earlier we saw the command ls, so let's look that up.
I'll type ls and press enter.
And here I can see some information
about the ls command.
I can see that it's for listing directory contents
and I get a quick overview of how to use the command
in the synopsis section.
I'd write ls followed by any of the options I need
and the file or folder path I want to use.
The terms in square brackets are optional.
I can just use the ls command by itself
to see the default output of listing the directory.
Here below the description header
there's a little bit more detailed information
about the command,
including it's default behavior and usage notes.
Below that is a listing of the options
that the command takes.
Occasionally you'll come across a command
that takes no options, but that's fairly rare.
Here at the bottom of the screen
I have a little status bar that tells me I'm on line one
and offers some options to help or quit.
I'll hit h to show the help
and I want to direct your attention
to the moving section here.
Two of the most useful key command here are
f and b, for moving forward and backward.
There's also z and w, which move in a similar way
but I find that I accidentally hit q,
which quits the man pages tool when I mean to hit w.
Anyway, there's a whole lot of information here,
which you can page through hitting f to go forward
and b to go back up.
If you're feeling adventurous,
you can explore that on your own time.
It's worth noting that these commands
are actually for another tool called less
but we'll get into that later on.
There are a lot of ways to use the man pages
very, very efficiently.
But for our purposes here, paging up and down
is just fine.
I'll press q to exit the help
and go back to the man page for ls.
Here I can use the f and b keys we saw before
to move through the information.
Notice that the status bar at the bottom
is showing me where I am in the file
in terms of lines of text.
Alright, I'm not looking up anything in particular yet
so I'll press q to quit.
I just want you to be familiar with man as we go along
in case you want to look anything up.
Many commands also have an option called help
which provides a brief amount of information about them.
However, they usually refer you to the man pages
for more detailed documentation.
You can see if a command you're using
has this feature available by typing
dash dash help after the command.
For example, ls --help.
And you can scroll up
and take a look at some of the information.
There's another command that's useful
when you're working in bash
and that's just help by itself.
As we get into working with the bash shell
in particular later on the help tool
can act as a handy reminder for the syntax
of some bash specific commands.
Không có nhận xét nào:
Đăng nhận xét