How one can safely delete a consumer account on Linux

Deleting customers on a Linux server ought to be dealt with with this greatest observe.

In the event you make use of Linux in your information middle, or just your on-premises servers of any kind, likelihood is you’ve got customers that log into these servers to make the most of one service or one other. The likelihood can also be excessive that sooner or later, you are going to must delete a consumer. This can be as a result of an worker strikes on to a different division, job, or firm. 

Irrespective of the rationale why, you could know find out how to safely delete that consumer account in your Linux server. I will present you find out how to do exactly that.

SEE: 10 harmful app vulnerabilities to be careful for (TechRepublic obtain)

What you may want

To be able to accomplish this process, you may want a Linux server up and operating (it does not matter what distribution of Linux you utilize) and a consumer account with sudo privileges. With these issues on the prepared, let’s delete some customers.

Lock ’em out

As a substitute of diving proper in and deleting a consumer, it is best to first lock mentioned consumer out of their account. By doing this, you forestall that consumer from having access to their account. That is additionally a great step to take ought to a consumer be positioned on suspension or take a depart of absence (the place they don’t seem to be allowed to log into their account). 

To be able to lock out a consumer account, log into the Linux server for which they’ve an account, after which concern the command:

sudo passwd -l USERNAME

The place USERNAME is the consumer to be locked out.

Earlier than you proceed on, try to alter to that consumer with the command su USERNAME. You need to see (regardless of what number of occasions you sort the password accurately) an authentication failure alert (Determine A).

Determine A


Consumer don has been locked out.

In the event you’re unsure if the consumer in query is already logged in (earlier than you lock them out), you would possibly need to pressure a sign off on them with the command:

sudo killall -9 -u USERNAME

The place USERNAME is the identify of the consumer in query. When you’re sure they don’t seem to be logged in, you possibly can then lock them out of their account. 

Backup consumer information

Earlier than you delete the consumer, you would possibly need to take a backup of their residence listing (in case there may be information you need to save). To do this, concern the next instructions:

sudo tar -zcvf USER_backup.tgz /residence/USER

The place USERNAME is the identify of the consumer in query.

You would then transfer that newly created tar file right into a backup listing (the place you retain deleted consumer information).

Delete cron and print jobs

The final step, earlier than deletion, could be to delete any cron and print jobs. These two duties may be accomplished with the next instructions:

sudo crontab -r -u USERNAME
sudo lprm USERNAME

The place USERNAME is the identify of the consumer in query.

Delete the consumer

Now you possibly can safely delete the consumer account. To do that, concern the command:

sudo userdel -r USERNAME

The place USERNAME is the identify of the consumer to be deleted.

Utilizing the -r choice can even delete the house listing of the consumer (which is why we backed it up earlier than deleting it).

And that is the way you safely delete a consumer on a company-owned Linux server. Sure, there are different methods to care for this process, however by following the method I’ve outlined you possibly can delete customers safely and with out a lot trouble.

Additionally see


Picture: Jack Wallen

Leave a Reply

Your email address will not be published. Required fields are marked *