Chapter 1: Exploring Linux Command-Line Tools Flashcards

1
Q

shell

A

A program that interprets text commands and provides an interface to the system, e.g. bash in terminal.

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

Environment Variables

A

Placeholders for 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

bash

A

Most common default shell

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

sh

A

The original Bourne shell which bash is based off of, and not often used

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

tcsh

A

Based on the C shell (csh), fairly popular

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

ksh

A

The Korn shell, designed to combine the best features of sh and csh

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

zsh

A

Tries to extend ksh

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

Default Interactive Shell

A

The shell a user uses to enter commands, run run programs, run shell scripts, etc., from command line.

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

Default System Shell

A

Used to run system shell scripts, typically at startup

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

/bin/sh

A

A file that points to the system’s default system shell (normally bin/bash)

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

uname -a

A

Shows the operating system being run, along with hostname and kernel version

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

Built-In Commands

A

Commands built into the shell program, AKA internal commands

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

time

A

Command that tells you how long commands take to execute, e.g. time pwd tells you how long pwd takes to execute

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

set

A

Displays options relating to bash shell operation.

Can also change options if specified.

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

exit and logout

A

exit terminates any shell, and logout terminates only login shells

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

type ____

A

Checks if a command is internal or external

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

type -a ____

A

Same as type, but checks to see if there are both internal and external versions of the command

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

path

A

A list of directories in which commands can be found

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

How to Search for a Previously Done Command

A

Ctrl+R then type what you’re looking for.

Ctrl+S to search forward if you pass what you were looking for

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

If Ctrl+S not working when searching for a command, what command should you use to fix it?

A

stty -ixon

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

How to exit searching for a command?

A

Ctrl+G

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

How to move to beginning of line?

A

Ctrl+A

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

How to move to end of line?

A

Ctrl+E

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

How to move through a line one word at a time?

A

Ctrl+Left or Right Arrow

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

Backspace vs. Delete

A

Backspace deletes the character to the left of the cursor, while Delete deletes the character under the cursor

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

How to delete all text from cursor to the end of the line?

A

Ctrl+K

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

How to delete all text from cursor to beginning of the line?

A

Ctrl+X then Backspace

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

How to transpose letters or words?

A

Ctrl+T

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

How to change a word to uppercase? lowercase?

A

Esc then U

Esc then L

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

How to change a single letter to uppercase?

A

Esc then C

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

How to bring up an editor of the command on the line?

A

Ctrl+X then Ctrl+E

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

How to retrieve the last command and execute it?

A

!!

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

How to clear the command history?

A

history -c

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

How to execute a command by number?

A

! followed by the number

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

What is the name of the file where command history is stored?

A

.bash_history

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

What does an environment variable look like?

A

$VAR

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

How to view all environment variables?

A

env

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

How to delete an environment variable?

A

unset

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

How to search man pages?

A

man -k along with your keyword in quotes

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

whatis database

A

Contains a short description of each man page

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

How to create or update the whatis database?

A

makewhatis

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

man section 1

A

Executable programs and shells

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

man section 2

A

System calls provided by the kernel

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

man section 3

A

Library calls provided by program libraries

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

man section 4

A

Device Files

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

man section 5

A

File formats

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

man section 6

A

Games

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

man section 7

A

Miscellaneous

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

man section 8

A

System administration commands

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

man section 9

A

Kernel routines

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

An alternative to man

A

info

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

What are the pages about the built in commands called?

A

help pages

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

Stream

A

A data entity that can be manipulated

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

>

A

Creates a new file containing STDOUT

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

> >

A

Appends STDOUT to an existing file

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

2>

A

Creates a new file containing STDERR

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

A

Appends STDERR to the existing file

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

&>

A

Creates a new file containing STDOUT and STDERR

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

Sends the contents of the specified file to be used at STDIN

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

Accepts text on the following lines as STDIN

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

Causes the specified file to be used as both STDIN and STDOUT

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

What is the file you redirect output to if you want to get rid of it?

A

/dev/null

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

here document

A

Takes text from subsequent lines as standard input

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

How do you indicate that you are done with typing input when you use the

A

EOF

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

(pipe)

A

Redirects the first program’s standard output to the second programs standard input

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

tee

A

Splits STDIN so that it’s displayed on STDOUT and in as many files as you specify.
Often used with pipes

67
Q

xargs

A

Builds a command from it’s standard input.

xargs [options] [command [initial arguments]]

68
Q

What do you surround a command with if you want it to be treated as a separate command from the rest of the line?

A

Either ` or $()

69
Q

cat

A

Links together an arbitrary number of files end to end and sends the result to STDOUT

70
Q

How to show end of lines when using cat?

A

cat -E

71
Q

How to number the lines when using cat?

A

cat -n numbers all lines

cat -b numbers only the lines that have text

72
Q

How to compress blank lines when using cat?

A

cat -s

Makes multiple blank lines into a single blank line

73
Q

cat -T

A

Displays tab characters as ^I

74
Q

cat -v

A

Displays special characters using carat (^) and M- notations

75
Q

tac

A

Like cat, but reverses the order of the lines

76
Q

join

A

Combines two files by matching the contents of specified fields.
Fields are typically space-separated

77
Q

How to specify a different separator for the fields when using join?

A

join -t [char you want]

78
Q

How to make join case-insensitive?

A

join -i

79
Q

How to specify the fields you want to join?

A

join -1 [num] -2 [num]

80
Q

paste

A

Merges files line by line, separating the lines from each file by a tab

81
Q

What is the command that converts tabs to spaces?

A

expand

82
Q

od

A

Displays a file in octal

83
Q

sort

A

Used to sort files

84
Q

sort -f

A

Causes sort to ignore case

85
Q

sort -M

A

Sorts by three letter month abbreviations

86
Q

sort -n

A

Sort by number

87
Q

sort -r

A

Sort in reverse

88
Q

How do you sort by a specific field with sort?

A

sort -k [number of the field you want to use]

89
Q

split

A

Splits a file into two or more files

90
Q

split -b [size]

A

Splits a file into the specified size of bytes

91
Q

split -l [num]

A

splits the file by the number of lines specified

92
Q

How do you signal EOF with a keystroke?

A

Ctrl+D

93
Q

tr [options] [set1] [set2]

A

each character in set 1 is replaced by the corresponding element of set 2

94
Q

tr -d

A

Deletes the characters specified in set1, and set 2 is omitted

95
Q

tr -t

A

Makes set 1 the same size as set 2 if they are different sizes

96
Q

unexpand

A

Converts multiple spaces to tabs

97
Q

uniq

A

Removes duplicate lines.

98
Q

fmt

A

Tries to format a file well.

Makes lines no longer than 75 characters by default

99
Q

fmt -w [num]

A

Allows you to set the desired length of the lines

100
Q

nl

A

Command used to number lines

101
Q

nl -b [style]

A

Specifies the body numbering style

102
Q

nl -h [style]

A

Specifies the header numbering style

103
Q

nl -f [style]

A

Specifies the footer numbering style

104
Q

nl -d=[code]

A

Tells it that a new page starts wherever it sees what you specify as the code

105
Q

nl -p

A

Tells it to not start renumbering when it reaches a new page

106
Q

nl -n [format]

A

Specifies the numbering format:

1) ln (left justified, no leading zeroes)
2) rn (right justified, no leading zeroes)
3) rz (right justified, with leading zeroes)

107
Q

Styles if numbering for nl

A

1) t: number the lines that aren’t empty only
2) a: number all lines
3) n: omits all line numbers
4) p[REGEX]: only lines that match the REGEX are numbered

108
Q

pr [file]

A
  • Puts the file into a format for printing.
  • 80 character line lengths
  • Includes the original text with headers, which list the current date and time, the original filename, and the page number.
109
Q

How to make pr use a certain number of columns?

A

pr -[num]
or
pr –columns=[num]

110
Q

How to make pr use double spacing?

A

pr -d
or
pr –double-space

111
Q

How to make pr form-feed between pages?

A
pr -f
or
pr -F
or
pr --form-feed
112
Q

How to set the page length for pr?

A

pr -l [num]
or
pr –length=[num]

113
Q

How to set the text to be displayed in the header using pr?

A

pr -h [text]
or
pr –header=[text]

114
Q

How to change the left margin for pr?

A

pr -o [num]
or
pr –indent=[num]

115
Q

How to set the page width for pr? Also, what is the default width?

A

pr -w [num]
or
pr -width [num]

72

116
Q

head [file(s)]

A

Shows you the first 10 lines of one or more files

117
Q

How to specify the number of bytes you want to view for head?

A

head -c [num]
or
head –bytes=[num]

118
Q

How to specify the number of lines you want to view for head?

A

head -n [num]
or
head –lines=[num]

119
Q

tail [file(s)]

A

Displays the last 10 lines of one or more files.

Options are the same as head for specifying bytes or lines desired.

120
Q

How to keep a file open and see when lines are added to it for tail?

A

tail -f
or
tail –follow

121
Q

How to tell tail to stop tracking once a certain process ends?

A

tail -pid=[process ID]

122
Q

How to move forward a screen when using less?

A

spacebar

123
Q

How to move backward a screen when using less?

A

Esc then V

124
Q

How to search forward in a file while using less?

A

/ followed by the search term

125
Q

How to move to the next occurrence of a searched term in less? previous?

A

n

N

126
Q

How to search backward in a file while using less?

A

? then the search term

127
Q

How to move to a specific line while using less?

A

g followed by the number of the line

128
Q

How to view help while in less?

A

h

129
Q

cut

A

Extracts portions of input lines and displays them on STDOUT

130
Q

How to specify the list of bytes to cut using cut?

A

cut -b [list]
or
cut –bytes=[list]

131
Q

How to specify characters to be cut using cut?

A

cut -c [list]
or
cut –characters=[list]

132
Q

How to use cut by field?

A

cut -f [list]
or
cut –fields=[list]

133
Q

How to set the delimiting character when using cut?

A
cut -d [char]
or 
cut --delim=[char]
or
--delimiter=[char]
134
Q

wc [file]

A

Produces a word count of a file, as well aslines and bytes

135
Q

How to limit the output of wc to line count? word count? byte count? character count? max line-length?

A

–lines or -l

–words or -w

–bytes or -c

–chars or -m

–max-line-length or -L

136
Q

Regular Expression

A

A tool for describing or matching patterns in text

137
Q

What would be matched using the regular expression b[eia]g

A

beg, big, and bag

138
Q

What would be matched using the regular expression a[2-4]z

A

a2z, a3z, a4z

139
Q

What would be matched using the regular expression a.z

A

Any three character string beginning with a and ending with z

140
Q

Which symbol represents the beginning of a line in regular expressions? the end of a line?

A

$

141
Q

What does the * repetition operator indicate?

A

Zero or more occurrences

142
Q

What does the + repetition operator indicate?

A

One or more occurrences

143
Q

What does the ? repetition operator indicate?

A

Zero or one occurrence

144
Q

What would be matched to the regular expression car|truck

A

car or truck

145
Q

What are parentheses used for in regular expressions?

A

Used to group subexpressions

146
Q

grep [options] [regex] [files]

A

Searches for files that contain a specified string

147
Q

How to count the number of lines that match for grep?

A

grep -c
or
grep –count

148
Q

How to specify a pattern input file for grep?

A

grep -f [file]
or
grep –file=[file]

149
Q

How to make grep case-insensitive?

A

grep -i
or
grep –ignore-case

150
Q

How to search in specified directory and all subdirectories with grep?

A
grep -r
or
grep --recursive
or
rgrep
151
Q

How to make grep not recognize characters as regular expression characters and instead take them literally?

A
grep -F
or
grep --fixed-strings
or
fgrep
152
Q

How to use extended regular expressions with grep?

A
grep -e
or
grep --extended-regexp
or
egrep
153
Q

sed [options] -f [script-file] [input-file]
or
sed [options] [script-text] [input-file]

A
  • Modifies input-file using a set of commands specified in script-text or script-file, and sends it to STDOUT.
  • Typically you should surround script-text in single quotes.
154
Q

sed command =

A

Displays the current line number

155
Q

sed command a"text”

A

Append “text” to the file

156
Q

sed command i"text”

A

Insert “text” into the file

157
Q

sed command r “filename”

A

Append text from “filename” into the file

158
Q

sed command c"text”

A

Replace the selected range of lines with the provided text

159
Q

sed command s/”regexp”/”replacement”

A

Replace text that matches “regexp” with “replacement”

160
Q

sed command w “filename”

A

Write the current pattern space to the specified file

161
Q

sed command q

A

Immediately quit the script, but print the current pattern space

162
Q

sed command Q

A

Immediately quit the script.

163
Q

What is a special purpose program that can convert a DOS-style file to a Unix-style file?

A

dos2unix