Reading Files Flashcards

1
Q

[cmd] echo $SSH_CONNECTION

A

returns the ip address and port of the the client ssh and then shows the IP and port on the current server.

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

[cmd] $

A

expands a variable. So anything after the $ is a bash variable. So ie: echo $SSH_CONNECTION, the SSH_CONNECTION is the variable and the $ expands it to see its value

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

[cmd] cat /etc/hosts

A

cat stands for concatenate and will print the contents of a file or multiple files provided in the arguments as one single output

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

[cmd] wc -l /etc/server

A

wc stands for word count and the -l option counts the number of lines in the file provided in the argument

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

[cmd] !$

A

!$ is the variable that stores the last argument

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

[cmd] less

A

can use this cmd to print a files contents like you can with cat, but it allows you to page up and down for really long files. You can also search for s

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

[less] /text

A

the / search for whatever you text you type after the / in the open document. it is a forward search.

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

[less] ?text

A

Same as / but it searches backwards in the file

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

[less] n

A

When you search using / or ? you can use the n button to go the next found item

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

[less] q

A

closes the file and returns you to the normal bash cmd line

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

[cmd] head /etc/services

A

works the same way as cat but only shows you the first few lines (10 lines is the default)

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

[cmd] head -n 3

A

the -n 3 option specifies the number of lines you want head to return, so in this case it would return the top 3 lines.

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

[cmd] tail

A

the same as head but shows the last x lines. (the options work the same way too so -n 3 shows the last 3)

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

[cmd] yum list installed

A

lists all the installed packages on the system

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

[cmd] | (pipe)

A

the | (pipe) sends the output of the first cmd before the | to the second command after the |

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

[cmd] grep

A

a cmd line utility for searching plain text data for lines that match a regular expression.

17
Q

[regex] ^text

A

the ^ at the beginning searches for lines that start with the text after the carrot and will ignore any matches that aren’t at the beginning.