Linux Commands Flashcards

1
Q

what command is used to remove a entire directory with files included?

A

rm -f

Tip: If using wildcards or in general a safe way before removing a file is to first “ls -la” with your wildcard to see what will all be removed.

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

For I/O redirection please explain each of the following commands

1) ls > file_list.txt
2) ls&raquo_space; file_list.txt
3) sort < file_list.txt
4) sort < file_list.txt > sorted_file_list.txt

A

1) Redirects S/O to file_list.txt
2) Appends S/O to file_list.txt instead of overwriting
3) Sorts the information in the file as S/I and exports it out to the screen
4) Sorts the information in the file as S/I and exports it out into sorted_file_list.txt

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

What do each of the following commands do?

sort
uniq
grep
fmt
pr

A

sort Sorts standard input then outputs the sorted result on standard output.

uniq Given a sorted stream of data from standard input, it removes duplicate lines of data (i.e., it makes sure that every line is unique).

grep Examines each line of data it receives from standard input and outputs every line that contains a specified pattern of characters.

fmt Reads text from standard input, then outputs formatted text on standard output.

pr Takes text input from standard input and splits the data into pages with page breaks, headers and footers in preparation for printing.
head Outputs the first few lines of its input. Useful for getting the header of a file.
tail Outputs the last few lines of its input. Useful for things like getting the most recent entries from a log file.

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

What do each of the following commands do?

tr
sed
awk

A

tr Translates characters. Can be used to perform tasks such as upper/lowercase conversions or changing line termination characters from one type to another (for example, converting DOS text files into Unix style text files).

sed Stream editor. Can perform more sophisticated text translations than tr.

awk An entire programming language designed for constructing filters. Extremely powerful.

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