Module 6
Module 6
Module 6
Shell Scripting
Linux Kernel
• What is a Kernel?
• Interface between hardware and Software
Browser, sendmail
Software
GUI, bash, csh
Operating System
Program
CPU, Memory, HD
• What is a Shell?
• Its like a container
• Interface between users and Kernel/OS
• CLI is a Shell
Starting a Shell
• Type shell name e.g. csh
• Type exit to exit out of shell
• Shell (#!/bin/bash)
• Comments (# comments)
• Commands (echo, cp, grep etc.)
• Statements (if, while, for etc.)
• Shell script should have executable permissions (e.g. -rwx r-x r-x)
• Shell script has to be called from absolute path (e.g /home/userdir/script.bash)
• If called from current location then ./script.bash
• Creating tasks
• Telling your id, current location, your files/directories, system info
• Creating files or directories
• Output to a file “>”
• Filters/Text processors through scripts (cut, awk, grep, sort, uniq, wc)
read
echo
• If then statement
• For loops
• do while
while [ condition ]
do
command1
command2
commandN
done
• Case
• User = /home/user/.bashrc
• Global = /etc/bashrc
alias hh=“hostname”
• Command “history”