User Tools

Site Tools


opus:fall2014:vgarfiel:start

Victoria's Fall2014 Opus

For Stories, Notes, && Whatever Else I'm Told To Do

Introduction

My name is Victoria Garfield. I originally come from Columbus, GA, but moved to Corning to live with my dad and go to school.
In high school, I took classes in Web Design, and even designed the school's website as a project. From there, I developed a love for coding and wanted to learn more, which influenced my major choice for Computer Science. I also have a deep rooted appreciation for video games, and have played since I was very young thanks to my older brother.
I was raised playing Spyro and Crash Bandicoot on PS1, and The Legend of Zelda and Pokemon on Nintendo64. These days, I play an array of games on the PC, as well as the XBOX and Playstation consoles.

I EAT ONION CHIPS AND TOUCH PEOPLE'S ARMS!~

UNIX/Linux Fundamentals Journal

August 28, 2014

(Keeping these questions on my first entry for reference)

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • Why was this significant?
  • What concepts are you dealing with that may not make perfect sense?
  • What challenges are you facing with respect to the course?

So far, I am struggling with the lecture and grasping how to get to the repository, and to the lab46 chatrooms. Will need to read Unix for the Beginning Mage to help. From reading the text, I am learning basic commands in the terminal such as “cd” to return to home, and “..” to return to the folder above that which I am in.

Other useful commands include:

  • whoami - Prints Username
  • pwd - Prints absolute path of the directory
  • mkdir - creates directory with specified name, i.e mkdir CCC (Creates folder with name CCC)
  • ls - Prints contents of directory

September 3, 2014

Reading “Unix for the Beginning Mage” has basically clarified everything we are currently going over in class. I have finally realized I need to download a Unix program to fully utilize the information in the booklet, so I am doing that now before I continue reading through. I will have it downloaded to my USB so I may use it when I get home as well.

Yesterday we went over nano in class, but I was unaware of it's simple text editing. I will more than likely use nano for taking notes in all of my computer classes once I download Unix to my thumb-drive.

September 4

Put my notes in nano. Will need to figure out how to copy/paste to the Opus.

To copy/paste to Opus:

*In command line: type “cp FILENAME ~/public_html/” *In browser, locate file by typing in URL “lab46.corning-cc.edu/~USERNAME/FILENAME”

September 9

Commands:

  • * status unix- pulls up your attendance and assignments
  • * cal- displays simple calendar in traditional formal
  • * ncal- offers alternative layout, more options, and the date of Easter
  • * date- shows current date and time to the second
  • * man COMMAND- the system's manual pager. Each page argument given to man is normally the name of a program utility or function.
  • * pom- Displays the current phase of the moon.Useful for selecting software completion target dates and predicting managerial behavior.
  • *write “user”- utility that allows you to communicate with other users by copying lines from your terminal to other's.
    • to exit, ctrl+D
    • to turn off messaging: mesg n

September 11

September 11, 2014

*Bill Joy came up with the idea of editing text on a computer screen. -insert text -commands (action)

  • deletion
  • saving
  • print
  • search/replace
  • move

*Became known as a VI or Visual Editor.

*Visual Editor maintained the “bimodal” layout, while other text editors merged them together.

  • Insert Mode: Every key will put characters in the text document
  • Command Mode: Keys turn into commands

*Typing “vi” brings up the text editor. It's a modern version called Vim. 1)

  • First command “i” - Insert.
    • Insert will show up in the bottom left hand corner
  • The ESC key will return you to Command Mode
    • Insert will disappear
    • You can tap ESC as many times as you want, you will go no further than the command mode

Insert Mode

  • “i” - will allow you to edit from where your cursor is placed
  • “I” - will allow you to edit at the beginning of the current line
  • “a” - will allow you to edit to the right of your cursor
  • “A” - will allow you to edit at the end of the current line
  • “o” - inserts a new line below your cursor's position and allows you to edit
  • “O” - inserts new line above your cursor's position and allows you to edit

*Character Navigation

  • You could use the arrow keys to move your cursor, but there is an easier command to get to the beginning of your file

Originally keys h, j, k, l. 2)

  • Adding a number previous to h, j, k, or l, the cursor will move that many spaces in that direction

*Word Navigation

  • The keys w & b will move your cursor by word, rather than space. 3)
    • Like character navigation, adding a number prior to the character will move the cursor that many spaces

*Line-based Navigation

  • The keys ^ & $ will move your cursor by line. 4)
  • Typing #G will take you to the line specified.

Manipulation

  • Typing the “x” key over a character will *cut* the character
    • Adding a number previous to the command will *cut* that number of characters
  • Typing “X” is equivalent to a backspace, and will delete by character as well

To Exit

  • “:w filename” will save as a file 5)
  • “:w” is used if file already exists 6)
  • “:q” quit to prompt save
  • “:q!” quit without saving

ARCHIVE HANDLING PROJECT

To Access The Public Directory & Access Project
  • cd /var/public/UNIX
  • cd archive_handling
    • Includes archive1.zip & archive2.tar.bz2
Copy Files To Directory
  • From within archive_handling folder
    • cp -r /var/public/UNIX/projects/archive_handling
Archive1.zip
  • unzip archive1.zip
    • Yielded 4 files including image1.jpg7), image2.gif8), image3.png9), and image4.txt10)
      • cat all images to view contents [see footnotes]
  • cp image1.jpg ~/public_html
    • did not have access to view in web browser, needed to change permissions
    • used ls -l
    • chmod 611)612)413) image1.jpg
    • Viewed image in web browser, and saw it was a BUNNY
  • cp image3.png ~/public_html
    • used same permissions as image1.jpg
    • Viewed image in web browser, saw it was a HUMPBACK WHALE
Archive2.tar.bz2
  • tar -j14)x15)v16)f17) archive2.tar.bz2
    • used tar -xfjv first, but did not work. Need to put use function last
    • Yielded image1.jpg18), image2.gif19), image3.png20), image4.txt
      • image4.txt showed up in UNIX command line, and was a HORSE
    • cp image2.gif ~/public_html
      • changed file permissions, and viewed image in web browser to see an ELEPHANT
    • cp image3.png ~/public_html
      • file name already existed, so I went back to public_html file to change old file to whale.png
      • changed permissions to file to view in web browser
        • File was corrupted, only half of the image was viewable.
Files In Order By Size

At this point, I created a new file from my home directory called myarchive.tar using the mkdir command. After creating this new file, I used the cp command to move the above listed files from their respective locations to my new file. After the files were copied into myarchive.tar, I entered this folder and used the mv command to change the file names26).

Archive

Now that all of the file names have been changed, I archived the myarchive.tar folder with tar -cvf.

  • -c: create
  • -v: list
  • -f: use
  • Full Command from myarchive.tar file: tar -cvf myarchive.tar smallest.jpg small.txt big.gif biggest.png
Compress

The project page gave direction to use gzip to compress the file, so I used the “man gzip” command to pull up the manual for this command to figure out which number should be specified. During the read, I read about the -n option. “By default, gzip keeps the original file name and timestamp in the compressed file. These are used when compressing the file with the -n option.”

  • -n –no-name
    • When compressing, does not save the original file name and time stamp by defualt

I also read about the -# command which “regulates speed of compression using specified digit #, where -1 indicates fastest (less compression) and -9 indicates slowest (best compression) default is 6

Project calls for second best, so 8 is the -# command used

  • Full command to compress: gzip -n8 myarchive.tar

September 18, 2014

Remember: View submitted projects with
*Submit Unix
Remember: View submitted grades with
*Status Unix

  • cat command
    • -n Numbered Lines
    • -e $ to show end of line
    • -x Shows Hexadecimal readout
  • grep 28)
    • Prints matching lines to pattern provided
    • grep 'word' /filename: shows lines including the characters provided
    • grep '\<word\>' /filename: will show lines including specific word
    • grep -i '\<word\>' /filename: will show lines including specific word regardless of case
    • grep -o '\<word\>' /filename: will show only the word of the line
  • output|input
    • od -x /filename|grep 'text': Will find specific text in hexadecimal format
  • wc -l: Word Count by line

Puzzlbox 1

To access the Project:

lab46:~$ cd /var/public/unix
lab46:/var/public/unix$ ls
archives  courselist  devel  file     grep        ka     list-archives  naming     projects   quests     shell  yeoldepuzzlebox
cluster   cs6         eoce   filters  groups      lab12  misc           narrative  puzzle     regex      stuff
conf      data        ex3    final    index.html  lab2   multitask      patterns   puzzlebox  scripting  web
lab46:/var/public/unix$ cd projects
lab46:/var/public/unix/projects$ ls
archive_handling  dataproc  puzzlebox  puzzlebox2
lab46:/var/public/unix/projects$ cd puzzlebox
lab46:/var/public/unix/projects/puzzlebox$ ls
file.txt  puzzle.txt

I copied the files to my Documents

lab46:/var/public/unix/projects/puzzlebox$ cp file.txt puzzle.txt ~/Documents

I used the file command to see it was an ASCII file:

lab46:~/Documents$ file file.txt
file.txt: ASCII text

Puzzlebox 2

  • Obtaining the files
lab46:~$ cd /var/public/UNIX
lab46:/var/public/UNIX$ cd projects
lab46:/var/public/UNIX/projects$ cd puzzlebox2
lab46:/var/public/UNIX/projects/puzzlebox2$ cp puzzlebox2.zip ~/Documents/Puzzlebox2
lab46:~/Documents/Puzzlebox2$ ls
puzzlebox2.zip
  • File Manipulation
lab46:~/Documents/Puzzlebox2$ unzip puzzlebox2.zip
Archive:  puzzlebox2.zip

The command prompted for a password. I didn't know the password, so I just pressed enter, and a README file appeared, so I used the cat command on the README:

lab46:~/Documents/Puzzlebox2$ cat README
Puzzlebox Deux
==============
You got this far- good!

Now the real fun begins. There is a file in the archive
called 'big_endian.ascii'; its password is "1337" (without the quotes).
Decrypt and extract it from the archive.

Look inside: big_endian.ascii

Figure out the encoding and 'decode' it.

Put it in a file called: stage2

Run this command:

cat stage2 | cut -d':' -f2 > $(cat stage2 | cut -d':' -f1).ascii

List your files. Anything new? That's where you want to direct your
attention next. Another (similar) code, just expressed differently.

Go and decode it, putting the result in a file called: password

The password to unlock the other files is stored in this file! Note
any and all spaces!

You should now be able to decrypt the remainder of the archive; there
are 4 files you are after: part1, part2, part3, and part4.

You need to combine parts 1, 2, and 3 into one file (called together.txt),
and arrange the lines in sequential order. Save the final combined/sorted
file as a file called 'result.txt'.

The contents of the file 'part4' are then to be appended to the end of
your 'result.txt' file.

That's it! Go ahead and submit it! You've solved this Puzzlebox!

The command to submit this project is:

submit unix puzzlebox2 results.txt

Week 6

I was absent this week with a cold, so I have no notes to add to the Opus. However, I did complete the dataproc 10/6/2014-10/7/2014

Week 8

  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 "Pat yourself on the back. You win." 
  9             exit 0 
 10          elif [ "$number" -lt "$choice" ];then 
 11             echo "The number you have guessed is too low." 
 12          else 
 13             echo "The number you have guessed is too high." 
 14          fi
 15 let guess=$guess+1
 16 done 
 17 exit 0

TO RUN THE PROGRAM, DON'T FORGET TO CHANGE THE PERMISSIONS

 chmod 700 nameoffile.sh 

THEN RUN

 ./nameoffile.sh 

LINK TO “while” MAN PAGE: http://linux.die.net/man/1/while

Week 9

How to calculate and display percentage:

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

To isolate attendance:

 status unix | grep $USER 

Get rid of blank lines in attendance:

Week 10

Example Project Thing

*Location:

cd /usr/share/dict

*File contains list of words, the following is how you search content and count lines

*Finds 4 characters or greater in a line

lab46:/usr/share/dict$ cat words | grep '....' | wc -l
98091

*Finds lines starting with 4 characters, then ends

lab46:/usr/share/dict$ cat words | grep '^....$' | wc -l
3352

*Matches lines with four or more characters, and ending with 'g'

lab46:/usr/share/dict$ cat words | grep '^....*g$' | wc -l
6999
lab46:/usr/share/dict$ cat words | grep '...g$' | wc -l
6999

*3 or more words with only lowercase letters

lab46:/usr/share/dict$ cat words | grep '^[a-z][a-z][a-z][a-z]*$' | wc -l
62915

*Finds all lines with at least 3 letters that contain vowels

lab46:/usr/share/dict$ cat words | grep '^.*[aeiouy].*[aeiouy].*[aeiouy].*$' | wc -l
64422
lab46:/usr/share/dict$ cat words | grep '[aeiouy].*[aeiouy].*[aeiouy]' | wc -l
64422

*Finds all lines that end with -ed or -ing

lab46:/usr/share/dict$ cat words | egrep '(ed|ing)$' | wc -l
13412
lab46:/usr/share/dict$ cat words | egrep 'ed$|ing$' | wc -l
13412
Expansion on Regular Expressions

Isolating, and formatting Opus

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

Isolating users and usernames from the 'getent passwd' command

lab46:~$ getent passwd | grep '^[vag]' | sed 's/^\([a-z][a-z0-9]*\):x:\([0-9][0-9]*\):[0-9][0-9]*:\(.*\):\/home\/[a-z0-9]*:\/bin\/bash$/\3 is user \1 with userid \2/' 
games:x:5:60:games:/usr/games:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
Matt Vanderhoof is user alius with userid 1004
Andrew Brundage is user abrunda1 with userid 5501
Alicia L. Strupp,,, is user astrupp with userid 5167
Dr. Hans-Peter Appelt,,, is user appelthp with userid 5024
Gregory Redder is user gr015546 with userid 5440
Anthony Fassett is user afassett with userid 5541
Adam Carpenter is user acarpen5 with userid 5615
Andrew Sowers is user asowers with userid 5688
Abraham Canfield is user acanfie1 with userid 5706
Vincent Cordes is user vcordes1 with userid 5738
Gabriel Gamarra is user ggamarra with userid 5740
Andrew Hazen is user ahazen with userid 5770
Aman Kundlas is user akundlas with userid 5773
Anthony Morse is user amorse15 with userid 5774
Ashley Ward is user award4 with userid 5794
Anna Warunek is user awarunek with userid 5795
Alex Hughes is user ahughe12 with userid 5815
Alex Sutcliffe is user asutclif with userid 5816
Alexandra Sullivan is user asulliv9 with userid 5821
Amy Sutton is user asutton5 with userid 5828
Anthony Dahmane is user adahmane with userid 5839
Alexander Force is user aforce2 with userid 5841
Heidi Gerth is user gerth with userid 5850
Austin Paul is user apaul9 with userid 5854
Alan Smith is user asmit125 with userid 5857
Alana Whittier is user acrowle1 with userid 5861
Arthur Dier is user adier with userid 5862
Alex Fervan is user afervan with userid 5863
Anthony Pardini is user apardini with userid 5864
Grace M. Cooper is user gcooper6 with userid 5883
Gregory M. O'Bryan is user gobrian1 with userid 5893
Gary L. Wentling is user gwentlin with userid 5898
April Campbell is user acampb11 with userid 5901
Ashley Paucke-Sweet is user apauckes with userid 5908
Austin S. Buck is user abuck4 with userid 5912
Aaron T. Carson is user acarson1 with userid 5913
Andrew A. Hoover is user ahoover3 with userid 5914
Anthony Volino is user avolino with userid 5915
Victoria A. Garfield is user vgarfiel with userid 5933
Ashley Greible is user agreible with userid 5938
Austin Sorber is user asorber with userid 5942
Andrew Thomas is user athoma13 with userid 5943

Week 11

FIND OUT WHEN THAT SHIT WAS CREATED

lab46:~$ status unix > output
lab46:~$ stat output
  File: ‘output’
  Size: 1925      	Blocks: 8          IO Block: 1048576 regular file
Device: 15h/21d	Inode: 130943001   Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 5933/vgarfiel)   Gid: ( 5000/   lab46)
Access: 2014-11-11 17:04:51.166171228 -0500
Modify: 2014-11-11 17:04:54.330231551 -0500
Change: 2014-11-11 17:04:54.330231551 -0500
 Birth: -
lab46:~$ stat output | grep "Modify"
Modify: 2014-11-11 17:04:54.330231551 -0500

MAKE THAT SHIT PRETTY

lab46:~$ stat output | grep "Modify" | cut -d : -f2 | date
Tue Nov 11 17:09:12 EST 2014

SHOW HOW LONG AGO FROM THE BEGINNING OF TIME THE FILE WAS CREATED

lab46:~$ date -d "$(stat output | grep 'Modify' | sed 's/^Modify: //g')" +%s
1415743494

CREATE VARIABLES FOR SHORTCUTS

lab46:~$ ftime=`date -d "$(stat output | grep 'Modify' | sed 's/^Modify: //g')" +%s`
lab46:~$ echo $ftime
1415743494

Week 12

“last” - Shows all logins that have occurred from beginning of year “lastlog” - Lists individual user's last login

  1. You can see who hasn't logged in
lab46:~$ lastlog | grep 'Never' | wc -l 
61

Show personal login for the month of October

lab46:~$ last | grep $USER | grep 'Oct' | wc -l 
25

*Write script* timeonline project:
-accept via command-line argument, or user input if no argument, the desired user name to process
-validate that the user exists (be sure the code proceeds only if/when the argument is not met)
-for each month of the semester:
-determine number of logins (display in histogram)
-total time spent on the system for that month
-total logins for semester & total time for semester

1)
Upon opening, you are in command mode
2)
h-left, j-down, k-up, l-right
3)
w-moves right, b-moves left
4)
^-takes you to start of the line, $-takes you to end of the line
5)
save as
6)
save
7) , 9)
produced jibberish
8) , 10)
blank file
11)
user read/write
12)
group read/write
13)
world read
14)
filter archive through bzip2, because of file extenxion
15)
extract files from archive
16)
verbosely list files processed
17)
use archive file
18)
blank
19) , 20)
jibberish
21)
smallest
22)
small
23)
big
24)
biggest
25)
old file name image3.png from zip file
26)
see above footnotes for file names
27)
octal dump
28)
Globally Search for Regular Expression and Print
opus/fall2014/vgarfiel/start.txt · Last modified: 2014/12/21 11:16 by 127.0.0.1