Commands in Linux

These are my notes on commands in linux.

In Linux, a command can be a program, something in the shell, a shell function,
and an alias. Programs are those in the /usr/bin directory. There can be many
different types. Commands in the shell are built in to the shell. A shell
function is a small script that does something useful, hopefully. Aliases are
commands that we make ourselves, that come from other commands.

Type
It can be useful to know what kind of command you are using. You can find out by
typing:
type free or
type dnf
You could get a different result for each command, depending on what you type.
The reason is, as mentioned above, there are a few different types of commands.
So, don't freak out when you see multiple types. 

Which
The which command gives you the location of an executable. 
which free
It only works for executable programs.

Documentation
We can now get the documentation for a command. Use "help" for the built in
commands.
help cd
It will give a description of what the command does as well as options. Alos,
when square brackets appear in the description of a command's syntax, they
indicate optional items. A vertical bar character indicates mutually exclusive
items. There is a help option after these commands, so you can get help either
way you like.
free --help
This gives you usage and options related to the command in question.

Man
Most programs will have a manual page. It can be abbreviated as "man".
man free
This will give you almost everything related to the "free" command. Probably
more than you care to know, honestly. Just know it is available. Most do not
provide examples and are just a reference. 

Apropos
This will display appropriate commands related to a search term. 
apropos free
This will give different man pages that might be helpful. The first column is
the name of the man page and afterwards, a description. 

Whatis
This command will display one line manual page descriptions.
whatis dnf
It is a simplified view but can be useful.

Info
This will display a program's info entry. 
info dnf
It gives you a lot of information but it is well formatted. It contains
hyperlinks to help you move around in the directory structure. use page up or
page down to move quickly. Hit enter with a hyperlink selected. Then, Q to quit
the info program.

Readme Files
A lot of software packages that are installed on your system have documentation
files. These files are located in the /usr/share/doc directory. Most of these
are stored in text format and can be viewed with the less command. Some are also
in HTML format and can be viewed in a web browser. 

Creating Aliases
We can create our own commands, or aliases, for other commands and associated
options. The first thing we do is see if there is an alias for a command you are
thinking of. If I want to check for freem, for free memory, I would type:
type fr
It will say not found if it is available. So, you might use the same aliases on
every system you are on. Sometimes I can't remember what I have done on a
system, that is why it is useful to check. To make an alias:
alias fr='free -h'
As you can see, we aren't just making a shorter command to type less. We
included an option there too. We are typing a lot less when we do this command
several times a day. We can again use the type command and we can see our alias
now. 
type fr
You can see what we just did, which is cool! The aliases will go away when your
session ends, so remember that. We will go over how to make them permanent
later, which is very useful.