Syntax of a Unix Command Line
Unix
command lines can be simple, one-word entries such as the
date command. They can also be more complex; you
may need to type more than the command or program name.[1]
A Unix command can have arguments. An argument can be an option or a filename. The general format for a Unix command line is:
command option(s) filename(s)There isn’t a single set of rules for writing Unix commands and arguments, but these general rules work in most cases:
Enter commands in lowercase.
Options modify the way in which a command works. Options are often single letters prefixed with a dash (
-, also called “hyphen” or “minus”) and set off by any number of spaces or tabs. Multiple options in one command line can be set off individually (such as-a -b). In most cases, you can combine them after a single dash (such as-ab), but most commands’ documentation doesn’t tell you whether this will work; you’ll have to try it.Some commands also have options made from complete words or phrases and starting with two dashes, such as
--deleteor--confirm-delete. When you enter a command line, you can use this option style, the single-letter options (which each start with a single dash), or both.The argument
filenameis the name of a file you want to use. Most Unix programs also accept multiple filenames, separated by spaces or specified with wildcards (see Chapter 8). If you don’t enter a filename correctly, you may get a response such as "filename: no such file or directory” ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access