Turns out a new blank folder with correct permissions works just fine. In order to delete a directory (dir) on your Mac running macOS via the Terminal application you can make use of the rmdir command. I went ahead and copied over the user's files, set flags and permissions, and attempted a login.įor some reason I thought that the Server App-generated home directory template, the Library folder specifically, was important to this process.
$HOMEDIR_PATH and $uName are the values of the main home folder repository for all of our users and specified username, respectively. # rename old user directory and create new, blank on in its place # switch directories to the root home folder directory Thanks for the comprehensive, updated workflow! The final mkdir command creates a new, blank home directory for a user, which is a little different from what Server App does when it both creates the directory and populates it with sub directories and (I'm guessing) the appropriate permissions.Ĭurbing my skepticism, I went ahead and tried this out, beginning with a few lines to rename the old home and create the new one: How can I use Terminal commands to replicate this behavior and generate a fresh home folder for an existing user? You can make changes to your files right.
nanoThis seems to do what it's supposed to do. create /Users/userName NFSHomeDirectory /Users/userName The resulting commands would read something like this in El Capitan: I'm fairly green at this, but my nearest guess is that I need to run the dscl command to either create or change the user's NFSHomeDirectory entry ( source).
Create new folder in mac terminal how to#
Server app then creates a new blank home folder for the user, with the correct internal directories, and I can begin copying over their personal files into it.īut to save myself a bunch of clicking and typing, I want to execute this process via the command line. In this video you'll learn how to easily create a new directory on your computer right from the terminal command line. "None - Services Only"), renaming their old home folder to userName-old, and then setting the location back to its original. This involves changing their home folder's location in the Server app (e.g. Occasionally I will need to recreate a Network User's home directory in order to start them with a "clean" account. The following screenshot shows an example of a script created using a template.
Create new folder in mac terminal code#
I'm exploring bash shell scripting (Terminal) to manage my routine tasks with and have one process that's proving challenging to reproduce in the command line. A new Script Editor document window opens containing prewritten code and preconfigured settings.