1

I am reinstalling the older Ubuntu machines with the latest RHEL 6.0 in servers.

I have /etc/passwd and /etc/group and /etc/shadow file backed up for the list of user accounts that I need to create after reinstallation of OS.

I have installed RHEL 6.0 in couple of machines and I need to grant access to the users immediately.

I want to use the /etc/passwd and other files into this machine so that the users can start using the server with their user accounts. But, I do not wish to create a /home/user directory for the users for couple of reasons.

  • The users will be accessing only the partition /mounts which apparently has the project data.
  • I am eventually planning to configure NFS and openldap at a later stage. So, if I have to provide home directory for the users, I need to backup the home directory for the users in all the machines where I gave the local user account for users and put it in the NFS server which is a redundant step.

Is it possible to give users access without home folder? I have seen machines without /home directory using / as the home directory. But I am not sure if this is a safe step and I want the users to be unaware that their home directories do not exist.

EDIT

I see the users can be added without creating the home directory for them using the below command.

adduser --system --no-create-home USERNAME

But my challenge lies in how can I use the same user account as in /etc/passwd and other files without creating a home directory? I want the users be able to use their same passwords as in /etc/passwd now without a home directory.

  • As far as I know, each user who needs to access a Desktop environment must have a home directory writable by their account. – Joseph R. Jun 11 '14 at 21:18
  • @JosephR., the users do not need a desktop environment. They just need to be able to login to the server with their username/password and be able to access the machine. – Ramesh Jun 11 '14 at 21:19
  • In this case, you can just make / their home directory (and optionally make /home/user a link to /, but be very careful when removing it later!!). – Joseph R. Jun 11 '14 at 21:22
  • Note that -s /bin/false will not allow users to log in! – Joseph R. Jun 11 '14 at 21:22
  • @JosephR., I changed the useradd command. But that is not my main concern. My concern lies in using the same usernames/passwords as in /etc/passwd file. – Ramesh Jun 11 '14 at 21:25
4

When you're using /etc/passwd and /etc/shadow for user accounts (as set in /etc/nsswitch.conf and PAM), then entry in those two files are fully sufficient to create the account. (/etc/group may be needed too, for their groups).

All useradd does is edit those files. If you edit them yourself with vipw & vigr and add the user, you've created the account.

useradd wil also (optionally) create a home directory as well, basically doing:

cp -p /etc/skel /home/newuser
chown -R newuser:newgroup /home/newuser

That said, without a home directory, your users will face a lot of challenges, as many files are stored there—

  • Editor configuration files
  • Authorized keys for ssh
  • Shell startup scripts
  • Random program configuration files

You could set all their home directories to a single root-owned, mode 0755 (not writable by the users) directory with sane defaults for them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.