•  Home
  •  Dashboard
  •  Company
    • About Us
    • Blog
    • Careers
    • Contact Us
    • Data Centers
    • Looking Glass
    • Network
    • Reseller
  •  Hosting Services
    • Backup
    • Content Delivery Network
    • Colocation Hosting
    • Dedicated Hosting
    • DDoS Mitigation
    • IP Transit
    • Private Cloud
    • Wavelength
  •  Solutions
    • Ecommerce
    • Finance
    • Gaming
    • Hosting
    • Management
    • Security
    • System Integrator
  •  Support
    • Community
    • Knowledge Base
    • Open A Ticket
  •  USA & Canada: 800-933-1517
  •  International: 626-549-2801
  •  Email: sales@psychz.net
  • Services
    • Dedicated Servers
    • Colocation
    • Private Cloud
    • DDos Protection
    • IP Transit
    • CDN
    • Backup
  • Solutions
    • Ecommerce
    • Security
    • Gaming
    • Hosting
    • Management
    • Finance
    • System Integrator
  • Dashboard

Delete User In Linux

  • Home
  • Client
  • Qa Forum
  • Delete User In Linux

Posted By: Hector | 1 Replies | Last Reply On: Nov 09, 2021 12:10:05

What command can I use to delete the user on the Linux server? 

Psychz - Yugandhara

Votes: 0Posted On: Nov 09, 2021 12:10:05
 

You may come across various scenarios where you may feel the need to remove a user from your Linux machine/server. If you are a system admin of an organization, you may want to delete a user who probably no longer works with the company. Or you may want to delete a demo user from your local machine. The command to do so is simple.

To do so, you must be a root user or have sudo previleges. To delete a user account named 'john_doe' use the command 'userdel usename'

# userdel john_doe

To remove the user’s home directory at the same time, add the -r option:

# userdel -r john_doe

The userdel command won’t work if the user is currently logged in or has processes running under the account. In this case, you have two options. You can either kill all the user’s processes with the killall command or use the -f option with the userdel command to force deletion.

When invoked, the command reads the content of the /etc/login.defs file. Properties defined in this file override the default behavior of userdel. If USERGROUPS_ENAB is set to yes in this file, userdel deletes the group with the same name as the user, only if no other user is a member of this group. The command removes the user entries from the /etc/passwd and /etc/shadow, files.

In this situation, it is recommended to log out the user and kill all user’s running processes with the killall command:

# killall -u username

Once done, you can remove the user.

# userdel -r john_doe

Another option is to use the -f (--force) option that tells userdel to forcefully remove the user account, even if the user is still logged in or if there are running processes that belong to the user.

Deleting a user can be done using the same syntax for any Linux distribution, including Ubuntu, CentOS, RHEL, Debian, Fedora, and Arch Linux.

Was this reply helpful?

Related topics

  • How to change user password in Linux?
  • How to set or change user passwords with ldappasswd?
  • How to add user to sudoers?
  • Centos - Add User To Group
  • Add user to sudoers Centos
  • Basic and useful Linux commands
  • Psychz CDN Products and Features Updates
  • Top Useful Features Of Linux Mint
  • Scientific Linux and its features
  • How to free up disk space on a cPanel server
  • API Introduction
  • How to move existing domain from one CDN device to another
  • What Scientific Linux is and its features
  • How to temporarily/permanently enable DDoS IP diversion for a Single IP Address?
  • Linux File Permissions Cheat Sheet
Hosting Services
  • Dedicated Hosting
  • Colocation Hosting
  • Backup
  • IP Transit
  • DDoS Mitigation
Support
  • Portal Login
  • Knowledgebase
  • Community
Company
  • About Us
  • Contact Us
  • Network
  • Data Centers
  • Looking Glass
  • Affiliates
  • Reseller
  • Blog
Policies
  • Privacy Policy
  • Acceptable Usage Policy
  • Terms and Conditions
  • Service Level Agreement
Company
  • Psychz Networks,
    A Profuse Solutions Company
    611 Wilshire Blvd #300
    Los Angeles,California 90017
    USA
  • US/Canada: 800-933-1517
  • International: 626-549-2801
Subscribe to Our Mailing List
* indicates required
Copyright © 2023 Psychz Networks, A Profuse Solutions Inc Company