Friday, December 17, 2010

File Systems 3

Now I realize I should have made my blog posts with the chapter name and a number signifying which one it is. Oh well.

Now on cp command. Basic syntax for copying something would be cp this_file /over/here. Now switches

-f does not ask when overwriting files
-i interactively asks before overwriting
-r recursive
-s creates symlink to the source file
-u only copies when the source is newer or there is no pre-existing target.

mv on the other hand moves files. It uses the same syntax as cp and switches (except recursive because it is recursive).

Here's something that I would just use a GUI but anyways. The dd command (according to the book) is often use for duplicating things like a CD .img or partition. So an example would be.

dd if=/dev/fd0 of=/dev/fd1. if is inputed, of is output and this would do a 1:1 copy of a CD to another CD. The same thing can be used for a partition, just change the devices. If you want to backup the MBR you would do.

dd if =/dev/hda of=/root/MBR.img count=1 bs=512. count sets the number of reads from the input file and bs sets the block size so you don't copy all the blocks.

Lastly mkdir/rmdir and rm. mkdir makes directories. To make a directory you would do mkdir directory or mkdir directory/directory2 to make a subdirectory. rmdir works the same way but the directory must be empty.

rm removes files AND can remove directories full of files. You don't need me to tell you the syntax so here are the switches.

-f removes a file without a prompt
-rf removes all contents in a directory with a prompt.

Enough for now...

1 comment:

  1. You should try using the dd command. I used to use it alot to make backup copies of floppy disks. I still have some of the resulting .img files around, so I could recreate a set of DOS 6.22 floppies if we ever wanted them (we won't with FreeDOS out now, but anyway).

    ReplyDelete