Today you’ll learn how to use some built-in
commands to self-help your way to learning
all sorts of different tools on the Linux
command line. Let’s dive right in!You’re
probably familiar with the man pages by now,
which give you detailed usage information
on a particular command. But often times you
don’t even know which commands to use! You
might have a vague idea of the functionality
you’re looking for, and not much else. This
is where the apropos command comes in. Apropos
takes a keyword and searches through all of
the man pages for it, giving the entries that
match what you’re looking for.Let’s say
I wanna see which commands have to do with
the keyword, “search”. Apropos will give
you tons of results containing that keyword.
To filter some out, all you gotta do is qualify
it with some more keywords using the -a, for
AND, flag, which you can add as many as you
want. By throwing in the keyword, “files”,
I get fewer and more relevant entries. If
I add the keyword, “directory”, it reveals
the find command, which I can run against
man to see its usage.This is a useful way
to discover and learn tools that you’ve
never heard of before. For example, If I run
apropos delete, apparently there’s an ntfsundelete
command that I had never known about. This
lets you scan and recover supposedly deleted
files from NTFS volumes. Pretty neat.If you
know a command’s name but not exactly what
it does, the whatis command is your friend.
Running whatis ntfsundelete gives you a one-liner
description from its man pages.There's also
times when you wanna see the file locations
about a tool. The whereis command will give
you the binary, source code, and man page
files if they’re available. If you just
need the binary’s default file location,
I tend to use, “which”, more often since
it’s more direct. Sometimes a command may
appear in multiple locations. Passing which
the -a flag will show all of them to you.
In this case, you’ll notice /usr/sbin and
/sbin. The second one is actually a shortcut,
aka symbolic link. If I run ls with the -d
flag on this folder, you can see that /sbin
points to /usr/sbin. By the way as a note,
/sbin is a folder that mostly contains administrative
tools that often need root privileges to fully
run.The last command that can help you understand
bash commands is info. The info pages provide
more recent and detailed descriptions than
the man pages. It has tables of contents and
links to other pages. If an info page doesn't
exist for a command, it’ll display the man
page. When I type, “info ls”, notice how
there’s a more comprehensive write-up here.....
than in the man pages. You can use the arrow
keys to scroll, page up and down to jump a
screenful, enter to dive into a link, L to
jump back, capital H to see more command keys,
and q to quit.So that's it for command line
self-help tools. I gotta say, being able to
reference things without searching online
can save a ton of time when you're in the
command line. There's many instances when
you may not have access to the Internet and
gotta rely on your own memory and built-in
documentation to solve sysadmin problems.
This kind of self-sufficiency is just another
step towards becoming pro. If you found this
Linux tutorial helpful, hit that like button,
subscribe if you aren’t already, and let
me know what commands you'd like to learn
in the comments below. See you soon!