From 30106144fe6f065b36faf3833a930f78b828529a Mon Sep 17 00:00:00 2001 From: johannst Date: Sun, 13 Apr 2025 19:34:18 +0000 Subject: deploy: c929dc819132694c50a22eccb5c90b20aa39d97d --- binary/xxd.html | 5 ++ cli/dd.html | 249 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ cli/find.html | 4 +- cli/index.html | 1 + print.html | 47 +++++++++++ searchindex.js | 2 +- toc.html | 2 +- toc.js | 2 +- tools/index.html | 4 +- tools/qemu.html | 4 + 10 files changed, 313 insertions(+), 7 deletions(-) create mode 100644 cli/dd.html diff --git a/binary/xxd.html b/binary/xxd.html index 97d58ae..209d0cc 100644 --- a/binary/xxd.html +++ b/binary/xxd.html @@ -184,6 +184,11 @@ >> }; >> unsigned int _proc_self_fd_11_len = 4; +

Patching binary file by hand in hex mode

+
  xxd /bin/ls > ls.hex
+  # edit binary file in hex format (ascii)
+  xxd -r ls.hex > ls
+
diff --git a/cli/dd.html b/cli/dd.html new file mode 100644 index 0000000..80d8e2d --- /dev/null +++ b/cli/dd.html @@ -0,0 +1,249 @@ + + + + + + dd - Notes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + + + + +
+
+

dd(1)

+

Copy data block-wise.

+
dd [opts]
+    if=<path>         input file to read (stdin in case not specified)
+    of=<path>         oputput file to write
+    status=progress   show progress while copying
+    bs=<bytes>        block size
+    count=<n>         copy only <n> blocks
+    skip=<n>          skip <n> blocks in input (seek input)
+    seek=<n>          skip <n> blocks in oputput (seek output)
+    conv=<conv>
+         notrunc      dont truncate output file
+         excl         fail if output already exists
+         nocreat      fail if output does not exists
+
+

Example: bootstick

+
dd bs=4M if=<iso> of=<blkdev> oflag=sync status=progress
+
+

Example: patch file in place

+
# Create a 1024 bytes file filled with zeros.
+dd if=/dev/zero of=disk bs=512 count=2
+
+# Overwrite 4 bytes starting at byte 0.
+printf "aaaa" | dd of=disk bs=1 seek=0 conv=notrunc
+
+# Overwrite 4 bytes starting at byte 512.
+printf "bbbb" | dd of=disk bs=1 seek=512 conv=notrunc
+
+hexdump disk
+# 0000000 6161 6161 0000 0000 0000 0000 0000 0000
+# 0000010 0000 0000 0000 0000 0000 0000 0000 0000
+# *
+# 0000200 6262 6262 0000 0000 0000 0000 0000 0000
+# 0000210 0000 0000 0000 0000 0000 0000 0000 0000
+# *
+# 0000400
+
+ +
+ + +
+
+ + + +
+ + + + + + + + + + + + + + + + + + +
+ + diff --git a/cli/find.html b/cli/find.html index 01364cc..24f2a21 100644 --- a/cli/find.html +++ b/cli/find.html @@ -196,7 +196,7 @@ exec modifier characters ; and + also may need to be e - @@ -210,7 +210,7 @@ exec modifier characters ; and + also may need to be e - diff --git a/cli/index.html b/cli/index.html index 71932b2..6889ddf 100644 --- a/cli/index.html +++ b/cli/index.html @@ -172,6 +172,7 @@
  • xargs
  • grep
  • find
  • +
  • dd
  • diff --git a/print.html b/print.html index 2d17d9e..7fa2797 100644 --- a/print.html +++ b/print.html @@ -1004,6 +1004,7 @@ status -f # abs path of current file
  • xargs
  • grep
  • find
  • +
  • dd
  • awk(1)

    awk [opt] program [input]
    @@ -1477,6 +1478,43 @@ exec modifier characters ; and + also may need to be e
     > find . -maxdepth 1 -type d -exec echo x {} +
     # x . ./.github ./book ./src ./.git ./docs
     
    +

    dd(1)

    +

    Copy data block-wise.

    +
    dd [opts]
    +    if=<path>         input file to read (stdin in case not specified)
    +    of=<path>         oputput file to write
    +    status=progress   show progress while copying
    +    bs=<bytes>        block size
    +    count=<n>         copy only <n> blocks
    +    skip=<n>          skip <n> blocks in input (seek input)
    +    seek=<n>          skip <n> blocks in oputput (seek output)
    +    conv=<conv>
    +         notrunc      dont truncate output file
    +         excl         fail if output already exists
    +         nocreat      fail if output does not exists
    +
    +

    Example: bootstick

    +
    dd bs=4M if=<iso> of=<blkdev> oflag=sync status=progress
    +
    +

    Example: patch file in place

    +
    # Create a 1024 bytes file filled with zeros.
    +dd if=/dev/zero of=disk bs=512 count=2
    +
    +# Overwrite 4 bytes starting at byte 0.
    +printf "aaaa" | dd of=disk bs=1 seek=0 conv=notrunc
    +
    +# Overwrite 4 bytes starting at byte 512.
    +printf "bbbb" | dd of=disk bs=1 seek=512 conv=notrunc
    +
    +hexdump disk
    +# 0000000 6161 6161 0000 0000 0000 0000 0000 0000
    +# 0000010 0000 0000 0000 0000 0000 0000 0000 0000
    +# *
    +# 0000200 6262 6262 0000 0000 0000 0000 0000 0000
    +# 0000210 0000 0000 0000 0000 0000 0000 0000 0000
    +# *
    +# 0000400
    +

    Tools