In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Linux system dd command how to use, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
In the Linux system, the dd command can copy a file with a block of specified size and perform the specified conversion at the same time.
Parameter comments:
Bs=BYTES read and write BYTES bytes at a time (also see ibs= Obs=) cbs=BYTES convert BYTES bytes at a time conv=CONVS convert the file as per the comma separated symbol list count=N copy only N input blocks ibs=BYTES read BYTES bytes at a time (default: 512) if=FILE read from FILE instead of stdin (default is standard input) iflag=FLAGS read as per the comma separated symbol list obs=BYTES write BYTES bytes at a time (default: 512) of=FILE write to FILE instead of stdout (default is standard output) oflag=FLAGS write as per the comma separated symbol list seek=BLOCKS skip BLOCKS obs-sized blocks at start of output skip=BLOCKS Skip BLOCKS ibs-sized blocks at start of input status=WHICH WHICH info to suppress outputting to stderr Optional parameters for 'noxfer' suppresses transfer stats,' none' suppresses allCONVS
Ascii from EBCDIC to ASCII ebcdic from ASCII to EBCDIC ibm from ASCII to alternate EBCDIC block pad newline-terminated records with spaces to cbs-size unblock replace trailing spaces in cbs-size records with newline lcase change upper case to lower case nocreat do not create the output file excl fail if the output file already exists notrunc do not truncate the output file ucase change lower case to upper case sparse try to seek rather than write the output for NUL input blocks swab swap every pair of input bytes noerror continue after read errors sync pad every input block with NULs to ibs-size Optional parameters for when used with block or unblock, pad with spaces rather than NULs fdatasync physically write output file data before finishing fsync likewise, and but also write metadataFLAGS
Append append mode (makes sense only for output; conv=notrunc suggested) direct use direct I count=N' as a byte count O for data sync likewise, but also for metadata fullblock accumulate full blocks of input (iflag only) nonblock use non-blocking I count=N' as a byte count O noatime do not update access time noctty do not assign controlling terminal from file nofollow do not follow symlinks count_bytes treat 'count=N' as a byte count (iflag only) Note: if the specified number ends with the following characters, it is multiplied by the corresponding number:
C = 1, w = 2, b = 512, kB = 1000, K = 1024, MB = 1000, M = 1024, xM = M GB = 1000, G = 1024, and so on for T, P, E, Z, Y II, use examples
1. Back up the local / dev/hdb to / dev/hdd
Dd``if`` = ``/ dev/ hdb``of=`` / dev/hdd2, backup / dev/hdb full data to the image file of the specified path
Dd``if`` = ``/ dev/ hdb`` of=`` / root/image3, backup / dev/hdb full data, and use gzip tool to compress and save to the specified path
Dd``if`` = ``/ dev/ hdb`` | `gzip`` >`` / root/ image`.gz4. Split a file into 3 files.
# the file size is 2.3k [Oracle@rhel6 ~] $ll db1_db_links.sql-rw-r--r-- 1 oracle oinstall 2344 Nov 21 10:39 db1_db_links.sql # split this file into each file 1kjm Oracle@rhel6 1kjr count1 Use the skip parameter to specify how many bs branches are skipped in the input file to read [oracle@rhel6 ~] $dd if=db1_db_links.sql of=dd01.sql bs=1k count=1 1'0 records in 1'0 records out 1024 bytes (1.0 kB) copied, 4.5536e-05 s, 22.5 MB/s [oracle@rhel6 ~] $dd if=db1_db_links.sql of=dd02.sql bs=1k count=1 skip=1 1'0 records in 1'0 records out 1024 bytes (1.0 kB) copied, 0.000146387 s 7.0 MB/s [oracle@rhel6 ~] $dd if=db1_db_links.sql of=dd03.sql bs=1k count=1 skip=2 01records in 01records out 296bytes (296B) copied, 0.000204216 s 1.4 MB/s # split file [oracle@rhel6 ~] $ll dd*sql-rw-r--r-- 1 oracle oinstall 1024 May 20 14:58 dd01.sql-rw-r--r-- 1 oracle oinstall 1024 May 20 14:58 dd02.sql-rw-r--r-- 1 oracle oinstall 296 May 20 14:58 dd03.sql5, merge the split file into one
# merge operation, where seek parameter is used Used to specify the number of bs skipped in the input file [oracle@rhel6 ~] $dd of=1.sql if=dd01.sql 2'0 records in 2'0 records out 1024 bytes (1.0 kB) copied, 0.000176 s, 5.8 MB/s [oracle@rhel6 ~] $dd of=1.sql if=dd02.sql bs=1k seek=1 1'0 records in 1'0 records out 1024 bytes (1.0 kB) copied, 0.000124038 s, 8.3 MB/s [oracle@rhel6 ~] $dd of=1.sql if=dd03.sql bs=1k seek=2 0,1 records in 0,1 records out 296 bytes (296B) copied 0.00203881 s, 145 kB/s # check with the pre-split file [oracle@rhel6 ~] $diff 1.sql db1_db_links.sql [oracle@rhel6 ~] $6, insert data in the location specified in the output file Without truncating the output file
Need to use the conv=notrunc parameter
[oracle@rhel6 ~] $``dd``if`` = 2.sql of=1.sql bs=1k seek=1 count=2 conv=notrunc after reading the above, have you mastered how to use the dd command in the Linux system? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.