Queensborough Community College
Engineering Technology Department
Linux
ET-506
Prof.
John
Ducroiset
Exercise Lecture: 15
Shell Scripting 2
1.
#!/bin/bash
# A simple shell script to display system information
echo "System Information"
echo "--------------------"
echo "Hostname: $(hostname)" echo
"Kernel Version: $(uname -r)" echo
"Uptime: $(uptime -p)" echo "Logged-
in Users: $(who | wc -l)" echo
"--------------------"
exit 0
2.
#!/bin/bash
# Function to display general system information
system_info() { echo "System Information"
echo "--------------------"
echo "Hostname: $(hostname)"
echo "Kernel Version: $(uname -r)" echo
"--------------------"
}
# Function to display system uptime
show_uptime() { echo "System
Uptime"
echo "--------------------" uptime
echo "--------------------"
}
# Function to display available drive space