0

Using the cp command, one can move files and folders on linux.

I want to make a new user and move the contents of the skeleton map to their home directory.

I use this command:

cp -r /etc/skel/ /home/testuser/

However, this only creates a skel folder in testuser. The idea is that the contents of the /etc/skel folder be copied to /home/testuser, and not that a map be made in /home/testuser with those contents.

I've checked the man page: Link, but nothing on there really seemed like the solution to me.

Is there a way to do this, or do files really need to be moved manually, 1 by 1?

1 Answer 1

2

When creating new users on the system manually from the command-line using the useradd command, the -m switch can be used to automatically create a home directory as well as copy the contents of the skeleton directory into it.

In your case, however, the following will be sufficient:

cp -R /etc/skel/* /home/testuser/
6
  • Sadly, this did not copy the contents. Instead, there is now an empty folder /home/testuser/testuser
    – KdgDev
    Jun 17, 2010 at 17:38
  • Even worse, every folder I now create with useradd has the empty "testuser" folder in it. Even after a restart, it still happens.
    – KdgDev
    Jun 17, 2010 at 17:45
  • Even after deleting the user and cleaning the passwd and shadow file and restarting, it is still happening.
    – KdgDev
    Jun 17, 2010 at 18:00
  • 2
    @WebDevHobo: It sounds like you may have copied testuser into skel by reversing the arguments to cp or somehow overwritten the contents of skel or created a symlink in it. What does ls -la /etc/skel give you? Jun 17, 2010 at 18:27
  • Yes, the empty folder was indeed now located in skel for some reason. I don't remember doing it...
    – KdgDev
    Jun 17, 2010 at 20:36

You must log in to answer this question.

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