memtool(1)
๐ memtool(1) โ the manual, but make it slay ๐
okay so bestie, gather round, because this one is a General Commands Manual and it's genuinely so useful. It's called memtool, and yes, it does exactly what the name says. Let's go. โจ
๐ธ NAME ๐ธ
memtool โ display and modify memory. that's it, that's the whole vibe. ๐
๐ SYNOPSIS ๐
memtool -V
memtool md [-b|-w|-l|-q] [-x] [-s filename] region
memtool mw [-b|-w|-l|-q] [-d filename] start data...
like, three whole moods. pick your fighter. ๐ซถ
๐ฆ DESCRIPTION ๐ฆ
So memtool lets you read and write regions of files. And here's the iconic part: when you point it at /dev/mem โ which is the default file, btw, in case you were wondering โ those regions are literally memory mapped registers. main character behaviour, honestly. ๐
Right now there are exactly two subcommands, no more no less:
mwโ write to memory / a file ๐mdโ read from memory / a file ๐
Usually memtool operates on files (regular ones or devices) using mmap(2). But here's the plot twist ๐ซข โ if filename is of the form mdio:ethname.id, where ethname is the name of an ethernet device and id is an MDIO address, then the phy with address id on the MDIO bus related to the ethernet device ethname gets accessed instead. (iykyk ๐) And to prevent ambiguities when you're using the mmap access method, just use mmap:filename as the parameter. easy. โจ
โ ๏ธ Real talk, bestie. On some machines there are alignment restrictions that forbid, for example, reading a word from an address that isn't word aligned. memtool does not try to be smart here โ it just tries whatever the caller requested. This might result in all kinds of errors, and those errors are not considered to be a bug of the tool, but either the machine or the caller. so like... don't come for memtool, okay? ๐ญ
โจ OPTIONS โจ
-Vโ dumpmemtoolversion and exit. short, sweet, done. ๐
๐ COMMON OPTIONS FOR SUBCOMMANDS ๐
these ones you'll be reaching for constantly, ngl.
-bโ use byte wise (8-bit) access ๐-wโ use word wise (16-bit) access ๐ธ-lโ use long wise (32-bit) access ๐ฆ-qโ use quad wise (64-bit) access โจ-d filenameโ write tofilename. ๐-s filenameโ read fromfilename. ๐-xโ swap bytes at output ๐
๐ REGIONS ๐
Memory regions can be specified in two different forms, and honestly both are giving:
start[+size]
start-end
Okay let's break it down ๐ซถ:
startspecifies the byte offset of the region's beginning, i.e. the first included address.sizespecifies the size of the region in bytes and defaults to0x100. yes bestie, that's the default, don't forget it. ๐- Alternatively,
endspecifies the offset of the last included address.
And about those offsets โ you can write them in decimal or in hexadecimal with a prefix 0x. Plus, for the big numbers era, you can use the suffixes G, M, and k, which multiply by 1024^3, 1024^2, and 1024 respectively. math but make it cute. ๐งฎโจ
and that's the whole page, bestie!! this lovely little manual is from December 2015, and the page itself is memtool(1) โ general commands manual, iconic as always. go read some memory, you've got this. ๐๐๐ฆ
๐ฆ where this page comes from
- debian bookworm: memtool 2018.03.0-1 ยท GPL-2.0-only
- debian trixie: memtool 2018.03.0-1 ยท GPL-2.0-only
- ubuntu jammy: memtool 2018.03.0-1 ยท GPL-2.0-only
- ubuntu noble: memtool 2018.03.0-1 ยท GPL-2.0-only
- ubuntu resolute: memtool 2018.03.0-2 ยท GPL-2.0-only
- ubuntu stonking: memtool 2018.03.0-2 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms