Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

On a CentOS 8 server, use useradd (or the compatible adduser command) to create a local account, passwd to set its password, and usermod --append -G wheel to grant administrative access. Remove only the account with userdel, or remove the account, home directory, and mail spool with userdel -r.

CentOS Linux 8 reached end of life on December 31, 2021. It receives no further CentOS Linux 8 content updates, so treat any remaining host as legacy infrastructure and plan migration to a supported operating system. The commands below are for maintaining an existing CentOS 8 installation while that work is scheduled.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What you need before changing accounts

You need root access or an account that already has equivalent sudo permission. Account administration changes the system password database, ownership metadata, login policy, and sometimes security labels, so use a maintenance record or change ticket where your organization requires one.

Check the account and data first

  • Confirm the exact username, including capitalization and spelling. A mistaken name in userdel -r can destroy the wrong home directory.
  • Determine whether the account owns a service, systemd unit, scheduled job, SSH key, application configuration, database files, uploads, or backups.
  • Decide whether files must be retained, reassigned, archived, or destroyed before choosing a deletion command.
  • Check for files owned by the user outside the home directory. The account may own files under application, web, backup, or shared-data paths.
  • If the user is logged in, end the session before deletion. Terminating the session does not make a retention decision; it only prevents an active login from continuing while the account is changed.

End an active session

Replace the placeholder with the verified login name:

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.
sudo loginctl terminate-user <username>

Use this before either form of userdel. If the account runs a service, stop or reconfigure that service through its normal administrative procedure rather than assuming session termination handles it.

Add a local CentOS 8 user

Create the account

Red Hat documents the form useradd <options> <username>. A straightforward local account creation sequence is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo useradd <username>
sudo passwd <username>

passwd prompts for the new password twice. Password length, complexity, expiration, and reuse rules should follow your site’s security policy; the command itself does not replace those policy decisions.

Many CentOS installations also provide adduser as a compatible command. A commonly used form is:

sudo adduser <username>

On systems using the usual defaults, this creates /home/<username> and copies starter files from /etc/skel. Defaults can vary, so verify the result instead of assuming that the home directory was created. If your host’s useradd defaults do not create a home directory, use the documented local convention consistently or create the account with the host-approved home-directory option.

Verify the identity and home directory

Run all three checks as an administrator:

id <username>
getent passwd <username>
ls -ld /home/<username>

id displays the numeric user ID and group memberships. getent passwd confirms that the account resolves through the system’s configured name-service path and shows its login shell and home path. The ls command confirms that the expected directory exists and lets you inspect its owner and permissions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If the home path shown by getent passwd is different from /home/<username>, inspect the path reported there instead. Do not create a second directory merely because the conventional path is absent.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Set or reset the password

For a newly created account, or when an existing account needs a new local password, run:

sudo passwd <username>

The password is stored for local authentication. A successful password change does not guarantee that the user can connect over SSH: the SSH daemon may be configured to reject password authentication entirely. In that case, install an approved public key in the user’s .ssh directory, apply the site’s ownership and permission requirements, and confirm the server’s sshd authentication policy separately.

Give the user sudo access safely

Add the user to the administrative group

On CentOS and RHEL-style systems, the conventional administrative group is wheel. Append the group without replacing the user’s existing supplementary groups:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo usermod --append -G wheel <username>

The --append option matters. Omitting it while supplying a supplementary-group list can remove other group memberships that the account needs.

Confirm that the wheel rule is enabled

Membership alone grants no privilege unless the sudoers policy authorizes it. The standard policy is equivalent to:

%wheel ALL=(ALL) ALL

Inspect the active sudoers configuration and ensure the wheel rule is not commented out. When changing sudoers files, use visudo; it checks syntax before installing the edit and helps prevent a malformed policy from locking administrators out.

Test as the target user

Start a login shell for the account and ask sudo to identify the effective user:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
sudo -iu <username> sudo whoami

The expected output is:

root

If the command fails, check the user’s current group list, the enabled wheel rule, and any site-specific restrictions such as command-specific sudo policies. A newly changed group membership may require a new login session before the shell sees the change.

Choose the correct deletion operation

There are two materially different outcomes. The plain command removes the login account but leaves its files; the recursive form removes the account’s home directory and mail spool as well.

Goal Command What it does Main risk
Remove login account, retain files sudo userdel <username> Deletes the account entry while leaving the user’s files for archiving, reassignment, or review. Orphaned files and services may remain and still contain sensitive data.
Remove account and home data sudo userdel -r <username> Deletes the account, home directory, and the user’s mail spool. Home and mail data are removed; recovery requires a separate backup.
RHEL 8-style full cleanup sudo userdel --remove --selinux-user <username> Performs recursive removal and removes the SELinux user mapping where applicable. Still destructive; additional AccountsService metadata may need removal.

The choice is a retention decision, not merely a syntax preference. Do not run the recursive form until the username, backup status, and destruction approval have been checked.

Delete an account but keep its files

Inventory ownership and preserve required data

Before deletion, identify data outside the home directory and decide who or what should own it afterward. Typical checks include service definitions, scheduled tasks, SSH authorized keys, application directories, shared uploads, and logs. Archive or copy required material according to your retention policy. If files need to remain available to a team, reassign ownership deliberately rather than leaving an undocumented numeric user ID behind.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A broad ownership search can produce a large result set, so review it carefully and exclude virtual filesystems or other paths that are irrelevant to your policy. The important point is to search beyond /home/<username>; deleting the account does not find or remove those files.

Terminate the session and remove only the account

  1. End active sessions:
    sudo loginctl terminate-user <username>
  2. Remove the account entry but keep its files:
    sudo userdel <username>
  3. Archive, reassign, or review the retained files according to the approved retention plan.

After plain userdel, files that still carry the deleted user’s numeric UID can appear with no name in directory listings. That is expected; it does not mean the deletion failed. Change ownership only after confirming the correct replacement owner and group.

Delete the account and its home directory

Run the destructive command only after approval

Once required data is backed up or explicitly approved for destruction, terminate the session and run:

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
sudo loginctl terminate-user <username>
sudo userdel -r <username>

The -r option removes the account’s home directory and mail spool in addition to the account record. It does not serve as a general search-and-destroy operation for every file the user owns elsewhere on the server. Files outside the home directory require a separate, reviewed cleanup.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Handle SELinux and AccountsService metadata when needed

Red Hat’s fuller RHEL 8 procedure uses:

sudo userdel --remove --selinux-user <username>

On systems that have an AccountsService record for the user, remove the corresponding file only after confirming that the account was deleted and that the path belongs to the same username:

sudo rm /var/lib/AccountsService/users/<username>

The AccountsService file may not exist. Do not treat a missing file as an error, and do not remove files for another account. SELinux behavior and local policy can differ, so preserve audit records and follow the host’s security administration procedure if the command reports a labeling or mapping problem.

Verify that deletion completed

Check name-service resolution after either deletion path:

getent passwd <username> || echo "account removed"
id <username>

After successful removal, getent passwd should return no account entry and id should fail. The failed id lookup is expected in this specific check. Also verify the outcome that matches your chosen operation:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • For plain userdel, confirm that intentionally retained files still exist and that their ownership or archival state is documented.
  • For userdel -r, confirm that the home directory and mail spool are gone, while remembering that files elsewhere are not automatically removed.
  • Review service status, scheduled jobs, SSH configuration, and monitoring alerts so an application does not continue trying to run as a deleted identity.
  • Record the operator, time, username, command, retention decision, and any remaining file ownership changes when audit rules apply.

Local login, SSH login, and sudo are separate controls

Creating an account, setting a password, enabling an SSH authentication method, and granting sudo are four different controls. A user can exist in /etc/passwd yet be unable to log in because the shell is disabled, the password is locked, SSH password authentication is disabled, or no approved public key is installed. Conversely, an account that can log in need not have administrative privileges.

Question Check Interpretation
Does the account exist? id <username> and getent passwd <username> Confirms identity resolution, UID, groups, shell, and home path.
Can it use a local password? sudo passwd <username>, followed by the site’s login test Confirms password setup, but not SSH acceptance.
Can it connect through SSH? Review sshd authentication policy and the approved key or password method SSH daemon policy decides which credentials are accepted.
Can it administer the host? sudo -iu <username> sudo whoami Expected output is root only when sudo policy and wheel membership permit it.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common failures

“User already exists”

Do not rerun creation with a different spelling until you know whether the existing account is the intended identity. Use getent passwd <username> and id <username> to inspect it. Reusing an existing account may be safer than creating a duplicate, but only after its owner, purpose, shell, home path, and group memberships are confirmed.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

The home directory is missing

Inspect the home path reported by getent passwd rather than assuming the conventional path. If the host’s account-creation defaults did not create the directory, follow the server’s approved method for creating it and copying starter files. Ensure the resulting directory is owned by the new account before permitting normal use.

Sudo still says the user is not allowed

Check that the user is actually in wheel, that the wheel sudoers rule is enabled, and that the test is being run from a new login session. Use visudo for policy changes. Site-specific sudoers entries can intentionally override or restrict the general wheel rule.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

SSH rejects the new account

First distinguish a password problem from an SSH policy problem. If password authentication is disabled, setting a local password cannot make password login work; install an authorized public key and verify the daemon’s accepted authentication methods. Also check that the account’s shell is valid and that any organization-level access controls permit the connection.

Deletion reports an active process

Terminate the user’s login session with loginctl terminate-user, then identify whether a system service, scheduled task, container, or supervisor is still running under that UID. Stop or migrate the workload through its normal procedure before retrying deletion. Do not kill an unknown production process solely to make userdel finish.

Files remain after recursive deletion

userdel -r targets the account’s home directory and mail spool; it does not promise removal of every file with the user’s numeric UID on every mounted filesystem. Search for remaining ownership, decide whether each item is required, and archive, reassign, or remove it under the retention policy.

Plan migration from CentOS Linux 8

CentOS Linux 8 has been unsupported since December 31, 2021, with no further content updates from the CentOS Project. User administration on a legacy host should therefore be paired with a migration plan rather than treated as a long-term operating model.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Inventory local users, service accounts, sudo rules, SSH keys, scheduled jobs, file ownership, and SELinux mappings before moving workloads.
  • Separate human accounts from noninteractive service identities and document which applications depend on each UID or group.
  • Test account creation, SSH authentication, sudo policy, and deletion procedures on the supported destination operating system.
  • Preserve required files and ownership mappings during migration; a numeric UID change can make existing files appear unowned even when the data is still present.
  • Retire the CentOS 8 host only after services, credentials, monitoring, backups, and audit records have been validated on the replacement platform.

For an immediate maintenance change, follow the least-destructive command that matches the approved outcome. For new deployments, choose a currently supported operating system instead of extending the life of CentOS Linux 8.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.