This Bash script allows you to quickly gather system information such as disk usage, memory usage, and CPU-consuming processes. It comes with an easy-to-use interface that accepts command-line options to specify what information to display. The script also offers the ability to export the output to a file.
- Show disk usage sorted by usage percentage in descending order.
- Display memory usage in a human-readable format.
- Show the top 10 CPU-consuming processes.
- Supports both short-form and long-form command-line options.
- Optional output redirection to a file.
- Bash Shell Interpreter
df
,free
, andps
utilities should be installed on the system.
Run the script using the following syntax:
./sys_info.sh [options] [output_file]
-d, --disk
: Show disk usage, sorted by usage percentage.-m, --memory
: Display memory usage in a human-readable format.-p, --process
: Show the top 10 CPU-consuming processes.-h, --help
: Display the help message and exit.
output_file
: Optional parameter specifying the file to which the output will be saved. If not provided, output will be displayed on the terminal.
./sys_info.sh -h
To display disk usage sorted by usage percentage in descending order, use the following command:
./sys_info.sh -d
To display memory usage in a human-readable format, use the following command:
./sys_info.sh -m
To show the top 10 CPU-consuming processes, use the following command:
./sys_info.sh -p
You can redirect the output to a file by providing the output_file parameter. For example, to save disk usage information to a file named "disk_usage.txt," you can use the following command:
./sys_info.sh -d disk_usage.txt
This script is provided under the MIT License.
DrIOSx