Skip to content
AD-506 · Linux Lab/Quick Revision Short Notes

Linux Lab (AD-506) - Unit 2 Short Notes

How unit 2 is examined

This unit covers shell scripting (variables, if/case, loops, break/continue, sleep, debugging) and the server roles Linux plays; no past question has been asked on either topic.

Shell Variables, Branching, Loops, Break/Continue, Sleep, Debugging

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. ==A shell script is a text file of commands run by the shell, and a shell variable is a named storage location set as name=value and read as $name.==

Key points.

  1. Variables have no spaces around =, and read x takes input.
  2. Branching uses if [ cond ]; then ... elif ... else ... fi and case $x in a) ... ;; esac.
  3. Loops are for i in list; do ... done, while [ cond ]; do ... done and until; break leaves a loop and continue skips to the next pass.
  4. sleep 5 pauses the script for 5 seconds; debug with bash -x script (trace) or set -x.
for i in 1 2 3 4; do
  [ $i -eq 2 ] && continue
  [ $i -eq 4 ] && break
  echo $i; sleep 1
done
# prints 1 then 3

Linux as Web, File, Directory, Application, DNS, SMTP, Firewall and Proxy Server

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>Linux is used as a server OS because it is stable, secure and free, and runs one service per role.</mark>

Key points.

  1. Web server: Apache/Nginx serve HTTP pages; file server: Samba/NFS share files; directory server: OpenLDAP keeps user records.
  2. Application server: Tomcat runs Java applications; DNS server: BIND maps names to IP addresses; SMTP server: Postfix/Sendmail sends mail.
  3. Firewall: iptables/nftables filter packets by rules; proxy server: Squid caches and filters client web requests.

Last-minute revision

  • Assign x=5, read $x, no spaces around =.
  • if ... fi, case ... esac, loops end with done.
  • break exits the loop; continue skips one pass.
  • sleep N waits N seconds.
  • bash -x or set -x debugs a script.
  • Apache = web, Samba = file, LDAP = directory, Tomcat = application.
  • BIND = DNS, Postfix = SMTP, iptables = firewall, Squid = proxy.

Memory hooks

  • Blocks close backwards: if-fi, case-esac.
  • Web-file-directory-app-DNS-SMTP-firewall-proxy: A S L T B P I S.

Coverage checklist

  • Shell Variables, Branching Control Structures, Loop-Control Structure, Continue and break Statements, Sleep Command, Debugging Script: no past questions.
  • Use of Linux as webserver, file server, directory server, application server, DNS server, SMTP server, Firewall, Proxy server: no past questions.
Go to where you left off?

Quick Add to Notes

Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.

Create free account

Have an account? Log in