Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello everyone, I am a newbie with the linux OS and have been playing around with adding and removing users, after adding a new user, I tried deleting the user using the userdel command without the -r option, using the ls command still shows the user on my PC and if i try to delete the user again, it says such user does not exist even when i use the -r option. What should I do to get rid of the user ? Iam using the Centos Distro. any help will be appreciated
Hello and welcome to LQ! The "-r" option removes the user's home directory along with its mail (see below the lines from the man page). If you have already issued the "userdel" command, the user is not there anymore, so it doesn't have any effect now: what you see with the "ls" command is not the user itself, but its home directory ("ls" lists files, not existing users). If you want to remove the mentioned home directory you now have to do that manually (as root) with the "rm -r" (remove recursively) command. Pay attention to the fact that after you have removed it, the directory and its content are gone, and might be recovered (no guarantee) only by using specific tools.
Code:
$ man userdel
Code:
-r, --remove
Files in the user's home directory will be removed along with the
home directory itself and the user's mail spool. Files located in
other file systems will have to be searched for and deleted
manually.
Last edited by Philip Lacroix; 09-20-2014 at 04:11 AM.
Thanks @Philip Lacroix I tried using the rm -r command to remove the user home directory but the directory still exists, I am probably getting something wrong, the recursive remove does not seem to be doing the job for me.
Can you post the exact command you're entering and any error messages you might have received? Note that you will generally need to have root priveliges to delete a directory not owned by you. Also, it good to remember that rm is permanent. There's no trash bin like on some other OSes from which you can recover the files. So make sure there's really nothing in that directory that you (or someone else) might want before you delete it. Tools do exist for data recovery, but it's best to not need to use them in the first place!
I tried using the rm -r command to remove the user home directory but the directory still exists, I am probably getting something wrong, the recursive remove does not seem to be doing the job for me.
Please follow btmiller's above suggestions, so that we can help you effectively. If you still have doubts about commands, files, folders and permissions on Linux systems, I recommend you a guide which is worth reading:
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,491
Rep:
Quote:
Originally Posted by harunaadoga
Thanks @Philip Lacroix I tried using the rm -r command to remove the user home directory but the directory still exists, I am probably getting something wrong, the recursive remove does not seem to be doing the job for me.
Needs the command to be issued as the 'root' user; either use sudo or su, to gain 'root', (if using su, don't forget to use 'exit', so that you don't do anything bad accidentally ).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.