Score:0

Why .ssh,.cache or .local folders not visible with sudo?

tg flag

why du -h --max-depth 1 /home/jay shows more folders (.ssh, .local etc) than sudo du -hcs /home/jay/* ?

muru avatar
us flag
Have you tried running `sudo du -h --max-depth 1 /home/jay`?
hr flag
`*` expands to *non-hidden* files and directories only by default...
Raffa avatar
jp flag
Actually because of both the above @muru and @Terrance ... The globbing character `*` will not show hidden files by default and the `-s` option limits the output and conflicts with the all `-a` option.
Score:5
id flag

When in doubt consult the man page.

From man du for the commands of du -hcs and du -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

Using -hcs means to make it human readable, produce a total and to summarize (no output) each argument. In the first command of du -h --max-depth 1 ... allows for the output to the screen of all directories and files instead of summarizing. -s with * (glob) will summarize and show you the output to the screen of all the non-hidden files and directories.

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 is the same as using the --all switch to show all files and directories, but conflicts with --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

However, using the * will override the --max-depth and only show non-hidden files and directories.

(ignore all my testing files and directories ;) )

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

One other thing, you can use .* in combination with the --max-depth or -d or -s to show both hidden and non-hidden directories.

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
Terrance avatar
id flag
@Raffa That is a good point. I will have to update in a bit. Only wrote this in a hurry, but I have to go take care of somethings. But thank you for the comment. :)
Raffa avatar
jp flag
Perfect … +1 done earlier :-)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.