Subject: Open Source Software Lab
Student: Shambhavi Singh |24BAI10077
Branch: B.Tech CSE (AIML) — 2nd Year
Academic Year: 2026–2027
This folder contains 5 beginner-friendly Bash shell scripts written as part of the university project "Open Source Audit of Git". Each script demonstrates basic Linux shell scripting concepts — variables, if-else, for loops, while loops, case statements, and file I/O.
All scripts are:
- Clean and readable
- Fully commented line by line
- Easy to run on any Ubuntu/Debian Linux system
- Designed to be explained step-by-step in a viva
| File | Purpose | Key Concepts |
|---|---|---|
script1_system_info.sh |
Display OS, kernel, user, uptime, date | Variables, $(), echo |
script2_git_checker.sh |
Check if Git is installed, show version | if-else, case, command -v |
script3_directory_audit.sh |
Audit directories — show permissions and size | for loop, ls -ld, du -sh, printf |
script4_log_analyzer.sh |
Analyze a log file for errors and warnings | $1 argument, grep, wc, while loop |
script5_manifest.sh |
Ask 3 questions, save answers to a file | read, heredoc, date timestamp |
chmod +x script1_system_info.sh
chmod +x script2_git_checker.sh
chmod +x script3_directory_audit.sh
chmod +x script4_log_analyzer.sh
chmod +x script5_manifest.sh# Script 1 — No arguments needed
bash script1_system_info.sh
# Script 2 — No arguments needed
bash script2_git_checker.sh
# Script 3 — No arguments needed
bash script3_directory_audit.sh
# Script 4 — Pass a log file path as argument
bash script4_log_analyzer.sh /var/log/syslog
# Script 5 — No arguments needed (interactive)
bash script5_manifest.shDisplays a clean summary of the current Linux system:
- OS name (from
/etc/os-release) - Kernel version (
uname -r) - Logged-in user (
$USER) - System uptime (
uptime -p) - Current date and time (
date) - Hostname (
hostname) - Total RAM and disk usage
Checks whether Git is installed on the system:
- Uses
command -v gitto detect Git - Displays the installed version
- Uses a
casestatement to print a relevant message based on the version number
Loops through five important Linux directories:
/etc /home /usr/bin /var/log /tmp
For each directory it shows:
- Permission string (e.g.
drwxr-xr-x) - Disk usage size (e.g.
5.8M)
Output is formatted in aligned columns using printf.
Accepts a log file as a command-line argument ($1) and:
- Counts total lines in the file
- Counts lines containing
error(case-insensitive) - Counts lines containing
warning - Prints the first 5 error lines using a
whileloop - Gives a final verdict: clean / a few errors / many errors
Usage:
bash script4_log_analyzer.sh /var/log/syslogTo create a test log file:
cat > test.log << EOF
2026-03-26 10:00 INFO Server started
2026-03-26 10:01 ERROR Failed to connect to database
2026-03-26 10:02 WARNING Retry attempt 1 of 3
2026-03-26 10:03 ERROR Connection timeout
2026-03-26 10:04 INFO Reconnecting...
EOF
bash script4_log_analyzer.sh test.logInteractively asks the user 3 questions using read:
- Full name
- Favourite programming language
- Why they chose the AIML branch
Saves the answers into a text file with a timestamp in the filename (e.g. manifest_2026-03-26_15-45-00.txt) so each run creates a new unique file. Uses a heredoc (cat << EOF) to write formatted content into the file.
| Concept | Used In |
|---|---|
Variables and $() substitution |
Script 1, 2, 4, 5 |
if / else / fi |
Script 2, 3, 4, 5 |
case / esac |
Script 2 |
for loop |
Script 3 |
while loop |
Script 4 |
read (user input) |
Script 5 |
grep -i -c (search & count) |
Script 4 |
wc -l (line count) |
Script 4 |
printf (formatted output) |
Script 3 |
du -sh (disk usage) |
Script 3 |
ls -ld (permissions) |
Script 3 |
Heredoc cat << EOF |
Script 5 |
date for timestamps |
Script 5 |
exit 1 (error handling) |
Script 4 |
2>/dev/null (suppress errors) |
Script 3 |
- Linux (Ubuntu 20.04+ or similar)
- Bash shell (
bash --version) - Git installed (for Script 2 to detect it)
- No additional packages required
Shambhavi Singh
Registration No: 24BAI10077
B.Tech CSE — Artificial Intelligence & Machine Learning
2nd Year | Open Source Software Lab | 2026–2027
These scripts are part of the university project: Open Source Audit of Git