Question: How Do I Restrict Root Access in Linux?
Contents

The simplest method to disable root user login is to change its shell from /bin/bash or /bin/bash (or any other shell that permits user login) to /sbin/nologin , in the /etc/passwd file, which you can open for editing using any of your favorite command line editors as shown.

How do I restrict a root user?

From the menu bar in Directory Utility:

  1. Choose Edit > Enable Root User, then enter the password that you want to use for the root user.
  2. Or choose Edit > Disable Root User.

How do I prevent root from reading a file?

Yes, there are ways to prevent root from overwriting files.

  1. Set the immutable bit with chattr ( +i sets, -i unsets). Requires root access, works only on ext2/ext3 (presumably ext4 too), but is otherwise practical.
  2. Don’t run apps as root. No root privs, no overwriting files. …
  3. Unmount the filesystem. …
  4. Turn off computer.
Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest