In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use the compress and dd commands in Linux. It is very detailed and has a certain reference value. Friends who are interested must finish it!
Compress command
[root@linux ~] # compress [- dcr] file or directory
◆ parameters:
-d: parameter used to decompress
-r: it can be compressed together with the files in the directory.
-c: output compressed data to standard output (output to screen)
◆ example:
Example 1: copy / 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--r-- 1 root root 2605 Jul 27 11:43 man.config.Z
Example 2: unlock the compressed file you just had
[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--r-- 1 root root 4506 Jul 27 11:43 man.config
-rw-r--r-- 1 root root 2605 Jul 27 11:46 man.config.back.Z
# the parameter of-c is more interesting! He will output the data of the compression process to the screen instead of writing it as
# file.Z file. Therefore, we can export the data to another file name by redirecting the data stream.
# about 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: even input file ~ can also be a device!
Of: it's output file. Wow, it can also be a device.
Bs: the size of a planned block. If not set, the default is 512 bytes.
Count: how many bs means.
◆ example:
Example 1: backup / 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--r-- 1 root root 1746 Aug 25 14:16 / etc/passwd
-rw-r--r-- 1 root root 1746 Aug 29 16:57 / tmp/passwd.back
# take a closer look, my / etc/passwd file size is 1746 bytes, because I didn't set bs
# so the default is 512 bytes as a unit, so the above 312 1 indicates that there are three complete
The meaning of # 512 bytes and another block under 512 bytes!
# in fact, it feels like the command cp.
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
# this needs to be understood. ~ We know that the MBR of the whole hard drive is 512 bytes
# is the * sector on the hard drive, so I can use this way to
All the materials in # MBR are recorded, which is really impressive! ^ _ ^
Example 3: back up the entire / dev/hda1 partition.
[root@linux ~] # dd if=/dev/hda1 of=/some/path/filenaem
# this command is very powerful! Backup all the contents of the whole partition ~
# the following of must not be in the / dev/hda1 directory ~ otherwise, you can't finish it.
# this action is very effective. If you have to fill in the whole partition content another day,
# can use dd if=/some/file of=/dev/hda1 to write data to the hard disk.
# if you want to back up the whole hard disk, it's like Norton's ghost software
# from disk to disk, hey hey ~ just use dd ~ awesome!
The above is all the contents of the article "how to use compress and dd commands in Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.