RSS Subscription
Linux Howtos & Tutorials

Enter your email:

Delivered by


NOTE:New tutorials are from LinuxCareer.com

Poll

Do you own or wish to have iPhone?
 


Linux eBooks FREE Download
A guide to programming Linux kernel modules
Introduction to Linux - A Hands on Guide
A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

Linux: The Hacking Solution (v.3.0)

SQLite 3 with PHP Essential Training – Free Video Training Tutorials

This guide will introduce you to the world of GNU/Linux

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)

Advanced Bash-Scripting Guide

Set up, maintain, and secure a small office email server

Partner Linux Sites:
How-To.LinuxCareer.com
Jobs.LinuxCareer.com
TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
All For Linux

Remove all files and directories owned by a specific user

Question:

Hi, how do I remove all files owned by a certain user. What I need is to find all files and directories and remove them system wide.

Answer:

The tool which may come handy to is a find command. Find command will find all files and directories owned by a specific user and execute rm command to remove them. The following command will find and remove all files within /home/ directory owned by a user "student". The following command is executed as root user:

NOTE: replace /home with your target directory.

# find /home/ -user student -exec rm -fr {} \;

 

The following command will do the same however, it will search for a file and directories which belong to a group student:

 

# find /home/ -group student -exec rm -fr {} \;

However, if you are trying to remove a user from the system along with his/her files and directories you may find deluser command also useful. deluser will remove user from the system as well as remove all files associated with this user. The command below will demonstrate just that where the target is a user "student"

# deluser --remove-all-files student

Hope this helps...

Linux questions and answers

Share this linux post:

Submit Remove all files and directories owned by a specific user in Delicious Submit Remove all files and directories owned by a specific user in Digg Submit Remove all files and directories owned by a specific user in FaceBook Submit Remove all files and directories owned by a specific user in Google Bookmarks Submit Remove all files and directories owned by a specific user in Stumbleupon Submit Remove all files and directories owned by a specific user in Technorati Submit Remove all files and directories owned by a specific user in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.


Linux eBooks FREE Download