Linux: Fun with Command Line Utilities
From ReceptiveIT
Contents |
ChMod - Change Mode
Recursively chmod directories only
find . -type d -exec chmod 775 {} \;
This will recursively search your directory tree (starting at dir ‘dot’) and chmod 775 all directories only.
Recursively chmod files only
This will recursively search your directory tree (starting at dir ‘dot’) and chmod 664 all files only.
find . -type f -exec chmod 664 {} \;
Mounting a disk image
Sometimes you will be in the situation where you have used a utility like dd to create an image of a disk utility, but that disk image has a partition table with multiple partitions. You know you can use the loopback module to mount the disk image, but how do you mount a specific partition on that disk image? Let me show you how easy it is.
Step 1 - Find the image geometry
root@holland:/virtual# fdisk -u -l venetian-broken.img
You must set cylinders.
You can do this from the extra functions menu.
Disk venetian-broken.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0940093f
Device Boot Start End Blocks Id System
venetian-broken.img1 * 63 41913584 20956761 7 HPFS/NTFS
Partition 1 has different physical/logical endings:
phys=(1023, 254, 63) logical=(2608, 254, 63)
venetian-broken.img2 41913585 83875364 20980890 7 HPFS/NTFS
Partition 2 has different physical/logical beginnings (non-Linux?):
phys=(1023, 0, 1) logical=(2609, 0, 1)
Partition 2 has different physical/logical endings:
phys=(1023, 254, 63) logical=(5220, 254, 63)
root@holland:/virtual#
Step 2 - Mount the image
When using the mount command, you can tell it to start the mount at a specific offset. You get that offset by multiplying the Unit size by the number of units. In the example above, to mount the second partition, it would be 512 x 41913585 = 21459755520
root@holland:/virtual# mount -t auto -o loop,offset=21459755520 /virtual/venetian.img /mnt/recovery

