LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   rm usage question (https://www.linuxquestions.org/questions/linux-newbie-8/rm-usage-question-4175586353/)

GooberJack 08-05-2016 09:26 AM

rm usage question
 
Hello,

I just recently started using CentOS 6.4. I've been tasked with deleting an account from the system. The command given to do this is:
userdel -f <username>

Next is to cd to /export/home and type:
rm -fr username.date so the output looks like rm -fr user.080516

I see the username in the /export/home as a directory. I'm trying to understand what this command with the username.date is doing. I executed the command but the users home directory still shows in /export/home.

suicidaleggroll 08-05-2016 09:57 AM

"rm -fr" is a dangerous command. It means "delete this directory and every file and directory it contains without prompting for confirmation". Run as root, it will delete anything you tell it, including the operating system itself. Typos, accidental wildcards, or simply being in the wrong directory when you run it can result in a lot of damage. Used properly of course there's no problem, it's just "risky".

When you ran the command, did you get any error messages? An error should be the only thing that keeps it from completely removing the directory and its contents, which you said it didn't do. Either that or you typed the directory name incorrectly, did you use tab completion or copy-paste, or did you just type the name in by hand and hope for the best?

GooberJack 08-05-2016 10:12 AM

Thanks for the reply. I didn't get an error running the command. What I didn't quite understand is the instructions say to enter the username followed by the date.
example: username.080516

In /export/home the directories are only listed with the username and no date. So, if I run the command using the username.date format I'm not sure what it's removing since all the directories are just the username. In order to remove the directory and contents wouldn't I just enter the command followed by username only?

hydrurga 08-05-2016 10:18 AM

Quote:

Originally Posted by GooberJack (Post 5586481)
Thanks for the reply. I didn't get an error running the command. What I didn't quite understand is the instructions say to enter the username followed by the date.
example: username.080516

In /export/home the directories are only listed with the username and no date. So, if I run the command using the username.date format I'm not sure what it's removing since all the directories are just the username. In order to remove the directory and contents wouldn't I just enter the command followed by username only?

Could you possibly cut and paste the instructions here?

GooberJack 08-05-2016 10:27 AM

There's just two commands:

userdel -f <username>

Next is to cd to /export/home and type:

rm -fr username.date so the output looks like rm -fr username.080516

suicidaleggroll 08-05-2016 10:30 AM

Quote:

Originally Posted by GooberJack (Post 5586481)
Thanks for the reply. I didn't get an error running the command. What I didn't quite understand is the instructions say to enter the username followed by the date.
example: username.080516

In /export/home the directories are only listed with the username and no date. So, if I run the command using the username.date format I'm not sure what it's removing since all the directories are just the username. In order to remove the directory and contents wouldn't I just enter the command followed by username only?

You are correct. Running "rm -fr username.080516" when there is no directory called "username.080516" will not do anything, it will just silently exit. "rm -fr" will only do anything if the argument you give it is a real file/directory, in which case it will remove it.

Habitual 08-05-2016 10:30 AM

Quote:

Originally Posted by GooberJack (Post 5586456)
I'm trying to understand what this command with the username.date is doing. I executed the command but the users home directory still shows in /export/home.

I would expect ...
Code:

rm -fr username 080516
for bash history?

You can test using:
Code:

echo rm -fr username 080516
to see it as a "dry run".

Just a thought...

hydrurga 08-05-2016 10:42 AM

Is there a possibility that your implementation of userdel includes the configuration variable USERDEL_CMD in /etc/login.defs which automatically populates /export/home with the new folder username.date?

In this case, you would have to run the userdel command to create the username.date directory.

Just a thought.


All times are GMT -5. The time now is 04:10 PM.