相关疑难解决方法(0)

如何将子目录(和文件)移动和覆盖到父目录?

我想移动到父目录的子目录中有大量文件和目录。目标目录中已经有一些文件和目录需要覆盖。只存在于目标中的文件应该保持不变。我可以强迫mv这样做吗?它 ( mv * ..) 抱怨

mv: cannot move `xyz' to `../xyz': Directory not empty
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

command-line shell files

205
推荐指数
5
解决办法
54万
查看次数

如何复制合并两个目录?

我在Linux中有两个具有这种结构的目录images和images2:

/images/ad  
/images/fe  
/images/foo  
Run Code Online (Sandbox Code Playgroud)

...和其他 4000 个文件夹

另一个是这样的:

/images2/ad  
/images2/fe  
/images2/foo
Run Code Online (Sandbox Code Playgroud)

...和其他 4000 个文件夹

这些文件夹中的每一个都包含图像,图像和图像2下的目录名称完全相同,但它们的内容不同。然后我想知道如何将/images2/ad 的图像复制合并到images/ad 中,将/images2/foo 的图像复制合并到images/foo 中,等等所有4000 个文件夹。

ubuntu directory file-copy

177
推荐指数
6
解决办法
21万
查看次数

硬链接创建 - 权限?

哪些权限会​​影响硬链接的创建?文件所有权本身重要吗?


假设用户alice想要创建一个指向target.txt目录中文件的硬链接target-dir。

  • 和都alice需要哪些权限?target.txttarget-dir
  • 如果target.txt是由用户拥有bill和target-dir被用户所拥有chad,它改变什么?

我试图模拟这种情况,在ext4文件系统中创建以下文件夹/文件结构:

#> ls -lh . *
.:
drwxr-xr-x 2 bill bill 60 Oct  1 11:29 source-dir
drwxrwxrwx 2 chad chad 60 Oct  1 11:40 target-dir

source-dir:
-r--r--r-- 1 bill bill 0 Oct  1 11:29 target.txt

target-dir:
-rw-rw-r-- 1 alice alice 0 Oct  1 11:40 dummy
Run Code Online (Sandbox Code Playgroud)

虽然alice可以创建到 的软链接target.txt,但她不能创建硬链接:

#> ln source-dir/target.txt target-dir/
ln: …
Run Code Online (Sandbox Code Playgroud)

linux permissions hard-link

25
推荐指数
1
解决办法
3万
查看次数

CentOS 6 和 CentOS 7 之间的硬链接权限行为不同

当我尝试创建硬链接时,我在 CentOS 7 中遇到权限错误。在 CentOS 6 中设置相同的权限时,我没有收到错误消息。问题集中在组权限上。我不确定哪个操作系统版本是正确的,哪个是错误的。

让我来说明正在发生的事情。在我当前的工作目录中,我有两个目录:源和目标。一开始,destination 是空的;源包含一个文本文件。

[root@tc-dlx-nba cwd]# ls -l
total 0
drwxrwxrwx. 2 root root  6 Jun 12 14:33 destination
drwxrwxrwx. 2 root root 21 Jun 12 14:33 source
[root@tc-dlx-nba cwd]# ls -l destination/
total 0
[root@tc-dlx-nba cwd]# ls -l source/
total 4
-rw-r--r--. 1 root root 8 Jun 12 14:20 test.txt
[root@tc-dlx-nba cwd]# 
Run Code Online (Sandbox Code Playgroud)

如您所见,两个目录的权限为 777,所有者和组都设置为 root。文本文件的所有者和组也都设置为 root。但是,文本文件的权限对于所有者是可读写的,而对于组是只读的。

当我以 root 身份登录时,在目标目录中创建指向文本文件(在源目录中)的硬链接没有问题。

[root@tc-dlx-nba cwd]# ln source/test.txt destination/
[root@tc-dlx-nba cwd]# ls destination/
test.txt
Run Code Online (Sandbox Code Playgroud)

但是,如果我以其他用户(在本例中为 admin)身份登录,则无法创建链接。我得到:“不允许操作。”

[root@tc-dlx-nba cwd]# rm …
Run Code Online (Sandbox Code Playgroud)

permissions centos hard-link

9
推荐指数
1
解决办法
5268
查看次数