I. Viewing memory information
You can use the free command to display the total amount of physical memory and swap partitions for the system, as well as the amount of memory used, idle, shared, in-kernel buffering, and cached.
Use the free command to display the memory capacity of a computer system.
[Email protected] ~]# free--help
Free:invalid option--'-'
Usage:free [-b|-k|-m|-g] [-l] [-o] [-t] [-s delay] [-c Count] [-v]
-b,-k,-m,-g show output in bytes, KB, MB, or GB
-L Show detailed low and high memory statistics
-O use old format (no-/+buffers/cache line)
-t display total for RAM + swap
-s update every [delay] seconds
-c update [count] Times
-V Display version information and exit
[Email protected] ~]#
Example 1: View the total amount of physical memory and swap partitions for the system.
[[email protected] ~]# free
Total used free shared buffers Cached
mem:1592280 368792 1223488 0 51824 122532
-/+ buffers/cache:194436 1397844
swap:3211256 0 3211256
[Email protected] ~]#
Example 2: View the total amount of the system's physical memory and swap partitions in megabytes.
[Email protected] ~]# free-m
Total used free shared buffers Cached
MEM:1554 360 1194 0 50 119
-/+ buffers/cache:189 1365
swap:3135 0 3135
[Email protected] ~]#
Example 3: Displays the sum of physical memory and swap partitions.
[Email protected] ~]# free-t
Total used free shared buffers Cached
mem:1592280 368792 1223488 0 51880 122532
-/+ buffers/cache:194380 1397900
swap:3211256 0 3211256
total:4803536 368792 4434744
Two. View disk space usage
Use the DF command to display information about the disk. Check your file system for disk space usage, and use this command to get information about how much space your hard disk occupies and how much space is left.
[Email protected] ~]# DF--help
USAGE:DF [OPTION] ... [FILE] ...
Show information about the file system in which each file resides,
or all file systems by default.
Mandatory arguments to long options is Mandatory for short options too.
-A,--all include dummy file systems
-B,--block-size=size use size-byte blocks
--direct Show statistics for a file instead of Mount point
--total produce a grand total
-H,--human-readable print sizes in human readable format (e.g., 1K 234M 2G)
-H,--si likewise, but use powers of 1024
-I,--inodes list inode information instead of block usage
-K like--block-size=1k
-L,--local limit listing to local file systems
--no-sync do not invoke sync before getting usage info (default)
-P,--portability use the POSIX output format
--sync invoke sync before getting usage info
-T,--type=type limit listing to file systems of type type
-T,--print-type print file system type
-X,--exclude-type=type limit listing to file systems not of type type
-V (ignored)
--help Display this Help and exit
--version output version information and exit
Example 1: Displays the amount of disk space used by the system.
[[email protected] ~]# DF
Filesystem 1k-blocks used Available use% mounted on
/dev/sda3 27499388 6662112 19440388 26%/
Tmpfs 796140 796052 1%/DEV/SHM
/DEV/SDA1 297485 33069 249056 12%/boot
[Email protected] ~]#
Example 2: Displays the amount of disk space used by the system in megabytes or gigabytes.
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/sda3 27G 6.4G 19G 26%/
Tmpfs 778M 88K 778M 1%/DEV/SHM
/DEV/SDA1 291M 33M 244M 12%/boot
[Email protected] ~]#
Example 3: Display the Ext4 file system type disk space usage.
[Email protected] ~]# df-t EXT4
Filesystem 1k-blocks used Available use% mounted on
/dev/sda3 27499388 6662112 19440388 26%/
/DEV/SDA1 297485 33069 249056 12%/boot
[Email protected] ~]#
Example 4: The file system type is also displayed when disk space usage is displayed in megabytes or gigabytes.
[Email protected] ~]# DF-HT
Filesystem Type Size used Avail use% mounted on
/dev/sda3 ext4 27G 6.4G 19G 26%/
Tmpfs tmpfs 778M 88K 778M 1%/DEV/SHM
/DEV/SDA1 ext4 291M 33M 244M 12%/boot
[Email protected] ~]#
Example 5: Show disk Space I node usage.
[Email protected] ~]# df-i
Filesystem inodes iused IFree iuse% mounted on
/dev/sda3 1746240 107517 1638723 7%/
TMPFS 199035 3 199032 1%/DEV/SHM
/DEV/SDA1 76912 76873 1%/boot
[Email protected] ~]#
Three. Display the size of the directory or file
Use the du command to display the size of a directory or file.
[email protected] ~]# du--help
Usage:du [OPTION] ... [FILE] ...
Or:du [OPTION] ...--files0-from=f
Summarize disk usage of each FILE, recursively for directories.
Mandatory arguments to long options is Mandatory for short options too.
-A,--all write counts for all files, not just directories
--apparent-size Print apparent sizes, rather than disk usage; Although
The apparent size is usually smaller
Larger due to holes in (' sparse ') files, internal
Fragmentation, indirect blocks, and the like
-B,--block-size=size use size-byte blocks
-B,--bytes equivalent to '--apparent-size--block-size=1 '
-C,--total produce a grand total
-D,--dereference-args dereference only symlinks that is listed on the
Command line
--files0-from=f summarize disk usage of the nul-terminated file
Names specified in file F;
If F Is-then read names from standard input
-h equivalent to--dereference-args (-D)
-H,--human-readable print sizes in human readable format (e.g., 1K 234M 2G)
--si like-h, but use powers of 1024
-K like--block-size=1k
-L,--count-links count sizes many times if hard linked
-M like--block-size=1m
-L,--dereference dereference all symbolic links
-P,--no-dereference don ' t follow any symbolic links (this is the default)
-0,--null end each output line with 0 byte rather than newline
-S,--separate-dirs do not include size of subdirectories
-S,--summarize display only a total for each argument
-X,--one-file-system skip directories on different file systems
Example 1: Displays the size of the file/root/a.sh.
[Email protected] ~]# du/root/a.sh
4/root/a.sh
[Email protected] ~]#
[Email protected] ~]# du-h a.sh
4.0K a.sh
[Email protected] ~]#
Linux Viewing System Information