The purpose of this lab is to develop skills in using, storing, and manipulating data in bash scripts. Do the practice activities before trying to do the hostname-changer.sh script.
The purpose of the script is to download some image files, put them into your ~/public_html/pics directory, and then summarize what was put there. The script uses the test command to check if files and directories exist before trying to use them. It can be improved fairly easily.
$ getpics.sh
Found 23 files in the Pictures directory.
The Pictures directory uses 4.3M space on the disk.
wget -O ~/COMP2101/bash/getpics.sh https://zonzorp.github.io/COMP2101/Labs/bash/scripts-lab2/getpics.sh
chmod +x ~/COMP2101/bash/getpics.sh
vi ~/COMP2101/bash/getpics.sh
getpics.sh
This exercise practices working with arithmetic and producing useful output.
wget -O ~/COMP2101/bash/improveddice.sh https://zonzorp.github.io/COMP2101/Labs/bash/scripts-lab2/improveddice.sh
chmod +x ~/COMP2101/bash/improveddice.sh
improveddice.sh
vi ~/COMP2101/bash/improveddice.sh
improveddice.sh
This exercise provides practice with doing arithmetic and math in a bash script
wget -O ~/COMP2101/bash/arithmetic-demo.sh https://zonzorp.github.io/COMP2101/Labs/bash/scripts-lab2/arithmetic-demo.sh
chmod +x ~/COMP2101/bash/arithmetic-demo.sh
arithmetic-demo.sh
vi ~/COMP2101/bash/arithmetic-demo.sh
arithmetic-demo.sh
This exercise practices using and creating dynamic data on the command line in a script.
wget -O ~/COMP2101/bash/welcome-message.sh https://zonzorp.github.io/COMP2101/Labs/bash/scripts-lab2/welcome-example.sh
chmod +x ~/COMP2101/bash/welcome-message.sh
welcome-message.sh
vi ~/COMP2101/bash/welcome-message.sh
welcome-message.sh
Your task is to improve the script named sysinfo.sh from the previous lab, and to run it on your Linux computer. Be sure you test it and update your github site with your finished script.
The purpose of this script is to display some important identity information about a computer so that you can see that information quickly and concisely, without having to enter multiple commands or remember multiple command options. It is a typical script in that it is intended to be useful, time and labour saving, and easily used by any user of the computer regardless of whether they know or understand any of the commands in your script. The improvements we will do are designed to include more information and make it easier to read with more concise and human friendly data. The following improvements are to be done to get full marks for this lab:
ip route
command to find that address.$ ./sysinfo.sh
Report for myvm
===============
FQDN: myvm.home.arpa
Operating System name and version: Debian GNU/Linux 10 (buster)
IP Address: 192.168.0.16
Root Filesystem Free Space: 5.6G
===============
You can use whatever commands you like to create your script. But ensure your script begins with the command interpreter specification (#!/bin/bash), and has sufficient comments to explain what the script is doing and how it does it. Here is a list of some of the commands you might find useful in your script to generate the necessary output. You can use whatever commands you like, but you need to keep your output labelled, concise, and easy to read. Your work must be your own. Work copied from the internet or from another student will not be accepted.
echo
hostname
ip
grep
df
cut
awk
sed
vi ~/COMP2101/bash/sysinfo.sh
sysinfo.sh
git add ~/COMP2101/bash/sysinfo.sh
git commit -m "your commit comment"
git push
There is nothing to submit for this lab. This lab exists to create a useful script and learn to use some important commands. It will provide the basis for the Bash Assignment later in the course which does count towards your semester mark. Ask your professor for help to complete this lab before starting the next lessson in this course if you are unable to complete it on your own.