1833776 Members
2386 Online
110063 Solutions
New Discussion

Deleteing users

 
SOLVED
Go to solution
Peter Gillis
Super Advisor

Deleteing users

Hi,
I am curious,why when you delete a user but leave files and directories in place do some of the files/directories remain with an owner name of owner name and other times with an owner name of the owner id? Would it screw things up if you were to change the owner id back to the owner name? If I was to do this to two userids would they end up with the smae number (userid #) in the owner field or are they really just owner names converted to owner ids?

Does that make sense, and can anyone clear that up for me?
Thanks Maria.
10 REPLIES 10
Balaji N
Honored Contributor
Solution

Re: Deleteing users

Hi,
If you leave the files of the user and just delete the user, all the files/directories owned by the corresponding user will show the user-id only. This is because there is no uid to user name resolution since there is no entry in the passwd file or the corresponding NIS maps.
And if you attempt to change the owner id to its name i guess it will give an error saying no such user id exists.

my 2p's.
hth
-balaji
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.
KapilRaj
Honored Contributor

Re: Deleteing users

Diff. to get what u need ..... OK Let me explain my views in UM ....

When u delete a user and leave some of his file/directories, The oener for those files/directories would be the id (number). If you create another user with the same uid (nopt user name), the owner will be set as the newly created user..

Eg: User Name : tech001
User id : 1023

ls -ld /user/tech_001.dbf
-rw------- 1 tech001 techgrp 8383 Oct 20 1998 /user/tech_001.dbf

- Delete the user and leave the above mentioned file

ls -ld /user/tech_001.dbf

-rw------- 1 1023 techgrp 8383 Oct 20 1998 /user/tech_001.dbf

- Create another user tech002 with 1023 as the uid,

ls -ld /user/tech_001.dbf

-rw------- 1 tech002 techgrp 8383 Oct 20 1998 /user/tech_001.dbf

Hope i did'nt confuse u...

Nice day,

kaps
Nothing is impossible
Sridhar Bhaskarla
Honored Contributor

Re: Deleteing users

Hi,

Your message is slightly confusing to me.

When you delete the user, then the files owned by him will carry the ownership of his/her numeric login id.
However, if you have another user with the same id, then they will appear with the other login name as the owner.


-Sri



You may be disappointed if you fail, but you are doomed if you don't try
T G Manikandan
Honored Contributor

Re: Deleteing users

Hi Maria,

When you delete a user leaving his files,then those files will have the UID as the owner of the file.
When you create a new user of the same UID then that user will become the owner of those files.
When you create the same user with the same UID as before then the permissions and the ownership should be the same,

S.K. Chan
Honored Contributor

Re: Deleteing users

To add a few points ..
Before you delete a user account it is important to make sure you find out first where are the location of this user's files and directories in your system ( I'm not talking about just the home directory as the user could have files everywhere out of his/her home dir). Once these are identified, you would determined if they are important files or not (eg: data files) and if they are some chose to transfer the ownership to another UID. If they are not, these files and dirs should be deleted first before you blow away the account.
Rajeev  Shukla
Honored Contributor

Re: Deleteing users

Hi Maria,
Under Unix all files are owned by some or the other user which is always in the numeric form(user ID and Group ID) But this is always translated from /etc/passwd and /etc/group file.
So when you delete a user the files owned by that gets subsituted by the numeric Id because it can not find refrence of that ID to the user name any more. And this owenship information is kept in the Inode as long as the file is there or the ownership is not changed manually. Ok now when you create a user with the same UID then the UID gets translated by password file and the user name is replaced by that ID. In other sence this user becomes the owner of those files.
To delete a user whose files you dont require use userdel -r . Also you can search the whole system for (which will slow down the system a bit) for any files with numeric UID. Use find with -nouser option. Or go through the man pages of find.

Bill Hassell
Honored Contributor

Re: Deleteing users

The inode information never carries the username, only the user ID. The ll command is performing a translation for you by looking in the passwd and group files, then replacing the numbers with the more meaningful user/group names. So the directories and files are always owned by numbers which will be displayed when ll can't find a match.

How are you deleting users? SAM and userdel (actually: /usr/sbin/userdel) will handle the former user's files/directories. Simply removing an entry in the passwd file leaves user 'droppings' all over the system.


Bill Hassell, sysadmin
Peter Gillis
Super Advisor

Re: Deleteing users

Thankyou to everyone who tried to help me with this. Things are much clearer now - but I still wonder how it is that not all the files that were left behind changed the owner name to the uid.

Bill, I am using sam to remove the users.
Thanks again.
Sridhar Bhaskarla
Honored Contributor

Re: Deleteing users

Hi Maria

// but I still wonder how it is that not all the files that were left behind changed the owner name to the uid. //

can you do a 'grep owner /etc/passwd' and see if the owner is still there?. If not, there is no way you can see the files owned by that login name. The only possibility is if you have duplicate ids.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
James R. Ferguson
Acclaimed Contributor

Re: Deleteing users

Hi Maria:

If I recall correctly, SAM offers you the ability to simply delete the user and simply leave his/her files untouched; to delete the user *and* all files in his/here $HOME directory; to delete the user *and* all files owned by him/her; or to delete the user and transfer the ownership of any of his/her files to another user. Does this clarifies the behavior you see.

Regards!

...JRF...