2.3 Given a scenario, create, modify, and redirect files Flashcards

1
Q

grep

A

Use the grep command to search files for lines that contain a specific pattern. By default, the grep command will display the entire line when it finds a matching pattern

grep “the” /etc/rsyslog.conf

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

cat

A

The cat command displays the contents of text files

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

tail

A

The tail command displays the bottom part of text data. By default, the last ten lines are displayed. Use the -n option to display a different number of lines

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

head

A

The head command displays the top part of text data. By default, the top ten lines are displayed

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

less

A

The less command is used to display large chunks of text data. Unlike the cat command, the less command will pause after displaying the first page of information. Keys on the keyboard allow the user to scroll through the document

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

more

A

The more command is a slightly less capable version of the less command. Essentially everything that the more command can do, the less command also has as a feature. However, the less command has additional features that the more command does not have

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

cmd < file

A

Override STDIN so the input comes from the file specified

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

cmd > file

A

Override STDOUT so the output goes into the file specified

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

cmd 2> file

A

Override stderr so the output goes into the file specified.

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

cmd &> file

A

Override both STDOUT and stderr so the output goes into the file specified.

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

cmd1 | cmd2

A

Override STDOUT from cmd1 so it goes into cmd2 as STDIN

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

/dev/null

A

You can redirect these messages into the /dev/null device file. This file is called the “bit bucket” and acts as a trash can that never needs to be emptied. Anything sent to the /dev/null device is immediately discarded

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

/dev/tty

A

Several files in the /dev directory are used to send data to display devices. These include virtual terminals

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

xargs

A

The xargs command takes data from STDIN to build and execute commands. Here is the format of the command

input_command | xarg execute_command

The input_command is designed to provide information for xargs to provide as arguments to the execute_command. For example, suppose you want to run the wc -l command on every file in the /etc directory that begins with the letter “e”:

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

tee

A

If you want STDOUT to be sent both to the terminal and to a file, send the output to the tee command and provide an argument that indicates the file in which you want to store the information.

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

awk

A

head /etc/passwd | awk -F: ‘{print $1,$7}’

root /bin/bash
bin /sbin/nologin
daemon /sbin/nologin
adm /sbin/nologin
lp /sbin/nologin
sync /bin/sync
shutdown /sbin/shutdown
halt /sbin/halt
mail /sbin/nologin
operator /sbin/nologin
17
Q

sed

A

Use the sed utility to make automated modifications to files. The basic format for the sed command is sed ‘s/RE/string/’ file