The terminal doesn't actually do any of that, instead it's the program running in the terminal that handles commands, by default Bash (a shell).
When you run a command, Bash does a bunch of things, but a lot of them are irrelevant to this example so I'll skip them (e.g. redirections, most expansions, keywords, and builtins).
When you run wget www.myurl.com
, Bash:
- Splits it into words and treats the first word as a command name, i.e.
wget
- Checks if the command name is an alias, is a function, and/or has a hashed path
- Checks each directory in the
PATH
environment variable for an executable with that name
- In my case
wget
is at /usr/bin/wget
. Run type wget
to see for yourself.
- Runs the exectuable,
/usr/bin/wget
, with the arguments wget
(the command name) and www.myurl.com
(the command line argument you supplied)
- Bash does not validate the arguments itself
- Waits for the command to complete and returns its exit status
For more details see Shell Operation in the Bash manual, and the links there.