dd if=/dev/sdb of=/root/flashcopy




Download 7,3 Mb.
Pdf ko'rish
bet108/125
Sana14.05.2024
Hajmi7,3 Mb.
#232858
1   ...   104   105   106   107   108   109   110   111   ...   125
Bog'liq
linuxbasicsforhackers

dd if=/dev/sdb of=/root/flashcopy
1257441=0 records in
1257440+0 records out
7643809280 bytes (7.6 GB) copied, 1220.729 s, 5.2 MB/s
Let’s break down this command: 
dd
is your physical “copy” command; 
if
designates your input file, with 
/dev/sdb
representing your flash drive in 
the /dev directory; 
of
designates your output file; and 
/root/flashcopy
is the 
name of the file you want to copy the physical copy to. (For a more com-
plete explanation of the Linux system designation of drives within the /dev 
directory, see Chapter 10.)
Numerous options are available to use with the 
dd
command, and you 
can do a bit of research on these, but among the most useful are the 
noerror
option and the 
bs
(block size) option. As the name implies, the 
noerror
option 
continues to copy even if errors are encountered. The 
bs
option allows you 
to determine the block size (the number of bytes read/written per block) of 
the data being copied. By default, it is set to 512 bytes, but it can be changed 
to speed up the process. Typically, this would be set to the sector size of the 


Compressing and Archiving
99
device, most often 4KB (4,096 bytes). With these options, your command 
would look like this:
kali >
dd if=/dev/media of=/root/flashcopy bs=4096 conv:noerror
As mentioned, it’s worth doing a little more research on your own, but 
this is a good introduction to the command and its common usages.
Summary
Linux has a number of commands to enable you to combine and compress 
your files for easier transfer. For combining files, 
tar
is the command of 
choice, and you have at least three utilities for compressing files—
gzip

bzip2

and 
compress
—all with different compression ratios. The 
dd
command goes 
above and beyond. It enables you to make a physical copy of storage devices 
without the logical structures such as a filesystem, allowing you to recover 
such artifacts as deleted files.
E XERCISES
Before you move on to Chapter 10, try out the skills you learned from this 
chapter by completing the following exercises:
1. Create three scripts to combine, similar to what we did in Chapter 8. 
Name them 
Linux4Hackers1

Linux4Hackers2
, and 
Linux4Hackers3
.
2. Create a tarball from these three files. Name the tarball 
L4H
. Note how the 
size of the sum of the three files changes when they are tarred together.
3. Compress the 
L4H
tarball with 
gzip
. Note how the size of the file changes. 
Investigate how you can control overwriting existing files. Now uncompress 
the 
L4H
file. 
4. Repeat Exercise 3 using both 
bzip2
and 
compress
.
5. Make a physical, bit-by-bit copy of one of your flash drives using the 
dd
command.




Download 7,3 Mb.
1   ...   104   105   106   107   108   109   110   111   ...   125




Download 7,3 Mb.
Pdf ko'rish