Topic 6 - Scripting and archiving Flashcards

1
Q

this will create a .tar archive file named mylife.tar containing the life/ directory and its contents.

It will then proceed to verbose the files processed

A

what is the outcome of typing

tar –create –verbose –file=mylife.tar life/

into a linux terminal

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

this will decompress and extract the path and any files ending with burnet from the file mylife.tgz it will then print the files processed

A

what is the outcome of typing

tar –extract –verbose –file=mylife.tgz –wildcards ”*burnet

into a linux terminal

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

this will decompress and extract the contents of the file mylife.tgz it will then print the files processed

A

what is the outcome of typing

tar –extract –verbose –file=mylife.tgz

into a linux terminal

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

does

tar

perform compression

A

no this command will only archive a directory and by itself does not perform any compression

although it is able to work with other commands that do perform compression

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

this is accomplished by using the following format:

Variable-name=value

No space should be used either side of the equals sign

A

in a linux script how do you declare a variable

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

no this command will only archive a directory and by itself does not perform any compression

although it is able to work with other commands that do perform compression

A

does

tar

perform compression

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

what was

tar (tape archive)

originally built for

A

this was originally developed to transfer files from very space limited hard drives to magnetic tapes and vice versa. However it became useful in creating an archive file that could be transported over the internet

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

lists the contents of the mylife.zip file (does not perform extraction)

A

what is the outcome of typing

unzip -l mylife.zip

into a linux terminal

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

what is the outcome of typing

unzip mylife.zip life/animals/

into a linux terminal

A

decompresses and extracts the directory and path life/animals/ from mylife.zip

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

what is the linux

tree

command used for

A

This is used to list the contents of a directory to the terminal window in a tree like format

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

what is the outcome of typing

bzip2 –verbose –keep mylife.tar

into a linux terminal

A

this will compress the file mylife.tar in the process preserving the original and creating a new file mylife.tar.bz2. it will then print information about the compression ratio

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

in linux how are

double quotes

handled

A

Anything wrapped inside these will be interpreted.

so spaces will be preserved, variables will be read and these are stripped after interpretation

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

decompresses and extracts the directory and path life/animals/ from mylife.zip

A

what is the outcome of typing

unzip mylife.zip life/animals/

into a linux terminal

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

what is

compression

A

this is the act of taking a file and reducing the number of bytes that it takes up, reducing storage space and bandwidth

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

this can be achieved by:

  • holding the argument place in a variable
    • arg1=$1
    • arg2=$2
  • hold all arguments given in a single variable
    • ​args=$@
A

in linux what are the 2 ways that we can

read the arguments given by the user

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

in a linux script how do you declare a variable

A

this is accomplished by using the following format:

Variable-name=value

No space should be used either side of the equals sign

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

this will create an archive file and then compress it. the file will be named mylife.tgz and will contain the contents of the life/ directory. It will then continue to give verbose output about the archived files

A

what is the outcome of typing

tar –create –verbose –gzip –file=mylife.tgz life/

into a linux terminal

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

this will decompress and extract the file and path life/animals/insects from mylife.tgz it will then print the files processed

A

what is the outcome of typing

tar –extract –verbose –file=mylife.tgz life/animals/insects

into a linux terminal

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

what is the outcome of using

Read variable-name

in a linux script

A

this can be used to get input from the user and hold it in the variable variable-name

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

what is

archiving

A

this is the act of combining files and directories into a single file which can then be stored or copied

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

this will recursively compare the files in ~/work/life against the files in ~/extract/life

A

what is the outcome of typing

diff -r ~/work/life ~/extract/life

into a linux terminal

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

what is the outcome of typing

gzip mylife.tar

into a linux terminal

A

this will compress and replace the file mylife.tar to mylife.tar.gz

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

this can be achieved by enclosing the command and any options within brackets and appending a $ to the opening bracket

syntax

command-output=$(command-and-options)

A

in a linux script how can we hold the output of a command as a variable value

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

in a linux script what does the following accomplish

Today=$(date -I)

A

this will run the command

date -I

and the output will be stored as the value to the variable today

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

this will uncompress and replace the file mylife.tar.gz to mylife.tar

A

what is the outcome of typing

gunzip mylife.tar.gz

into a linux terminal

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

what is the outcome of typing

gzip –verbose –keep mylife.tar

into a linux terminal

A

this will compress the file mylife.tar in the process preserving the original and creating a new file mylife.tar.gz. it will then print information about the compression ratio

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

name a common cryptographic hash function used to produce

message digests

A

sha256 is one common hash function that is used to produce this

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

what are the file extensions for gzip

  1. on its own
  2. with tar using single extension
A

these include:

  1. on its own - .gz
  2. with tar using single extension -.tgz
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

what is the outcome of typing

tar –create –verbose –bzip2 –file=mylife.tbz life/

into a linux terminal

A

this will create an archive file and then compress it. the file will be named mylife.tbz and will contain the contents of the life/ directory. It will then continue to give verbose output about the archived files

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

This is used to list the contents of a directory to the terminal window in a tree like format

A

what is the linux

tree

command used for

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

this will display the contents of the archive file named life.tar in the terminal

A

what is the outcome of typing

tar –list –file=life.tar

into a linux terminal

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

what is the outcome of typing

tar –extract –verbose –file=mylife.tgz

into a linux terminal

A

this will decompress and extract the contents of the file mylife.tgz it will then print the files processed

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

NO

in this case tar will make use of the linux file command to find the type of compression used.

it can then use this information and execute the suitable decompression programme

A

when using tar to extract the contents of a compressed archive file. must you specify the compression that the file has used

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

where are

message digests

commonly used

A

these will normally be used on the internet

the creator of a file will post this along with the original file. the user can then download the file and run the same hashing algorithm to verify that this matches what has been posted online

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

this is accomplished by appending $ to the beginning of the variable name

$variable-name

A

in a linux script how do we access a variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q
  • variables created within a linux script - these exist only for as long as the script is executing
  • environmental variables such as $PATH - these exist for the duration of the terminal session although any changes made to this via a linux script will outlast the scripts execution
A

what is the lifespan for each of the following:

  • variables created within a linux script
  • environmental variables such as $PATH
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

these are used to verify the integrity of files ensuring that the file is neither corrupted or tampered with

A

what are

message digests

used for

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

this is sometimes referred to as a

tarball

A

what is a

.tar file

sometimes referred to as

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

what is the outcome of typing

tar –create –verbose –gzip –file=mylife.tgz life/

into a linux terminal

A

this will create an archive file and then compress it. the file will be named mylife.tgz and will contain the contents of the life/ directory. It will then continue to give verbose output about the archived files

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

decompresses and extracts any files or directories ending with burnet from the archived file mylife.zip

A

what is the outcome of typing

unzip mylife.zip *burnet

into a linux terminal

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

these include:

  1. on its own - .gz
  2. with tar using single extension -.tgz
A

what are the file extensions for gzip

  1. on its own
  2. with tar using single extension
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

during this operation it will preserve:

  1. The structure of the directories
  2. The contents of files
  3. Owner of file
  4. File permissions
  5. Timestamps
A

name 5 pieces of information that the tar command will preserve when creating a .tar file

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

what are

message digests

used for

A

these are used to verify the integrity of files ensuring that the file is neither corrupted or tampered with

44
Q

what is the outcome of typing

tar –list –file=life.tar

into a linux terminal

A

this will display the contents of the archive file named life.tar in the terminal

45
Q

if a script does not contain the #! at the beginning of the script how can it be executed

A

if a script does not contain this then you must specify the name of the interpreter before the script name

46
Q

why will

tar add padding

when creating an archive file

A

tar performs this since it was built to work with block devices such as tape drives

what this means is that each file starts at a new block. this makes it easier to pull out individual files

to fill in any gaps between the end of a file and a new block this is performed

47
Q

what is a

.tar file

sometimes referred to as

A

this is sometimes referred to as a

tarball

48
Q

to accomplish this the command is

chmod +x script-name

A

what is the command to make a script containing the #! executable

49
Q

this is the act of taking a file and reducing the number of bytes that it takes up, reducing storage space and bandwidth

A

what is

compression

50
Q

decompresses and extracts the contents of mylife.zip file

A

what is the outcome of typing

unzip mylife.zip

into a linux terminal

51
Q

this will run the command

date -I

and the output will be stored as the value to the variable today

A

in a linux script what does the following accomplish

Today=$(date -I)

52
Q

name 2 common compression programs available on linux

A

these include:

  • gzip (GNU zip)
  • bzip2

note

bzip2 is usually more space efficient than gzip

53
Q

this will compress the file mylife.tar in the process preserving the original and creating a new file mylife.tar.gz. it will then print information about the compression ratio

A

what is the outcome of typing

gzip –verbose –keep mylife.tar

into a linux terminal

54
Q

what is the outcome of typing

diff -r ~/work/life ~/extract/life

into a linux terminal

A

this will recursively compare the files in ~/work/life against the files in ~/extract/life

55
Q

If a script would be useful for all users on the system then where is it normally placed

A

in this case the script should be added to

/usr/local/bin

this location will already be in the $PATH and so is accessible for all users

56
Q

sha256 is one common hash function that is used to produce this

A

name a common cryptographic hash function used to produce

message digests

57
Q

how can you execute a script without specifying its path

A

to accomplish this the script must be in one of the directories in which bash will search for programs

these can be found using echo $PATH

58
Q

in a linux script how do we access a variable

A

this is accomplished by appending $ to the beginning of the variable name

$variable-name

59
Q

what is the outcome of typing

unzip mylife.zip *burnet

into a linux terminal

A

decompresses and extracts any files or directories ending with burnet from the archived file mylife.zip

60
Q

this was originally developed to transfer files from very space limited hard drives to magnetic tapes and vice versa. However it became useful in creating an archive file that could be transported over the internet

A

what was

tar (tape archive)

originally built for

61
Q

what is the outcome of typing

unzip mylife.zip

into a linux terminal

A

decompresses and extracts the contents of mylife.zip file

62
Q
  • how does the zip software differ from the tar software
  • what makes zip so popular
A
  • how does the zip software differ from the tar software - tar on its own does not perform compression however zip has archiving and compression built in and carries it out by default
  • what makes zip so popular - zip is supported by all major operating systems making it the archive format for sharing files between operating systems
63
Q

what is

tar (tape archive)

A

This is an archiving program that can store multiple files into a single file (an archive) and also extract those files from the archive

64
Q

in this case the script should be added to

~/bin

and then this path should be added to the $PATH

A

If a script is for a single user on the system then where is it custom to add it to

65
Q

when using tar to extract the contents of a compressed archive file. must you specify the compression that the file has used

A

NO

in this case tar will make use of the linux file command to find the type of compression used.

it can then use this information and execute the suitable decompression programme

66
Q
  • how does the zip software differ from the tar software - tar on its own does not perform compression however zip has archiving and compression built in and carries it out by default
  • what makes zip so popular - zip is supported by all major operating systems making it the archive format for sharing files between operating systems
A
  • how does the zip software differ from the tar software
  • what makes zip so popular
67
Q

what is the outcome of typing

unzip -l mylife.zip

into a linux terminal

A

lists the contents of the mylife.zip file (does not perform extraction)

68
Q

what is the outcome of typing

tar –extract –verbose –file=mylife.tgz –wildcards ”*burnet

into a linux terminal

A

this will decompress and extract the path and any files ending with burnet from the file mylife.tgz it will then print the files processed

69
Q

this is an accronym for

tape archive

A

what does

tar

stand for

70
Q

this will compress and replace the file mylife.tar to mylife.tar.gz

A

what is the outcome of typing

gzip mylife.tar

into a linux terminal

71
Q

the syntax for this is:

For variable-name in iterable

Do

Looped code here

Done

A

what is the syntax for a

linux for loop

72
Q

what is the outcome of typing

zip -r mylife.zip life/

into a linux terminal

A

this recursively archives and compresses the life/ directory into the mylife.zip file

73
Q

what is the outcome of typing

tar –extract –verbose –file=life.tar

into a linux terminal

A

this will extract the files from the archive file life.tar and then verbosely list the processed files in the terminal window

74
Q

in this case the script should be added to

/usr/local/bin

this location will already be in the $PATH and so is accessible for all users

A

If a script would be useful for all users on the system then where is it normally placed

75
Q

this recursively archives and compresses the life/ directory into the mylife.zip file

A

what is the outcome of typing

zip -r mylife.zip life/

into a linux terminal

76
Q

to accomplish this the script must be in one of the directories in which bash will search for programs

these can be found using echo $PATH

A

how can you execute a script without specifying its path

77
Q

these will normally be used on the internet

the creator of a file will post this along with the original file. the user can then download the file and run the same hashing algorithm to verify that this matches what has been posted online

A

where are

message digests

commonly used

78
Q

these include:

  1. on its own - .bz2
  2. with tar using a single extension - .tbz
A

what are the file extensions for bzip2

  1. on its own
  2. with tar using a single extension
79
Q

what is the syntax for a

linux for loop

A

the syntax for this is:

For variable-name in iterable

Do

Looped code here

Done

80
Q

in linux how are

single quotes

handled

A

Anything wrapped inside these is taken literally and is not interpreted.

in this case a variable would be seen as text and not read

81
Q

Anything wrapped inside these will be interpreted.

so spaces will be preserved, variables will be read and these are stripped after interpretation

A

in linux how are

double quotes

handled

82
Q

what is the command to make a script containing the #! executable

A

to accomplish this the command is

chmod +x script-name

83
Q

this will create an archive file and then compress it. the file will be named mylife.tbz and will contain the contents of the life/ directory. It will then continue to give verbose output about the archived files

A

what is the outcome of typing

tar –create –verbose –bzip2 –file=mylife.tbz life/

into a linux terminal

84
Q

name 5 pieces of information that the tar command will preserve when creating a .tar file

A

during this operation it will preserve:

  1. The structure of the directories
  2. The contents of files
  3. Owner of file
  4. File permissions
  5. Timestamps
85
Q

This is used to print or check sha256 checksums

A

what is the linux

sha256sum

command used for

86
Q

This is an archiving program that can store multiple files into a single file (an archive) and also extract those files from the archive

A

what is

tar (tape archive)

87
Q

what is the outcome of typing

gunzip mylife.tar.gz

into a linux terminal

A

this will uncompress and replace the file mylife.tar.gz to mylife.tar

88
Q

what is the outcome of typing

tar –create –verbose –file=mylife.tar life/

into a linux terminal

A

this will create a .tar archive file named mylife.tar containing the life/ directory and its contents.

It will then proceed to verbose the files processed

89
Q

If a script is for a single user on the system then where is it custom to add it to

A

in this case the script should be added to

~/bin

and then this path should be added to the $PATH

90
Q

this will compress the file mylife.tar in the process preserving the original and creating a new file mylife.tar.bz2. it will then print information about the compression ratio

A

what is the outcome of typing

bzip2 –verbose –keep mylife.tar

into a linux terminal

91
Q

this can be used to get input from the user and hold it in the variable variable-name

A

what is the outcome of using

Read variable-name

in a linux script

92
Q

if a script does not contain this then you must specify the name of the interpreter before the script name

A

if a script does not contain the #! at the beginning of the script how can it be executed

93
Q

this is the act of combining files and directories into a single file which can then be stored or copied

A

what is

archiving

94
Q

in linux what are the 2 ways that we can

read the arguments given by the user

A

this can be achieved by:

  • holding the argument place in a variable
    • arg1=$1
    • arg2=$2
  • hold all arguments given in a single variable
    • ​args=$@
95
Q

this will extract the files from the archive file life.tar and then verbosely list the processed files in the terminal window

A

what is the outcome of typing

tar –extract –verbose –file=life.tar

into a linux terminal

96
Q

This is used to compare files line for line. If the files are the same then the command ends silently

A

what is the linux

diff

command used for

97
Q

what are the file extensions for bzip2

  1. on its own
  2. with tar using a single extension
A

these include:

  1. on its own - .bz2
  2. with tar using a single extension - .tbz
98
Q

Anything wrapped inside these is taken literally and is not interpreted.

in this case a variable would be seen as text and not read

A

in linux how are

single quotes

handled

99
Q

what is the lifespan for each of the following:

  • variables created within a linux script
  • environmental variables such as $PATH
A
  • variables created within a linux script - these exist only for as long as the script is executing
  • environmental variables such as $PATH - these exist for the duration of the terminal session although any changes made to this via a linux script will outlast the scripts execution
100
Q

what is the linux

diff

command used for

A

This is used to compare files line for line. If the files are the same then the command ends silently

101
Q

in a linux script how can we hold the output of a command as a variable value

A

this can be achieved by enclosing the command and any options within brackets and appending a $ to the opening bracket

syntax

command-output=$(command-and-options)

102
Q

tar performs this since it was built to work with block devices such as tape drives

what this means is that each file starts at a new block. this makes it easier to pull out individual files

to fill in any gaps between the end of a file and a new block this is performed

A

why will

tar add padding

when creating an archive file

103
Q

what is the linux

sha256sum

command used for

A

This is used to print or check sha256 checksums

104
Q

what is the outcome of typing

tar –extract –verbose –file=mylife.tgz life/animals/insects

into a linux terminal

A

this will decompress and extract the file and path life/animals/insects from mylife.tgz it will then print the files processed

105
Q

these include:

  • gzip (GNU zip)
  • bzip2

note

bzip2 is usually more space efficient than gzip

A

name 2 common compression programs available on linux

106
Q

what does

tar

stand for

A

this is an accronym for

tape archive