You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用Bash将MacOS的Documents目录移回默认位置?

How to Move Your Documents Folder Back to Default Location

Hey there! Let's walk through this step by step since you're still getting comfortable with Bash. First, let's recap what the original script did—this is key to fixing this right:

The original script moved your actual Documents folder into Box Sync, then created a symbolic link (that's the ln -s part) at your old /Users/$USER/Documents path. This link acted like a shortcut: any time you saved something to "Documents", it actually went to the folder inside Box Sync.

The Problem With Your Current Script

If you run your existing mv command directly, it'll cause issues. Right now, /Users/$USER/Documents is a soft link pointing to /Users/$USER/Box Sync/Documents. Trying to move the real folder into the link would either throw an error (since you can't move a folder into itself indirectly) or accidentally mess up your file structure.

Correct Steps to Fix This

Follow these commands in order to safely move everything back:

  1. Delete the symbolic link first (critical—don't skip this!)

    rm /Users/$USER/Documents
    

    Important: Don't add -r here! -r would delete the actual files in Box Sync, not just the shortcut. Since this is a soft link, a simple rm removes only the link itself.

  2. Move the real Documents folder back to your home directory

    mv /Users/$USER/Box\ Sync/Documents /Users/$USER/
    

    If you get a permission error here, you can add sudo at the start—but only if necessary. Most user folder operations don't require root access unless the original script messed up permissions.

  3. Verify it worked
    Run this command to check if /Users/$USER/Documents is now a real folder (not a link):

    ls -l /Users/$USER/Documents
    

    Look at the first character in the output:

    • d means it's a real directory (good!)
    • l means it's still a link (double-check step 1 if this happens)

Quick Notes

  • You don't need to keep sudo in your script unless you hit permission blocks. Using sudo unnecessarily can cause permission issues down the line.
  • If you ever need to check if a path is a link again, ls -l is your go-to tool—it'll show you where the link points if it's one.

内容的提问来源于stack exchange,提问作者deefo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:27:23