04 Manipulating Files and Directories Flashcards

1
Q

What does the wildcard * match?

A

Any characters

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

What does the wildcard ? match?

A

Any single character

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

What does the wildcard [characters] match?

A

Any characters of the set [characters]

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

What does the wildcard [!characters] match?

A

Any characters that don’t belong to the set [characters]

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

What does the wildcard [[:class:]] match?

A

Any characters that belong to the specified class

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

What does the special class [:alnum:] match?

A

Any alphanumeric characters

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

What does the special class [:alpha:] match?

A

Any alphabetic characters

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

What does the special class [:digit:] match?

A

Any number

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

What does the special class [:lower:] match?

A

Any lower-case characters

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

What does the special class [:upper:] match?

A

Any uppercase characters

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

Which files would the wildcard * match?

A

All files

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

Which files would the wildcard g* match?

A

Any files that begin with “g”

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

Which files would the wildcard b*.txt match?

A

Any files that begin with “b” and end with “.txt”

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

Which files would the wildcard Data??? match?

A

Any files beginning with “Data” followed by exactly 3 characters

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

Which files would the wildcard [abc]* match

A

Any files that begin with the lower-case letters “a”, “b”, or “c”

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

Which files would the wildcard BACKUP.[0-9][0-9][0-9] match?

A

Any files beginning with “BACKUP.” followed by exactly 3 numerals

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

Which files would the wildcard [[:upper:]]* match?

A

Any files beginning with an upper-case letter

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

Which files would the wildcard [![:digit:]]* match?

A

Any file not beginning with a numeral

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

Which files would the wildcard *[[:lower:]123]

A

Any file ending with a lower-case letter or a “1”,”2”,or”3”

20
Q

How many directories can you create using a single instance of the mkdir command?

A

You can make multiple directories using mkdir in a single instance…mkdir dir1 dir2 dir3…etc

21
Q

What would be the result of the following command:

cp item1 item2

A

File or directory Item1 would be copied to file or directory item2

22
Q

What would be the result of the following command:

cp item1… dir1

A

File item1 would be copied into dir1

23
Q

Describe the use of the following cp options:

-a / –archive

A

Copy files/dirs with their existing attributes, instead of the attributes of the user performing the copy

24
Q

Describe the use of the following cp options:

-i / –interactve

A

Prompt for confirmation before copying (and possibly overwriting) the destination item.

25
Q

Describe the use of the following cp options:

-r / –recursive

A

Recursively copy (go into each subdirectory and copy) the directory contents

26
Q

Describe the use of the following cp options:

-u / –update

A

Only copy items that are new or have changed.

27
Q

Describe the use of the following cp options:

-v / –verbose

A

Display informative messages as copy progresses

28
Q

Describe the use of the mv command

A

Moves or renames files

29
Q

Describe the use of the following mv options:

-i / –interactive

A

Prompt for confirmation before moving/renaming (and possibly overwriting) the destination item.

30
Q

Describe the use of the following mv options:

-u / –update

A

When moving files from one directory to another, only move the files that don’t exist or are newer than existing corresponding files

31
Q

Describe the use of the following mv options:

-v / –verbose

A

Display informative messages as move progresses

32
Q

Describe the use of the rm command

A

Remove (delete) files or directories

33
Q

Describe the use of the following rm options:

-i / –interactive

A

Prompt for confirmation before deleting a file

34
Q

Describe the use of the following rm options:

-r / –recursive

A

If a directory being deleted has subdirectories, remove them, too. This option must be specified in order to delete a directory

35
Q

Describe the use of the following rm options:

-f / –force

A

Don’t prompt when deleting files, ignore non-existent files

36
Q

Describe the use of the following rm options:

-v / –verbose

A

Display informative messages as the deletion is performed.

37
Q

What are two restrictions to keep in mind when creating hard links?

A
  1. Hard link cannot refer to file on another filesystem

2. Hard links cannot refer to a directory

38
Q

True or False: every file has a single hard link that gives that file its name

A

True

39
Q

True or False: a hard link is completely indistinguishable from the referenced file itself

A

True. Hard links have no special indicators of their link

40
Q

True or False: if a hard link is deleted, the file that it links to is also deleted

A

False

41
Q

How do you create a hard link to a file?

A

ln file link

42
Q

True or False: a symlink can represent a file or a directory

A

True. Hardlinks can only reference files

43
Q

True or False: a symlink is a text pointer to a referenced file or directory

A

True

44
Q

True or False: if a symlink is deleted, only the link is removed; the original file remains intact

A

True

45
Q

What is the term for the situation that occurs when a file is symlinked and the original file is deleted

A

a “broken” link

46
Q

How would you determine if an item is hard linked?

A

Hardlinks are indistinguishable from originals. You would need to compare the inodes of the two files to see if they referenced the same “portion” of the disk. You could do that by ls -li

47
Q

How would you create a symlink to the file foo.txt?

A

Go to location where you wish to create the symlink and create it relative to the original. For example, if the symlink is to be created in directory ‘baz’ and the original is in the parent directory:

pwd
baz
ln -s ../foo.txt bar.txt