Manage files in Terminal on Mac (2024)

Manage files in Terminal on Mac (1)

In Terminal, you can move and copy files locally or remotely using the mv, cp, and scp command-line tools.

Tip: It’s easier to move and copy files using the Finder. See Organize files in folders.

Open Terminal for me

Move a file or folder locally

  • In the Terminal app Manage files in Terminal on Mac (2) on your Mac, use the mv command to move files or folders from one location to another on the same computer. The mv command moves the file or folder from its old location and puts it in the new location.

    For example, to move a file from your Downloads folder to a Work folder in your Documents folder:

    % mv ~/Downloads/MyFile.txt ~/Documents/Work/MyFile.txt

    You can also change the name of the file as it’s moved:

    % mv ~/Downloads/MyFile.txt ~/Documents/Work/NewFileName.txt

See the mv command man page.

Copy a file or folder locally

  • In the Terminal app Manage files in Terminal on Mac (3) on your Mac, use the cp command to make a copy of a file.

    For example, to copy a folder named Expenses in your Documents folder to another volume named Data:

    % cp -R ~/Documents/Expenses /Volumes/Data/Expenses

    The -R flag causes cp to copy the folder and its contents. Note that the folder name does not end with a slash, which would change how cp copies the folder.

See the cp command man page.

Copy a file or folder remotely

  • In the Terminal app Manage files in Terminal on Mac (4) on your Mac, use the scp command to copy a file or folder to or from a remote computer.

    scp uses the same underlying protocols as ssh.

    For example, to copy a compressed file from your home folder to another user’s home folder on a remote server:

    % scp -E ~/ImportantPapers.tgz username@remoteserver.com:/Users/username/Desktop/ImportantPapers.tgz

    You’re prompted for the user’s password.

    The -E flag preserves extended attributes, resource forks, and ACL information.

    The -r flag, which isn’t used in this example, causes scp to copy a folder and its contents.

See the scp command man page.

Noderīgs?

Pateicamies par atsauksmēm!

Manage files in Terminal on Mac (2024)
Top Articles
Latest Posts
Article information

Author: Golda Nolan II

Last Updated:

Views: 6107

Rating: 4.8 / 5 (78 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Golda Nolan II

Birthday: 1998-05-14

Address: Suite 369 9754 Roberts Pines, West Benitaburgh, NM 69180-7958

Phone: +522993866487

Job: Sales Executive

Hobby: Worldbuilding, Shopping, Quilting, Cooking, Homebrewing, Leather crafting, Pet

Introduction: My name is Golda Nolan II, I am a thoughtful, clever, cute, jolly, brave, powerful, splendid person who loves writing and wants to share my knowledge and understanding with you.