4. Becoming a Power User Flashcards

1
Q

How do you chain multiple commands in a way that the output from one program is sent as an input to another?

A

By using a pipe symbol.

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

How do you search for text in a file and what kind of output do you get when you do?

A

By executing the grep command and passing it the search term as well as the file name.

grep 1978 oscars.tsv

When we do, we get a list of lines that contains the search term (1978).

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

How do sort records (lines) of text or binary files?

A

By executing the sort command and passing it the lines of text or binary files.

grep 1978 oscars.tsv | sort
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you save the output from a command to a file?

A

By using a greater than sign and a filename. This sends the output of a command to that new file, but be careful — this will override any data if the file you send it to already exists.

grep 1987 oscars.tsv > 1987-oscars.tsv
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you cut out a specific column of each line of a file containing delimiter-separated lines of text?

A

By executing the cut command and passing it the column number using the f flag as well as the filename.

cut -f 3 oscars.tsv
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you count the words, lines, characters, or bytes in a given text file?

A

By executing the wc command with -w for words, -l for lines, -m for characters, and -c for bytes.

wc -l oscars.tsv
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you search for a given text in all files in the current folder?

A

By executing the grep command and passing it the search term as well as an asterisk

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

What is the primary wildcard character?

A

The asterisk (*).

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

How do you get the shell to repeat an input back to you?

A

By using the echo command.

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

What does the echo command do in its most simple form?

A

It repeats (or echoes) its input back to you.

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

How do you echo all of the file names in the current directory?

A

By executing the echo command and passing it an asterisk.

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

How do you list all files in a directory whose name starts with a given text?

A

By executing the ls command and passing it the text suffixed with an asterisk.

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

How do you list all files in a directory whose name ends with a given text?

A

By executing the ls command and passing it the text prefixed with an asterisk.

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

How do you list all files in a directory whose name contains a given text?

A

By executing the ls command and passing it the text surrounded by asterisks.

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

How do you move all the files whose names end with a certain text into a given folder?

A

By executing the mv command and passing it the text prefixed with an asterisk as well as the folder into which you want to move them.

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

What is sudo the abbreviation for?

A

SuperUser DO

17
Q

How do you run a command that only a superuser can?

A

By passing the command as well as all its arguments to sudo.

sudo nano /etc/hosts