Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

chown, and userdel problems


  • Please log in to reply

#1
SuperSam

SuperSam

    Member

  • Member
  • PipPipPip
  • 693 posts
Hi, I have come across a problem on my server. I am trying to delete an old user (samj), and create a new one (supersam). I cannot delete the old user as;
userdel: error deleting password entry
userdel: error deleting shadow password entry
userdel: /home/.sites/143/site2/.users/78/samj not owned by samj, not removing

I know where the files are that "samj" owns, but chown doesn't work properly when I try to change it to the user "supersam";

Report bugs to <[email protected]>.
[root web]# chown -R supersam
chown: too few arguments

Sun Cobalt RaQ 4, running 550 OS (based on RH9)

-- If you need to know any other information, please ask.

Thanks for any help.

Edited by SuperSam, 30 March 2006 - 10:53 AM.

  • 0

Advertisements


#2
dsenette

dsenette

    Je suis Napoléon!

  • Community Leader
  • 26,047 posts
  • MVP
looks like chown is looking for more info....type man chown and see what the FULL syntax is supposed to be
  • 0

#3
SuperSam

SuperSam

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 693 posts
Hi dsnette, thanks for the reply.

However, I have come across another problem...
[root /home]# chown -R --from=samj supersam /
chown: getting attributes of `//proc/2364/fd/3': No such file or directory

Forgot to say that I had already created the "supersam" user, just in case anybody would guide me through that. Once again, thanks for any help...

Edited by SuperSam, 30 March 2006 - 10:52 AM.

  • 0

#4
Kemasa

Kemasa

    Nobody

  • Technician
  • 1,727 posts
First, if you are trying to remove a user most likely you need to do it as "root" since then the protections are not an issue, but you need to be very careful since you can do anything and that can be bad. The /proc file system is not something you want to be messing around with unless you know what you are doing.

The chown command requires two arguments as a minimum. The first is the user you want to change the files/directories to and the second is what you want to change. The "-R" is recursive, as I suspect you know.

Edited by Kemasa, 02 April 2006 - 12:46 PM.

  • 0

#5
SuperSam

SuperSam

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 693 posts
Yes, I knew the above. I was also using the "su -" command to get the full root properties.

Its because the website is not in "samj"s home directory, but as it is an administrator I can jump up folders, where I went to my websites home directory and created the website (using samj). I just need to change the ownership of these files to "supersam", so that then I can still use the samj@*.* email address.

If I could also change the username of "samj" it would be a step forward, as then I could use the samj@*.* email address on supersam.

Can you help me with either anybody?

Thanks.
  • 0

#6
Kemasa

Kemasa

    Nobody

  • Technician
  • 1,727 posts
I am not quite sure of what you are asking, but you change the uid of "samj" in the passwd file (/etc/passwd, typically using vipw). You can give samj a new uid and use the old uid for supersam.

The passwd file is a mapping between the username and the uid. Files are owned by the uid, not the username, but translated by the ls command. You can have more than one username per uid, but there can be some issues with that.
  • 0

#7
SuperSam

SuperSam

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 693 posts
Basically, I want "samj" deleted, but NEED the files he has. The files are in the sites directory (www.eee.bbb/site) I need to have these files changed ownership, or download ALL to my computer, delete, then reupload. But if I do choose that, I will probably have to upload for an entire day.
  • 0

#8
Kemasa

Kemasa

    Nobody

  • Technician
  • 1,727 posts
What site?

There is something which you not saying I think.

If there are files on another computer, then the ownership or the passwd file would need to be changed on that computer. The uids don't need to match between computers, but it is a good idea. On one computer the username fred could be set to uid 1001, on another computer fred could have uid 1024. It does not matter unless something like NFS is used to remotely mount the filesystem.
  • 0

#9
SuperSam

SuperSam

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 693 posts
I don't think you fully understand me Kemasa. I'll just explain in full exactly what I need to do.

I have a website, www.snjj.co.uk, and I have, for around 3 years used the email address "[email protected]". Recently something in the username "samj" became corrupted, so I had to create a new username, and delete the old one. Creating the new one was easy, and I had done it before. However deleting the old one was a problem, because "samj" has files outside of his own home directory. Now, I know that his files outside his directory are ONLY going to be in the website directory of www.snjj.co.uk. So I need to have these files changed ownership to the new user, "supersam".

I need to delete the old user "samj" so I can use "samj@*.*.*" as my email alias again. As the user "samj" owns the email alias "samj", as it is his username I cannot use it on "supersam".

Also, if there is a way I could RENAME the USER "samj" to something else, so I can use the email alias on supersam.

Now I hope you understand me, if there is anything I missed out or you need to know please ask.
  • 0

#10
Kemasa

Kemasa

    Nobody

  • Technician
  • 1,727 posts
Do you have access to the website machine or it is just as a user? Based on the previous messages it seems like you do.

You can use the find command to find all the files owned by a given user:

find / -user samj -print

but based on the previous messages you changed the ownership (the error with the /proc filesystem can be ignored), so it might not find it. It does help if you know which subdirectories the files are in so as to avoid filesystems such as /proc, which is a bit strange.

There are some files which are based on the username, such as mail files in /var/spool/mail. Otherwise you can rename the username in the passwd file.

You can redirect email so that email to samj goes to supersam, the exact details depends on what mail package you are using, often it is /etc/aliases. This is true even if the account samj still exists.

Are the files outside of the home directory an issue? Could you just restore or install new files in the home directory?

You can use the find command above to find all the files owned by a given user, then you can decide what to do with the files. Often it helps to save the output to a file so that you can use the list again to do what you need.

So, the first step is to find all the files which you are interested in and either remove, move or change the ownership of those files. You can also move the home directory of the use samj, to keep it and then create a new user or move an existing user to that name (make sure that the ownership matches).

In your first message there was an error due to a file not being owned by samj, which could be manually removed or the ownership changed and the command executed again. The userdel will not remove all the files and you can manually do the same thing as it does, which I personally think is best as that gives you more control.

Does that answer your question?
  • 0

#11
SuperSam

SuperSam

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 693 posts
I've used the FIND commands to find what files "samj" owns. I know what he owns, I just want the ownership changed and the "samj" account deleted. The email account on it entirely is corrupted.

The server is MINE, I own the entire box and have all the permissions needed, just need the commands :\.
  • 0

#12
Kemasa

Kemasa

    Nobody

  • Technician
  • 1,727 posts
To change the ownership, either use:

chown NEWUSER FILES

you can use the -R as in your other message, but it is best to start at a subdirectory instead of / to avoid /proc.

You can use the find command:

find / -user samj -exec chown supersam {} \;

If it is just the email which is corrupted, you can remove the mail directory in the home directory (.Mail, .mail, Mail or mail, perhaps something else, check the mail program or take a look around). Also you may need to remove /var/spool/mail/samj. You need to see where the mail is being stored and remove the files. That is much easier than removing the account.

To remove the account, you can use userdel (fix the errors and try it again) or use vipw to delete the account from /etc/passwd, remove the samj line, save the changes and then it will ask if you want to edit the shadow file, say yes and remove the line with samj. Then edit /etc/group and remove samj from there.

You could just remove the entire home directory of samj (or move it), create or copy a new home directory and change the ownership of the whole directory to samj. Depending on the mail setup, the mail is often stored in the home directory.
  • 0

#13
SuperSam

SuperSam

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 693 posts
I deleted his mail, and the "mbox" folder. The username cannot be deleted because it has files outside of his home directory.

Will "find / -user samj -exec chown supersam {} \;" change the ownership of files from samj to supersam?
  • 0

#14
Kemasa

Kemasa

    Nobody

  • Technician
  • 1,727 posts

I deleted his mail, and the "mbox" folder. The username cannot be deleted because it has files outside of his home directory.

Will "find / -user samj -exec chown supersam {} \;" change the ownership of files from samj to supersam?


Yes, the find command would change the ownership.

Have you checked to see if there are any other mail files?
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP