Showing posts with label Command Releted. Show all posts
Showing posts with label Command Releted. Show all posts

Wednesday, January 21, 2015

dd command

dd if =/dev/sda of=funny  bs=1 count=512
In this command  what is the
meaning  of  bs and  count

ganesh kumar dubey

<dubeyganeshkumar07@gmail.com>



Please refer below notes.
Bs is the block size is the physical size of a block.
Source is the data being read. Target is where the data gets written.
Warning!! If you reverse the source and target, you can wipe out a lot of data. This feature has inspired the nickname "dd" Data Destroyer. Warning!! Caution should be observed when using dd to duplicate encrypted partitions.
Examples: duplicate one hard disk partition to another hard disk partition: Sda2 and sdb2 are partitions. You want to duplicate sda2 to sdb2.
Code:
dd if=/dev/sda2 of=/dev/sdb2 bs=4096 conv=notrunc,noerror
If sdb2 doesn't exist, dd will start at the beginning of the disk, and create it. Be careful with order of if and of. You can write a blank disk to a good disk if you get confused. If you duplicate a smaller partition to a larger one, using dd, the larger one will now be formatted the same as the smaller one. And there will be no space left on the drive. The way around this is to use
Code:
rsync
, as described below.
To make an iso image of a CD: This duplicates sector for sector. MyCD.iso will be a hard disk image file of the CD.
Code:
dd if=/dev/hdc of=/home/sam/myCD.iso bs=2048 conv=sync,notrunc
You can mount the image like this:
Code:
mkdir /mnt/myCD
mount -o loop /home/sam/myCD.iso /mnt/myCD
This will make the CD root directory the working directory, and display the CD root directory.
Code:
cd /mnt/myCD
This will duplicate a floppy disk to hard drive image file:
Code:
dd if=/dev/fd0 of=/home/sam/floppy.imageIf you're concerned about spies taking the platters out of your hard drive, and scanning them using superconducting quantum-interference detectors, you can always add a "for" loop for US Government DoD approved secure hard disk erasure. Copy and paste the following two lines into a text editor.
Code:
#!/bin/bash
for n in `seq 7`; do dd if=/dev/urandom of=/dev/sda bs=8b conv=notrunc; done
Save the file as anti_scqid.
Code:
chmod +x anti_swqid
Don't run the program until you want to wipe the drive.
Best Laptop Backup: Purchase a laptop drive and an USB 2.0 drive enclosure (Total cost $100.00USD). Assemble the lappy drive into the external enclosure. Plug the external drive into the lappy USB port, and boot with The Knoppix live CD. Launch a terminal. This command will backup the existing drive:
Code:
dd if=/dev/hda of=/dev/sda bs=64k conv=notrunc,noerror
This command will restore from the USB drive to the existing drive:
Code:
dd if=/dev/sda of=/dev/hda bs=64k conv=notrunc,noerror
If the existing disk fails, you can boot from the external drive backup and have your system back instantaneously.
This series will make a DVD backup of hard drive partition:
Code:
dd if=/dev/hda3 of=/home/sam/backup_set_1.img bs=1M count=4430
dd if=/dev/hda3 skip=4430 of=/home/sam/backup_set_2.img bs=1M count=4430 
dd if=/dev/hda3 skip=8860 of=/home/sam/backup_set_3.img bs=1M count=4430
And so on. This series will burn the images to DVD+/-R/RW:
Code:
wodim -dev=/dev/hdc --driveropts=burnfree /home/sam/backup_set_1.img
and so forth. To restore the from the backup, load the DVDs in order, and use commands like these:
Code:
dd if=/media/dvd/backup_set_1.img of=/dev/hda3 bs=1M conv=sync,noerror
Load another DVD
Code:
dd if=/media/dvd/backup_set_2.img of=/dev/hda3 seek=4430 bs=1M conv=sync,noerror
Load another DVD
Code:
dd if=/media/dvd/backup_set_3.img of=/dev/hda3 seek=8860 bs=1M conv=sync,noerror
 

Anil Mavarkar

<anilmavarkar@gmail.com>


bs= sets the blocksize, for example bs=1M would be 1MiB blocksize.
count= copies only this number of blocks (the default is for dd to keep going forever or until the input runs out). Ideally blocks are of bs= size but there may be incomplete reads, so if you use count= in order to copy a specific amount of data (count*bs), you should also supply iflag=fullblock.

Please refer below mentioned link for more information.

http://unix.stackexchange.com/questions/134299/dd-bs-count-seek


Shashikant More

<m.shashikant86@gmail.com>

 DD command uis used to copy data. Only superuser can execute dd command.


BS = Block size.

Count = No. of blocks to be define  (Its only integer no.)


Example :1)


#dd if =/dev/sda of=funny  bs=1 count=512


“if” represents inputfile, and “of” represents output file. So the exact copy of /dev/sda will be available in /dev/sdb.


BS=1 (This will take default block size)  

To find default block size use below command :


# tune2fs -l /dev/sda1 | grep -i 'block size'


If default block size is 8k then calculation will be  8k X 512 = 4096KB



Example :2)

You can also define BS size in MB or GB

#dd if =/dev/sda of=funny  bs=1MB count=512

This will create 512 MB size of funny file.



Refer below link for DD command examples : 



Tushar Bachhav

<bachhav.tushar@gmail.com>
 
 
 
 


Tuesday, January 20, 2015

Command not find showing error

In our Data Center last two day before I was facings problem on new REDHAT 6.5 linux VM machine,
When we use some basic commands it was showing command not find,
That time we were not able find  anything on this issue because of work load,
So pls help us for resolving this issue ...
Now same issue we facing on new installed  Redhat VM

Nitin Kumbhar

<kumbharnv@gmail.com>

____________________________________________________________________________________

I guess most probably you should share which commands you are executing and  also ensure that  by command "which"  for Path whether it exist in /bin  /sbin  /usr/bin  /usr/sbin
Add star 

Hanif Niyas

<mohd.niyas92@gmail.com>

___________________________________________________________________________________
Also make an export path entry in ~/.bash_profile file for user

Sagar B

<forlinuxdata@gmail.com>

Sunday, January 18, 2015

exclude option in linux command

How to use exclude option in rm -rf  command

____________________________________________________________________________________\

Check this out :

http://www.linuxquestions.org/questions/red-hat-31/does-rm-command-has-a-option-exclude-623091/

___________________________________________________________________________________

You can use following tricks to exclude files 

Using Bash extglob ( not it will exclude file1.txt, I've used ls command for demo )

rahul@lappy:/tmp/test$ ls -rlht
total 0
-rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file1.txt
-rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file5.txt
-rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file4.txt
-rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file3.txt
-rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file2.txt
rahul@lappy:/tmp/test$ shopt extglob
extglob         on
rahul@lappy:/tmp/test$ ls -rlht !(file1.txt)
-rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file5.txt
-rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file4.txt
-rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file3.txt
-rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file2.txt

Using find command 

find . -type f ! -iname 'file1.txt' -exec ls -lrt {} \;