(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:
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:
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.
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”
Commands:
September 11, 2014
*Bill Joy came up with the idea of editing text on a computer screen. -insert text -commands (action)
*Became known as a VI or Visual Editor.
*Visual Editor maintained the “bimodal” layout, while other text editors merged them together.
*Typing “vi” brings up the text editor. It's a modern version called Vim. 1)
*Character Navigation
Originally keys h, j, k, l. 2)
*Word Navigation
*Line-based Navigation
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).
Now that all of the file names have been changed, I archived the myarchive.tar folder with tar -cvf.
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.”
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
Remember: View submitted projects with
*Submit Unix
Remember: View submitted grades with
*Status Unix
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
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
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
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
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
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:
*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
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
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
“last” - Shows all logins that have occurred from beginning of year “lastlog” - Lists individual user's last login
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