为什么使用 sudo 时看不到 .ssh、.cache 或 .local 文件夹?

为什么使用 sudo 时看不到 .ssh、.cache 或 .local 文件夹?

为什么du -h --max-depth 1 /home/jay显示比 更多的文件夹(.ssh、.local 等)sudo du -hcs /home/jay/*

答案1

如果有疑问,请查阅手册页。

来自和man du的命令:du -hcsdu -h --max-depth

  -a, --all
          write counts for all files, not just directories
  -c, --total
          produce a grand total
  -h, --human-readable
          print sizes in human readable format (e.g., 1K 234M 2G)
  -s, --summarize
          display only a total for each argument
  -d, --max-depth=N
          print the total for a directory (or file, with --all) only if it
          is   N   or  fewer  levels  below  the  command  line  argument;
          --max-depth=0 is the same as --summarize

使用-hcs意味着使其易于阅读,产生总计并总结(无输出)每个参数。在第一个命令中,du -h --max-depth 1 ...允许将所有目录和文件输出到屏幕而不是总结。 -s使用*(glob) 将总结并向您显示所有目录和文件的输出到屏幕非隐藏文件和目录。

terrance@terrance-ubuntu:~$ du -hcs *
206M    bin
20K consoletype
4.0K    consoletype.c
4.0K    ctrl_test.bsh
4.0K    Desktop
468K    Documents
12G Downloads
4.0K    getintip.bsh
4.0K    HomeIP
560K    Icons
4.0K    intrepid_check.bsh
140K    Music
156K    notifications
2.6G    Pictures
4.0K    Public
212K    scripts
11M snap
20K Templates
4.0K    usb.vmdk
4.0K    Videos
16M VirtualBox VMs
14G total

Where与使用开关显示所有文件和目录--max-depth相同,但与--all--summarize

terrance@terrance-ubuntu:~$ du -hc --max-depth 1 
12K ./.psensor
507M    ./.gdfuse
560K    ./Icons
20K ./Templates
212K    ./scripts
7.3M    ./.local
16M ./VirtualBox VMs
152K    ./.dvdcss
693M    ./.vscode
4.0K    ./.hardinfo
468K    ./Documents
76K ./.pki
11M ./snap
32K ./.vmware
40K ./.ssh
3.1M    ./.MakeMKV
2.6G    ./Pictures
16G ./.steam
60K ./.audacity-data
4.0K    ./Videos
12G ./Downloads
4.0K    ./Public
1.5G    ./.wine
8.0K    ./.gnome
206M    ./bin
140K    ./Music
237M    ./.mozilla
4.0K    ./Desktop
156K    ./notifications
16K ./.gnupg
21M ./.var
2.0G    ./.config
1.8G    ./.cache
36G .
36G total

但是,使用*将覆盖--max-depth并且仅显示非隐藏文件和目录。

(忽略我所有的测试文件和目录;))

terrance@terrance-ubuntu:~$ du -hc --max-depth 1 *
206M    bin
20K consoletype
4.0K    consoletype.c
4.0K    ctrl_test.bsh
4.0K    Desktop
456K    Documents/Mac Crap Some More
468K    Documents
672M    Downloads/packardbellmastercd170802-03september1996
4.5M    Downloads/FIX95
1.4M    Downloads/r8168-8.050.03
7.6M    Downloads/Thermostat
23M Downloads/Audiostation
925M    Downloads/packardbellmulti-mediamastercd170210rev.4.0february1995
489M    Downloads/170580
914M    Downloads/Bootcamp
598M    Downloads/Microsoft Windows 95B (4.00.1111) (OSR2) [English] (CD)
22M Downloads/tmp
4.8M    Downloads/Microsoft Windows 95 OSR2 - Boot Disk (Dell OEM) (3.5-1.44mb)
48K Downloads/stratton
1.3G    Downloads/BootCamp 2
55M Downloads/scitechdoctor
496M    Downloads/master-cd-170991
12G Downloads
4.0K    getintip.bsh
4.0K    HomeIP
560K    Icons
4.0K    intrepid_check.bsh
140K    Music
156K    notifications
1.6G    Pictures/Yellowstone_2020
4.0K    Pictures/smplayer_screenshots
84K Pictures/Screenshots
1.2M    Pictures/Robotech Repairs
328K    Pictures/Clipart
260K    Pictures/Work
205M    Pictures/Wallpapers
2.6G    Pictures
4.0K    Public
212K    scripts
11M snap/bitwarden
16K snap/canonical-livepatch
4.0K    snap/firefox
228K    snap/warble
4.0K    snap/snap-store
20K snap/code
4.0K    snap/google-webapp
4.0K    snap/google-docs
11M snap
20K Templates
4.0K    usb.vmdk
4.0K    Videos
244K    VirtualBox VMs/Ubuntu Unity 22.04
704K    VirtualBox VMs/Ubuntu 16.04.7
1.5M    VirtualBox VMs/Windows 10
300K    VirtualBox VMs/Windows XP
532K    VirtualBox VMs/Ubuntu 18.04 mini upgraded
2.7M    VirtualBox VMs/Ubuntu 18.04 Work
588K    VirtualBox VMs/Windows 98 SE
972K    VirtualBox VMs/Xubuntu 20.04
520K    VirtualBox VMs/Ubuntu 21.04
916K    VirtualBox VMs/Xubuntu 22.04
3.4M    VirtualBox VMs/MS-DOS 6.22
1.4M    VirtualBox VMs/Mac
824K    VirtualBox VMs/Xubuntu 21.04
376K    VirtualBox VMs/Android_x64
572K    VirtualBox VMs/Windows 11
200K    VirtualBox VMs/Ubuntu 20.04 LTS
16M VirtualBox VMs
14G total

还有一件事,你可以.*--max-depth或结合使用-d 或者 -s展示两者非隐藏目錄。

terrance@terrance-ubuntu:~$ du -hcd 1 .*
12K ./.psensor
507M    ./.gdfuse
560K    ./Icons
20K ./Templates
212K    ./scripts
7.3M    ./.local
16M ./VirtualBox VMs
152K    ./.dvdcss
693M    ./.vscode
4.0K    ./.hardinfo
468K    ./Documents
76K ./.pki
11M ./snap
32K ./.vmware
40K ./.ssh
3.1M    ./.MakeMKV
2.6G    ./Pictures
16G ./.steam
60K ./.audacity-data
4.0K    ./Videos
12G ./Downloads
4.0K    ./Public
1.5G    ./.wine
8.0K    ./.gnome
206M    ./bin
140K    ./Music
248M    ./.mozilla
4.0K    ./Desktop
156K    ./notifications
16K ./.gnupg
21M ./.var
2.0G    ./.config
1.8G    ./.cache
36G .
4.0K    ..
36G total

相关内容