Copy a file to the root directory

terminal

I have a satnav device which the TomTom Home software does not recognise since it was updated. The TomTom help instructed me to download a folder and copy it to the root directory of my Mac. Using Cmd-G shows me the root directory but does not allow me to copy the folder into it.

How do I copy this folder into my root directory? (I'm running El Capitan.)

Best Answer

OS X prevents you from copying files and folders to the root directory or your "Macintosh HD". It prefers you write files only in your user directory to prevent accidental file deletions, overwrites, etc.

However, if you have a file or folder on your Desktop, and you are an administrator on the computer, you can copy the file using your super user privileges.

Simply open up the Terminal application. You can use Spotlight to search for it or go to your Applications folder, then Utilities folder.

Once in Terminal, you'll be faced with a prompt.

Run the command below to put the file or folder in your root directory. Put the name of the file or folder in place of "FILE".

sudo cp -p Desktop/FILE /

Press the return key. You'll be prompted for your password.

sudo is a command to provide super user privileges. cp is copy. -p means to preserve the file owner and permissions.

If you are required to change the owner or permissions of the file, you can run a command like chown change owner or chgrp change group or chmod change file permissions.