### Install QDirStat Source: https://github.com/shundhammer/qdirstat/blob/master/README.md Install QDirStat after compiling. This command typically installs to the default /usr directory. Use 'su -c make install' for root privileges if needed. ```bash sudo make install ``` -------------------------------- ### Build and Install Software Manually Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Unpkg-View.md Standard command sequence for compiling and installing software directly to system directories. ```bash make && sudo make install ``` -------------------------------- ### Install and Run QDirStat from Live Media Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Install QDirStat on a live Linux system using `apt` and then run it with `sudo` to analyze a mounted filesystem. Running with `sudo` ensures access to all subdirectories. ```bash tux@live-linux:~$ sudo apt install qdirstat tux@live-linux:~$ xhost + tux@live-linux:~$ sudo qdirstat /mnt ``` -------------------------------- ### Install QDirStat Packages on Ubuntu Source: https://github.com/shundhammer/qdirstat/blob/master/README.md Use this command to install the necessary packages for building QDirStat on Ubuntu. It includes build essentials, Qt6 development files, and zlib. ```bash sudo apt-get install build-essential qtbase6-dev qt6-5compat-dev zlib1g-dev ``` -------------------------------- ### Install QDirStat to Custom Directory Source: https://github.com/shundhammer/qdirstat/blob/master/README.md Install QDirStat to a custom directory by specifying the INSTALL_PREFIX during the qmake6 configuration. This is useful for non-standard installations. ```bash qmake6 INSTALL_PREFIX=/usr/local ``` -------------------------------- ### Install QDirStat Packages on SUSE Source: https://github.com/shundhammer/qdirstat/blob/master/README.md Install the required development packages for building QDirStat on SUSE Linux. This includes C/C++ development tools, Qt6 development files, and zlib. ```bash sudo zypper install -t pattern devel_C_C++ sudo zypper install qt6-widgets-devel qt6-qt5compat-devel zlib-devel ``` -------------------------------- ### Start QDirStat with Package Filter (Starts With) Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Pkg-View.md Launch QDirStat and filter packages starting with 'chrom'. This uses auto-mode, defaulting to a 'starts with' match for package names. Patterns are case-insensitive. ```bash qdirstat pkg:/chrom ``` -------------------------------- ### QDirStat Cache File Format Example Source: https://github.com/shundhammer/qdirstat/blob/master/doc/cache-file-format.txt An example of a QDirStat cache file in version 2.0 format. This format is used for storing directory and file information. Lines starting with '#' are comments and are ignored. ```text # Generated by qdirstat-cache-writer # Do not edit! # # Type path size uid gid perm. mtime D /work/home/sh/src/qdirstat 4096 1000 1000 0775 0x65e0ce47 ``` -------------------------------- ### Generate Dpkg File Lists Source: https://github.com/shundhammer/qdirstat/blob/master/scripts/pkg-tools/README.md Creates lists of installed packages and their files for dpkg-based systems. Output paths are printed to stdout. The QDirStat temporary directory is created if it doesn't exist. ```bash [sh @ balrog] ...qdirstat/scripts/pkg-tools % complete-filelist-dpkg 2459 /tmp/qdirstat-sh/pkglist.txt 268507 /tmp/qdirstat-sh/filelist.txt ``` -------------------------------- ### Install URI::Escape Perl Module Source: https://github.com/shundhammer/qdirstat/blob/master/doc/QDirStat-for-Servers.md Install the URI::Escape Perl module using cpan. Ensure 'make' is installed if the installation fails. ```bash cpan URI::Escape ``` -------------------------------- ### Retrieve Installed Package List Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Pkg-View.md Commands used by QDirStat to fetch the list of installed packages from the system. ```bash dpkg-query --show --showformat='${Package} | ${Version} | ${Architecture} | ${Status}\n' ``` ```bash rpm -qa --queryformat '%{name} | %{version}-%{release} | %{arch}\n' ``` ```bash pacman -Qn ``` -------------------------------- ### Start QDirStat with Unpackaged Files View Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Unpkg-View.md Launches QDirStat directly into the unpackaged files view for a specified directory. Uses previously saved exclude and ignore patterns. ```bash qdirstat unpkg:/usr/share ``` ```bash qdirstat unpkg:/ ``` -------------------------------- ### Select Qt6 Environment on Ubuntu Source: https://github.com/shundhammer/qdirstat/blob/master/README.md If you have multiple Qt versions installed, use qtchooser to select Qt6 for building QDirStat. This ensures the correct Qt libraries are used. ```bash sudo apt-get install qtchooser export QT_SELECT="qt6" ``` -------------------------------- ### Display Disk Usage of Qt Installation Directory Source: https://github.com/shundhammer/qdirstat/wiki/QDirStat-MacOS-Dev Use 'du -skh *' to display disk usage for each item in the current directory. This is useful for understanding the space occupied by a Qt installation. ```bash cd ~/qt du -skh * ``` -------------------------------- ### Start QDirStat with Package Filter (Wildcard) Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Pkg-View.md Launch QDirStat and filter for packages containing 'gtk'. The '*' wildcards must be quoted to prevent shell expansion. Patterns are case-insensitive. ```bash qdirstat "pkg:/*gtk*" ``` -------------------------------- ### Start QDirStat with Package Filter (Regular Expression) Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Pkg-View.md Launch QDirStat and filter for packages matching the regular expression '.*qt[45].*'. This selects packages related to Qt4 or Qt5. Patterns are case-insensitive. ```bash qdirstat "pkg:/.*qt[45].*" ``` -------------------------------- ### Profile QDirStat with Valgrind Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Debugging-Tips.md Start QDirStat with Valgrind's callgrind tool to profile its execution. This significantly slows down the application, so avoid using very large directories. Results are saved to callgrind.out.* files. ```bash valgrind --tool=callgrind --dump-instr=yes --simulate-cache=yes --collect-jumps=yes qdirstat ~ ``` -------------------------------- ### Filter Snap Packages with df Source: https://github.com/shundhammer/qdirstat/blob/master/doc/DevHistory.md Example command to identify snap package loopback mounts cluttering filesystem output. ```bash df -hT | grep snap /dev/loop0 squashfs 159M 159M 0 100% /snap/chromium/1244 /dev/loop1 squashfs 55M 55M 0 100% /snap/core18/1880 /dev/loop2 squashfs 63M 63M 0 100% /snap/gtk-common-themes/1506 /dev/loop3 squashfs 30M 30M 0 100% /snap/snapd/8542 ``` -------------------------------- ### Start QDirStat Without Directory Prompt Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Unpkg-View.md Starts QDirStat without prompting for a directory, allowing immediate access to the menu for selecting a scan target. ```bash qdirstat -d ``` -------------------------------- ### Start QDirStat with Package Filter (Multiple Regex) Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Pkg-View.md Launch QDirStat and filter for packages matching a list of common browser names using a regular expression. Use anchors like '^' and '$' for precise matching if needed, as regex uses partial matching by default. Patterns are case-insensitive. ```bash qdirstat "pkg:/(firefox|mozilla|chrome|chromium|opera)" ``` -------------------------------- ### Start QDirStat with Package Filter (Exact Match) Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Pkg-View.md Launch QDirStat and filter for the exact package name 'emacs'. The '=' prefix explicitly sets the match mode to 'exact match'. Patterns are case-insensitive. ```bash qdirstat pkg:/=emacs ``` -------------------------------- ### Create and Checkout a Feature Branch Source: https://github.com/shundhammer/qdirstat/blob/master/doc/GitHub-Workflow.md Start by checking out the master branch, then create and switch to a new feature branch for your work. This isolates your changes and makes managing pull requests easier. ```git git checkout master git branch kilroy-transmogrify git checkout kilroy-transmogrify ``` -------------------------------- ### Collect Disk Usage Data on Server Source: https://github.com/shundhammer/qdirstat/blob/master/doc/QDirStat-for-Servers.md Use qdirstat-cache-writer with root permissions to collect disk usage data for specified filesystems. The first argument is the scan start point, and the last is the output cache file name. ```bash sudo qdirstat-cache-writer / myserver-root.cache.gz sudo qdirstat-cache-writer /var myserver-var.cache.gz sudo qdirstat-cache-writer /srv myserver-srv.cache.gz ``` -------------------------------- ### Create New Feature Branch Source: https://github.com/shundhammer/qdirstat/blob/master/doc/GitHub-Workflow.md Starts a new development branch based on the current state of the pull request branch. ```bash git branch kilroy-hyperforble git checkout kilroy-hyperforble ...(work in that branch...) ``` -------------------------------- ### C++ Brace Style Example Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Contributing.md Follow this brace style for C++ code, with opening braces on new lines and spaces after opening and before closing parentheses. Avoid K&R style. ```cpp if ( someCondition ) { doSomething( arg1, arg2 ) } ``` -------------------------------- ### Configure Qt Environment Variables for MacOS Source: https://github.com/shundhammer/qdirstat/wiki/QDirStat-MacOS-Dev Set environment variables to point to your Qt installation directory and its binary path. This allows the system to find Qt tools. Remember to source your shell configuration file after making changes. ```bash export QT_HOME=$HOME/qt/ export QT_5_15_BIN=$QT_HOME/5.15.0/clang_64/bin export PATH=$PATH:$QT_5_15_BIN ``` -------------------------------- ### Rename Git Remote Source: https://github.com/shundhammer/qdirstat/blob/master/doc/GitHub-Workflow.md Rename an existing Git remote, for example, changing 'origin' to 'mine'. This is useful if the default remote name was not set as desired during cloning. ```bash git remote rename origin mine ``` -------------------------------- ### Clear Linux Disk Caches Source: https://github.com/shundhammer/qdirstat/wiki/disk-usage-tools-compared Use this command in a root shell to clear the kernel directory caches before performance testing. This ensures consistent results by starting with a cold cache. ```bash echo 3 >/proc/sys/vm/drop_caches ``` -------------------------------- ### Check Disk Usage of a Mounted Directory Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md After mounting a filesystem, use `du -hs` to get a human-readable summary of the disk space used by a specific directory. This helps in identifying large directories that might contain shadowed files. ```bash tux@live-linux:~$ sudo du -hs /mnt/home 2.0G /mnt/home ``` -------------------------------- ### Display QDirStat Help Source: https://github.com/shundhammer/qdirstat/blob/master/README.md View all available command-line options for QDirStat by using the --help option. ```bash qdirstat --help ``` -------------------------------- ### Bind-Mount Multiple Directories Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Demonstrates creating target directories and performing bind-mounts for multiple distinct directories, ensuring unique target paths to avoid shadowing. ```bash root@linux:~# mkdir -p /mnt/shadowed/win_app root@linux:~# mount -o bind /mnt/root/win/app /mnt/shadowed/win_app root@linux:~# mkdir -p /mnt/shadowed/win_boot root@linux:~# mount -o bind /mnt/root/win/app /mnt/shadowed/win_boot ``` -------------------------------- ### Build QDirStat on MacOS Source: https://github.com/shundhammer/qdirstat/wiki/QDirStat-MacOS-Dev Follow these steps to clone the QDirStat repository, configure the build with qmake, and compile the application using make. The resulting executable will be in a .app directory. ```bash mkdir ~/work cd ~/work git clone https://github.com/shundhammer/qdirstat.git cd qdirstat qmake make ``` -------------------------------- ### Launch QDirStat via Command Line Source: https://context7.com/shundhammer/qdirstat/llms.txt Use these commands to launch the QDirStat application with specific directories, cache files, or specialized views. ```bash # Basic usage - scan a directory qdirstat /home/user/Documents # Scan with slow update mode (3 sec intervals instead of 333 ms) qdirstat --slow-update /home/user qdirstat -s /var/log # Start without showing the directory selection dialog qdirstat --dont-ask qdirstat -d # Read from a pre-generated cache file qdirstat --cache /path/to/cache.gz qdirstat -c /tmp/server-cache.qdirstat.cache.gz # View installed packages matching a pattern (starts with "chrom") qdirstat pkg:/chrom # View all Qt4 or Qt5 packages using regex qdirstat "pkg:/.*qt[45].*" # View exact package name only qdirstat "pkg:/=emacs" # View unpackaged files in system directories qdirstat unpkg:/usr/share qdirstat unpkg:/ # Show help qdirstat --help ``` -------------------------------- ### List All Block Devices with lsblk Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Use `lsblk` to display all block devices and their partitions, regardless of whether they are mounted. This command does not require root permissions. ```console sh@balrog:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 931,5G 0 disk ├─sda1 8:1 0 97,7G 0 part /win/boot └─sda2 8:2 0 833,9G 0 part /win/app sdb 8:16 0 931,5G 0 disk ├─sdb1 8:17 0 2G 0 part ├─sdb2 8:18 0 30G 0 part /hd-root-18-04 ├─sdb3 8:19 0 30G 0 part /hd-root-14-04 ├─sdb4 8:20 0 1K 0 part └─sdb5 8:21 0 869,5G 0 part /work sdc 8:32 0 232,9G 0 disk ├─sdc1 8:33 0 2G 0 part [SWAP] ├─sdc2 8:34 0 30G 0 part / ├─sdc3 8:35 0 30G 0 part /ssd-root-20-04 └─sdc4 8:36 0 170,9G 0 part /ssd-work sr0 11:0 1 1024M 0 rom ``` -------------------------------- ### List Block Devices and Mount Filesystem Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Use `lsblk` to identify partitions and `mount` to access a specific partition from a live environment. This is useful for inspecting filesystems that might be inaccessible from the running system. ```bash tux@live-linux:~$ lsblk /dev/sdb NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb 8:16 0 931,5G 0 disk ├─sdb1 8:17 0 2G 0 part ├─sdb2 8:18 0 30G 0 part ├─sdb3 8:19 0 30G 0 part ├─sdb4 8:20 0 1K 0 part └─sdb5 8:21 0 869,5G 0 part tux@live-linux:~$ sudo mount /dev/sdb2 /mnt ``` -------------------------------- ### Compile QDirStat Source: https://github.com/shundhammer/qdirstat/blob/master/README.md Compile QDirStat from source after setting up the build environment. Navigate to the source directory and run qmake6 followed by make. ```bash qmake6 make ``` -------------------------------- ### Download and Make Executable qdirstat-cache-writer Source: https://github.com/shundhammer/qdirstat/blob/master/doc/QDirStat-for-Servers.md Download the qdirstat-cache-writer script to the server and make it executable. It's recommended to review the script's content for security. ```bash ssh root@myserver cd /usr/local/bin wget https://github.com/shundhammer/qdirstat/raw/master/scripts/qdirstat-cache-writer chmod 755 qdirstat-cache-writer ``` -------------------------------- ### Open QDirStat Application on MacOS Source: https://github.com/shundhammer/qdirstat/wiki/QDirStat-MacOS-Dev After building QDirStat, you can open the application bundle using the 'open' command or by navigating to it in Finder. ```bash cd qdirstat.app open qdirstat.app ``` -------------------------------- ### Inspect shadowed files with QDirStat Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Launch QDirStat to visually inspect and manage shadowed files. ```console root@linux:~# qdirstat /mnt/shadowed ``` -------------------------------- ### Access Application Settings Source: https://context7.com/shundhammer/qdirstat/llms.txt Manage application configuration using QSettings and the Settings class. Use fixFileOwners to correct permissions after sudo operations. ```cpp #include "Settings.h" #include // Access settings (uses QSettings internally) QSettings settings; // General settings settings.beginGroup("MainWindow"); bool showTreemap = settings.value("ShowTreemap", true).toBool(); int treemapHeight = settings.value("TreemapHeight", 300).toInt(); settings.endGroup(); // Directory tree settings settings.beginGroup("DirectoryTree"); bool crossFilesystems = settings.value("CrossFilesystems", false).toBool(); int slowUpdateMs = settings.value("SlowUpdateMillisec", 3000).toInt(); settings.endGroup(); // Treemap settings settings.beginGroup("Treemap"); int minTileSize = settings.value("MinTileSize", 3).toInt(); bool squarified = settings.value("Squarify", true).toBool(); settings.endGroup(); // Package view settings settings.beginGroup("Pkg"); int maxParallel = settings.value("MaxParallelProcesses", 6).toInt(); int minCacheSize = settings.value("MinCachePkgListSize", 200).toInt(); settings.endGroup(); // Cleanup settings are stored per-cleanup in numbered groups: // [Cleanup_01], [Cleanup_02], etc. // MIME categories stored in: // [MimeCategory_01], [MimeCategory_02], etc. // Exclude rules stored in: // [ExcludeRule_01], [ExcludeRule_02], etc. // Fix file ownership after running with sudo QDirStat::Settings::fixFileOwners(); ``` -------------------------------- ### Bind-mount the Root Directory Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Create a directory and then use `mount -o bind` to create a read-only bind mount of the root filesystem. This allows access to the original filesystem structure without interference from other mounts. ```bash root@linux:~# mkdir -p /mnt/root root@linux:~# mount -o bind / /mnt/root ``` -------------------------------- ### Create Target Directory for Bind-Mount Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Creates a parent directory (`/mnt/shadowed/work`) where a filesystem mount will be bind-mounted. ```bash root@linux:~# mkdir -p /mnt/shadowed/work ``` -------------------------------- ### Package Manager Integration Reference Source: https://github.com/shundhammer/qdirstat/blob/master/doc/DevHistory.md Reference for implementing support for additional package managers in QDirStat. ```cpp https://github.com/shundhammer/qdirstat/blob/master/src/PkgManager.cpp#L140 ``` -------------------------------- ### Force Cache Recreation with show-unpkg-files Source: https://github.com/shundhammer/qdirstat/blob/master/scripts/pkg-tools/README.md Use the -f option with show-unpkg-files to force the recreation of the root cache file and file list, even if they already exist. ```bash ./show-unpkg-files -f ``` -------------------------------- ### Run Show Unpackaged Files Script Source: https://github.com/shundhammer/qdirstat/blob/master/scripts/pkg-tools/README.md Execute the main script to display unpackaged files. Ensure you have sudo permissions. Be cautious when deleting files in the view. ```bash ./show-unpkg-files ``` -------------------------------- ### Fetch the Unshadow Mount Points Script Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Download the latest version of the `unshadow-mount-points` script using `wget`. Ensure the script is downloaded to a suitable location, such as a temporary directory. ```bash tux@linux:~/tmp> wget https://raw.githubusercontent.com/shundhammer/qdirstat/master/scripts/shadowed/unshadow-mount-points ``` -------------------------------- ### Pack the test directory Source: https://github.com/shundhammer/qdirstat/blob/master/test/data/README.md Creates a compressed tarball of the test directory. Requires sudo to preserve restrictive permissions and the -S flag to handle sparse files correctly. ```bash sudo tar cjvf test-dir.tar.bz2 -S test ``` -------------------------------- ### Display All Mounts with findmnt Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md A plain `findmnt` command displays all mounted filesystems, including kernel pseudo-filesystems. This can be useful for a comprehensive overview but may include 'cruft'. ```console sh@balrog:~$ findmnt TARGE SOURCE FSTYPE OPTIONS / /dev/sdc2 ext4 rw,relatime,errors=remount-ro,data=order ├─/sys sysfs sysfs rw,nosuid,nodev,noexec,relatime │ ├─/sys/kernel/security securityfs securityf rw,nosuid,nodev,noexec,relatime │ ├─/sys/fs/cgroup tmpfs tmpfs ro,nosuid,nodev,noexec,mode=755 │ │ ├─/sys/fs/cgroup/unified cgroup cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelega │ │ ├─/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec,relatime,xattr,na │ │ ├─/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec,relatime,blkio │ │ ├─/sys/fs/cgroup/hugetlb cgroup cgroup rw,nosuid,nodev,noexec,relatime,hugetlb │ │ ├─/sys/fs/cgroup/perf_event cgroup cgroup rw,nosuid,nodev,noexec,relatime,perf_eve │ │ ├─/sys/fs/cgroup/cpu,cpuacct cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpua │ │ ├─/sys/fs/cgroup/net_cls,net_prio cgroup cgroup rw,nosuid,nodev,noexec,relatime,net_cls, │ │ ├─/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpuset │ │ ├─/sys/fs/cgroup/pids cgroup cgroup rw,nosuid,nodev,noexec,relatime,pids │ │ ├─/sys/fs/cgroup/rdma cgroup cgroup rw,nosuid,nodev,noexec,relatime,rdma │ │ ├─/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec,relatime,memory ``` -------------------------------- ### Troubleshoot Cleanup Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Retry command for the cleanup script if previous attempts failed due to busy mounts. ```console tux@linux:~/tmp> sudo ./unshadow-mount-points -c ``` -------------------------------- ### Configure QDirStat Performance Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Pkg-View.md Configuration settings for parallel processing and caching thresholds in ~/.config/QDirStat/QDirStat.conf. ```ini [Pkg] MaxParallelProcesses=6 ``` ```ini [Pkg] MinCachePkgListSize=200 ``` -------------------------------- ### Show Btrfs Filesystem Information Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Btrfs-Free-Size.md Use `btrfs filesystem show` with root permissions to display general information about a Btrfs filesystem, including its label, UUID, total devices, and space used. Provide the mount point as an argument. ```bash sudo btrfs filesystem show /mybtrfs ``` ```bash sudo btrfs fi show /mybtrfs ``` -------------------------------- ### Create QDirStat Cache Manually Source: https://github.com/shundhammer/qdirstat/blob/master/scripts/pkg-tools/README.md Manually create a QDirStat cache file for the root directory. This command can be run without root permissions, but may generate warnings and miss some files. ```bash qdirstat-cache-writer -l / /tmp/qdirstat-$USER/root.cache.gz ``` -------------------------------- ### Create and Configure a Dedicated Trash Directory Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Troubleshooting.md Use these commands to create a dedicated trash directory on a specific filesystem mount point. Ensure the directory has the correct permissions (01777) as required by the XDG trash specification. ```bash cd /data sudo mkdir .Trash sudo chmod 01777 .Trash ``` -------------------------------- ### Integrate Package Manager with PkgFilter Source: https://context7.com/shundhammer/qdirstat/llms.txt Use PkgFilter to select packages and PkgManager to query file ownership and lists. Requires the PkgFilter and PkgManager headers. ```cpp #include "PkgFilter.h" #include "PkgManager.h" #include "PkgInfo.h" #include "DirTree.h" // Create package filter with pattern QDirStat::PkgFilter filter("chromium"); // Starts with "chromium" // Different filter modes (auto-detected from pattern) QDirStat::PkgFilter exactFilter("=emacs"); // Exact match QDirStat::PkgFilter wildcardFilter("*gtk*"); // Wildcard QDirStat::PkgFilter regexFilter(".*qt[45].*"); // Regex QDirStat::PkgFilter allFilter(""); // All packages // Access filter properties QString pattern = filter.pattern(); QDirStat::PkgFilter::FilterMode mode = filter.filterMode(); // Modes: Auto, Contains, StartsWith, ExactMatch, Wildcard, RegExp // Read packages into DirTree QDirStat::DirTree * tree = new QDirStat::DirTree(); tree->readPkg(filter); // Check if a package manager is available QDirStat::PkgManager * pkgManager = QDirStat::PkgManager::primary(); if (pkgManager && pkgManager->isPrimaryPkgManager()) { qDebug() << "Primary package manager:" << pkgManager->name(); // Get file list for a package QStringList files = pkgManager->fileList("chromium-browser"); // Check which package owns a file QString pkg = pkgManager->owningPkg("/usr/bin/chromium"); } // Query unpackaged files view (excludes packaged files) // Use "unpkg:/usr/share" URL or menu "File" -> "Show Unpackaged Files" // Configuration stored in ~/.config/QDirStat/QDirStat.conf: // [Pkg] // MaxParallelProcesses=6 // MinCachePkgListSize=200 ``` -------------------------------- ### List shadowed files with tree Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Use tree to visualize the directory structure of shadowed files. ```console root@linux:~# tree /mnt/shadowed ``` -------------------------------- ### Show Btrfs Filesystem Disk Free Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Btrfs-Free-Size.md Use `btrfs filesystem df` with root permissions to show a summarized view of disk space usage for different Btrfs data types. Provide the mount point as an argument. ```bash sudo btrfs filesystem df /mybtrfs ``` ```bash sudo btrfs fi df /mybtrfs ``` -------------------------------- ### Retrieve Package File List Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Pkg-View.md Commands used to list files associated with a specific package. ```bash dpkg-query --listfiles pkgname ``` ```bash rpm -ql pkgname ``` ```bash pacman -Qlq pkgname ``` -------------------------------- ### Generate QDirStat Cache File Source: https://github.com/shundhammer/qdirstat/blob/master/README.md Use the qdirstat-cache-writer script to generate a cache file for QDirStat. This can speed up analysis of large, infrequently changing directories. ```bash qdirstat-cache-writer -l ``` -------------------------------- ### Find Mounted Filesystems with findmnt Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Use `findmnt` to show the mount hierarchy of all mounted filesystems. It can filter by filesystem type and does not require root permissions. ```console sh@balrog:~$ findmnt -t ext4,ext3,ext2,xfs,btrfs,fuseblk,vfat,vboxsf TARGET SOURCE FSTYPE OPTIONS / /dev/sdc2 ext4 rw,relatime,errors=remount-ro,data=ordered ├─/hd-root-14-04 /dev/sdb3 ext4 rw,relatime,data=ordered ├─/hd-root-18-04 /dev/sdb2 ext4 rw,relatime,data=ordered ├─/ssd-root-20-04 /dev/sdc3 ext4 rw,relatime,data=ordered ├─/ssd-work /dev/sdc4 ext4 rw,relatime,data=ordered ├─/win/boot /dev/sda1 fuseblk rw,relatime,user_id=0,group_id=0,default_permissions,allow_other ├─/win/app /dev/sda2 fuseblk rw,relatime,user_id=0,group_id=0,default_permissions,allow_other └─/work /dev/sdb5 ext4 rw,relatime,data=ordered ``` ```console tux@linux:~> findmnt -t ext4,ext3,ext2,xfs,btrfs,fuseblk,vfat,vboxsf TARGE SOURCE FSTYPE OPTIONS / /dev/sda2[/@] btrfs rw,relatime,space_cache,subvolid=256,subvol=/@ ├─/opt /dev/sda2[/@/opt] btrfs rw,relatime,space_cache,subvolid=262,subvol=/@/opt ├─/boot/grub2/i386-pc /dev/sda2[/@/boot/grub2/i386-pc] btrfs rw,relatime,space_cache,subvolid=264,subvol=/@/boot/grub2/i386-pc ├─/boot/grub2/x86_64-efi /dev/sda2[/@/boot/grub2/x86_64-efi] btrfs rw,relatime,space_cache,subvolid=263,subvol=/@/boot/grub2/x86_64-efi ├─/var /dev/sda2[/@/var] btrfs rw,relatime,space_cache,subvolid=258,subvol=/@/var ├─/root /dev/sda2[/@/root] btrfs rw,relatime,space_cache,subvolid=261,subvol=/@/root ├─/srv /dev/sda2[/@/srv] btrfs rw,relatime,space_cache,subvolid=260,subvol=/@/srv ├─/usr/local /dev/sda2[/@/usr/local] btrfs rw,relatime,space_cache,subvolid=259,subvol=/@/usr/local ├─/work/tmp work_tmp vboxsf rw,nodev,relatime ├─/work/src work_src vboxsf rw,nodev,relatime └─/home /dev/sda4 ext4 rw,relatime,data=ordered ``` -------------------------------- ### View Cache File Data with QDirStat Source: https://github.com/shundhammer/qdirstat/blob/master/doc/QDirStat-for-Servers.md Open the transferred cache file using QDirStat on your desktop machine via the command line or the 'File' menu. ```bash qdirstat --cache ~/tmp/myserver-root.cache.gz ``` ```bash qdirstat -c ~/tmp/myserver-root.cache.gz ``` -------------------------------- ### Apply Review Feedback Source: https://github.com/shundhammer/qdirstat/blob/master/doc/GitHub-Workflow.md Switches to the pull request branch to incorporate requested changes and pushes them to the fork. ```bash git checkout kilroy-transmogrify ...(add requested fixes...) git commit -am "Added code review changes" git push mine kilroy-transmogrify ``` -------------------------------- ### Generate Cache Files with qdirstat-cache-writer Source: https://context7.com/shundhammer/qdirstat/llms.txt Use this Perl script to generate cache files for remote servers or headless environments. Files can be compressed with gzip if the .gz extension is used. ```bash # Basic usage - write cache to default location (.qdirstat.cache.gz in target directory) qdirstat-cache-writer /home/user # Write to specific cache file (auto-compressed if .gz extension) qdirstat-cache-writer /srv/data /tmp/srv-data.cache.gz # Long format - include full paths for all entries (useful with zgrep as locate replacement) qdirstat-cache-writer -l /home /tmp/home-full.cache.gz # File format 1.0 without UID/GID/permissions (smaller files) qdirstat-cache-writer -1 /var/log /tmp/varlog.cache.gz # File format 2.0 with UID/GID/permissions (default) qdirstat-cache-writer -2 /etc /tmp/etc.cache.gz # Scan mounted filesystems (cross filesystem boundaries) qdirstat-cache-writer -m / /tmp/full-root.cache.gz # Ignore directory own size (useful for CephFS) qdirstat-cache-writer -i /ceph/data /tmp/ceph.cache.gz # Verbose output qdirstat-cache-writer -v /home/user /tmp/user.cache.gz # Debug mode qdirstat-cache-writer -d /srv /tmp/srv.cache.gz # Combine options qdirstat-cache-writer -l -v -2 /var /tmp/var-detailed.cache.gz ``` -------------------------------- ### List Real Mounts from /proc/mounts Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Filters `/proc/mounts` to show only actual data mounts, excluding system directories like `/sys`, `/proc`, `/dev`, `/run`, and bind-mounts in `/mnt`. ```bash root@linux:~# egrep -v ' /(sys|proc|dev|run|mnt)' /proc/mounts /dev/sdc2 / ext4 rw,relatime,errors=remount-ro,data=ordered 0 0 /dev/sdb2 /hd-root-18-04 ext4 rw,relatime,data=ordered 0 0 /dev/sdb3 /hd-root-14-04 ext4 rw,relatime,data=ordered 0 0 /dev/sdc3 /ssd-root-20-04 ext4 rw,relatime,data=ordered 0 0 /dev/sdc4 /ssd-work ext4 rw,relatime,data=ordered 0 0 /dev/sda1 /win/boot fuseblk rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0 /dev/sdb5 /work ext4 rw,relatime,data=ordered 0 0 /dev/sda2 /win/app fuseblk rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0 ``` -------------------------------- ### Specify Cache File at Command Line Source: https://github.com/shundhammer/qdirstat/blob/master/README.md You can specify a cache file to be read directly by QDirStat using the --cache option. ```bash qdirstat --cache cache-file ``` -------------------------------- ### View QDirStat Cache File with zless Source: https://github.com/shundhammer/qdirstat/blob/master/doc/QDirStat-for-Servers.md Use 'zless' to view the contents of a gzipped QDirStat cache file. This is useful for inspecting the file format and its entries. ```bash [qdirstat 1.0 cache file] # Generated by qdirstat-cache-writer # Do not edit! # # Type path size mtime D /var 4096 0x53cef170 # Device: /dev/sda6 L run 4 0x54bbf0e3 L lock 9 0x54bbf0e3 D /var/cache 4096 0x58125237 D /var/cache/dictionaries-common 4096 0x53ceef0a F hunspell.db 188 0x53ceef0a F ispell-dicts-list.txt 0 0x53ceef0a F wordlist.db 267 0x53cef022 F ispell.db 188 0x53ceef0a F jed-ispell-dicts.sl 881 0x53cef024 F aspell.db 741 0x53cef024 F sqspell.php 366 0x53cef024 F emacsen-ispell-default.el 173 0x53ceef0a F emacsen-ispell-dicts.el 897 0x53cef024 D /var/cache/cracklib 4096 0x53ceef8b F cracklib_dict.pwi 22972 0x53ceef8b F cracklib_dict.hwm 1024 0x53ceef8b F src-dicts 104 0x53ceef8b F cracklib_dict.pwd 412618 0x53ceef8b D /var/cache/cups 4096 0x58a842ad F job.cache 992 0x58a842ad F ppd-updates 271 0x567b004a ``` -------------------------------- ### Configure Custom Cleanup Actions Source: https://context7.com/shundhammer/qdirstat/llms.txt Defines shell command execution for files or directories with support for variable expansion and refresh policies. ```cpp #include "Cleanup.h" #include "CleanupCollection.h" // Create a custom cleanup action QDirStat::Cleanup * cleanup = new QDirStat::Cleanup( "tar cjf '%n.tar.bz2' '%n' && rm -rf '%n'", // Command "Compress and Delete", // Menu title parent ); // Configure the cleanup cleanup->setActive(true); cleanup->setWorksForDir(true); cleanup->setWorksForFile(false); cleanup->setWorksForDotEntry(false); cleanup->setRecurse(false); cleanup->setAskForConfirmation(true); // Set refresh policy after execution cleanup->setRefreshPolicy(QDirStat::Cleanup::RefreshParent); // Options: NoRefresh, RefreshThis, RefreshParent, AssumeDeleted // Configure output window behavior cleanup->setOutputWindowPolicy(QDirStat::Cleanup::ShowAfterTimeout); // Options: ShowAlways, ShowIfErrorOutput, ShowAfterTimeout, ShowNever cleanup->setOutputWindowTimeout(3000); // 3 seconds cleanup->setOutputWindowAutoClose(true); // Set shell (default uses $SHELL, fallback to /bin/bash, then /bin/sh) cleanup->setShell("/bin/bash"); // Set icon cleanup->setIcon("archive"); // Variable expansion in commands: // %p - Full path in single quotes: '/home/user/Documents/file.txt' // %n - Name only in single quotes: 'file.txt' // %d - Directory path: '/home/user/Documents' // %terminal - Desktop terminal: konsole, gnome-terminal, xfce4-terminal // %filemanager - Desktop file manager: dolphin, nautilus, thunar // Example cleanup commands: // "xdg-open %p" - Open with default app // "%terminal --workdir %d" - Open terminal here // "%filemanager %d" - Open file manager here // "rm -rf %p" - Delete immediately // "gzip -9 %p" - Compress file // "convert %p -resize 50%% %p" - Resize image // Execute the cleanup on a FileInfo item cleanup->execute(fileInfo, outputWindow); ``` -------------------------------- ### Bind-Mount a Single Directory Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Performs a bind-mount of `/mnt/root/work` to `/mnt/shadowed/work`, making the contents of the former accessible at the latter. ```bash root@linux:~# mount -o bind /mnt/root/work /mnt/shadowed/work ``` -------------------------------- ### Create QDirStat Cache with Exclusions Source: https://github.com/shundhammer/qdirstat/blob/master/scripts/pkg-tools/README.md Excludes a list of files from an uncompressed QDirStat cache file. The script reads from stdin and writes to stdout. Input must be uncompressed. ```bash zcat qdirstat-cache.gz | ./cache-exclude exclude-file | gzip >result-cache.gz ``` -------------------------------- ### View Git Remotes Source: https://github.com/shundhammer/qdirstat/blob/master/doc/GitHub-Workflow.md Verify the configured remotes ('mine' and 'upstream') for your local repository. This command lists all remote connections and their associated URLs. ```bash git remote -v ``` -------------------------------- ### Find shadowed files with find Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Use find to locate all files within the shadowed directory. ```console root@linux:~# find /mnt/shadowed -type f ``` -------------------------------- ### Access Filesystem Metadata with FileInfo Source: https://context7.com/shundhammer/qdirstat/llms.txt The FileInfo class provides methods to retrieve file attributes, size metrics, ownership, and tree navigation data. It is designed for high-performance access during large-scale filesystem scans. ```cpp #include "FileInfo.h" #include "DirInfo.h" // Access file properties from a FileInfo pointer void analyzeFile(QDirStat::FileInfo * item) { // Basic identification QString name = item->name(); // Filename without path QString fullPath = item->url(); // Complete path QString baseName = item->baseName(); // Last path component // File type checks if (item->isDir()) { /* Directory */ } if (item->isFile()) { /* Regular file */ } if (item->isSymLink()) { /* Symbolic link */ } if (item->isDevice()) { /* Block or character device */ } if (item->isSparseFile()) { /* File with holes */ } if (item->isBrokenSymLink()) { /* Broken symlink */ } // Size information QDirStat::FileSize size = item->size(); // Logical size (respects hard links) QDirStat::FileSize rawSize = item->rawByteSize(); // Raw byte size QDirStat::FileSize allocated = item->allocatedSize(); // Actual disk allocation QDirStat::FileSize blocks = item->blocks(); // 512-byte blocks // For directories/subtrees QDirStat::FileSize totalSize = item->totalSize(); int totalFiles = item->totalFiles(); int totalSubDirs = item->totalSubDirs(); int totalItems = item->totalItems(); // Timestamps time_t mtime = item->mtime(); short year = item->mtimeYear(); // 1970-2037 short month = item->mtimeMonth(); // 1-12 // Ownership and permissions if (item->hasUid()) { uid_t uid = item->uid(); QString userName = item->userName(); } if (item->hasGid()) { gid_t gid = item->gid(); QString groupName = item->groupName(); } if (item->hasPermissions()) { QString symbolic = item->symbolicPermissions(); // "-rwxr-xr-x" QString octal = item->octalPermissions(); // "0755" } // Tree navigation QDirStat::DirInfo * parent = item->parent(); QDirStat::FileInfo * sibling = item->next(); QDirStat::DirTree * tree = item->tree(); int depth = item->treeLevel(); // Percentage of parent float percent = item->subtreePercent(); } ``` -------------------------------- ### Make Script Executable Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Grant execute permissions to the downloaded `unshadow-mount-points` script using `chmod`. This allows the script to be run directly from the command line. ```bash tux@linux:~/tmp> chmod 755 unshadow-mount-points ``` -------------------------------- ### List Btrfs Subvolumes on Root Device Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Shows all entries in `/proc/mounts` that use the specified root device, useful for identifying Btrfs subvolumes. ```bash tux@linux:~> grep $ROOT_DEVICE /proc/mounts /dev/sda2 / btrfs rw,relatime,space_cache,subvolid=256,subvol=/@ 0 0 /dev/sda2 /boot/grub2/i386-pc btrfs rw,relatime,space_cache,subvolid=264,subvol=/@/boot/grub2/i386-pc 0 0 /dev/sda2 /boot/grub2/x86_64-efi btrfs rw,relatime,space_cache,subvolid=263,subvol=/@/boot/grub2/x86_64-efi 0 0 /dev/sda2 /opt btrfs rw,relatime,space_cache,subvolid=262,subvol=/@/opt 0 0 /dev/sda2 /var btrfs rw,relatime,space_cache,subvolid=258,subvol=/@/var 0 0 /dev/sda2 /root btrfs rw,relatime,space_cache,subvolid=261,subvol=/@/root 0 0 /dev/sda2 /srv btrfs rw,relatime,space_cache,subvolid=260,subvol=/@/srv 0 0 /dev/sda2 /usr/local btrfs rw,relatime,space_cache,subvolid=259,subvol=/@/usr/local 0 0 ``` -------------------------------- ### Manage Directory Trees with DirTree Source: https://context7.com/shundhammer/qdirstat/llms.txt Use the DirTree class to initiate directory scans, handle caching, and navigate the resulting tree structure. Ensure proper signal connections are established to monitor the asynchronous reading process. ```cpp #include "DirTree.h" #include "FileInfo.h" #include "DirInfo.h" // Create and start reading a directory tree QDirStat::DirTree * tree = new QDirStat::DirTree(); // Connect signals for progress updates connect(tree, &QDirStat::DirTree::startingReading, this, &MyClass::onStartReading); connect(tree, &QDirStat::DirTree::finished, this, &MyClass::onReadingFinished); connect(tree, &QDirStat::DirTree::aborted, this, &MyClass::onReadingAborted); connect(tree, &QDirStat::DirTree::progressInfo, this, &MyClass::onProgressInfo); // Start reading from a path tree->startReading("/home/user/Documents"); // Or read from a cache file tree->clearAndReadCache("/tmp/server.cache.gz"); // Configure filesystem boundary crossing (default: false) tree->setCrossFilesystems(false); // Access the tree structure QDirStat::DirInfo * root = tree->root(); QDirStat::FileInfo * topLevel = tree->firstToplevel(); QString device = tree->device(); // e.g., "/dev/sda1" // Locate a file by path QDirStat::FileInfo * item = tree->locate("/home/user/Documents/file.txt"); if (item) { qDebug() << "Found:" << item->url() << "Size:" << item->size(); } // Refresh a subtree tree->refresh(someDirInfo); // Write cache file for later use tree->writeCache("/tmp/documents.cache.gz"); // Check reading state if (tree->isBusy()) { tree->abortReading(); } // Clean up delete tree; ``` -------------------------------- ### Identify Bind Mount Limitations Source: https://github.com/shundhammer/qdirstat/blob/master/doc/Shadowed-by-Mount.md Demonstration of errors encountered when attempting to remove active bind mount points. ```console tux@linux:~/tmp> sudo rm -rf /mnt/shadowed/work_tmp rm: cannot remove '/mnt/shadowed/work_tmp': Device or resource busy tux@linux:~/tmp> sudo mv /mnt/shadowed/work_tmp . mv: cannot remove '/mnt/shadowed/work_tmp': Device or resource busy ``` -------------------------------- ### Transfer Cache Files to Desktop Source: https://github.com/shundhammer/qdirstat/blob/master/doc/QDirStat-for-Servers.md Use scp to copy the generated cache files from the server to your local desktop machine. ```bash scp "root@myserver:~/tmp/*.cache.gz" ~/tmp ```