linux file system related commands (df/du/fsck/dumpe2fs)

1, File system view command df

format

df [options] [mount point]

option

Name Effect
-a Display all file system information, including special file systems, such as / proc,/sysfs
-h Display capacity in customary units, such as KB,MB or GB
-T Show file system types
-m Display capacity in MB
-k Display capacity in kilobytes. The default is kilobytes

Example

# df command
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# df
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/vda1       41151808 13866168  25172208  36% /
devtmpfs          932240        0    932240   0% /dev
tmpfs             941744        0    941744   0% /dev/shm
tmpfs             941744      492    941252   1% /run
tmpfs             941744        0    941744   0% /sys/fs/cgroup
tmpfs             188352        0    188352   0% /run/user/0

[root@izm5e2q95pbpe1hh0kkwoiz tmp]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        40G   14G   25G  36% /
devtmpfs        911M     0  911M   0% /dev
tmpfs           920M     0  920M   0% /dev/shm
tmpfs           920M  492K  920M   1% /run
tmpfs           920M     0  920M   0% /sys/fs/cgroup
tmpfs           184M     0  184M   0% /run/user/0

2, Count directory or file size

format

du [options] [directory or filename]

option

option Effect
-a Display the disk usage of each sub file. By default, only the disk usage of subdirectories is counted
-h Use custom units to display disk usage, such as KB,MB or GB
-s Count the usage, not list the usage of subdirectories and sub files

Example

[root@izm5e2q95pbpe1hh0kkwoiz tmp]# du -h
4.0K    ./.font-unix
4.0K    ./.ICE-unix
4.0K    ./.X11-unix
4.0K    ./.XIM-unix
36K     ./hsperfdata_root
4.0K    ./systemd-private-9255c5ee9ec84f5987c1d9ba485e177e-ntpd.service-eKcnmD/tmp
8.0K    ./systemd-private-9255c5ee9ec84f5987c1d9ba485e177e-ntpd.service-eKcnmD
4.0K    ./.Test-unix
512K    .

[root@izm5e2q95pbpe1hh0kkwoiz tmp]# du -sh
512K    .

The difference between du command and df command

df command statistics space is larger than du command statistics space!!!!

Space occupied (the most common is that the file has been deleted, but the program does not free space)

The du command is file oriented and only calculates the space occupied by the file or directory

3, File system repair command fsck

format

fsck [options] partition device filename

Automatic execution of system startup

option

option Effect
-a Automatically repair file system without user prompt
-y Auto repair. Works the same as - a, but some file systems only support - y

4, Display disk status command dumpe2fs

format

dumpe2fs partition device filename

Example

[root@izm5e2q95pbpe1hh0kkwoiz tmp]# df
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/vda1       41151808 13866916  25171460  36% /
devtmpfs          932240        0    932240   0% /dev
tmpfs             941744        0    941744   0% /dev/shm
tmpfs             941744      492    941252   1% /run
tmpfs             941744        0    941744   0% /sys/fs/cgroup
tmpfs             188352        0    188352   0% /run/user/0


[root@izm5e2q95pbpe1hh0kkwoiz tmp]# dumpe2fs /dev/vda1
dumpe2fs 1.42.9 (28-Dec-2013)
Filesystem volume name:   <none>
Last mounted on:          /
Filesystem UUID:          eb448abb-3012-4d8d-bcde-94434d586a31
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              2621440
Block count:              10485248
Reserved block count:     524262
Free blocks:              8958387
Free inodes:              2519237
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      1021
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
RAID stride:              32639
Flex block group size:    16
Filesystem created:       Sun Oct 15 23:18:59 2017
Last mount time:          Tue Aug 14 10:15:43 2018
Last write time:          Tue Aug 14 18:15:42 2018
Mount count:              6
Maximum mount count:      -1
Last checked:             Wed Jun 27 22:35:57 2018
Check interval:           0 (<none>)
Lifetime writes:          30 GB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               256
Required extra isize:     28
Desired extra isize:      28
Journal inode:            8
First orphan inode:       1050280
Default directory hash:   half_md4
Directory Hash Seed:      2579899c-6862-4625-a8e6-425550384200
Journal backup:           inode blocks
Journal features:         journal_incompat_revoke
Journal size:             128M
Journal length:           32768
Journal sequence:         0x006d2f6d
Journal start:            5782
......

Keywords: Linux Unix Fragment

Added by seventheyejosh on Fri, 28 Feb 2020 09:52:15 +0200