linux commands

linux commands

Hervey Allen
Network Startup Resource Center

PacNOG 6: Nadi, Fiji

Using Commands in Linux

The format of a command
command [options] parameters
“Traditionally, UNIX command-line options consist of a dash,
followed by one or more lowercase letters. The GNU utilities
added a double-dash, followed by a complete word or
compound word.”
Two very typical examples are:
-h
--help
and
-v
--version

Command parameters
•  The parameter is what the command
acts on.
•  Often there are multiple parameters.
•  In Unix UPPERCASE and lowercase for
both options and parameters matter.
Spaces ___ are ___ critical ___ .
“-- help”

is wrong.

“--help”

is right.

Some command examples
Let's start simple:
Display a list of files:
ls
Display a list of files in a long listing format:
ls -l

Display a list of all files in a long listing format
with human-readable file sizes:
ls -alh

Some command examples cont.
Some equivalent ways to do “ls -alh”:
ls -lah
ls -l -a -h
ls –l --all --human-readable
Note that there is no double-dash (‘--’) option
for “-l”. You can figure this out by typing:
man ls
Or by typing:
ls --help

Where's the parameter?
We typed the “ls” command with several
options, but no parameter. Do you think
“ls” uses a parameter?
- What is the parameter for “ls -l”?
- It is “.” which represents our current directory.
- “ls -l” and “ls -l .” are the same.
- We'll discuss files and directories later.

A disconcerting Unix feature
If a command executes successfully there is
no output returned from the command
execution. this is normal.
That is, if you type:
cp file1 file2
The result is that you get your command
prompt back. Nothing means success.
Let's give this a try...

A disconcerting Unix feature
Try doing the following on your machine:
$ cd

[cd = change dir]

$ touch file1

[touch = create/update]

$ cp file1 file2
[cp = copy]

The “$” indicates the command prompt for a
normal...

Similar Essays