7CCSMNSE Network Security
Lab 1
MSc Computing and Security
1 min read
1
a.
date
b.
man head
man tail
man touch
c.
head: outputs the start of a file.-nis the number of lines to output.tail: outputs the end of a file.-nis the number of lines to output.touch: creates a blank new file.more: a filter for paging through text one screenfull at a time.less: similar tomorebut allows for backwards paging as well as additional enhancements.man: provides paging through program manuals.
d.
head -n3 /etc/passwd
tail -n5 /etc/passwd
e.
cd ~
ls
touch file.txt
ls
Yes
2
a. We do not see our own KCL usernames in the list because we are not local-users.
b.
cut -d: -f7 /etc/passwd
c.
cut -d: -f7 /etc/passwd | uniq
d.
cut -d: -f7 /etc/passwd | sort | uniq
ef.
ls /etc/password 1>~/logfile
~/logfileis empty.
ls /etc/passwd 1>~/logfile
~/logfilecontains
/etc/passwd
g1.
ls /etc/password 2>/dev/null || echo "Sorry, could not find file"
g2.
ls /etc/passwd && cut -d: -f7 /etc/passwd | sort | uniq
g3.
#!/bin/bash
if [ -a $1 ]; then
cat $1
else
echo "sorry, cant find file"
fi