In order to use a UNIX/Linux system, the user must input commands following a command prompt in the terminal window. A command prompt is essentially as it sounds, the computer is prompting the user for command input. These commands are short character combinations that the computer is programmed to understand and in the University’s EOS system, the computer command prompt is eos$. Once the user inputs a command, the computer attempts to execute that command. When the system completes the requested action, it will issue another command prompt.
Linux/UNIX commands have options and/or arguments that can be typed after the basic command to further specify an action. Arguments are typically paths to files (ref. File Systems) and options assign more specific functions to the command, or add additional actions to the command. Options must be preceded by a dash (-) in order to work. Also, all commands used in this course must be lowercase to function properly.
The syntax for a UNIX command is broken into three parts: the command, a list of options, and a list of arguments. For the purposes of this class, all three must be done in this order, although either the options or the list of arguments may be excluded depending on what command you are using and how it is being used. Each part of a command is separated by a space.
syntax: command -(options) argument1 argument2 ...
The first part, the command, tells the computer what sort of operation is being done.
- For example, if I want to use the ls command (which outputs the contents of a certain directory), I would always begin by typing ls.
The list of options changes the way commands operate — for example, some options might change the format of the output or allow a command to work on an entire directory of files instead of individual files. Each option is usually represented by a single letter, and these letters are combined (with no spaces or separators of any kind) and preceded with a hyphen to create a list of options (the hyphen is required to tell the computer that these are options).
- For example, if I wanted to use the -a option (which stands for “all”) and the -l option (which stands for “long”), both of which can be used with the ls command, my “option list” could be -al or -la (order does not matter).
Finally, many commands utilize a list of arguments. An argument is any piece of additional information that might be necessary to execute the command. This is often the path to a file or folder, but it can be any piece of information (such as a Unity ID or perhaps a date). In many cases, arguments are required. There can be more than one argument for a command, and arguments must always be supplied in the order they are expected. Each argument should be separated by a space (which is why it is important not to include spaces in the names of files and folders).
- For example, the ls command can accept the path to a specific directory as an argument; this will cause it to print the contents of that specific directory. My first (and in this case, only) argument, therefore, might be ~/ (the relative path to my home directory). If I had additional arguments, each would be separated by a space.
Putting it together:
eos$ ls -al ~/
Begin with the command name: ls. Follow that with a space, then the option list: -al. Follow that with a space, then the first argument: ~/. You will learn more about the options and arguments for each command in the next few sections of this chapter.
Note: eos$ is given by the computer and should NOT be typed into the terminal.