473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Finding orphan files in linux system after owner account is deleted

I want to write a perl script for the below condition

Files not contained in the user's home directory and files contained in the user's home directory, and owned by that user(user's account deleted), will remain on the system. The file will still be owned by the deleted account's user ID (UID).

I want to throw a warning message whenever files(orphaned files) with no owners (i.e owner's deleted) are exists in the system.
Mar 15 '10 #1
6 6632
numberwhun
3,509 Expert Mod 2GB
Ok, you have told us what you want to do, but do you have a question? Have you started coding it? If so, and you are stuck, post your code here and ask your question(s) and we will help you.

My point is that we are not a coding service, but will happily help you achieve your goal.

Regards,

Jeff
Mar 16 '10 #2
Dude i want to write a perl script.. I thought of using the stat function but dont have any clue about how to go about it.. any help will be appreciated... thanks..
Mar 16 '10 #3
numberwhun
3,509 Expert Mod 2GB
Ok, dude, so give it a shot. Any Perl command you want to use, simply look up its page at perldoc.perl.org.

The issue I have with stat though, with relation to your issue, is that it will return the users UID, even if the file in question has the users name on it. The files you are looking for have the users UID, due to the acct being deleted already.

What you really want to do is scour the directory system and look for files that are owned by the UID in question. I have a few ideas in my head at the moment right now on how to do it, but to put them here would be like a book and probably be too confusing to read. (trust me).

One idea is to use the system level command "find" to look for all files on the system owned by the specific UID and store the results in a file. Then, open the file and read it in and then you can do whatever you need to to the files. You can even use Perl's chown function to change ownership of the files to someone else, or even Perl's unlink function to remove the file completely. Its up to you.

If you get stuck, post your code here and let us know the problem you are having and we will help.

Regards,

Jeff
Mar 16 '10 #4
RonB
589 Expert Mod 512MB
See:

File::Find - http://search.cpan.org/~dapm/perl-5....b/File/Find.pm
man find
man stat
man finger
Mar 16 '10 #5
What u said is exactly true, but the problem here is i do not have any list of users whose accounts have been deleted. The first thing what i need to do is find the files whose owner account have been deleted and report the warning message for those files saying .. ORPHAN FILES FOUND IN THE FILE SYSTEM.
Mar 17 '10 #6
RonB
589 Expert Mod 512MB
What makes you think you need to have a list of deleted users prior to running the script?

Step 1) build a hash table of all user accounts in /etc/passwd

Step 2) use the system's find utility or the perl File::Find module to get each and every file in the system.

Step 3) as you "find" each file, stat it to get the uid.

Step 4) lookup the uid in the hash table
a) do something if it exists
b) do something else if it doesn't


That's the basic outline for this homework assignment.
Mar 17 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Hal Vaughan | last post by:
I want to have a config file for my program, which means I need to know where the config file is. If I type: java myclass and it runs myclass.class, is there any way to obtain the location of...
22
by: Tony Houghton | last post by:
I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use "~/.bombz", in Windows something like "C:\Documents...
24
by: Mark Goldin | last post by:
Can I run my aspx pages from Linux box? Will these pages be able to connect to SQL server? Thanks
0
by: newspost2000 | last post by:
I have built a Domino Web Application. I am looking for a tool that will be able to scour my site and find all files that are orphaned. I have found a few tools on the web that can do this kind of...
7
by: newspost2000 | last post by:
I have a golden list of urls to each and every file on our corporate website. This includes all webpages and file resources. I am looking for a tool whereby I can plug in the base url of our...
2
by: nospam | last post by:
I am writing this app in .net 2003 since all machines don't have 2.0 framework. I am trying to delete old profiles, but I am getting access denied or file in use errors. A lot of these files I am...
3
by: Bruno LIVERNAIS | last post by:
Hi, We are currently installing a DB2 V9 ESE on a Linux server (RHEL4U4-x86_64). Installation runs successfully on each node. Database user environment is OK and the instance is well created. To...
7
by: elgiei | last post by:
Good morning at all, i have to implement a server,that every n-seconds (eg. 10sec) sends to other clients,which files and directory has been deleted or modified. i build a n-tree, for each...
1
by: Okonita | last post by:
Hi all, I have gone through the process of installing DB2 UDBv9 Express-C in my local linux environment. I am used to having icon placed on my Desktop or taskbar for easy access to (db2cc)...
0
by: rkmr.em | last post by:
the memory usage of a python app keeps growing in a x86 64 linux continuously, whereas in 32 bit linux this is not the case. Python version in both 32 bit and 64 bit linux - 2.6.24.4-64.fc8 Python...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.