- In my directory on the course linux server (my username
is "gj"), is a directory called "public_html/dropbox". In
this location, create a directory the name of which is your
studentid. Set the permissions on this directory to only
allow yourself all permissions (i.e. make sure that nobody
else on the system can get into this directory). Create a
link called "mysyslog" into your directory, link it to the
file called "syslog" in "public_html/". Make sure you can
read its contents. From here on, all lab exercises should
take place in the directory you have just created (i.e. any
new files you create have to go in there).
# go to the directory, so I don't have to type so much
# create directory, where my studentid is 01234567890
# set the permissions as indicated with chmod
chmod 700 01234567890
#link the file
ln ../syslog 01234567890/mysyslog
#go to the directory
- From mysyslog, select all those lines that have to do
with firewall rules, example:
Feb 13 20:20:33 idallen-home1 kernel: Shorewall:net2all:DROP:IN=eth0 OUT= MAC=00:80:c8:4b:b7:75:00:04:e2:50:08:96:08:00 SRC=184.108.40.206 DST=192.168.9.198 LEN=908 TOS=0x00 PREC=0x00 TTL=117 ID=17592 PROTO=UDP SPT=13111 DPT=1026 LEN=888
But do not select any other lines. Put these lines in a file
called firewall.log You may not use an editor or cut and
# we look for "Shorewall"
grep Shorewall mysyslog > firewall.log
- How many lines are there in firewall.log? How many
different source IP addresses are there in firewall.log? How
many different destination IP addresses? How many different
source ports? How many different destination ports? Find an
efficient way to get these numbers (counting on your fingers
is not efficient!).
# How many lines
wc -l firewall.log
# How many different source IP addresses
cut -d' ' -f9 firewall.log | sort -u | wc -l
# How many different destinateion IP addresses
cut -d' ' -f10 firewall.log | sort -u | wc -l
# How many different source ports
cut -d'=' -f13 firewall.log | sort -u | wc -l
# How many different destination ports
cut -d'=' -f14 firewall.log | sort -u | wc -l
- Create a file called "partgroup", the contents of which
are selected from the GIDs from the first 20 lines of the
password file. Make sure the list is sorted in reverse
numerical order, and remove the highest and lowest number.
You may not use an editor, or copy and paste to create this
file. (Build your command pipeline!) Explain what every part
of the pipeline does (or is supposed to do).
# first 20 lines, GID only (fourth field), sort reverse numeric,
# remove the last line, remove the first line, redirect to "partgroup"
head -20 /etc/passwd | cut -d: -f4 | sort -rn | head -19 | tail -18 > partgroup
- List all the umask setting so that when you create a
file, you end up with permissions r---w-rw-. List all the
umask settings so that when you create a directory, you end up
with permissions r-x-wxrw-.
240, 241, 250, 340, 341, 350, 351