CL Extras Flashcards

1
Q

What does the cal command do?

A

prints out a calendar

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

What would you type if you wanted to see the current year’s calendar?

A

cal -y

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

What would you do if you wanted to display the calendar of a different year?

A

cal 2015

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

How can you display the month of a year?

A

pass two integer parameters:

cal 8 2016 = august 2016

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

What command will print out the contents of a file to standard output?

A

cat

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

How can you send the output of cat to a file?

A

cat file1.txt file2.txt > new_file.txt

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

How can we print to the screen a file’s contents with line numbers added?

A

cat -b file.txt

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

What is the default signal for kill?

A

15 or SIGTERM

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

How can we find the process ID of the process that we need to stop?

A

ps command shows PID

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

What does this command do:

kill 123456

A

It sends a signal to process 123456 to peacefully shut down when it is ready.

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

What two ways can you pass a signal to the kill command?

A

with the value of the signal or by using the -s flag and passing the name of the signal.

kill -9 123456

kill -s SIGKILL 123456

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

What command prints out information about commands?

A

man

syntax: $ man command_you_want_to_learn_about

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

What command allows us to look at the end of a file?

A

Tail

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

What is the tail command good for?

A

monitoring log files in a production environment

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

By default, when you pass a file name to the tail command, the last __ lines of a file will be printed to the screen, and ___.

A

10

tail will exit.

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

How do we change the number of lines that are displayed by tail?

A

with the -n flag

tail -n 5

17
Q

How can we reverse the direction of how tail displays the selected lines of the file to us?

A

with the -r flag

tail -r -n 5 /path/filename displays the last five lines of the file with the last line first

18
Q

What flag makes the tail command go live, continuing to output new data as it is added to the end of a watched file?

A

-f

tail -f /path/file.log

19
Q

What is a live file referred to?

A

A ‘tailing’ file.

20
Q

How can we filter the live output of a tail command?

A

tail -f /path/name.log | ag com.apple.windowserver

21
Q

What command allows you to recursively list the contents of a directory in a high level view?

A

tree

22
Q

How can you limit the depth of tree’s recursion?

A

with the -L flag

tree -L 2 will only display the first two levels of a tree of directories

23
Q

By default tree will list both files and directories, how can we print out just the directories?

A

with the -d flag

tree -d

24
Q

How can we count the number of words in a file?

A

wc -w filename.txt

25
Q

How can we count the number of lines in a file?

A

wc -l file

26
Q

How can we see in how many lines the pattern DHH is repeated?

A

ag DHH | wc -l