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
this will uncompress and replace the file *mylife.tar.gz* to *mylife.tar*
what is the outcome of typing **gunzip** *mylife.tar.gz* into a linux terminal
26
what is the outcome of typing **gzip --verbose --keep** *mylife.tar* into a linux terminal
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
27
name a common cryptographic hash function used to produce ## Footnote **message digests**
sha256 is one common hash function that is used to produce this
28
what are the file extensions for gzip 1. **on its own** 2. **with tar using single extension**
these include: 1. **on its own** - .gz 2. **with tar using single extension -**.tgz
29
what is the outcome of typing **tar --create --verbose --bzip2 --file=***mylife.tbz life/* into a linux terminal
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
30
This is used to list the contents of a directory to the terminal window in a tree like format
what is the linux **tree** command used for
31
this will display the contents of the archive file named *life.tar* in the terminal
what is the outcome of typing **tar --list --file=***life.tar* into a linux terminal
32
what is the outcome of typing **tar --extract --verbose --file=***mylife.tgz* into a linux terminal
this will decompress and extract the contents of the file *mylife.tgz* it will then print the files processed
33
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
when using tar to extract the contents of a compressed archive file. must you specify the compression that the file has used
34
where are **message digests** commonly used
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
35
this is accomplished by appending $ to the beginning of the variable name **$***variable-name*
in a linux script how do we access a variable
36
* **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
what is the lifespan for each of the following: * **variables created within a linux script** * **environmental variables such as $PATH**
37
these are used to verify the integrity of files ensuring that the file is neither corrupted or tampered with
what are **message digests** used for
38
this is sometimes referred to as a ## Footnote **tarball**
what is a **.tar file** sometimes referred to as
39
what is the outcome of typing **tar --create --verbose --gzip --file=***mylife.tgz life/* into a linux terminal
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
40
decompresses and extracts any files or directories ending with *burnet* from the archived file *mylife.zip*
what is the outcome of typing **unzip** *mylife.zip* ***\*****burnet* into a linux terminal
41
these include: 1. **on its own** - .gz 2. **with tar using single extension -**.tgz
what are the file extensions for gzip 1. **on its own** 2. **with tar using single extension**
42
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
name 5 pieces of information that the tar command will preserve when creating a .tar file
43
what are **message digests** used for
these are used to verify the integrity of files ensuring that the file is neither corrupted or tampered with
44
what is the outcome of typing **tar --list --file=***life.tar* into a linux terminal
this will display the contents of the archive file named *life.tar* in the terminal
45
if a script does not contain the #! at the beginning of the script how can it be executed
if a script does not contain this then you must specify the name of the interpreter before the script name
46
why will **tar add padding** when creating an archive file
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
what is a **.tar file** sometimes referred to as
this is sometimes referred to as a ## Footnote **tarball**
48
to accomplish this the command is **chmod +x** *script-name*
what is the command to make a script containing the #! executable
49
this is the act of taking a file and reducing the number of bytes that it takes up, reducing storage space and bandwidth
what is ## Footnote **compression**
50
decompresses and extracts the contents of *mylife.zip* file
what is the outcome of typing **unzip** *mylife.zip* into a linux terminal
51
this will run the command **date -I** and the output will be stored as the value to the variable today
in a linux script what does the following accomplish **Today=$(date -I)**
52
name 2 common compression programs available on linux
these include: * gzip (GNU zip) * bzip2 note bzip2 is usually more space efficient than gzip
53
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
what is the outcome of typing **gzip --verbose --keep** *mylife.tar* into a linux terminal
54
what is the outcome of typing **diff -r** *~/work/life ~/extract/life* into a linux terminal
this will recursively compare the files in *~/work/life* against the files in *~/extract/life*
55
If a script would be useful for all users on the system then where is it normally placed
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
sha256 is one common hash function that is used to produce this
name a common cryptographic hash function used to produce ## Footnote **message digests**
57
how can you execute a script without specifying its path
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
in a linux script how do we access a variable
this is accomplished by appending $ to the beginning of the variable name **$***variable-name*
59
what is the outcome of typing **unzip** *mylife.zip* ***\*****burnet* into a linux terminal
decompresses and extracts any files or directories ending with *burnet* from the archived file *mylife.zip*
60
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
what was **tar (tape archive)** originally built for
61
what is the outcome of typing **unzip** *mylife.zip* into a linux terminal
decompresses and extracts the contents of *mylife.zip* file
62
* **how does the zip software differ from the tar software** * **what makes zip so popular**
* **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
what is ## Footnote **tar (tape archive)**
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
in this case the script should be added to **~/bin** and then this path should be added to the $PATH
If a script is for a single user on the system then where is it custom to add it to
65
when using tar to extract the contents of a compressed archive file. must you specify the compression that the file has used
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
* **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
* **how does the zip software differ from the tar software** * **what makes zip so popular**
67
what is the outcome of typing **unzip -l** *mylife.zip* into a linux terminal
lists the contents of the *mylife.zip* file (does not perform extraction)
68
what is the outcome of typing **tar --extract --verbose --file=***mylife.tgz* **--wildcards** **"\****burnet***"** into a linux terminal
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
this is an accronym for ## Footnote **tape archive**
what does **tar** stand for
70
this will compress and replace the file *mylife.tar* to *mylife.tar.gz*
what is the outcome of typing **gzip** *mylife.tar* into a linux terminal
71
the syntax for this is: ## Footnote **For** *variable-name* **in** *iterable* **Do** *Looped code here* **Done**
what is the syntax for a ## Footnote **linux for loop**
72
what is the outcome of typing **zip -r** *mylife.zip life/* into a linux terminal
this recursively archives and compresses the *life/* directory into the *mylife.zip* file
73
what is the outcome of typing **tar --extract --verbose --file=***life.tar* into a linux terminal
this will extract the files from the archive file *life.tar* and then verbosely list the processed files in the terminal window
74
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
If a script would be useful for all users on the system then where is it normally placed
75
this recursively archives and compresses the *life/* directory into the *mylife.zip* file
what is the outcome of typing **zip -r** *mylife.zip life/* into a linux terminal
76
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
how can you execute a script without specifying its path
77
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
where are **message digests** commonly used
78
these include: 1. **on its own** - .bz2 2. **with tar using a single extension** - .tbz
what are the file extensions for bzip2 1. **on its own** 2. **with tar using a single extension**
79
what is the syntax for a ## Footnote **linux for loop**
the syntax for this is: ## Footnote **For** *variable-name* **in** *iterable* **Do** *Looped code here* **Done**
80
in linux how are **single quotes** handled
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
Anything wrapped inside these will be interpreted. so spaces will be preserved, variables will be read and these are stripped after interpretation
in linux how are **double quotes** handled
82
what is the command to make a script containing the #! executable
to accomplish this the command is **chmod +x** *script-name*
83
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
what is the outcome of typing **tar --create --verbose --bzip2 --file=***mylife.tbz life/* into a linux terminal
84
name 5 pieces of information that the tar command will preserve when creating a .tar file
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
This is used to print or check sha256 checksums
what is the linux **sha256sum** command used for
86
This is an archiving program that can store multiple files into a single file (an archive) and also extract those files from the archive
what is ## Footnote **tar (tape archive)**
87
what is the outcome of typing **gunzip** *mylife.tar.gz* into a linux terminal
this will uncompress and replace the file *mylife.tar.gz* to *mylife.tar*
88
what is the outcome of typing **tar --create --verbose --file=***mylife.tar life/* into a linux terminal
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
If a script is for a single user on the system then where is it custom to add it to
in this case the script should be added to **~/bin** and then this path should be added to the $PATH
90
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
what is the outcome of typing **bzip2 --verbose --keep** *mylife.tar* into a linux terminal
91
this can be used to get input from the user and hold it in the variable *variable-name*
what is the outcome of using **Read** *variable-name* in a linux script
92
if a script does not contain this then you must specify the name of the interpreter before the script name
if a script does not contain the #! at the beginning of the script how can it be executed
93
this is the act of combining files and directories into a single file which can then be stored or copied
what is ## Footnote **archiving**
94
in linux what are the 2 ways that we can ## Footnote **read the arguments given by the user**
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
this will extract the files from the archive file *life.tar* and then verbosely list the processed files in the terminal window
what is the outcome of typing **tar --extract --verbose --file=***life.tar* into a linux terminal
96
This is used to compare files line for line. If the files are the same then the command ends silently
what is the linux **diff** command used for
97
what are the file extensions for bzip2 1. **on its own** 2. **with tar using a single extension**
these include: 1. **on its own** - .bz2 2. **with tar using a single extension** - .tbz
98
Anything wrapped inside these is taken literally and is not interpreted. in this case a variable would be seen as text and not read
in linux how are **single quotes** handled
99
what is the lifespan for each of the following: * **variables created within a linux script** * **environmental variables such as $PATH**
* **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
what is the linux **diff** command used for
This is used to compare files line for line. If the files are the same then the command ends silently
101
in a linux script how can we hold the output of a command as a variable value
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
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
why will **tar add padding** when creating an archive file
103
what is the linux **sha256sum** command used for
This is used to print or check sha256 checksums
104
what is the outcome of typing **tar --extract --verbose --file=***mylife.tgz life/animals/insects* into a linux terminal
this will decompress and extract the file and path *life/animals/insects* from *mylife.tgz* it will then print the files processed
105
these include: * gzip (GNU zip) * bzip2 note bzip2 is usually more space efficient than gzip
name 2 common compression programs available on linux
106
what does **tar** stand for
this is an accronym for ## Footnote **tape archive**