Chapter 1 - Exploring Linux Command-Line Tools Flashcards

1
Q

what is the shell?

1-4

A

a program that accepts and interprets text-mode commands and provides an interface to the system

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

what are shell environment variables?

1-4

A

placeholders for data that may be useful to many programs

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

in linux, what is the most popular shell?

1-5

A

bash

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

there are 2 types of default shells: the default interactive shell and the default system shell. explain the difference between the 2 by describing their functions

1-5

A

default interactive shell - user uses this to enter commands, run programs from the command line, run shell scripts

default system shell - used by Linux to run system shell scripts

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

tell me the difference between internal and external commands

1-6

A

internal - also known as built-in commands, allow you to perform common tasks like changing the directory, timing an operation, setting options, and terminating the shell

external - commands that are not built-in

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

what happens when you type a command that is not recognized by the shell as one of its internal commands?

1-8

A

the shell checks its path to find a program by that name to execute it

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

you have hit Ctrl+R to begin a backward search. what do you hit to terminate the search?

1-10

A

Ctrl+G

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

how do you retrieve the last command in your shell history?

1-11

A

type !!

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

how do you retrieve the last 500 commands entered?

1-11

A

type history

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

bash configuration files are actually bash ____ ____

1-13

A

shell scripts

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

which environment variable provides the shell with a directory list to search when you’re entering command or program names?

1-14

A

$PATH

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

you can’t remember the exact name of a command to look up. the man utility has an option to help you out. what is that option?

1-15

A

the -k option

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

your Linux is missing its whatis database. what do you do?

1-15

A

type makewhatis at the prompt

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

there are file descriptors for standard input, output, and error. what are they?

1-17

A

input - 0
output - 1
error - 2

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

what keystroke corresponds to an end-of-file marker?

1-19

A

Ctrl+D

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

what is the | symbol for?

1-19

A

for redirecting a program’s output to another program’s input

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

tell me the syntax for xargs command for building a command from its standard input

1-20

A

xargs [options] [command [initial-arguments]]

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

the cat command is used for combining files, but its also commonly used for what?

1-22

A

to display the contents of a short file to STDOUT

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

how does the join command work?

1-23

A

it combines two files by matching the contents of specified fields within the fields

20
Q

which command allows you to display a file as octal numbers?

1-25

A

od

21
Q

which command allows you to break a file into pieces?

1-26

A

split

22
Q

which command lets you change characters from standard input?

1-27

A

tr

23
Q

which 3 commands are used for reformatting the text in a file?

1-28

A

fmt, nl, and pr

24
Q

what does the grep file do?

1-36

A

it searches for files that contain a specified string and returns the name of the file and a line of context for that string

25
Q

what is sed used for?

1-38

A

directly modifies a file’s contents, sending the hanged file to standard output

26
Q

you type a command into bash with a long file name, and the screen comes back “file not found”. what do you do?

1-42

A

retype the command, extra carefully
retype the command, using the Tab key
press Up arrow and use bash’s editing features to correct the typo

27
Q

cat, less, tee, sed, and echo. which are internal, which are external?

1-42

A

echo is internal, all the rest are external

28
Q

you type echo $PROC, the computer says Go away. what happened?

1-42

A

the $PROC environment variable has somehow been set to Go away

29
Q

what does the pwd accomplish?

1-42

A

prints the name of the working directory

30
Q

what is the surest way to run a program that’s located in the current working directory?

1-42

A

type ./ followed by the program name (run it all together)

31
Q

how does man display information by default on most linux systems?

1-43

A

it uses the less pager

32
Q

you want to store the output of the ifconfig command in a text file called file.txt for future reference, and you want to wipe out any existing data in the file. you don’t want to store standard error in this file, so how can you accomplish all of this?

1-43

A

ifconfig > file.txt

use the redirect symbol

33
Q

what is the effect of the following command:
$myprog &> input.txt

1-43

A

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

34
Q

how many commands can you pipe together at once?

1-43

A

far more than 16

35
Q

you want to run an interactive script called gabby which produced a lot of output in response to the user’s inputs. to facilitiate future study of this script, you want to copy its output to a file. how do you do this?

1-43

A

gabby | tee gabby-out.txt

36
Q

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

1-44

A

verbose 2> /dev/null

37
Q

how do the > and&raquo_space; operators differ?

1-44

A

> will create a new file or overwrite an existing one

|&raquo_space; creates a new file or appends to an existing one

38
Q

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

1-44

A

tail

39
Q

what is the effect of the following command?

$ pr report.txt | lpr

1-44

A

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

40
Q

which of the following commands will number the lines in aleph.txt? there are 3 ways to do it.

1-44

A

nl aleph.txt
cat -b aleph.txt
cat -n aleph.txt

41
Q

you have a data file, data.txt, to be processed by a particular program. however, the program cannot handle data separated by tabs. the data is separated by a tab stop at every eight characters. what command should you use before processing the data file with the program?

1-45

A

expand data.txt > data1.txt

42
Q

which of the following commands will change all occurrences of dog in the file animals.txt to mutt in the screen display?

1-45

A

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

43
Q

you’ve received an ASCII text file (longlines.txt) that uses no carriage returns within paragraphs but two carriages returns between paragraphs. the result is that your preferred text editor displays each paragraph as a very long line. how can you reformat this file so that you can more easily edit it(or a copy)?

1-45

A

fmt longlines.txt > longlines2.txt

44
Q

which of the following commands will print lines from the file world.txt that contain matches to changes and changed?

1-45

A

grep change[ds] world.txt

45
Q

which of the following regular expressions will match the strings dog, dug, and various other strings but not dig?

1-45

A

d[o-u]g