Linux: Standard Command Structures
scottalanmiller last edited by scottalanmiller
Linux commands can easily become complex and confusing. Each command is independent of the others and has an opportunity to select a different standard format for how it works, which adds a lot of unnecessary complexity (famously the tar command which is extremely common does not follow a common standard.)
The arena of command style standardization is one of the areas in which Microsoft with its advanced PowerShell environment has managed to best the Linux world. Why is this? In Linux, commands do not come from a central source but come often from individual projects - they are not unified in any way. In fact, many of the commands that we use, most of the most common ones in fact, significantly pre-date Linux often by decades. This provides little to no opportunity for standardization without rewriting the entire command line ecosystem from scratch by a single entity. Microsoft was able to do this with PowerShell and it made sense for them to do so as they lacked a preexisting robust shell environment. The UNIX world has many and lacks the justification for a change like PS provided. So, for now, Windows will continue to lead in command standardization, but Linux commands continue to often be more straightforward to learn and use.
For the most part, the commands that we use on Linux are stand alone commands. They exist on the filesystem as an independent program. They are not part of the shell itself or a part of Linux but are simply commonly associated utilities that are grouped together and included in the distribution. It is only convention that we have the collection of utilities that we generally expect to have at our disposal.
The command format of a Linux command is:
command flags and command modifiers, normally preceded by a dash and generally optional *command actors, the thing(s) on which the command will act.)
So to show a couple typical examples...
Is a command on its own, everything after the command itself is optional.
The ls command with a single "flag" that modifies how the command will work. The -l flag for ls tells it to output in "long format."
ls -l /tmp
Here we have the ls command with the "long" format flat and the directory on which to take the action... the /tmp directory.
With ls the -l is optional so we can also do...
Which is the same as the one above but with "short" formatting (the default.)
The ls command can take many flags. Three very common ones are -l for long formatting, -a for all which shows even hidden files (those whose names begin with a dot) and -h which shows file sizes in human readable form.
ls -lah /tmp
Part of a series on Linux Systems Administration by Scott Alan Miller