User Tools

Site Tools


opus:fall2014:nvitull1:journal

UNIX/Linux Fundamentals Journal

Week 1 - August 25 to August 29 2014

In the first week of class I was introduced to Linux. This has been my first direct experience with the system. In class we have covered several commands such as who and w. We have also covered opening a chat window using the screen, irssi, and server commands. Concepts covered in this week of class have included “The Unix Philosophy”, “3 Types of Files”, and “Access Control”. I found access control to be a little confusing at first but after playing with it for a wile it made a lot more sense. Outside of class I have read the first 3 chapters of “Unix for the Beginning Mage”.

Week 2 - September 1 to September 5 2014

In the 2nd week of class I set up my repository and learned how to push and pull from it. In class we learned about relative and absolute paths. We learned several commands including ctrl c, cat, and echo to name a few. We went over redirects. Note: check email weekly for possible extra credit.

Week 3 - September 8 to September 12 2014

In week 3 we continued to explore the folders we have access to. We were introduced to some cool tools like alpine, cal, date, and pon. Another tool we explored was messaging between two users on the same system. This week we also took a look at our first project and discussed the concepts of Archive and Compression. The climax of this week was vi (visual editor). This is the first time I have ever used an editor where there is a command mode and insert mode. It has taken some getting use to but once familiar I could see how this editor would improve productivity.

Week 4 - September 15 to September 19 2014

In week four we did some more work with Vi exploring the copy command and move. We also looked at searching for regular expressions. Vi is becoming more familiar and easier for me to use. Two important commands to remeber for class are submit unix and status unix.

Week 5 - September 22 to September 26 2014

In week five we learned about the very useful Super Mario Bros. pipe, well maybe it was a unix pipe. this great tool take output from one command and pipes it into input of the next command. We also learned about the head and tail command, as well as the different types of quotes within unix. The highlight of the week was a toss up between the puzzle box project and dinosaurs with hats.

Week 7 - October 6 to October 10 2014

ls -l /bin/ls

process - a program in action

PID = Process identification #

 16 bit number = 2^16 = 65536
 

ps - report a snapshot of the current processes

run cat - in one terminal and run ps in the other to see cat - PID

kill - send a signal to a program

kill -l - this list the ways to kill a program

kill -1 PID - PID is the number of the process

you can not stop a sigkill

ps aux | grep $USER - displays all processes being run by the user

top - displays Linux processes

shell - a user interface

 sh - bourne shell
 bash - bourn again shell
 BSD
 csh - C shell
 

ctrl z stops a process and can be resumed later

bg - puts a process in the back ground fg - fore ground

Week 8 - October 20 to October 24 2014

Tuesday

Knowledge assessment next Thursday

echo $RANDOM = spits out a semi-random number

%Modulus = the remainder when dividing numbers ex. 34 % 5 = 4

/Division = the whole number when dividing numbers ex. 34 / 5 = 6

when moding the remainder will not exceed the divisor. ie 5

- echo $(($RANDOM100%))    this produces a number 0 through 99
- echo $((($RANDOM100%)+1))   this produces a number 1 through 100
  1 #!/bin/bash
  2 choice=$((($RANDOM%100)+1))
  3 guess=0
  4 while [ "$guess" -lt 6 ];do
  5      echo -n "Guess a number: "
  6      read number
  7      if [ "$number" -eq "$choice" ];then
  8           echo "Bam, you got it, hot diggity dog"
  9           exit 0
 10      elif [ "$number" -lt "$choice" ]; then
 11           echo "Highter"
 12      else
 13           echo "Lower"
 14 fi
 15 let guess=$guess+1
 16 done

Thursday

answer=`echo “2+2” | bc` echo $answer

funscript

  1 #!/bin/bash                                                                 
  2 total=0
  3 evens=0
  4 for number in `cat datafile.txt`; do
  5      evencheck=`echo "$number%2" | bc`
  6      if [ "$evencheck" -eq 0 ]; then
  7           let evens=$evens+1
  8      fi
  9      let total=$total+1
 10 done
 11 echo "Out of $total numbers, there are $evens even numbers"
 12 exit 0

The next project

Project Status Script

  1. calculate project points
  2. calculate opus points
  3. calculate attendance points
  4. calculate project % (36%)
  5. calculate opus % (36%)
  6. calculate attendance % (28%)
  7. calculate current grade
  8. display stuff
  
  1 #!/bin/bash                                                                 
  2 opusT=`status unix | grep opus | wc -l`
  3 opusP=0
  4 opusS=`status unix | grep opus | cut -c5 > opusS`
  5 for number in `cat opusS`; do
  6      opusP=`echo "$number"+"$opusP" | bc`
  7 done
  8 echo "Out of $opusT possible points you have earned $opusP"
  9 exit 0

Week 9 - October 27 to October 31 2014

Tuesday

echo "$(echo "(6/7)*100" | bc -l | cut -c1-5)%"

85.71%

status unix | grep "$USER" | tr ' ' '\n' | grep -v '^$' | grep -v "$USER" | wc -w
status unix | grep UNIX | tr ' ' '\n' | grep -v '^$' | grep -v UNIX | wc -w

Week 10 November 3 to November 7 2014

Tuesday

Regular Expressions... Yay!

what can a regular expression(RegEx) do for you?

  1. Regular Expressions operate in files not on the file name
  2. . - match any single character
  3. * - match 0 or more of the previous
  4. [ ] - match 1 of enclosed
  5. [^ ] - do not match 1 of enclosed
  6. \< - match start of word
  7. \> - match end of word
  8. ^ - match start of line
  9. $ - match end of line

Extended RegEx

  1. | - or
  2. ( ) - grouping → \( \)
  3. + - match 1 or more of the previous
cd /usr/share/dict
cat words | grep 'REGEX' | wc -l
cat words | grep '^....$' | wc -l 
* This matches start of line followed by four characters followed by end of line
cat words | grep '...g$' | wc -l
cat words | grep '^....*g$'
* These matches four or more characters with the last one being a g
cat words | grep '^[a-z][a-z][a-z][a-z]*$' | wc -l
* This matches words with three or more lower case letters
cat words | grep '.*[aeiouy].*[aeiouy].*[aeiouy]' | wc -l
* this matches words with three or more vowels
cat words | egrep 'REGEX'
* egrep turns on the extended regular expressions
cat words | egrep '[e][d]$|[i][n][g]$' | wc -l
cat words | egrep '(ed$|ing$) | wc -l
* these matches words ending in ed or ing

Thursday

More Regular Expressions

status unix | grep 'opus' | grep '[02468]entry$'

This prints even days of the opus

Lets get ready to sed

status unix | grep 'opus' | sed 's/^.*\([01]\):\([a-z][a-z]*\):\(week\)\([0-9]\)\(.*\)$/\5 for \3 \4 \2 [\1]/g'

This out puts entry for week # opus [#]

getent passwd | sed 's/^\([a-z][a-z]*\):x:\([0-9][0-9]*\):\([0-9][0-9]*\):\([NBV][a-z]*\)/\4/g'

Week 11 November 10 to November 15 2014

Tuesday

Some new tools

whereis status # shows the path for the status command ./myscript a b c # $# - count of arguments (3) # $* - all your arguments "a b c" # $0 - script name # $1 - "a" # $2 - "b" # $3 - "c" status unix
 output.txt
# this would save the output from the status unix command in output.txt
status unix > ~/tmp/output.txt
rm -f output.txt
# puts the file in a tmp folder and then delets when done
stat ouput.txt | grep Modify | sed 's/^Modify: //g'

date -d "$(stat output.txt | grep Modify | sed 's/^Modify: //g')" +%s
# how old the file is in sec from the start of time
ftime=`date -d "$(stat output.txt | grep Modify | sed 's/^Modify: //g')" +%s`
# saves the time in a file called ftime
ctime=`date +%s`
let dtime=$ctime-$ftime
echo $dtime
time command
# shows the amount of time to run the command

at 531pm
# runs the command at 531pm
cron/crontab

Thursday

scheduling stuff

#at is a one time run and crontab is a reoccurring run
at 16:16
ls > out
# runs the ls command at 16:16 and saves it to out

crontab -e
# edit the crontab
*/4 * * * * /usr/bin/who
# emails the result of who every 4 min

# last - displays every time every one logged in
last | grep nvitull1 | wc -l
#counts the number of time I have logged in
# better to use "$USER" instead of nvitull1

Week 12 November 17 to November 21

Tuesday

A new project - cue the parade

Time Online

-accept via commandline argument, or user input if no arg, the desired user name to process -verify that its a valid user, proced only if valid -for each month of the semester determine number of loggins and total amount of time in days hours min -total loggins for semester, total time for semester -histogram

last - list all the loggons lastlog - list the last log on of each user

Thrusday

Work on stuff day

Week13 December 1 to December 5 2014

Tuesday

The begging of the End!!!

A Palindrome is a word or phrase that is the same forward as backward. like “taco cat”

Grading

status unix | sed -n '/^PROJECTS$/ {s///; :a; n; p; ba; }' | sed -n '/SUBMISSION REPORT/q;p' | sed 's/^.*\([01]\).*/\1/g'

This will print everything after PROJECTS

opus/fall2014/nvitull1/journal.txt · Last modified: 2014/12/02 16:41 by nvitull1