Lab 1

1

a.

1date

b.

1man head
2man tail
3man touch

c.

  • head: outputs the start of a file. -n is the number of lines to output.
  • tail: outputs the end of a file. -n is 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 to more but allows for backwards paging as well as additional enhancements.
  • man: provides paging through program manuals.

d.

1head -n3 /etc/passwd
2tail -n5 /etc/passwd

e.

1cd ~
2ls
3touch file.txt
4ls

Yes

2

a. We do not see our own KCL usernames in the list because we are not local-users.

b.

1cut -d: -f7 /etc/passwd

c.

1cut -d: -f7 /etc/passwd | uniq

d.

1cut -d: -f7 /etc/passwd | sort | uniq

ef.

1ls /etc/password 1>~/logfile
  • ~/logfile is empty.
1ls /etc/passwd 1>~/logfile
  • ~/logfile contains
1/etc/passwd

g1.

1ls /etc/password 2>/dev/null || echo "Sorry, could not find file"

g2.

1ls /etc/passwd && cut -d: -f7 /etc/passwd | sort | uniq

g3.

1#!/bin/bash
2
3if [ -a $1 ]; then
4  cat $1
5else
6  echo "sorry, cant find file"
7fi