Safely Use Root Commands

From Whonix


This wiki entry is intended to make attacks harder by denying root access: [1]

  • Prevent root compromise: these steps help to protect the virtualizer to avoid host compromise, and similarly the hardware to avoid hardware compromise. [2]
  • Protect against compromised non-root users: it is harder for any future, non-root users (such as www-data) to access user user or other parts of the system.
  • Usability: if the advanced advice to Prevent Malware from Sniffing the Root Password is not followed, then users will only require a single, secure root password for the user user account. It is no longer necessary to have two secure passwords for the user user and root accounts. [3]

Default Passwords[edit]

Whonix / Kicksecure default admin password is: changeme default username: user
default password: changeme

The default root account is locked (or should be locked). [4] This is a purposeful security feature -- see below for further details.

General Security Advice[edit]

Commands that require root permissions should be run individually using sudo. In all cases:

  • Do not login as root.
  • Do not run sudo su.

Graphical Applications with Root Rights[edit]

It is discouraged running GUI (graphical user interface) applications using sudo application.

  • Never login as root as explained above.
  • I.e. never use sudo su and then start GUI applications.

This will fail and is a limitation inherited from Debian. If a user attempts this action, error messages like those below will appear. [5]

No protocol specified
cannot connect to X server :0

As an XFCE user (Non-Qubes-Whonix default) use lxsudo. For example.

Open file /etc/default/keyboard in an editor with root rights.

(Qubes-Whonix ™: In TemplateVM)

This box uses sudoedit for better security. This is an example and other tools could also achieve the same goal. If this example does not work for you or if you are not using Whonix, please refer to this link.

sudoedit /etc/default/keyboard

Root Account[edit]

Enable Root Account[edit]

For security reasons the root account is locked and expired by default in Whonix ™ and above. For most users there should be no need to use the root account. If it must be enabled for some reason, run the following commands.

(Qubes-Whonix ™: Whonix-Gateway ™ and Whonix-Workstation ™ TemplateVMs)

Unexpire the root account.

sudo chage --expiredate -1 root

Set a root password.

sudo passwd

Disable Root Account[edit]

The current Whonix ™ stable release and earlier versions come with the root account by default. Most users should disable it by running the following commands (Qubes-Whonix ™: Whonix-Gateway ™ and Whonix-Workstation ™ TemplateVMs).

Lock the account.

sudo passwd --lock root


In the future, use sudo instead when it is necessary.

Unlock User Account: Excessive Wrong Password Entry Attempts[edit]

1. Boot into recovery mode.

2. Run the following command.

sudo pam_tally2 -u user -r --quiet

Advanced Users[edit]

Prevent Malware from Sniffing the Root Password[edit]

Any graphical application can see what is typed in another graphical application, for any user. [7] [8] Therefore it is safer to create a special, new user account that is less likely to have been compromised, since this reduces the chances of malware sniffing the password to gain root access.

To more securely perform administrative tasks that require root access:

  1. These instructions are ideally applied after installing the host / VM when it is still considered free of Malware.
  2. Create a new user account admin.
  3. Add it to the group sudo.
  4. Login as user admin.
  5. Remove user user from group sudo.
  6. Only then perform administrative tasks according to the instructions below.

This setup only needs to be completed once (Qubes-Whonix ™: Whonix-Gateway ™ and Whonix-Workstation ™ TemplateVMs).

1. Create a new user account admin.

sudo adduser admin

2. Add user admin to group sudo.

sudo addgroup admin sudo

Perform the following steps securely using sudo. Use one of the methods below.

Non-GUI Environment Method[edit]

This method is preferable until the limitation in the next section is documented.

1. Make sure keyboard gets disconnected from X Window System. (unraw) [9]

SysRq + r

2. Login as user admin from a non-graphical environment (virtual console). [10]

3. Perform any necessary administrative tasks.

4. Remove user user from group sudo.

Note: This only needs to be performed once.

sudo delgroup user sudo

5. Logout user admin and continue usual work as user user.

Logout Method[edit]

1. Login as user admin.

2. Logout user user first, then login as user admin.

Ensure that user user was really logged out and this process was not just simulated. TODO: research and document this procedure. SysRq + r?

3. Perform any necessary administrative tasks.

4. Remove user user from group sudo.

Note: This step only needs to be performed once.

sudo delgroup user sudo

5. Logout user admin and continue usual work as user user.

Substitute User (su) Command[edit]

The majority of users do not need to use the su command [11].

Group sudo membership is required to use su (by package security-misc).

To be able to run su from user user, it is necessary to:

(Qubes-Whonix ™: perform these steps in Whonix-Gateway ™ and Whonix-Workstation ™ TemplateVMs.)

  1. Enable the root account.
  2. Add user user to group root.

sudo adduser user root

Root Login[edit]

Root login within a virtual console will be disabled by default after upgrades. [12] [13]

To be able to login from a virtual console, first apply the Enable Root Account instructions above, then complete the steps below.

1. To allow root login, /etc/securetty needs to be configured.

Open file /etc/securetty in an editor with root rights.

(Qubes-Whonix ™: In TemplateVM)

This box uses sudoedit for better security. This is an example and other tools could also achieve the same goal. If this example does not work for you or if you are not using Whonix, please refer to this link.

sudoedit /etc/securetty

2. Add the following content.

Note: Some users might only add one tty, or more depending on their circumstances; see file /etc/


3. Save the file.

Recovery Mode[edit]

Root login is possible using recovery mode. [14]

When the root account is disabled, passwordless root login using recovery mode is possible; see below for the security impact.

Passwordless Recovery Mode Security Discussion[edit]

This is only relevant on the host and not inside virtual machines.

Passwordless recovery mode is allowed because a locked root password would break the rescue and emergency shell. Therefore the security-misc package enables a passwordless rescue and emergency shell. This is the same solution that Debian will likely adapt for Debian installer. [15]

With passwordless root login, using recovery mode is allowed (through use of the security-misc package) on the host. To prevent adverse security effects posed by lesser adversaries with physical access to the machine, set up BIOS password protection, bootloader grub password protection and/or full disk encryption.



  1. Also see: Permissions.
  3. On the flip-side, if the Prevent Malware from Sniffing the Root Password steps are followed, two secure passwords are required for the user user and user admin accounts.
  4. In new builds of Whonix version Earlier Whonix builds did not lock the root account by default and should be locked.
  5. No longer expiring the root account since this broke adduser, see: (To prevent SSH login, see: Linux Locking An Account. This might prevent other login methods but this requires further investigation.)
    sudo chage --expiredate 0 root
  6. Quote Joanna Rutkowska, security researcher, founder and advisor (formerly architecture, security, and development) of Qubes OS:

    One application can sniff or inject keystrokes to another one, can take snapshots of the screen occupied by windows belonging to another one, etc.

  7. If an application is compromised with an exploit due to a security vulnerability, it can be used as malware by the attacker. Once/if the application is not effectively confined by a mandatory access control (MAC) framework like AppArmor or firejail, it can compromise the user account where it is running and then proceed from there.
  8. Broken X Window System can block switching to virtual console. If X Window System is capable of that it logically follows that also malware that compromised X Window System could do that. "SysRq + r" can take away control from X Window System. After that, switching to another virtual console is possible.
  9. A GUI non-root user cannot sniff key strokes of different (non-)root users utilizing a virtual console.
  10. su is sometimes incorrectly referred to as the superuser command. It allows:

    ... a change to a login session's owner (i.e., the user who originally created that session by logging on to the system) without the owner having to first log out of that session.

    Although su can be used to change the ownership of a session to any user, it is most commonly employed to change the ownership from an ordinary user to the root (i.e., administrative) user, thereby providing access to all parts of and all commands on the computer or system.

    By comparison, sudo makes it possible to execute system commands without the root password.

  11. security-misc /etc/securetty is empty by default.
  12. When trying to login as root in a virtual console it will reply:

    Login incorrect.

    Without previously asking for a password. This is not the worst case for usability and is better than asking for password and then failing.

[advertisement] Looking to Sell Your Company? Contact me.

Are you proficient with iptables? Want to contribute? Check out possible improvements to iptables. Please come and introduce yourself in the development forum.

https | (forcing) onion
Follow: Twitter.png Facebook.png 1280px-Gab text logo.svg.png Rss.png 1024px-Telegram 2019 Logo.svg.png

Share: Twitter | Facebook

This is a wiki. Want to improve this page? Help is welcome and volunteer contributions are happily considered! Read, understand and agree to Conditions for Contributions to Whonix ™, then Edit! Edits are held for moderation.

Copyright (C) 2012 - 2019 ENCRYPTED SUPPORT LP. Whonix ™ is a trademark. Whonix ™ is a licensee of the Open Invention Network. Unless otherwise noted, the content of this page is copyrighted and licensed under the same Freedom Software license as Whonix ™ itself. (Why?)

Whonix ™ is a derivative of and not affiliated with Debian. Debian is a registered trademark owned by Software in the Public Interest, Inc.

Whonix ™ is produced independently from the Tor® anonymity software and carries no guarantee from The Tor Project about quality, suitability or anything else.

By using our website, you acknowledge that you have read, understood and agreed to our Privacy Policy, Cookie Policy, Terms of Service, and E-Sign Consent. Whonix ™ is provided by ENCRYPTED SUPPORT LP. See Imprint.