在Unix/Linux中将文件移动到其他目录所需的权限 [英] Permissions required to move file to different directory in Unix/Linux

查看:723
本文介绍了在Unix/Linux中将文件移动到其他目录所需的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想澄清所需的权限,以便将文件A从目录B移到目录C(我想该命令将是"mv B/AC/A",名称不变).

I would like clarification on the permissions required, in order to move a file A from directory B to directory C (the command would be "mv B/A C/A", I think), with name unchanged.

我是否正确认为需要以下条件?

Am I correct to think that the following are required?

  1. 执行此操作的用户/组必须具有目录B的写许可权(或B必须具有设置的许可权标志以允许所有用户/组都可以写它)
  2. 进行移动的用户/组必须具有目录C的写许可权(或C必须具有设置的许可权标志以允许所有用户/组进行写)
  3. 执行移动的用户/组必须具有文件A的写许可权(或A必须设置许可权标志以允许所有用户/组写文件)
  1. The user/group doing the move must have write permission for directory B (or B must have permission flag set to allow all users/groups to write it)
  2. The user/group doing the move must have write permission for directory C (or C must have permission flag set to allow all users/groups to write it)
  3. The user/group doing the move must have write permission for file A (or A must have permission flag set to allow all users/groups to write it)

谢谢.

推荐答案

实际上,移动文件是在单个文件系统上重命名文件,或者是创建副本并删除原始文件(通常仅在移动时从一个文件系统到另一个文件系统的迁移).

Actually, moving a file is either a rename of a file on a single file system or creating a copy and deleting the original (typically only done if the move is a migration from one file system to another).

无论哪种情况,您都需要执行 ,并且当然需要具有对目标目录和源目录的写入权限.但是,对于在单个文件系统上仅重命名(并且从一个目录移动到另一个目录也可以),您 不需要任何文件本身的权限.可以清除所有权限,仍然可以移动(重命名)它(只要您具有目录的写入执行权限).

In either case you need execute and of course write permissions to the target directory and the source directory. However, for a mere rename (and moving from one directory to another can be just that) on a single file system you do not need any permissions on the file itself. It can be cleared of all permissions and still you can move (rename) it (as long as you have write and execute permissions for the directories).

对于真实副本(将文件移动到其他文件系统时需要),您需要对文件本身具有 read 权限. 没有原始文件的写入权限是必要的,因为删除文件不是写入文件(而是写入文件所在的目录).

For a real copy (as it is needed when you move the file to a different file system), you need read permissions on the file itself. No write permissions on the original are necessary, as deletion of a file is not writing to it (but to the directory it is in).

这篇关于在Unix/Linux中将文件移动到其他目录所需的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆