Linux compression commands (3) compress and dd

Source: Internet
Author: User

Linux compression and decompression commands this series is the third lecture. We have introduced five commands earlier. Here we will continue to introduce the compress commands and dd commands for two other Linux compression and decompression commands, we will give an example to illustrate the problem.

Compress command

[Root @ linux ~] # Compress [-dcr] file or directory
◆ Parameters:
-D: extract parameters.
-R: It can be compressed together with files in the directory!
-C: output compressed data to standard output (output to the screen)
◆ Example:
Example 1: Convert/etc/man. config to/tmp and compress it
[Root @ linux ~] # Cd/tmp
[Root @ linux tmp] # cp/etc/man. config.
[Root @ linux tmp] # compress man. config
[Root @ linux tmp] # ls-l
-Rw-r -- 1 root 2605 Jul 27 :43 man. config. Z
Example 2: Unlock the compressed file
[Root @ linux tmp] # compress-d man. config. Z

Example 3: compress man. config into another file for backup
[Root @ linux tmp] # compress-c man. config> man. config. back. Z
[Root @ linux tmp] # ll man. config *
-Rw-r -- 1 root 4506 Jul 27 :43 man. config
-Rw-r -- 1 root 2605 Jul 27 :46 man. config. back. Z
# This-c parameter is interesting! He will output the data from the compression process to the screen, instead of writing the data
# File. Z file. Therefore, we can output data to another file name through data stream redirection.
# Concerning data stream redirection, we will discuss it in detail in bash shell!

Dd command

[Root @ linux ~] # Dd if = "input_file" of = "outptu_file" bs = "block_size "\
Count = "number"
◆ Parameters:
If: input file ~ It can also be a device!
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. The size of my/etc/passwd file 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!
# In fact, 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
# You have to understand this ~ We know that the MBR of the entire hard disk is 512 bytes,
# It is the first sector on the hard disk. Therefore, I can use this method
# Record all the data in the MBR. It's really amazing! Pai_^

Example 3: Back up the entire/dev/hda1 partition.
[Root @ linux ~] # Dd if =/dev/hda1 of =/some/path/filenaem
# 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 cannot finish reading ~
# 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, hey ~ You can use dd ~ Amazing!

I forgot to mention that these Linux compression and decompression commands must be put into practice by myself.

  1. Example 2: Linux compression and decompression commands
  2. Example 2: Linux compression and decompression commands
  3. Summary all Linux compression and decompression commands
  4. Detailed analysis of Sleep Status in Linux
  5. Reasons for choosing the path to Linux Authentication

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.