RH134 Ch 1: Shell Scripts for Daily Admin

The WebAsha helpdesk repeats the same commands every morning. Turn them into small Bash scripts: a system summary, a bulk user creator for new trainees, and a fix for a disk-check script a colleague left half working.

Tasks

  1. Create the executable script /usr/local/bin/sysinfo.sh that prints the host name on the first line and the running kernel release on the second line.
  2. Create the executable script /usr/local/bin/mkusers.sh. It takes a file of user names (one per line) as its first argument and creates each user that does not exist yet. Run without an argument it must print a message containing Usage and exit with status 1.
  3. Use your script to create the trainee accounts listed in /root/newhires.txt.
  4. Fix /usr/local/bin/diskcheck.sh: diskcheck.sh 0 must print a line starting with WARNING and diskcheck.sh 100 a line starting with OK. Right now it warns every time.
  5. Save every line of /etc/passwd whose login shell is /bin/bash into /root/bash-users.txt.