resetprop
resetprop is Magisk's tool for system properties. Unlike setprop it can change read-only ro.* properties, delete properties and wait for changes, because it can edit the property area in memory directly. This page covers every flag in v30.7 and v31.1, when changes do and don't trigger Android's property actions, and how to make a change stick.
Last updated 6 sourcesHow we check pages
- What it isApplet of
magiskRun as root - Read-only ro.* propsCan change and deletesetprop can't
- How long a change lastsUntil rebootExcept persist.* written with
-p - Every bootUse a moduleIts
system.propis applied at post-fs-data - In post-fs-data scriptsAlways add
-nGoing through init there deadlocks boot
Common uses
You need root: open adb shell, run su (see MagiskSU), then use the commands above. resetprop has three modes. With no flags it reads or writes. -w switches to wait mode. -f, -d and (from v31.0) -c are their own operations, and only one may be used per call.
Every flag and argument
This is the usage text printed by resetprop -h, which is the same in v30.7 and v31.1 apart from -c.
| Form | Mode | Effect |
|---|---|---|
| (no arguments) | Read | Print all properties as [name]: [value], sorted |
NAME | Read | Print one value; exit 1 if it does not exist |
NAME VALUE | Write | Set or create the property |
-f, --file FILE | Write | Set every name=value line in FILE (lines starting with # are skipped, spaces around names and values are trimmed) |
-d, --delete NAME | Write | Delete the property; exit 1 if nothing was deleted |
-w NAME | Wait | Block until NAME exists. The help text says "until property NAME changes", but the code returns as soon as the property exists. |
-w NAME OLD_VALUE | Wait | Return immediately if NAME is not OLD_VALUE, otherwise block until it changes |
-p | Read | Also read persist.* properties from storage when they are not in memory |
-p | Write | Also write or delete persist.* properties in storage |
-P | Read | Read persist.* properties from storage only |
-Z | Read | Print the property's SELinux context instead of its value |
-n | Write | Bypass property_service and write memory directly, so no on property: triggers fire |
-c, --compact [CONTEXT] | General | Compact the property storage areas, or only the one for a context label. Added in v31.0; not in v30.7. |
-v, --verbose | General | Print what it does to stderr (for example whether a write went "by property_service" or "by direct modification") |
-h, --help | General | Show the usage text |
When triggers fire, and when they don't
Android's .rc files can run actions when a property changes (on property:foo=bar). Those only run if the change goes through init's property_service. Which path resetprop takes depends on the name and the flags:
Does a resetprop write fire on property: actions?
ro.?- YesWritten directly to memory. No triggers fire. Values of 92 characters or more are allowed: the property is deleted and re-added.
- NoDid you pass
-n?- YesIs it a
persist.*property?- YesWritten to memory; also saved to storage only if you add
-p. No triggers. - NoWritten directly to memory. No triggers fire.
- Yes
- NoSent to init's property_service, like setprop. Triggers fire, and init saves persist.* itself.
- Yes
Magisk itself always uses the direct path: module system.prop files and Magisk's own property changes (such as the Zygisk native bridge property) never fire triggers. A side effect for module authors: a persist.* line in system.prop is set in memory but not saved to storage.
persist.* properties
persist.* properties exist twice: in memory, and in /data/property/persistent_properties, from which they are reloaded at boot. resetprop's defaults match getprop and only touch memory. That gives three traps:
- Reading a stored property that has not been loaded yet returns nothing unless you add
-p.resetprop -Plists what is in storage. - Deleting without
-premoves only the in-memory copy, so the property returns after a reboot. Useresetprop -p -d persist.name. - Writing with
-nskips init, which is what normally saves persist properties. Add-pas well if the value should survive a reboot.
Using resetprop in modules and scripts
Fixed values at every boot: use the module's system.prop, in build.prop format. Magisk loads it with resetprop at post-fs-data, before zygote starts, so apps see the new values from their first launch.
Values computed at boot: use post-fs-data.sh with resetprop -n if they must be in place before apps start, or service.sh otherwise. To wait for the system to finish booting in service.sh, Magisk's guide uses resetprop -w sys.boot_completed 0.
Device spoofing modules such as the Play Integrity Fix forks rely on these same mechanisms. For the module folder layout and boot stages, see module development and how Magisk works.
Version history
- v30.2: reduced the traces property modifications leave.
- v30.5: proper support for Android versions with property overrides.
- v30.7: all flags on this page except
-c. - v31.0: added
-c/--compact. Nothing else changed in resetprop through v31.1.
Errors and questions
What is the difference between resetprop and setprop?
setprop always asks init's property_service, which refuses to change ro.* properties that are already set and cannot delete anything. resetprop can write the shared property memory directly, so it can change ro.* values, delete properties, read persistent storage and wait for changes. For ordinary properties without -n, resetprop behaves like setprop.
My change is gone after a reboot
Properties live in memory and are rebuilt from the build.prop files at every boot. Only persist.* properties are stored, and only when set through property_service or with -p. To apply other properties at every boot, put them in a module's system.prop, or run resetprop from a module's post-fs-data.sh (with -n) or service.sh. See module development.
The value changed but nothing behaves differently
Many processes read properties once, when they start. Changing a value afterwards only affects processes that read it later. That is why spoofing and tweak modules set properties in system.prop or at post-fs-data, before zygote and the apps start. Also check that you did not need the property actions: ro.* changes and -n writes never fire on property: triggers.
Boot hangs when my post-fs-data script sets a property
Magisk's developer guide warns that setprop deadlocks boot during post-fs-data, because init is waiting for Magisk at that point. A resetprop write that goes through property_service (any non-ro.* property without -n) asks init the same way. Use resetprop -n NAME VALUE there, or move the script to service.sh.
I deleted a persist.* property and it came back
Without -p, delete removes the property from memory only; the copy in /data/property/persistent_properties is restored at the next boot. Use resetprop -p -d persist.name to remove both.
Reading a property prints nothing
The property does not exist in memory, and resetprop exits with code 1. For persist.* properties that are stored but not loaded, add -p (memory, then storage) or -P (storage only). resetprop | grep name lists everything that is set.
resetprop: not found
resetprop is installed by Magisk at boot, next to su, and needs root. Run it from a root shell (su first). If magisk -c also fails, Magisk is not running; see root not working.
Multiple operation mode detected! or Unrecognized argument
resetprop does one thing per call: wait (-w), compact (-c), load a file (-f), delete (-d), or read/set. Combining two of those prints the first error. It also takes at most two plain arguments (NAME and VALUE), so quote values that contain spaces: resetprop my.prop "two words".
Can apps tell that properties were changed?
Sometimes. resetprop changes what a property returns, but writing to the property area can leave traces; Magisk's changelog lists work to reduce them in v30.2. Whether a given app notices is outside Magisk's documentation. For Play Integrity, see the Play Integrity guide.
-c / --compact doesn't work
The compact flag was added in v31.0, so it is in the current v31.1 but not in v30.7 or older. Update Magisk if you need it.
No match. Try another word from the error message.
Sources
This page is written from the sources below. If anything here disagrees with them, the upstream source is correct.
- Magisk tools reference: resetprop (topjohnwu)
- Magisk internal details: resetprop (topjohnwu)
- Magisk developer guide: system.prop and boot scripts (topjohnwu)
- Magisk changelog: resetprop changes (topjohnwu)
- Magisk source: resetprop command line, native/src/core/resetprop/cli.rs at v31.1 (topjohnwu)
- Magisk source: resetprop command line at v30.7 (topjohnwu)
Found a mistake or something out of date? Tell us and we will check it against the source and fix the page. Confirmed corrections are listed in the corrections log.
Report a problem with this page