Topic 6 - Scripting and archiving Flashcards
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
what is the outcome of typing
tar –create –verbose –file=mylife.tar life/
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
what is the outcome of typing
tar –extract –verbose –file=mylife.tgz –wildcards ”*burnet“
into a linux terminal
this will decompress and extract the contents of the file mylife.tgz it will then print the files processed
what is the outcome of typing
tar –extract –verbose –file=mylife.tgz
into a linux terminal
does
tar
perform compression
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
this is accomplished by using the following format:
Variable-name=value
No space should be used either side of the equals sign
in a linux script how do you declare a variable
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
does
tar
perform compression
what was
tar (tape archive)
originally built for
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
lists the contents of the mylife.zip file (does not perform extraction)
what is the outcome of typing
unzip -l mylife.zip
into a linux terminal
what is the outcome of typing
unzip mylife.zip life/animals/
into a linux terminal
decompresses and extracts the directory and path life/animals/ from mylife.zip
what is the linux
tree
command used for
This is used to list the contents of a directory to the terminal window in a tree like format
what is the outcome of typing
bzip2 –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.bz2. it will then print information about the compression ratio
in linux how are
double quotes
handled
Anything wrapped inside these will be interpreted.
so spaces will be preserved, variables will be read and these are stripped after interpretation
decompresses and extracts the directory and path life/animals/ from mylife.zip
what is the outcome of typing
unzip mylife.zip life/animals/
into a linux terminal
what is
compression
this is the act of taking a file and reducing the number of bytes that it takes up, reducing storage space and bandwidth
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=$@
in linux what are the 2 ways that we can
read the arguments given by the user
in a linux script how do you declare a variable
this is accomplished by using the following format:
Variable-name=value
No space should be used either side of the equals sign
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
what is the outcome of typing
tar –create –verbose –gzip –file=mylife.tgz life/
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
what is the outcome of typing
tar –extract –verbose –file=mylife.tgz life/animals/insects
into a linux terminal
what is the outcome of using
Read variable-name
in a linux script
this can be used to get input from the user and hold it in the variable variable-name
what is
archiving
this is the act of combining files and directories into a single file which can then be stored or copied
this will recursively compare the files in ~/work/life against the files in ~/extract/life
what is the outcome of typing
diff -r ~/work/life ~/extract/life
into a linux terminal
what is the outcome of typing
gzip mylife.tar
into a linux terminal
this will compress and replace the file mylife.tar to mylife.tar.gz
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)
in a linux script how can we hold the output of a command as a variable value
in a linux script what does the following accomplish
Today=$(date -I)
this will run the command
date -I
and the output will be stored as the value to the variable today
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
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
name a common cryptographic hash function used to produce
message digests
sha256 is one common hash function that is used to produce this
what are the file extensions for gzip
- on its own
- with tar using single extension
these include:
- on its own - .gz
- with tar using single extension -.tgz
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
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
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
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
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
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
this is accomplished by appending $ to the beginning of the variable name
$variable-name
in a linux script how do we access a variable
- 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
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
this is sometimes referred to as a
tarball
what is a
.tar file
sometimes referred to as
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
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
these include:
- on its own - .gz
- with tar using single extension -.tgz
what are the file extensions for gzip
- on its own
- with tar using single extension
during this operation it will preserve:
- The structure of the directories
- The contents of files
- Owner of file
- File permissions
- Timestamps
name 5 pieces of information that the tar command will preserve when creating a .tar file