为什么 WSL 会在 cmd 或 Windows 文件资源管理器中显示不存在的文件?

为什么 WSL 会在 cmd 或 Windows 文件资源管理器中显示不存在的文件?

为什么ls -lWSL 中的命令会返回 Windows 文件资源管理器中或使用 cmd 命令时未出现的文件和目录dir

WSL2 Debian 11 中ll( ) 命令的输出:ls -l

user@computer:/mnt/c$ ll
ls: Config.Msi: Permission denied
ls: cannot access 'DumpStack.log.tmp': Permission denied
ls: cannot access 'hiberfil.sys': Permission denied
ls: cannot access 'pagefile.sys': Permission denied
ls: PerfLogs: Permission denied
ls: Recovery: Permission denied
ls: cannot access 'swapfile.sys': Permission denied
ls: 'System Volume Information': Permission denied
total 388
drwxrwxrwx 1 user user   4096 Dec 25  2020 '$Recycle.Bin'
dr-xr-xr-x 1 user user   4096 Jun 16 22:13 '$WinREAgent'
-r-xr-xr-x 1 user user 395268 Jul 10  2015  bootmgr
-r-xr-xr-x 1 user user      1 Oct 30  2015  BOOTNXT
-rwxrwxrwx 1 user user     80 Oct 21  2018  bootTel.dat
d--x--x--x 1 user user   4096 Jun 30 11:51  Config.Msi
lrwxrwxrwx 1 user user     12 Jul 10  2015 'Documents and Settings' -> /mnt/c/Users
-????????? ? ?    ?         ?            ?  DumpStack.log.tmp
-????????? ? ?    ?         ?            ?  hiberfil.sys
-????????? ? ?    ?         ?            ?  pagefile.sys
d--x--x--x 1 user user   4096 Dec  7  2019  PerfLogs
drwxrwxrwx 1 user user   4096 Feb 14 13:37  ProgramData
dr-xr-xr-x 1 user user   4096 Jun 30 14:07 'Program Files'
dr-xr-xr-x 1 user user   4096 Jun 30 14:56 'Program Files (x86)'
d--x--x--x 1 user user   4096 Mar 13 10:58  Recovery
-r-xr-xr-x 1 user user     27 Nov 30  2016  Settings.ini
drwxrwxrwx 1 user user   4096 Sep  2  2021  Strawberry
-????????? ? ?    ?         ?            ?  swapfile.sys
d--x--x--x 1 user user   4096 Jun 30 11:51 'System Volume Information'
drwxrwxrwx 1 user user   4096 Sep 21  2019  temp
dr-xr-xr-x 1 user user   4096 Dec 25  2020  Users
drwxrwxrwx 1 user user   4096 Apr  3 13:38  WCH.CN
dr-xr-xr-x 1 user user   4096 Jun 16 22:36  Windows

dir /a:hWindows 10 命令提示符中的命令输出:

C:\>dir /a:d
 C volume doesn't have a name
 Volume serial number is 5DFB-D456

 Directories from C:\

25/12/2020  02:49    <DIR>          $Recycle.Bin
16/06/2022  22:13    <DIR>          $WinREAgent
30/06/2022  11:51    <DIR>          Config.Msi
10/07/2015  14:21    <JUNCTION>     Documents and Settings [C:\Users]
07/12/2019  11:14    <DIR>          PerfLogs
30/06/2022  14:07    <DIR>          Program Files
30/06/2022  14:56    <DIR>          Program Files (x86)
14/02/2022  14:37    <DIR>          ProgramData
13/03/2022  11:58    <DIR>          Recovery
02/09/2021  22:29    <DIR>          Strawberry
30/06/2022  11:51    <DIR>          System Volume Information
21/09/2019  13:37    <DIR>          temp
25/12/2020  21:12    <DIR>          Users
03/04/2022  13:38    <DIR>          WCH.CN
16/06/2022  22:36    <DIR>          Windows
               0 file(s)                0 bytes
              15 dir(s)  51 495 235 584 free bytes

勾选“显示隐藏文件”选项后,Windows 文件资源管理器的屏幕截图显示 C 卷上的文件: Windows 文件资源管理器的屏幕截图

如您所见,WSL 显示更多文件,如或bootmgr,而命令显示比文件资源管理器更多的目录,如或。bootTel.datpagefile.sysdir /a:hConfig.MsiRecovery$Recycle.Bin

怎么会?

答案1

其中许多项目还具有S(系统)属性,除其他含义外,其含义是“隐藏,但更多”。您可以使用dir/adir/a:s,或通过禁用选项“隐藏受保护的操作系统文件”来查看它们。

相关内容