Tools

MagiskSU (su)

su is how apps and shells get root on a Magisk phone. The command itself is a thin client: it asks the Magisk daemon, which checks your Superuser settings and, if root is allowed, starts the shell for you. This page lists every option as the source code parses it and explains what changed in v31.1, the current stable release.

Last updated 6 sourcesHow we check pages

Basic use

Root shell and one-off commands
$adb shell $su # or run a single command as root and return $su -c id

A working root shell prints uid=0(root) gid=0(root) and context=u:r:magisk:s0 for id. Since v31.1 there are no root prompts: grant root ahead of time under Superuser > Grant Superuser, where the ADB shell is listed as Shell, and only then run su. On v30.7 and older, the first time a shell or app asks for root the Magisk app shows a prompt, and your choice is saved in the Superuser tab.

What is MagiskSU? Magisk's root implementation. su is a link to the magisk binary, which hands the request to the Magisk daemon over a socket. There is no separate MagiskSU download. How the binary ends up in PATH is explained on how Magisk works.

How a root request is decided

What happens when you type su

  1. 1su clientParses options, connects to Magisk's socket
  2. 2magiskd checks the callerUID, multiuser mode, saved grant
  3. 3No saved grant?v30.7: the app asks you. v31.1: refused
  4. 4Root process forkedMount namespace, groups, SELinux context applied
  5. 5I/O relayedThrough a pseudo-terminal or your pipes; exit code returned
From native/src/core/su/su.cpp and su/daemon.rs at tags v30.7 and v31.1, checked 26 October 2026.

The daemon looks up the calling UID in its database (/data/adb/magisk.db). Root (uid 0) and the Magisk app itself are always allowed. Everything else depends on the saved policy for that UID: Allow, Deny, or Restrict, which grants root with all Linux capabilities dropped. With no saved policy, v30.7 asks the Magisk app to show the prompt and waits for your answer (or the timeout); v31.1 refuses immediately. The Multiuser mode setting decides whose grants apply to apps in secondary users or work profiles.

Superuser settings in the Magisk app

Featurev30.7 (previous)v31.1 (current)
Prompt dialog when an app asks for rootYesNo
Grant an app before it has askedNoApps appear after their first requestYesSuperuser tab, Grant Superuser
Superuser access (Apps and ADB / Apps only / ADB only / Disabled)YesNo
Automatic response and Request timeoutYesNo
Reauthenticate after upgrade, Tapjacking protectionYesNo
User authenticationYesYes
Multiuser mode, Mount namespace modeYesYes
Superuser notificationYesNone or ToastYesNone, Toast or Notification
Restrict root capabilitiesYesYes
From the app's settings screens and strings at tags v30.7 and v31.1, checked 26 October 2026. v31.1 is the current stable release.

All options

Usage: su [options] [-] [user [argument...]] in v30.7, su [options] [--] [user [argument...]] in v31.1. The table follows each version's option parser, not just its help text.

OptionEffectVersion notes
-c, --command CMDRun a command instead of an interactive shellv30.7: an su option that takes all remaining arguments. v31.1: no longer parsed by su; it is passed to the shell, which runs sh -c CMD. Quote the command in both.
-i, --interactiveForce a pseudo-terminal even with -c (for commands like top)Both
-s, --shell SHELLUse another shell instead of /system/bin/shBoth
-g, --group GIDPrimary group (numeric)Handling fixed in v31.1
-G, --supp-group GIDAdd a supplementary group; repeatable. Without -g, the first one is also the primary group.Handling fixed in v31.1
-Z, --context CONTEXTRun with another SELinux context. -z and -cn are accepted as old aliases.Both
-t, --target PIDUse the mount namespace of process PID; 0 means Magisk's global namespaceBoth
-M, -mm, --mount-masterRun in the global mount namespace (same as -t 0). Can't be combined with -t.Both; dropped from the v31.1 help text but still accepted
-d, --drop-capDrop all Linux capabilitiesNot the default since v30.7
-m, -p, --preserve-environmentKeep the caller's whole environmentBoth
-, -l, --loginStart a login shellv30.7 only. In v31.1 they are no longer su options and go to the shell.
-v, --version / -VPrint version / version code and exitBoth
-h, --helpShow helpBoth
--Stop option parsingv31.1: parsing also stops at the first unknown option, and everything from there goes to the shell
userUser to switch to, by name or UID (default root)Both

Order matters in v31.1. Its parser stops at the first argument that is not an su option, so put su's own options first, then the user, then the shell arguments: su --drop-cap 2000 -c id works, while su 2000 --drop-cap -c id hands --drop-cap to the shell. v30.7 accepted options in any position.

Error messages come straight from the parser: Invalid GID, Invalid PID, Can't use -M and -t at the same time, and in v31.1 option '-s' requires an argument (with the option name). Each prints the help text after it.

Worked examples

Common tasks
# run one command over ADB without opening a shell $adb shell su -c 'ls /data/adb/modules' # mount so every app sees it (global namespace) $su -M -c 'mount -o bind /data/local/tmp/hosts /system/etc/hosts' # look at the files a running app sees (its mount namespace) $su -t $(pidof com.example.app) -c 'ls /system/etc' # run as the shell user (uid 2000) with capabilities dropped $su --drop-cap 2000 -c id # interactive program through -c needs a terminal $su -i -c top # exit code of the root command comes back to the caller $su -c 'test -d /data/adb/modules'; echo $?

Over adb shell with a command, the session has no terminal, so programs that need one (top, editors) need adb shell -t and su -i. For an app or script, check root with su -c id and look for uid=0; on v31.1 make sure users know to grant the app first. If an app only needs elevated access to Android APIs rather than full root, Shizuku may be enough.

Recent changes

  • v30.1: added the Restrict root capabilities option, which can apply per app.
  • v30.7: MagiskSU no longer drops Linux capabilities by default, even when switching to a non-root UID. Use --drop-cap if you need them dropped.
  • v31.1 (current stable): root prompts, the Superuser access mode and the re-authentication setting were removed; access is granted ahead of time. -g/-G handling was fixed, unknown options are forwarded to the shell, and signal handling for commands run by the daemon was fixed.

How root access is contained

Root shells run in Magisk's own magisk SELinux domain, so SELinux stays enforcing for everything else. A fixed set of client domains (zygote, shell, and system, privileged and regular apps) may connect to Magisk's socket, which carries su requests, and share the root shell's pseudo-terminal. Whether a request is allowed is then decided by the daemon from your Superuser settings. Older documentation described a separate magisk_client domain; current releases no longer use it. See how Magisk works. To change properties from a root shell, use resetprop.

Errors and questions

su says Permission denied

The Magisk daemon refused the request. su prints Permission denied and exits with code 13.

v31.1: there is no prompt any more. Open the Magisk app, go to Superuser, tap Grant Superuser and switch on the app (the ADB shell is listed as Shell; you can search for "adb"). A refused request is not logged and shows no toast unless the app already has an entry.

v30.7: check the Superuser tab for a Deny entry, and in Settings check that Superuser access is not Disabled, Apps only (blocks adb shell) or ADB only (blocks apps), and that Automatic response is not Deny. If the prompt timed out, try again and answer it. Requests are also refused if the Magisk app is not installed.

su: not found or su: inaccessible or not found

Magisk is not running, or it did not get to mount its tools. Run magisk -c: if that is also not found, the patched image is not the one booting. Follow Magisk installed but root not working.

If magisk -c works but su does not, see where Magisk put it with command -v su. Magisk adds su to a directory in PATH at boot; a shell started with a changed PATH may not see it. Calling it by full path works around that: $(magisk --path)/su, since Magisk's tmpfs directory holds links to all its applets.

Cannot connect to daemon

The su client could not reach magiskd, usually because Magisk failed at boot or the phone booted in a state where Magisk was not loaded (for example the stock image after an OTA update). Reboot, then check with magisk -v, which asks the running daemon for its version. If that fails too, reinstall Magisk; after an OTA update see updating Magisk and keeping root.

An app asks for root but no prompt appears

On v31.1 that is expected: prompts were removed. Grant the app in Superuser > Grant Superuser, then restart it.

On v30.7, check that the Magisk app is installed and not disabled, that Automatic response is Prompt, and that the app is not already in the Superuser list as denied. A leftover hidden (repackaged) Magisk app can also block the prompt; see root not working.

I mounted something as root but apps don't see it

Root shells use the Inherit namespace mode by default, so a mount made in an adb shell root session lives in the shell's mount namespace only. Use su -M (or su -t 0) to run in Magisk's global namespace, or change Mount namespace mode to Global namespace in Settings.

Do I need quotes with su -c?

Yes, quote the whole command: su -c 'ls -l /data'. On v30.7, -c joins every remaining argument into one command, so the unquoted form also works. On v31.1, arguments are passed to the shell as is; the unquoted form su -c ls -l /data still runs for compatibility, but Magisk logs it as a syntax error and the toast adds "Warning: Unsupported command line detected".

I'm root (uid 0) but still get Operation not permitted

Three common reasons. The app may be set to Restrict root capabilities (v30.1 and later), which runs it as uid 0 without Linux capabilities. You may have passed --drop-cap. Or the operation is blocked by something root does not control, such as a read-only partition (Magisk never remounts /system read-write; use a module instead) or by AVB integrity checks.

How do I check which su is running?

su -v prints the version followed by :MAGISKSU, and su -V prints the version code. If the output has no MAGISKSU, another root solution's su is first in PATH; the Magisk app also warns about a "su" binary not from Magisk.

How do I run a command as another user, such as shell?

Name the user before the command: su 2000 -c id or su shell -c id. Put any su options before the user name, because v31.1 passes everything after it to the shell. Since v30.7, switching to a non-root user keeps the root capabilities unless you add --drop-cap, so scripts that rely on losing privileges must add it.

Sources

This page is written from the sources below. If anything here disagrees with them, the upstream source is correct.

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