Shell Features Flashcards

1
Q

What are the 3 channels every linux program has when it starts?

A

File Desciptors
stdin 0<
stdout 1>
stderr 2>

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

How would you overwrite text to a file from the shell?

A

1> - stdout

i.e echo “Overwrite this.” 1> file.txt

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

How would you append text to a file from the shell?

A

1» - stdout

i. e ls -alh 1» file.txt
i. e echo “Append this.” 1» file.txt

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

How would you append error output to a text file from the shell?

A

i.e ls -alh nonexistant 2» file.txt

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

How would you overwrite error output to a text file from the shell?

A

2>

i.e ls -alh nonexistant 2> file.txt

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

How do you run a command sequentially after the other?

A

;

i.e ifconfig; touch file

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

How do you run a command sequentially only if the first completed successfully?

A

&&

i.e ls file && mkdir directory1

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

What is the command to search for text?

A

grep

i. e grep example file.txt
i. e grep example ./* -all files in current directory

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

What is the command to count the number of characters and words in a file?

A

wc

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

How do you pass the output from one command to another?

A

|

i.e cat file | sort

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

What is the command to select only portions of text from a file?

A

cut

i.e cat file | cut -d’ ‘ -f3,4

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

What is the command to only display unique text?

A

uniq

i.e cat file | uniq

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

What is the command to run a subsequent command only of the previous failed?

A

||
ls -l nonexistent || touch nonexistent
*or operator evaluates expressions either side

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