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.
- Variables have no spaces around
=, andread xtakes input. - Branching uses
if [ cond ]; then ... elif ... else ... fiandcase $x in a) ... ;; esac. - Loops are
for i in list; do ... done,while [ cond ]; do ... doneanduntil;breakleaves a loop andcontinueskips to the next pass. sleep 5pauses the script for 5 seconds; debug withbash -x script(trace) orset -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.
- Web server: Apache/Nginx serve HTTP pages; file server: Samba/NFS share files; directory server: OpenLDAP keeps user records.
- Application server: Tomcat runs Java applications; DNS server: BIND maps names to IP addresses; SMTP server: Postfix/Sendmail sends mail.
- 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 withdone.breakexits the loop;continueskips one pass.sleep Nwaits N seconds.bash -xorset -xdebugs 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.