Command Line Tools Flashcards

1
Q

The echo command is an internal command in bash (true or False)

A

True

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

You type “echo $PROC” and the computer replies “go away”. What does this mean?

A

The $PROC environment variable is set “Go away”.

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

What does the pwd command accomplish?

A

It prints the name of the working directory

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

In an xterm window launched from your window manager, you type exec gedit. What will happen when you exit from the gedit program?

A

The xterm window will close.

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

What is the surest way to run a program (say, myprog) that’s located in the current working directory?

A

Type ./ followed by the program name: ./myprog

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

How does man display information by default on most Linux?

A

Using the less pager

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

You want to store the standard output of the ifconfig command in a text file (file.txt) for future reference, and you want to wipe out any existing data in the file. You do not want to store standard error in this file. How can you accomplish these goals?

A

Type: ifconfig > file.txt

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

What is the effect of the following command?

$ myprog &> input.txt

A

Standard output and standard error from myprog are written to input.txt

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

How many commands can you pipe together at once?

A

An arbitrary number (in most cases, 16 may be a reasonable number.

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

You want to run an interactive script, gabby, which produces a lot of output in response to the user’s inputs. To facilitate future study of this script, you want to copy its output to a file. How might you do this?

A

Type: gabby | tee gabby-out.txt

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

A text-mode program, verbose, prints a lot of spurious “error” messages to standard error. How might you get rid of those messages while still interacting with the program?

A

Type: verbose 2> /dev/null

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

How do the > and&raquo_space; redirection operator differ?

A

The > operator creates a new file or overwrites an existing on; the&raquo_space; operator creates a new file or appends to an existing one.

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

What program would you use to display the end of a configuration file?

A

The tail command displays the last 10 line of a file.

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

What is the effect of the following command?

$ pr report.txt | lpr

A

The file report.txt is formatted for printing and sent to the lpr program.

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

What commands will number the lines in aleph.txt?

A

1) nl aleph.txt
2) cat -b aleph.txt
3) cat -n aleph.txt

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

What command will change all occurrences of dog in the file animals.txt to mutt in the screen display?

A

Type: sed ‘s/dog/mutt/g’ animals.txt

17
Q

You type a command into bash and pass a long filename to it, but after you enter the command, you receive a File not found error message because of a typo in the filename. What is the best course of action?

A

Press the Up arrow key, and use bash’s editing features to correct the typo.