This nice one-liner will print all filesystems and how much space is used and free on each one.
┗━━━━━━━━━━┓ john@localhost ~/Documents ┗━━━━━━━━━━━━━╾ ╍▷ df -h | awk '!/\/var*/ {print $6 "\t\t" $5 "\t\t " $4 "\t " $3 "\t\t " $2}' Mounted Use% Avail Used Size /dev 0% 4.0M 0 4.0M /dev/shm 0% 7.7G 0 7.7G /run 1% 3.1G 23M 3.1G / 23% 55G 16G 70G /mnt/ubuntu 75% 225G 645G 916G /boot 50% 515M 500M 1014M /home 15% 124G 22G 145G /run/user/1000 1% 1.6G 116K 1.6G |
This is very useful to get a picture of the filesystem usage.
The example below will print the creation date of all mounted filesystems on Linux.
[root@localhost Documents]# df -h | awk '! /\/var*/ {print $6}' | tail -n +2 | while read mount; do echo "$mount: $(stat -c %w $mount)"; done /dev: - /dev/shm: - /run: - /: 2023-02-06 13:20:59.262509000 +1100 /mnt/ubuntu: 2020-07-03 15:20:40.000000000 +1000 /boot: 2023-02-06 13:20:47.346778000 +1100 /home: 2023-02-06 13:20:55.893416000 +1100 /run/user/1000: - /run/media/john/707B-A3DF: - |
You may also do it this way.
┗━━━━━━━━━━┓ john@localhost ~/Documents ┗━━━━━━━━━━━━━╾ ╍▷ df -Hla df: /run/user/1000/doc: Operation not permitted Filesystem Size Used Avail Use% Mounted on proc 0 0 0 - /proc sysfs 0 0 0 - /sys devtmpfs 4.2M 0 4.2M 0% /dev securityfs 0 0 0 - /sys/kernel/security tmpfs 8.3G 0 8.3G 0% /dev/shm devpts 0 0 0 - /dev/pts tmpfs 3.3G 24M 3.3G 1% /run cgroup2 0 0 0 - /sys/fs/cgroup pstore 0 0 0 - /sys/fs/pstore none 0 0 0 - /sys/fs/bpf /dev/mapper/rl-root 76G 17G 59G 23% / selinuxfs 0 0 0 - /sys/fs/selinux systemd-1 - - - - /proc/sys/fs/binfmt_misc tracefs 0 0 0 - /sys/kernel/tracing mqueue 0 0 0 - /dev/mqueue debugfs 0 0 0 - /sys/kernel/debug hugetlbfs 0 0 0 - /dev/hugepages fusectl 0 0 0 - /sys/fs/fuse/connections configfs 0 0 0 - /sys/kernel/config /dev/loop1 132k 132k 0 100% /var/lib/snapd/snap/bare/5 /dev/loop0 262M 262M 0 100% /var/lib/snapd/snap/audacity/1051 /dev/loop4 123M 123M 0 100% /var/lib/snapd/snap/core/14784 /dev/loop2 123M 123M 0 100% /var/lib/snapd/snap/core/14447 /dev/loop5 67M 67M 0 100% /var/lib/snapd/snap/core20/1852 /dev/loop3 67M 67M 0 100% /var/lib/snapd/snap/core20/1778 /dev/loop7 97M 97M 0 100% /var/lib/snapd/snap/gtk-common-themes/1535 /dev/loop6 99M 99M 0 100% /var/lib/snapd/snap/mpv/1 /dev/sda1 983G 692G 241G 75% /mnt/ubuntu /dev/sdb1 1.1G 524M 540M 50% /boot /dev/mapper/rl-home 156G 24G 133G 15% /home sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs tmpfs 1.7G 119k 1.7G 1% /run/user/1000 gvfsd-fuse 0 0 0 - /run/user/1000/gvfs binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc /dev/sdc1 17G 16G 527M 97% /run/media/john/707B-A3DF |
If the parted utility is installed, this may be used to get information about your filesystems.
[root@localhost Documents]# parted -l Model: ATA WDC WD10EZEX-22M (scsi) Disk /dev/sda: 1000GB Sector size (logical/physical): 512B/4096B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 999GB 999GB primary ext4 3 999GB 1000GB 537MB primary fat32 boot Model: ATA WDC WDS240G2G0A- (scsi) Disk /dev/sdb: 240GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 1075MB 1074MB primary xfs boot 2 1075MB 240GB 239GB primary lvm Model: USB DISK 3.0 (scsi) Disk /dev/sdc: 16.2GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 4129kB 16.2GB 16.2GB primary fat32 lba |
Yet another way is using the Gnome Disks utility. This displays a list of all filesystems and you may click one to get a display of usage and free space.
The Gnome System Monitor application can also display all filesystems and disk usage. It is also possible to get the file creation date of a certain file with a small C program. Here is an example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include <stdio.h> #include <time.h> #include <stdlib.h> #include <sys/stat.h> int main() { struct stat file_stat; const char* filename = "ls.c"; if (stat(filename, &file_stat) == 0) { printf("File creation time: %s", ctime(&file_stat.st_ctime)); } else { printf("Error getting file information\n"); } return 0; } |