Question
How do I delete a non-cPanel user?
Please note that these steps should only be used if you are attempting to remove a user that does *not* have an associated cPanel account. If you would like to remove a cPanel account/user, the steps to do so can be found here.
Answer
To delete a user, the 'userdel' command can be used. Lets say that we wanted to remove a user named 'testuser':
[root@test ~]# id testuser
uid=1012(testuser) gid=1015(testuser) groups=1015(testuser)
This can be done using the 'userdel' command:
[root@test ~]# userdel testuser
[root@test ~]# id testuser
id: testuser: no such user
However, this leaves the home directory behind:
[root@test ~]# ls -lah /home/testuser
total 16K
drwx------ 2 1012 1015 62 May 19 21:37 .
drwx--x--x. 15 root root 4.0K May 19 21:37 ..
-rw-r--r-- 1 1012 1015 18 Mar 31 2020 .bash_logout
-rw-r--r-- 1 1012 1015 193 Mar 31 2020 .bash_profile
-rw-r--r-- 1 1012 1015 231 Mar 31 2020 .bashrc
If you want to remove that as well, the '-r' flag can be used:
[root@test ~]# userdel -r testuser
[root@test ~]#
Example:
[root@test ~]# id testuser
uid=1012(testuser) gid=1015(testuser) groups=1015(testuser)
[root@test ~]# ls -lah /home/testuser
total 16K
drwx------ 2 testuser testuser 62 May 19 21:37 .
drwx--x--x. 15 root root 4.0K May 19 21:37 ..
-rw-r--r-- 1 testuser testuser 18 Mar 31 2020 .bash_logout
-rw-r--r-- 1 testuser testuser 193 Mar 31 2020 .bash_profile
-rw-r--r-- 1 testuser testuser 231 Mar 31 2020 .bashrc
[root@test ~]# userdel -r testuser
[root@test ~]# ls -lah /home/testuser
ls: cannot access /home/testuser: No such file or directory