Linux Command details-general Linux technology-Linux technology and application information. For more information, see the following. 1. dd command:
[Root @ linux ~] # Dd if = "input_file" of = "output_file" bs = "block_size "\
Count = "number"
Parameters:
If: input file ??? Department tip Yun kiss Dad Mian FU? Br/> of: output file ~ It can also be a device;
Bs: the size of a planned block. If no value is set, the default value is 512 bytes.
Count: the number of bs.
Example:
Example 1: back up/etc/passwd to/tmp/passwd. back
[Root @ linux ~] # Dd if =/etc/passwd of =/tmp/passwd. back
3 + 1 records in
3 + 1 records out
[Root @ linux ~] # Ll/etc/passwd/tmp/passwd. back
-Rw-r -- 1 root 1746 Aug 25 14:16/etc/passwd
-Rw-r -- 1 root 1746 Aug 29 16:57/tmp/passwd. back
# Take a closer look, my/etc/passwd file size is 1746 bytes, because I have not set bs
# Therefore, the default value is 512 bytes. Therefore, the above 3 + 1 indicates three complete
#512 bytes, and another block under 512 bytes!
# Actually, it seems like the cp command.
Example 2: backup/dev/hda MBR
[Root @ linux ~] # Dd if =/dev/hda of =/tmp/mbr. back bs = 512 count = 1
1 + 0 records in
1 + 0 records out
# So you have to understand it well ??? Yi invasion? Le? The MBR is 512 bytes.
# It is the first sector on the hard disk. Therefore, I can use this method
# All data in the MBR is recorded. It's really amazing!
Example 3: Back up the entire/dev/hda1 partition.
[Root @ linux ~] # Dd if =/dev/hda1 of =/some/path/filename
# This command is amazing! Back up all the content of the entire partition
# The following of must not be in the/dev/hda1 directory. Otherwise, you can't finish reading it.
# This action is very useful. If you need to complete the content of the entire partition in the next day
# You can use dd if =/some/file of =/dev/hda1 to write data to the hard disk.
# If you want to back up the entire hard disk, it is similar to Norton's ghost software.
# From disk to disk, you can use dd. It's amazing!
You can say that tar can be used to back up key data, while dd can be used to back up the entire partition or the entire disk, which is quite good ~ However, if you want to return the data to filesystem, you may need to consider the original filesystem to succeed!
Notrunc = no O_TRUNC
O_TRUNC indicates that if the file exists and is read-only or only successfully opened, the length of the file will be truncated to 0, that is, if the file has content, it will be discarded and re-opened.
Seek = blocks
The blocks are skipped from the beginning of the output file and then copied.
2. 1>/dev/null 2>/dev/null
1>/dev/null indicates redirecting the standard output of the command to/dev/null
2>/dev/null indicates redirecting the command error output to/dev/null
1-denotes stdout (standard output)
2-denotes stderr (standard error)
/Dev/null is equivalent to the recycle bin in windows.
>/Dev/null indicates that the standard output and standard error information are not displayed.
B.>/dev/null 2> & 1 also can write as 1>/dev/null 2> & 1
-Stdout redirect to/dev/null (no stdout), and redirect stderr to stdout (stderr gone as well). end up it turns both stderr and stdout off
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service