[英]mv: cannot move 'water.txt' to '/liquid': Permission denied [Git bash] in Windows
I have created two directories in desktop as solid and liquid.Initially liquid doesn't have any files but solid has two files as rock.txt and water.txt.I tried to move water.txt to liquid but it throws and error.How can i fix this?我在桌面上创建了两个目录,分别是固体和液体。最初液体没有任何文件,但固体有两个文件,分别是 rock.txt 和 water.txt。我试图将 water.txt 移动到液体,但它会抛出错误。如何我可以解决这个问题吗?
''' $ mv water.txt /liquid ''' $ mv water.txt /液体
mv: cannot move 'water.txt' to '/liquid': Permission denied mv:无法将“water.txt”移动到“/liquid”:权限被拒绝
''' '''
Following your steps, your Desktop/
folder should look like this:按照您的步骤,您的Desktop/
文件夹应如下所示:
├── liquid
├── solid
│ ├── rock.txt
│ └── water.txt
There are two major issues causing this behaviour.有两个主要问题导致了这种行为。
Assuming you are currently in solid/
directory, you need to reference the relative path of the liquid/
directory.假设你当前在solid/
目录下,需要引用liquid/
目录的相对路径。 Since it resides in the same level as the parent directory of water.txt file, you need to use ..
(double dots) according to the unix convention.由于它与 water.txt 文件的父目录位于同一级别,因此您需要根据 unix 约定使用..
(双点)。 ( for more context read dot definition ) (更多上下文阅读点定义)
# currently in solid directory $ pwd /c/Users/USER/Desktop/solid # move file to liquid directory ✔ $ mv water.txt../liquid/
In Unix based systems, directories are typically represented by it's name followed by a front slash /
, not the other way around.在基于 Unix 的系统中,目录通常由其名称后跟前斜杠/
表示,而不是相反。 Ex: music/
.例如: music/
. In fact, putting /
in front of a directory name is prohibited in both Windows and Linux .事实上,在 Windows 和 Linux 中都禁止在目录名称前放置/
。 Moreover, when the two arguments are in the same directory, mv command interprets it as a rename operation on the first argument.此外,当两个 arguments 在同一目录下时, mv命令将其解释为对第一个参数的重命名操作。
# git bash thinks /liquid is a file in current directory; rename operation fails ❌ $ mv water.txt /liquid # git bash thinks liquid to be in upper level; no renaming; move succeeds ✔ $ mv water.txt../liquid/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.