Running Commands Flashcards

1
Q

Command line interface advantages…?

A

Efficiency and flexibility. (Simplicity is not one of them.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

If commands entered on the command line were compared to English sentences, the commands could be thought of as…?

A

having verbs, adverbs, and direct objects. (The verb is the command to run, the adverbs are the various command line switches that can be used to modify the behavior of the command (“quietly”, or “verbosely”), and any remaining words are the direct objects (what the command is supposed to act on). Again, as in languages, there are irregularities, and for almost every rule mentioned, there will be exceptions.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

First word of any command is generally the …?

A

Name of a program that lives as a file somewhere in the filesystem. (For example, the previous lessons used the ps and who commands. If we want to know which file contains these programs, there is a program called which which can help us. The which command, followed by the name of another command, will tell you “which” file is being run.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

when running a command, the shell process asks…?

A

the kernel to execute the specified program as a separate process, and arranges the output (or, more correctly, the standard out stream) of the process to be written to the terminal. The shell then pauses until the command’s process terminates. Once the command finishes, the shell prints another prompt, and waits to be told what to do next.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Many commands can have their behavior modified by…?

A

Specifying different command line switches. (An easy example is the ls command, which is used to list the contents of a directory.) (Continued on next cards)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

ls /usr …?

A

Simply lists the contents of the directory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

ls -s /usr …?

A

Includes the -s command line switch, gives the sizes of the content as well.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

ls -l /usr …?

A

Gives a “long” listing including all kinds of details about the files, such as ownerships, permissions, and modify times.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

-s and -l, are single letter switches. These are referred to as…?

A

“short” command line switches. (Sometimes, short command line switches can also take an argument. For example, the ls command has a -w command line switch, which specifies how “wide” the output should be, in characters.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Command line switch arguments simply follow the…?

A

Command line switch.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you know which command line switches take arguments and which don’t?

A

Short answer is through experience.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

More than ____ command switch can be used at a time.

A

One

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Multiple command line switches are simply…?

A

bunched together, squeezed between the command and any command arguments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Often, when using multiple command lines switches, users will take…?

A

Advantage of a shortcut that lets all switches be “piled together” onto one hyphen (-).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

All of the single letter switches that don’t take an argument, in this case -s and -r, can be piled together, sharing a…?

A

Single -

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

If a switch does take an argument, such as -w 40, it can only share a hyphen if it comes…?

A

last. (That way, its argument can be specified next on the command line.)

17
Q

Long switches are composed of…?

A

Words (Rather than single letter switches, and rather than starting with a leading hyphen, long switches are proceeded by double hyphens (–). Some commands use only short switches, some commands use long. Many commands, including ls, handle some both.)

18
Q

When long command line switches take an argument, the syntax differs slightly as well. Rather than the argument following the switch as a separate word, the argument is.?

A

bunched together with the long switch, separated by an =, as in –width=40. (Note also, that short and long command line switches can be mixed.)

19
Q

Whatever words are left over on the command line, after the command name and after any command line switches, are called…?

A

arguments to the command.

20
Q

What a command expects as arguments, or if it expects any at all, depend on…?

A

the command (For example, the ls command, if given arguments, will treat the arguments as the files or directories to be listed. The ps command expects no arguments. The cal command takes from zero to two, a possible month and a possible year to generate the calendar for. Learning what arguments a program excepts, and what it does with its argument, is part of learning how to use that command.)

21
Q

Most commands support either the _____ long command like switch, or the -h or -? short command line switches

A

–help

22
Q

Some things to note in the usage message…?

A
  • Optional elements are enclosed in square brackets ([ and ]).
  • Here, the usage message refers to multiple short command line switches using the shortcut notation.
  • Note the ls supports both the short (-s) and long (–size) forms of this command line switch.
  • Here is the -w or –width command line switch, which requires an argument.
    (Usage messages do not provide a complete reference for the command, but merely provide enough info to refresh memories.)
23
Q

Which of the following would be a legitimate invocation of the touch command?

  • touch -k /etc/services
  • touch -ac /etc/services
  • touch -nocreate /etc/services
  • touch -t
A

Touch -ac /etc/services

24
Q

Which of the following would be legitimate invocation of the touch command?

  • touch -from /etc/services
  • touch –cm /etc/services
  • touch –no-create a /etc/services
  • touch
A

touch –no-create -a /etc/services

25
Q

What best describes why madonna got the “file arguments missing” error message when running touch -r /etc/services…?

A

The -r command line switch requires an argument, which madonna didn’t supply.

26
Q

What best describes why madonna got the “command not found” error message when running tooch /etc/services…?

A

madonna misspelled the command name, and no command name tooch could be found.

27
Q

What best describes why madonna got the “invalid option” error message when running touch -k /etc/services?

A

The touch command doesn’t support the -k command line switch.

28
Q

When madonna ran the command touch -r /etc/services /tmp/foo, what best describes the role of the word /etc/services…?

A

The word serves as an argument to the -r command line switch.

29
Q

When a user runs the command who from the command line, what happens…?

A

The shell asks the kernel to execute the contents of the file /usr/bin/who as a separate process, displaying the process’s output on the terminal.

30
Q

When long command line switches were introduced, what best describes why they were preceded with a double hyphen (such as –size) instead of a single hyphen (such as -size)….?

A

The word -size could be interpreted as a shortcut for the -s -i -z -e short command line switches, instead of a single long command line switch.