[K12OSN] Script to flush down the drain files from every user home...

James P. Kinney III jkinney at localnetsolutions.com
Mon Jun 23 03:15:56 UTC 2008


On Sat, 2008-06-21 at 11:20 -0500, Les Mikesell wrote:

> > for users in `ls -1 /home`
> > do
> > cd /home/$user
> > rm -rf .mozilla .g* .cxoffice*
> > done
> > 
> > Just add more dotfiles to the list. This is a very aggressive script and
> > it will not spare any users. Make sure you have a backup of /home first.
> 
> I think as-is, that would delete all of the home folders since it sets 
> the variable "users" and uses "user" which will be empty.   Also you 
> don't want the extra stuff from -l in your ls listing and you probably 
> want to make sure the cd succeeded before removing anything.
> 
typo checking Les is on the case!

Yes that should be $users in all locations.
And yes the rm line is dangerous as it will try and run whether the cd
happens or not. "-1" makes things be a single column from the ls
command.

A better form would be :

for user in `ls -1 /home`
do
 for dotfile in .gnome .mozilla .cxoffice
 do
  rm -rf /home/$user/$dotfile
 done
done

If you know you want to clobber all the same files in all /home
directories

rm -rf /home/*/.mozilla

will remove the .mozilla directory in every /home directory on the
system.

As said in Spiderman "With great power come great responsibility.".
rm -rf is tremendously powerful. Use a ls -lr first to test what you are
about to remove!

> -- 
>    Les Mikesell
>     lesmikesell at gmail.com
> 
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
> 
-- 
James P. Kinney III          
CEO & Director of Engineering 
Local Net Solutions,LLC                           
http://www.localnetsolutions.com

GPG ID: 829C6CA7 James P. Kinney III (M.S. Physics)
<jkinney at localnetsolutions.com>
Fingerprint = 3C9E 6366 54FC A3FE BA4D 0659 6190 ADC3 829C 6CA7


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




More information about the K12OSN mailing list