Display information about your PC’s processor
You can use the lscpu command in a Linux terminal to display information about your PC’s processor. Here’s a simple Bash program that runs the lscpu command and displays the processor information:
#!/bin/bash
echo "Processor Information:"
lscpu
You can save this script to a file, for example, processor_info.sh, and make it executable using the following command:
chmod +x processor_info.sh
Then, you can run the script in your terminal:
./processor_info.sh
When you run this script, it will execute the lscpu command and display information about your PC’s processor, including details like CPU family, model, number of cores, threads, and more.
Display hard disk information
To display the free capacity of each partition or disk along with the hard disk information, you can modify the Bash script as follows:
#!/bin/bash
echo "Hard Disk Information:"
lsblk
echo -e "\nFree Capacity of Each Partition/Disk:"
df -h
This modified script includes an additional command, df -h, to display the free capacity of each partition or disk in a human-readable format. The -h option is used to show the sizes in human-readable units (e.g., GB, MB).
Save the script, make it executable, and then run it as described in the previous response. It will show both the hard disk information and the free capacity of each partition or disk on your Linux PC.
Display information about your PC’s battery
To display battery information in a Linux terminal, you can use the upower command, which provides information about power devices, including batteries. If you don’t have upower installed, you can install it using your system’s package manager.
Here’s a simple Bash script that uses upower to display battery information:
#!/bin/bash
# Check if upower is installed
if ! command -v upower &> /dev/null; then
echo "upower is not installed. Please install it using your system's package manager."
exit 1
fi
# Get battery information
battery_info=$(upower -i $(upower -e | grep 'BAT') 2>/dev/null)
# Check if battery information is available
if [ -z "$battery_info" ]; then
echo "Battery information not available."
exit 1
fi
# Display battery information
echo "Battery Information:"
echo "$battery_info"
Save this script to a file (e.g., battery_info.sh) and make it executable using the following command:
chmod +x battery_info.sh
Then, you can run the script by executing ./battery_info.sh in your terminal, and it will display the battery information. Please note that the availability of battery information and the format may vary depending on your system and hardware.
display information about your PC’s RAM.
You can use the dmidecode command in a Bash script to display information about your PC’s RAM. dmidecode is a tool that reads information from the system DMI (Desktop Management Interface) table, which includes details about hardware components like RAM.
Here’s a simple Bash script that displays RAM information:
#!/bin/bash
# Check if the dmidecode command is available
if ! command -v dmidecode &> /dev/null; then
echo "dmidecode is not installed. Please install it before running this script."
exit 1
fi
echo "RAM Information:"
dmidecode -t 17 | grep Size
dmidecode -t 17 | grep Type
dmidecode -t 17 | grep Speed
dmidecode -t 17 | grep Manufacturer
dmidecode -t 17 | grep Serial
Save this script to a file, for example, ram_info.sh, and make it executable with the following command:
chmod +x ram_info.sh
You can then run the script by executing:
./ram_info.sh
This script will use dmidecode to extract and display information about the RAM size, type, speed, manufacturer, and serial number. Make sure you have appropriate permissions to run dmidecode, or run the script with sudo if necessary.
Please note that the availability and format of the information may vary depending on your hardware and Linux distribution.