System information commands in Unix, such as uname
, df
, du
, and free
, are used to retrieve various types of information about the system's configuration, disk space usage, and memory usage. Here's a detailed explanation of each command with more examples:
1. uname
Command:
The uname
command is used to display system information, including the system name, kernel version, and more.
Basic Usage:
uname [options]
Common Options:
-a
: Display all available information.-s
: Display the system name.-n
: Display the network node hostname.-r
: Display the kernel release.-v
: Display the kernel version.-m
: Display the machine hardware name.-p
: Display the processor type.-i
: Display the hardware platform.
Example:
$ uname -a
Linux myserver 4.15.0-74-generic #84-Ubuntu SMP Thu Dec 19 08:06:28 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
2. df
Command:
The df
command is used to display disk space usage on mounted filesystems.
Basic Usage:
df [options] [filesystem]
filesystem
: Specify a specific filesystem or directory to display disk usage for.
Common Options:
-h
: Display sizes in a human-readable format (e.g., MB, GB).-T
: Display filesystem type.
Examples:
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 20G 10G 8.5G 54% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sdb1 100G 50G 50G 50% /data
3. du
Command:
The du
command is used to display the estimated file and directory space usage.
Basic Usage:
du [options] [directory/file]
directory/file
: Specify a directory or file to calculate disk usage for.
Common Options:
-h
: Display sizes in a human-readable format (e.g., MB, GB).-s
: Display only the total space used by the specified directory or file.
Examples:
$ du -h /var/log
10M /var/log
$ du -sh /var/log
10M /var/log
4. free
Command:
The free
command is used to display system memory usage, including total, used, free, and swap memory.
Basic Usage:
free [options]
Common Options:
-h
: Display memory sizes in a human-readable format (e.g., MB, GB).-t
: Display a total line summarizing memory and swap usage.
Examples:
$ free -h
total used free shared buff/cache available
Mem: 7.7G 3.2G 1.6G 1.4G 2.8G 2.9G
Swap: 2.0G 190M 1.8G
These system information commands are valuable for monitoring and managing system resources, disk space, and memory usage. They provide crucial insights into system health and performance, helping you troubleshoot issues and optimize resource utilization in a Unix-like environment.