Lab 5 Building a Script

This lab allowed me to apply the knowledge gathered from the past four labs to create a scripts to gather information about the current directory and automate the security of my public_html folder.

Procedure

During this lab session, the first exercise, which involved counting files and directories, was completed. This included writing code to

  1. List the number of hidden files in a given directory,
  2. List the number of hidden files,
  3. List the number of directories,
  4. List the number of hidden directories, excluding the link to the current directory (.) and the parent directory (..),
  5. List the total number of files and directories.

In line with other system utilities which function give details about folders, if no argument was supplied the current directory was the default. This code was saved as folder-stats-1.sh.

For the second exercise, the folder-stats-2.sh file was coded. This code included

  1. Checking permissions of the public_html directory, and recursively listing the permissions of all regular files,
  2. Changing the permissions of all files and directories to drwxr-xr-x to protect security.

Commands

There were no new commands used during this lab.