Home Forums OS X Server and Client Discussion Questions and Answers Terminal Command to Create Folder for Every User

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #374994
    mrhayes
    Participant

    Here is what I tried:

    sudo -> password

    mkdir /Users/*/Sites

    However, three accounts already have /Sites, so I got an error saying /Sites folder exists in such and such account. However, it didn’t make /Sites in the other 100 or so folders.

    I run the Xserve as classroom Webserver hosting student sites. I created user accounts using Webmin and the directories are empty. For student Websites to show on the Internet, they have to be in their /Sites. So, I need a way to create /Sites for every user, excluding those accounts that already have /Sites.

    #374995
    Magus255
    Participant

    You might need more than just a single command. Something like this should work.

    #!/bin/bash
    for i in `ls | grep -v [.]`; do
    mkdir /Users/”$i””/Sites
    chown “$i” /Users/”$i”/Sites
    done

    #374996
    mrhayes
    Participant

    Unfortunately, you have lost me a bit. I have little experience with terminal. I may be the Net Tech for the 2 Xserves and 40 Macs in my lab, but that is just an adjunct duty to teaching. It is learn as I go since there is no support from the school. With that said, I need a little more specific help. 🙂

    Do I:

    1. sudo -s
    2. enter #!/bin/bash -> return
    3. enter for i in `ls | grep -v [.]`; do -> return
    4. enter mkdir /Users/”$i””/Sites -> return
    5. chown “$i” /Users/”$i”/Sites -> return

    ?

    I appreciate the help.

    #375011
    Magus255
    Participant

    Put all of that into a text file, make it executable then run it as root or with sudo. Obviously you should test it before running it on your main server.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Comments are closed