Deleting a user account in Oracle VirtualBox means removing that user's login from inside a virtual machine, not removing the virtual machine itself.
When you delete a user in VirtualBox, you are working inside the guest operating system — the OS running in the virtual machine. The steps differ depending on whether your guest is Windows, Linux, or macOS. You will need administrator or root access to complete the deletion, and you should back up any files belonging to that user first, because deletion is permanent.
This guide covers the most common scenarios: removing a user from a Windows guest, removing a user from a Linux guest, and what to do if you have forgotten the administrator password. The process takes a few minutes and requires no additional software beyond VirtualBox itself.
Key Takeaways
- User deletion happens inside the guest operating system, not in VirtualBox itself — you are removing a login account from Windows, Linux, or macOS.
- On Windows guests, use Settings > Accounts > Other people, or use the command line tool net user if the GUI is unavailable.
- On Linux guests, use the command userdel with the -r flag to remove the user and their home directory in one step.
- Back up the user's files before deletion, because the account and all its data are removed permanently and cannot be recovered.
- If you cannot log in as an administrator, you may need to boot into safe mode (Windows) or single-user mode (Linux) to regain access.
Deleting a user on a Windows guest
Start by logging into the virtual machine as an administrator. Click the Start button, then type Settings and open it. Navigate to Accounts, then select Other people from the left sidebar.
Find the user account you want to remove in the list. Click on it, then click the Remove button. Windows will ask you to confirm. A dialog box will appear asking what you want to do with the user's files — you can delete them immediately, or save them to a folder on the desktop for backup. Choose based on whether you need to keep any of that user's documents or settings. Click Delete account and data to finish.
If the Settings app does not open or you cannot reach the Accounts section, you can use the command line instead. Right-click the Start button, select Windows Terminal (Admin) or Command Prompt (Admin), and type this command, replacing username with the actual account name:
net user username /delete
Press Enter. Windows will remove the account and all its associated files immediately. This method leaves no confirmation dialog, so double-check the username before pressing Enter.
Deleting a user on a Linux guest
Open a terminal inside the virtual machine. You can usually do this by right-clicking the desktop and selecting Open Terminal, or by pressing Ctrl+Alt+T. Log in as root or use sudo if your user account has administrator privileges.
Type this command, replacing username with the account name you want to remove:
sudo userdel -r username
The -r flag tells the system to remove the user's home directory and all files in it at the same time. Without the -r flag, the user account is deleted but the home directory remains on disk. Press Enter and provide your password if prompted.
If you want to delete the account but keep the home directory (for example, to preserve files), omit the -r flag:
sudo userdel username
The account will be removed, but the folder /home/username will remain. You can then manually delete it later or leave it as a backup.
Deleting a user on a macOS guest
Click the Apple menu and select System Settings. Go to General, then click Users & Groups (or Login Items depending on your macOS version). You may need to click the lock icon and enter your administrator password to make changes.
Select the user account from the list on the left. Click the minus button (–) at the bottom of the list. macOS will ask whether you want to save the user's home folder or delete it. Choose based on whether you need to keep the user's files. Click Delete User to confirm.
If you are using a newer version of macOS and cannot find Users & Groups in System Settings, try System Preferences instead, or use the command line method described below.
Using the command line to delete a user on macOS
Open Terminal (found in Applications > Utilities). Type this command, replacing username with the account name:
sudo dscl . -delete /Users/username
Press Enter and provide your administrator password. The account will be deleted, but the home directory will remain. To delete the home directory as well, type:
sudo rm -rf /Users/username
Be very careful with this command — the -rf flags delete the folder and everything in it without asking for confirmation. Make sure you have the username spelled correctly before pressing Enter.
What to do if you cannot log in as administrator
If you have forgotten the administrator password or cannot access an admin account, you will need to boot the virtual machine into a special mode that bypasses the normal login.
On Windows, restart the virtual machine and press F8 repeatedly as it boots. Select Safe Mode with Command Prompt from the menu. Log in with the built-in Administrator account (which may have a blank password on some systems). Once at the command prompt, use the net user command described earlier to delete the account.
On Linux, restart the virtual machine and interrupt the boot process by pressing Escape or Shift (depending on your Linux distribution). Select the option to boot into single-user mode or recovery mode. You will be dropped into a root shell without needing a password. Use the userdel command to remove the account, then type exit to resume normal boot.
On macOS, restart the virtual machine and hold Command+S as it boots to enter single-user mode. Type fsck -fy to check the disk, then mount -uw / to make the system writable. Use the dscl command described earlier to delete the account, then type exit to resume normal boot.
Backing up user files before deletion
Before you delete any user account, copy that user's important files to a safe location. On Windows, open File Explorer and navigate to C:\Users\username. Copy the Documents, Desktop, and Downloads folders to another drive or location. On Linux, copy the contents of /home/username to a backup location. On macOS, copy the user's home folder to an external drive or another location on the system.
If you use the deletion method that offers to save files (such as Windows Settings or macOS System Settings), those files are usually saved to the desktop or a folder called Deleted Users. Check there after deletion to confirm the backup was created.
Frequently Asked Questions
Can I undo a user deletion?
No. Once a user account is deleted, it cannot be recovered through VirtualBox or the guest operating system. The account and its files are permanently removed. This is why backing up important files before deletion is essential. If you deleted the account by mistake, you will need to create a new user account with a different name.
What happens to the user's files if I delete the account?
It depends on the deletion method you use. Most graphical tools (Windows Settings, macOS System Settings) ask you to choose: delete the files immediately, or save them to a backup location. Command-line tools like userdel -r delete the files automatically. Always back up important files manually before deletion if you are unsure.
Do I need to shut down the virtual machine before deleting a user?
No. You can delete a user while the virtual machine is running, as long as that user is not currently logged in. If the user you want to delete is logged in, log out first, then proceed with deletion. Deleting the account of a logged-in user can cause unexpected behavior.
Will deleting a user in VirtualBox affect my host computer?
No. User deletion happens only inside the guest operating system running in the virtual machine. Your host computer and its user accounts are not affected. The virtual machine itself remains intact — only the user account inside it is removed.
What if the user account I want to delete is the only administrator account?
You will not be able to delete it through the normal GUI because you need administrator rights to delete an account. Create a second administrator account first, log out of the original account, log in as the new administrator, and then delete the original account. Alternatively, boot into safe mode or single-user mode (as described earlier) to gain access without needing an existing admin account.