YouTube Icon

Code Playground.

How to Delete/Remove Users in Linux (userdel Command)

CFG

How to Delete/Remove Users in Linux (userdel Command)

Linux is a multi-client framework, which implies that beyond what one individual can collaborate with a similar framework simultaneously. As a framework director, you have the duty to deal with the framework's clients and gatherings by making new clients and relegate them to various gatherings . 

At times, you may need to erase a client account. Maybe on the grounds that the client moved away from the association, or it was made for a particular help that no longer sudden spikes in demand for the framework. 

In Linux, you can erase a client record and all its related documents utilizing the userdel order. 

This instructional exercise covers the userdel order and its alternatives. 

userdel Command Syntax

The linguistic structure for the userdel order is as per the following: 

userdel [OPTIONS] USERNAME

To erase clients utilizing the userdel order, you should be signed in as root or a client with sudo access. 

How to Delete User in Linux

To erase a client account named username utilizing the userdel order you would run: 

userdel username

At the point when summoned, the order peruses the substance of the/and so forth/login.defs document. Properties characterized in this record supersede the default conduct of userdel. On the off chance that USERGROUPS_ENAB is set to yes in this record, userdel erases the gathering with a similar name as the client, just if no other client is an individual from this gathering. 

The order eliminates the client sections from the/and so forth/passwd and/and so on/shadow, documents. 

In most Linux conveyances, while eliminating a client account with userdel, the client home and mail spool catalogs are not taken out. 

Utilize the - r (- - eliminate) alternative to constrain userdel to eliminate the client's home index and mail spool: 

userdel -r username

The order above doesn't eliminate the client documents situated in other record frameworks. You need to look for and erase the records physically. 

In the event that the client you need to eliminate is as yet signed in, or if there are running cycles that have a place with this client, the userdel order doesn't permit to eliminate the client. 

In this circumstance, it is prescribed to log out the client and slaughter all client's running cycles with the killall order: 

sudo killall -u username

When done, you can eliminate the client. 

Another choice is to utilize the - f (- - power) choice that advises userdel to strongly eliminate the client account, regardless of whether the client is as yet signed in or if there are running cycles that have a place with the client. 

userdel -f username

Conclusion

In this instructional exercise, you figured out how to erase client accounts in Linux utilizing the userdel order. A similar language structure applies for any Linux appropriation, including Ubuntu, CentOS, RHEL, Debian, Fedora, and Arch Linux. 

userdel is a low-level utility, Debian and Ubuntu clients will almost certain utilization the more amicable deluser order all things being equal. 

Don't hesitate to leave a remark on the off chance that you have any inquiries.




CFG