0

I have a problem about linux user, I use a command to add user like:

useradd -u 532 -d /data/test01 -g test test01

but when I login as test01 and run mkdir x, it becomes like:

nobody test x

Why user becomes nobody? How do I fix it ?

13
  • Perhaps better at Ask Ubuntu?
    – 11684
    Mar 13, 2013 at 8:19
  • or superuser if it's not ubuntu. [note to admin : those 2 comments predate the migration and could be deleted] Mar 13, 2013 at 8:21
  • Could you provide the output of grep 532 /etc/passwd?
    – Huygens
    Mar 13, 2013 at 8:32
  • test01:x:532:528::/data/test01:/bin/bash
    – Rosser
    Mar 13, 2013 at 8:34
  • If you do ls -ldn x do you get 532 528 x for your directory ownership? And what about grep nobody /etc/passwd?
    – Huygens
    Mar 13, 2013 at 8:38

3 Answers 3

2

Another possible explanation is that you run this stuff on a filesystem which is fixed to one user.

Cases for this could be ntfs or vfat.

A nfs mount with root_squash (the default) might be another reason.

0

You can use the usermod command to modify various user parametes like the username and the UID.

0

User alias

A possible explanation is that you already had a user called nobody with the UID (User ID) 532. The result is you have created a "user alias".

You either can try to specify another UID for your user (or let the system pick-up one). Or you can leave it like that. The only security risk is that if a service or other user can access nobody's data then it will be able to access your data.

NFS User ID Mapping

For users to have the feeling they are accessing their own files, the UID on the NFS server should match the UID on the NFS clients. Although, you want to avoid that for root at least.

By default, NFS exportfs will choose UID/GID of 65534 which corresponds to your user nobody's UID. You need to instruct the NFS server not to map all UID to 65534 or if this is the wanted behaviour, you need to specify the mapped default UID.

For the first case, remove the all_squash and replace it by root_squash, but bare in mind that any non root user with a similar UID between the NFS server and any clients will be a match, so they own the files"

For the second case, keep the all_squash but add anonuid=532 (you can use also anongid for the GID (or Group ID)).

Example:

/               pc001(rw,root_squash)
/home/joe       pc002(rw,all_squash,anonuid=532,anongid=100)

Note: the changes should be done in the file /etc/exports on the NFS server.

2
  • my nobody uid is 99 : nobody:x:99:99:Nobody:/:/sbin/nologin
    – Rosser
    Mar 13, 2013 at 9:26
  • Thank for your explanation + solution , but the /etc/passwd in my NFS server is the same form NFS client , and my NFS server set is like : (rw,no_root_squash,sync), it should use the same uid not nobody...
    – Rosser
    Mar 14, 2013 at 16:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .