Skip to Content.
Sympa Menu

baslinux - [BL] some misc Linux tips

baslinux AT lists.ibiblio.org

Subject: Baslinux mailing list

List archive

Chronological Thread  
  • From: James Miller <jamtat AT mailsnare.net>
  • To: baslinux AT lists.ibiblio.org
  • Subject: [BL] some misc Linux tips
  • Date: Fri, 14 Jan 2005 03:44:08 -0600 (CST)

I ran across an article on using dd that had some interesting tips in it.
Though not specific to BL, I thought they would be the sort of Linux tips
BL users could appreciate. One deals with splitting, then rejoining files
using split (is it part of busybox, btw?). The second concerns completely
erasing files (not just the inodes that point to them) using /dev/urandom.
Here's the info:

------------------------------------------------------------
One way uses split. This simple utility reads data and writes it as many
fixed-size files as necessary. It fills one file after another until all
input data has been read (and written). It's handy, for instance, when
you have a long file that you want to transmit over an unreliable
network connection -- where (unlike modern FTP) the transfer protocol
can't resume an interrupted transfer -- so any transmission problem
means re-transmitting the whole file from the beginning. In that case,
it's best to break the huge file into smaller chunks, send the chunks
one-by-one (retransmitting any that fail), then re-assemble the
transmitted chunks into the complete file.

Here's an example. At your office, you have the 100 MB bigfile.tar.gz.
You want to split it into one hundred 1 MB files for downloading, via
dialup modem, from your home computer. You give the command:

office$ split -b 1m bigfile.tar.gz

Now you have one hundred 1 MB files named (by default) xaa, xab, xac,
... xdu, and xdv. You transmit them to your home system. At home, you
reassemble the one hundred files, using shell wildcard operators to
match all of the three-character filenames in alphabetical order, as in:

home% cat x[a-d]? > bigfile.tar.gz

It's best to use a utility like md5sum or sum to be sure that the
reassembled bigfile.tar.gz is identical to the original.

**********************************************************

Another use for dd is for "wiping" a text file before you delete it.
Simply removing a Linux file (with rm, for instance) only deletes the
inode that points to the data. A cracker with root access might read the
raw disk (with dd!) and find the "deleted" file. We can use dd to write
random data over the file before deleting it. Normally dd truncates a
file before writing, so use conv=notrunc to make it write over the
existing data. Set bs to the file size and count to 1. For example:

% ls -l afile
-rw------- ... 3769 Nov 2 13:41 afile
% dd if=/dev/urandom of=afile \
bs=3769 count=1 conv=notrunc
1+0 records in
1+0 records out
% rm afile

If you want to, you can repeat the "wiping" command several times with
the C shell repeat command, the Z shell repeat loop, or simply use the
history operator !!.
--------------------------------------------------------------

James




Archive powered by MHonArc 2.6.24.

Top of Page