Output Redirection, Regular Expressions Flashcards

1
Q

What is the command to create a directory?

A

mkdir

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

What is the command to remove an empty directory?

A

rmdir

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

What is the command to remove a directory with contents

A

rm -r

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

What is the command to create a parent directory and subdirectory?

A

mkdir -p

i.e mkdir -p parent/child

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

What is the command to create a non existing file/ update the timestamp of an existing file/directory?

A

touch

i. e touch file
- m modify timestamp to specific date

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

What is the command to rename a file/directory?

A

mv

i.e mv oldname newname

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

What is the command to copy a directory and its contents?

A

cp -r

-R –recursive

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

What the command to archive multiple files/directories?

A

tar -cf archivename file1 file2

  • c create -f file
  • f must be the last parameter
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the command to archive and compress multiple files/directories?

A

tar -cf

-z gzip -j bzip2

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

What is the command to extract a compressed tar file?

A

tar -xf

-x extract -f file -C destination

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

What is the command to list the contents of a tar file without extracting it?

A

tar -tf

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

How do you zip compress a file?

A

zip zipfilename file1 file2

  • r recursively on directories
  • creates a new compressed file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you uncompress a zip file?

A

unzip

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

How do you gzip compress a file?

A

gzip

*directly compresses file in place

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

How do you uncompress a gzip file?

A

gunzip

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

How do you bzip2 compress a file?

A

bzip2

*directly compresses file in place

17
Q

How do you uncompress a bzip2 file?

A

bunzip2

18
Q

What is the command to view a file will scrolling ability?

A

less
more
/ - search ? - reverse search
*when command is running

19
Q

What is the command to view the top of a file?

A

head

-n number of lines

20
Q

What is the command to view the last lines of a file?

A

tail

-f realtime update -n number of lines

21
Q

Where are the logs stored for authentication attempts to the system?

A

/var/log/secure

22
Q

How do you use output redirection to append to a file?

A

> >

i.e ls&raquo_space; file

23
Q

How do you use output redirection to overwrite a file?

A

>

i.e ls > file

24
Q

How do you use output redirection to redirect only stdout?

A

1>

25
Q

How do you use output redirection to redirect only stderr?

A

2>

26
Q

What is the command to remove specified text from a file and print specific fields?

A

cut

  • d delimiter -f field
    i. e cut file -d ‘ ‘ -f 4-
    i. e cut file -d : -f 1,5
27
Q

What is the command to arrange a file in alphabetical order?

A

sort

28
Q

How would you append a blank line to a file?

A

echo&raquo_space; file

29
Q

How do you count the number of word in a file?

A

wc

i. e cat file | wc
i. e wc file

30
Q

What is the regular expression to search the beginning of a line with matching characters?

A

i.e grep ^In file

31
Q

What is the regular expression to search the end of a line with matching characters?

A

$

i.e grep ing$ file

32
Q

What is the regular expression to search for a set of characters including an unknown character?

A

.

i. e grep .ast file
* equivalent of ? in globbing

33
Q

What is the regular expression to match zero or more preceding characters?

A

*

i. e grep www* file
* works opposite of globbing wildcard

34
Q

How do you grep with case insensitivity?

A

grep -i

35
Q

How do you input with stdin and output to stdout simultaneously?

A

tee

i. e date | tee file
- a append
* outputs piped input to a file and prints to shell