LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 08-05-2016, 09:26 AM   #1
GooberJack
LQ Newbie
 
Registered: Aug 2016
Distribution: CentOS 6.4
Posts: 7

Rep: Reputation: Disabled
Question 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.
 
Old 08-05-2016, 09:57 AM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
"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?

Last edited by suicidaleggroll; 08-05-2016 at 09:59 AM.
 
Old 08-05-2016, 10:12 AM   #3
GooberJack
LQ Newbie
 
Registered: Aug 2016
Distribution: CentOS 6.4
Posts: 7

Original Poster
Rep: Reputation: Disabled
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?
 
Old 08-05-2016, 10:18 AM   #4
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by GooberJack View Post
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?
 
Old 08-05-2016, 10:27 AM   #5
GooberJack
LQ Newbie
 
Registered: Aug 2016
Distribution: CentOS 6.4
Posts: 7

Original Poster
Rep: Reputation: Disabled
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
 
Old 08-05-2016, 10:30 AM   #6
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by GooberJack View Post
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.
 
Old 08-05-2016, 10:30 AM   #7
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by GooberJack View Post
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...
 
Old 08-05-2016, 10:42 AM   #8
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disk usage question joboy Debian 11 01-17-2016 11:13 PM
Memory usage question gymnart Linux - Hardware 4 10-26-2009 11:38 AM
Cpu usage question mokku Linux - Server 6 09-02-2008 08:33 AM
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li rags2k Programming 4 08-21-2004 04:45 AM
Memory usage question oneandoneis2 Linux - General 2 06-27-2004 12:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration