Talk:COMP 3000 2012 Midterm Material

From Soma-notes
Revision as of 19:18, 24 October 2012 by Cdelahou (talk | contribs) (added lab2)


Discussion

Only the facts

I'll be putting up my notes of notes up here. Hopefully people can benefit from these. I'll be summing up the answers from the lab and adding a few more details here and there.

Lab 1

Types of shell commands

 Built ins
 Shell functions
 binaries (scripts and binaries
 alias 


Shell builtins vs binaries

 binaries exist elsewhere
 faster, no forking needed
 Kernel functions (IO redirection)


ls -l

 1          2  3     4   5     6             7
 -rwxr-xr-x 1 root root 104508 Mar 31  2012 /bin/ls
   U  G  O
 -rwxrwxrwx
 Memnonic: 'You go hugo!'
 - denotes a regular file
 d denotes a directory
 b denotes a block special file
 c denotes a character special file
 l denotes a symbolic link
 p denotes a named pipe


 2) 1 link to /bin/ls
 3) user root
 4) group root
 5) size in bytes
 6) date last modified
 7) path/filename

I/O redirection

 << keyword    HEREDOC. Input until program reads specified keyword
 >> append
 < read from path
 > write to path, blow away anything there
 | pipes

file descriptors

 0 stdin
 1 stdout
 2 stderr
 3-9 other

fd redirection

 #> where # is a file descriptor
 a>&b redirects file descriptor a to b.
 COMMAND &>> file.txt
 Appends BOTH STDERR and STDOUT to file.txt

For loops

 //For all files in fold that start with l, echo the title
 for i in l*; do
   echo $i
 done

Bg vs fg

 Bash waits or doesn't for return
 Both write to stdout as normal

Shell vars

 shell vars only apply to shell. Live in shell
 environment is more global, but typically a COPY is passed on to child processes
 envp is a series of keyvalue strings passed in with exec*

Lab2

Processes

 ps aux
 ps -e
 top


Processes

 run pstree.
 notice that cron, upstart-socket, and others are owned by init. These are daemons.
 notice that gnome display manager is a child of lightdm. Killing lightdm kills
 gnome. That's why we had to log into a virtual console

= Upstart

 init is upstart
 started by kernel. It's the only think the kernel runs in userspace
 shutdown -r now
 switches to run level 6
 shutdown -h now
 switches to run level zero
 symlinks in /etc/init.d point to /lib/init/upstart-job
 successful sysV to upstart transition
 Upstart's entire deal is revamp the ol' sysV boot seq
 traditional init process is strictly synchronous, blocking future tasks until the
 current one has completed. 
 upstart is async. and allows more parralleissimsimsmmmsm

Logs

 /var/log 
 use lsof to check who's accessing a file.
 Rule of thumb.
   if logfile is generic, then written to by rsyslog (udev, auth, etc)
   if logfile has program name, written to by that program (apache)
 rsyslog
   daemon that handles syslog protocol
   handles generic logging for system