User Tools

Site Tools


opus:fall2012:escoute1:start

Eric Scouten's Fall2012 Opus

Introduction

I'm Eric Scouten, born and raised in Hornell, NY. I've been familiar with computers since I was a toddler due to my fathers huge interest in them; I've been working with computers on a technical level since I was 14 and built my first tower when I was 15, still using it today. My pursuits are to simply do very well in the subjects I've been taught and continue to expand my knowledge of them indefinitely. My interest in computers has brought me to want to work as a technical director for businesses, as well as a growing interest in the High-Performance Computing sector. As a side interest, I hope to also open up a radio station(broadcasting and internet) of my own for the local areas and internet.

My hobbies include video gaming, guitar, and longboarding. My favorite movie of all time is The Princess Bride. My musical interests are hard rock to melodic death metal; to instrumentals and electonica.

And I'm a proud geek.

September Lessons Learned

Entries

September 5, 2012

The UNIX Philosophy

  • Small is beautiful.
    • A similar phrase would be something like KISS, Keep It Simple Stupid. This clause of the UNIX Philosophy to me invokes consideration of whether I'm typing more than necessary or keeping it short and to the point. It's somewhat of a challenge principle, How short of a sentence does it take to explain your point?
  • Do one thing and do that one thing well.
    • A command has a very specific thing it needs to do. Take the ls command for example, it only does one thing and one thing only, it lists the contents of a directory and that is all. It won't remove anything, it won't copy, it will only do what it was meant to do.
  • Everything is a file.
    • “Everything in a UNIX system is a file. Well, except things that aren't files, such as sockets.”

We also went over file types and file paths, which is mostly covered as my keyword. There are two different file paths, an absolute path and a relative path.

An absolute path looks like this if you change directory: cd /home/name/src

  • Other examples of absolute paths are:
    • /bin (the absolute path for where the basic user commands are stored)
    • /etc (the absolute path for where configuration files are stored)
    • /dev (the absolute path for where device files(special files) are stored)
    • / (this is the root directory)

A relative path would look something like this: cd src

That relative path would only work if you were in the /home/name directory (confirming that using the pmd command)

September 7th, 2012

/lib - library files/functions. Libraries hold and reference to many smaller programs. ldd - command that lists the necessary functions to perform a command.

libc is the standard C library

/media - Directory for mounting file systems on removable media like CD-ROM drives, floppy disks, and Zip drives.

/mnt - where removable devices or temporary file systems are placed upon plug-in. Such as flash drives.

September 12, 2012

Everything(mostly) about Vi

“Vi (pronounce: “vee eye”, not “six”, not “vye”) is an editor. An editor is a program to edit files. Goodbye.”

To launch Vi, just use the vi command. Use vi with a filename after it to open a file, in Vi Two modes..

  1. Command Mode is where many of the keys are simply commands that either edit the file, without going into insert mode, navigate the cursor by jumping words or lines, and doing extra convieniences upon entering insert mode.
  2. Insert Mode is where every key on the keyboard is used to simply type up text and will operate just as if you were in WordPad in Windows. The only way out of insert mode is to hit ESC.

Here are a few commands in no special order..

  • a - append to next character into insert mode
  • A - append to end of line into insert mode
  • i - insert at the end of the line
  • I - insert at beginnning of the line
  • o - insert line below current line
  • O - insert line above current line
  • j - move cursor to the left one character
  • l - move cursor to the right one character
  • j - move cursor down one line
  • k - move cursor up one line
  • ^ - move cursor to the beginning of current line
  • $ - move cursor to the end of current line
  • w - move forward one word
  • W - move forward one word, includes spaces
  • b - move back one word
  • B - move back one word, includes spaces
  • x - deletes single character under cursor location
  • X - backspaces
  • dw - delete word to the right of the cursor
  • db - delete word to the left of the cursor
  • dd - delete line
  • cw - deletes word, enters insert mode
  • cb - delete word back, enter insert mode
  • cW - delete word forward with spaces, enter insert mode
  • cB - delete word back with spaces, enter insert mode
  • p - Paste in current line
  • P - paste under current line
  • yy - yanks line into buffer (cut)
  • yw - yank right word
  • yb - yank left word
  • ~ - toggle case, moves cursor right one
  • s - substitute a character, enter insert mode
  • S - substitute a line, enter insert mode

The colon : is extended command mode, which has some notable commands..

  • :w - write current contents
  • :w filename - write current content to a new file named filename
  • :q - quits
  • :q! - force quit
  • :w! - writes current content over preexisting file
  • :wq - save then quit if it has a filename
  • :r filename - reads the file filename
  • :12,35w smallfile - writes the contents of lines 12 to 35 to a new file named smallfile

September 19, 2012

This day we went over the archiving and compression commands known as tar, which is the archiver and gzip, the compressor. The neat thing about having two commands for this process, you have the option to do one or the other, or both. If you've seen a .zip file before, that is an extension that indicates it was compressed AND archived. That limitation is that you cannot have one or the other through the means of a Windows program like WinZip or 7Zip. tar by definition, saves many files together into a single tape or disk archive and can restore individual files from the archive. Some worthy extensions may include..

  • -c creates, when used this way: tar -c archive.tar foo bar , it will create archive.tar from files foo to bar.
  • -A appends files to an archive
  • -d deletes files in an archive
  • -r append files to the end of an archive
  • -t list contents of an archive
  • -x extract files from an archive
  • -v verbosely list files processed
  • -f file archive

gzip is the compression/decompression tool that is often used after archiving a file. Use gzip [filename] to compress your file Some worthy extensions that should be used accordingly..

  • -d decompress
  • -f force
  • -v verbose
  • -# Regulates the speed of compression with -1 being the fastest and -9 being the best.

In class we also went over the command last and eventually learned how to get personalized information through a super incantation.

The command last lists all the logins for a complete month, in the case of this day, it listed all the logins from the month of September. This will reset once it has become October. You can imagine this being a very hectic, long list but luckily we have some ways to get the information we need.

We can use a pager command such as more which will show a “page” full of lines being generated, and you press space to move onto the next page. You can also use less to list these pages in reverse (from the beginning of the month to end).

A command with the more or less commands must be an incantation through the use of the pipe | . Which would look something like this: last|more or last|less This can be useful but we want more specific information from the last command so we created a super incantation, which is the following.. echo “You logged in `last|grep $USER|wc -l` times this month” To break this down..

  • echo prints the quoted material “You logged in.. times this month”
  • The incantation within the quotes will display the number of logins that the current logged in user has done for that month.
    • last prints the list of logins
    • grep $USER searches for a pattern, in this case, it searches for the logged in username out of the last command's output
    • wc -l counts the lines or the times $USER has logged in and displays this number.

On the current day (9/30/2012), this incantation displays You logged in 28 times this month. This is really cool and all, but imagine if you had to type that every time you wanted to know how many times you've logged in? Let's get lazy!

We next learned how to make any file an executable or program. We can use the incantation we created above and just type it up into a file, or you can be even lazier, and type the incantation and direct its output into a new file by using a full quotation and adding another echo, like so: echo 'echo “You logged in `last|grep $USER|wc -l` times this month”' > login

This will display our incantation into a new file known as login or overwrite the existing file login.

And finally to make this a working program, we need to change the permissions which can be viewed using ls -l.

To change permissions, use the command chmod with the corresponding numbers 744: chmod 744 login

This will make our file a program and you can just run it using ./login assuming you are in the same folder, otherwise change the path accordingly.

Keywords

File Types

The Regular, Directory, and Special File Types

Definition

Unlike most keywords, this one isn't just one simple keyword. A file type is a vague term that represents files, and in order to really know what one is, they should be defined, SUCH AS:

  1. A regular file type: A regular file is the most common file type there is, this file type represents the text files, compressed files, binary files,and “file files.”(not a real file, I just like the word. Basically any file that you would send as an email attachment is considered a regular file, within reason.
  2. A directory file type: A directory file isn't commonly known as a file, but it is. The common folk would call this a “folder”. You put all types of files within a directory file, even another directory file. What a directory file does is points you in the direction of more files, usually more than one. A symbolic link(which is a file) would fall into this category for that reason, which could point to a specific file or a directory. (A file that points to a directory; which points to more files.)
  3. A special file type: A special file is the most uncommon file type. These files define the system devices and temporary files created by processes. There are 4 basic types of files that are considered “special” and they are FIFO (First in, first out) which are also known as pipes, which allow communication between processes temporarily, then there's block and character devices which define devices.

An important consideration when we're talking files is that each file has permissions for them that determine which users can Read, Write, or Execute a file. These are formally known as access modes. These access modes are often represented in this format: Eg. drwxrwxr– or srwxr—–

References

ls

Definition

ls is a command for directory listing. What this mean is it lists all the contents of the directory in a curt manner. Usually just the names of the directories, files, and their file types by color coordination.

  • -l changes how ls operates and causes the command to do a long/detailed listing, revealing the file type and permissions.
  • -al causes a formatted listing with hidden files.

References

  • From the LAIR computer desktop.

unix Keyword 1 Phase 2

Home Directory

Definition

The Home Directory is basically the place that all of a user's files and folders are stored. From the home directory, one may be able to access all of their files, or just access specifically places files. The user is able to completely customize their home directory. When files and folders are in a home directory (including readable, writable, and executable files), they are only able to be accessed by the user or any other administrator on the system. That can be changed at any point, however.

References

Demonstration

Demonstration of the Home Directory

Firstly, we identify where the home directory is. When you log in, you should be able to use the pwd command and boom, you it shows the absolute path of your home directory. Another way to ensure that it is YOUR home directory, you can use pwd $USER and the same result should display. Try that in another relative directory and you will get the same result every time, because $USER represents your username, which is mainly used to identify your home directory.

We can also change directory or cd to your home directory using an absolute path or a relative path if you are in the /home directory.

The home directory is the one directory where it's not recommended to even consider changing the Owner access controls.

One of the most useful things you can do related to your home directory is usage of the cd command in order to quickly return to it, from anywhere in the file system, including finding your way into another user's home directory, you can easily change back to yours with simply cd

And finally you can use ls to see what it looks like to verify that they are your directories.

Assume your username is rabidrabbit

Back to back demonstration..

lab46:~$ pwd
/home/rabidrabbit
lab46:~$ pwd $USER
/home/rabidrabbit
lab46:~$ cd /
lab46:/$ cd /home/$USER
lab46:~$ pwd
/home/rabidrabbit
lab46:~/src/submit$ cd
lab46:~$ pwd
/home/rabidrabbit
lab46:~$ cd /home/tmong
lab46:/home/tmong$ cd
lab46:~$ pwd
/home/rabidrabbit
lab46:~$ ls
Desktop    Downloads  Music     Public     Videos    closet  file.txt     src
Documents  Maildir    Pictures  Templates  archives  data    public_html

Compression Before Archiving Experiment

Question

I notice we always archive a group of files before we compress. What would happen if we compressed these files individually first, then we archived them, would it still give us the same outcome?

Resources

I'll be using the information I learned from class to generate some sort of outcome from this, using the tar and gzip commands exclusively. Most of this information can be referred to my dated entries in this Opus.

Hypothesis

I think that this will work normally. The archiving before compression feels like a good practice but doing it the other way feels taboo. At the end of this experiment, I think we will have the same files we created.

Experiment

I plan on creating a directory for this experiment, to keep all my other stuff safe. Then I'll use the touch command to create 3 files and type in some information in them. Instead of normally using tar first, I'll proceed to compress each of these files, then I'll select them all for archiving. Once that is completed, I'll proceed to reverse this process and hopefully have the same 3 files and the information within them in tact.

Data

lab46:~/closet$ mkdir thelab
lab46:~/closet$ cd thelab
lab46:~/closet/thelab$ touch file1 file2 file3
lab46:~/closet/thelab$ ls
file1  file2  file3
lab46:~/closet/thelab$ vi file1
lab46:~/closet/thelab$ vi file2
lab46:~/closet/thelab$ vi file3
lab46:~/closet/thelab$ cat file1
This is file 1
lab46:~/closet/thelab$ cat file2
This is not file 1 or file 3
lab46:~/closet/thelab$ cat file3
file 3 this is.
lab46:~/closet/thelab$ gzip file1 file2 file3
lab46:~/closet/thelab$ ls
file1.gz  file2.gz  file3.gz
lab46:~/closet/thelab$ tar cvf archive.tar file1.gz file2.gz file3.gz
file1.gz
file2.gz
file3.gz
lab46:~/closet/thelab$ tar tvf archive.tar
-rw-r--r-- escoute1/lab46   39 2012-09-30 17:17 file1.gz
-rw-r--r-- escoute1/lab46   49 2012-09-30 17:09 file2.gz
-rw-r--r-- escoute1/lab46   42 2012-09-30 17:09 file3.gz
lab46:~/closet/thelab$ rm file1.gz file2.gz file3.gz
lab46:~/closet/thelab$ ls
archive.tar
lab46:~/closet/thelab$ tar xvf archive.tar
file1.gz
file2.gz
file3.gz
lab46:~/closet/thelab$ ls
archive.tar  file1.gz  file2.gz  file3.gz
lab46:~/closet/thelab$ gzip -d file1.gz file2.gz file3.gz
lab46:~/closet/thelab$ ls
archive.tar  file1  file2  file3
lab46:~/closet/thelab$ cat file1
This is file 1
lab46:~/closet/thelab$ cat file2
This is not file 1 or file 3
lab46:~/closet/thelab$ cat file3
file 3 this is.

Analysis

Based on the data collected:

  • My hypothesis was correct that whether you compress first or archive first, it does not matter too much.
  • This method is not a lazy method and when you compress files individually, the archive will have a bunch of compressed files instead of simply all the files compressed into one .tar.gz
  • You have to be careful of your naming conventions when you create your tar file, because you can mistakenly have a tar file named as a .gz which will make things funny.

Conclusions

It does not matter which order you do archiving and compression, you will eventually end up with the same files you had before. The archive before compression method we use however is just a lot easier and I now understand why we don't compress first.

October Lessons Learned (Part 2)

Entries

Entry 1: October 3, 2012

Today we went over the numeric based For loop and we spent all class on it. Here's an example that I've somewhat broken down:

for((i=0;i<6;i++));do
  • the i is the looping variable
  • the 0 is the starting value
  • the 6 is the end variable or looping as long as
  • the ++ indicates it will advance i by +1 or for short i = i + 1
    • Similarly, i+ = 2 means i will advance by +2 or for short i = i + 2
    • i*=2 means it will advance multiplied by 2

Here is a sample script we created:

echo -n "Enter a number: "
read number
echo -n "How many times: "
read times
for((i=$number;i=$times;i++));do
      let x=i*i
      echo "[$i] $x"
done

We then were introduced to a few new commands such as cut, sort, and uniq.

  • cut is used to cut away redundant information from a list such as the output of ls -l. You can use cut -d ' ' F1 where F1 indicates the first side or the left side of the cut where the space is. Cut can also cut specific characters in the list by doing cut -d -f -c 20-24, 56-60
  • sort took the listed information and sorted or put remaining redundant information together.
  • uniq polished the output of redundant information and showed all unique information in the list.

We then went over the list based for loop or in other words, a loop that is typed out as a command/incantation

id username
for user in
    echo -n "[$user]"
    id $user

Entry 2: October 10, 2012

This day I thought it was Monday so I wasn't actually around for the lecture, but here's what someone else learned.

mkdir -p

  • the -p is parent folder nesting, which when used with mkdir creates multiple directories accordingly to the absolute or relative path given, creating folders that do not exist as well. For Example!
lab46:~/closet$ mkdir -p parent/child/seamen
lab46:~/closet$ ls
a_used_napkin  login       parent             ricky    seplogin
cabinet        loosemoose  parentchildseamen  script2  skeleton
cake           math        pirate_swag        script3  thelab
lab46:~/closet$ cd parent
lab46:~/closet/parent$ ls
child
lab46:~/closet/parent$ cd child
lab46:~/closet/parent/child$ ls
seamen

There was also a script that was created.. I'll just put that down here and interpret it later. The ^ is a reg function

#!/bin/bash
#
name ="`cat ${0}.conf|grep '^name='|cut -d '=' -f2 2>/dev/null`"
if [-z "${name}"]; then
   echo -n "Who are you?"
   read name
   echo "Pleased to meet you $name"
   echo "name=$name">${0}.conf
   else
   echo "Welcome back, ${name}"
fi

exit1: exit/return value as false exit0: exit/return value

Entry 3: October 12, 2012

On this day, we discussed Programming Paradigms and several types. Here's a bunch,

Structured/Imperative/Procedural

  • lua
  • Java
  • Assembly
  • Paskel
  • PHP
  • Python
  • C
  • Bash
  • Visual Basic

Functional

Lisp - great for lists

Logical

Prolog and Huskel, focuses on as or and nots

Object Oriented

  • C++, Java, Python, Eiffel, Small Talk

Entry 4: October 24th, 2012

On this October day, we discussed a few common debugging strategies in reference to puzzlebox2, I have created a complete Puzzlebox2 guide way down below that entails much of the debugging strategies. We also discussed..

Regular Expressions!

  • Here's a bunch of them listed!
  • ^ match beginning of line
  • $ match end of line
  • \< match beginning of word
  • \> match end of word
  • . match any single character
  • * zero or more of previous
  • [] character class match any of the enclosed
  • [^ ] inverted “ ” do not match any of the enclosed
  • () grouping
  • | or
  • + match 1 or more of the previous

Keywords

I/O Redirection

Definition

There is no clear definition for I/O redirection but both of these in the UNIX universe in particular are actually two components of our interface that we use at every given moment while actively using the terminal or even this browser. The Input is coming from your computer's keyboard or terminal keyboard while the Output is what you see on the monitor typically, such as in the Lab46 Terminal, the text you see is the output. In the middle of both input and output is actually where all the processing happens, this is key to the redirection as it has an effect to where the output will be directed. There are two kinds of I/O redirection, them being represented by the less than and greater than symbols ><. The less than < symbol is what does input redirection, commonly useful for when a program doesn't read files but reads from standard input, for example, you can have file1 send its contents to a mail of some sort like jackrabbit@rabies.org and the command would look something like this: mail jackrabbit@rabies.org < file1

The greater than > symbol does the “opposite” and is used in a different scenario. Say you wanted all the output you receive from issueing an ls -l command to be put into file2. Just do ls > file2 and all that output will be within the file.

Some other important concepts about I/O redirection is usage of the pipe | and the semicolon ;. The pipe and semi are used when you want to use more than one command at one time, but the difference between the two is crucial to a successful incantation. The pipe will redirect output from the initial command into the next command while the semicolon will not redirect any output into the next command, it will just perform it as if you were doing it singularly. A situation where the semicolon is crucial is if you have a cat command following your initial casting.

Now when you use the output redirect, one thing to keep in mind is that if you send another piece of output into file2 with a single >, it will overwrite the file with that new output and the old output from ls -l will no longer be there.

References

  • O'Reilly Learning The UNIX Operating System

unix Keyword 2 Phase 2

processes

Definition

Processes- programs or instances that operate concurrently with one another to produce a result.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

Demonstration

Demonstration of the indicated keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <stdio.h>
 
int main()
{
    return(0);
}

Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:

lab46:~$ cd src
lab46:~/src$ gcc -o hello hello.c
lab46:~/src$ ./hello
Hello, World!
lab46:~/src$ 

Kahmayhamayha!

Question

Can you create an incantation that is capable of make a directory, change into directory, creating two files, creating input to output into said files, rename them, change out of directory, archive it, and then compress it AND THEN decompress and extract them and cat them both as a sign of completion. And if this works, to make this better, make the incantation an application/program.

Resources

In class lectures and the O'Reilly Unix book.

Hypothesis

The incantation itself may be correct and will execute but I feel like a runtime error is possible. Possible problems could be when creating the two files and redirecting output into them and where compression and decompress will happen, as they are back to back.

Experiment

First, I'm going to do everything the normal way, normal as in typing each step out in seperate commands to get a feel for how it will look and ensuring I can assume file names when I tar and gzip. After doing that, I'll create the incantation itself and if it runs correctly, I will adjust it to be outputted into a file named “MobileCommandCenter” that will be the executable of this incantation, then I'll try running it in my practice area, then I'll move MobileCommandCenter into a seperate practice directory and do it again for consistency.

Data

lab46:~/closet/thelab/Experiment2/Practice2$ mkdir directory ; cd directory ; touch file1 file2 ; ls -l /home/$USER > file1 ; ls / > file2 ; mv file1 listhome ; mv file2 listroot ; cd .. ; tar cf directory.tar directory ; gzip directory.tar ; rm -rf directory ; gzip -d directory.tar.gz ; tar xf directory.tar ; cd directory ; cat listhome listroot > completion

Discovered the difference between the | and the ;. Where the | expects output and applies it to the next command, the semicolon ; just does the command on the left and simply moves onto the next without the output carrying over.

lab46:~/closet/thelab/Experiment2/Practice2/directory$ echo 'echo `mkdir directory ; cd directory ; touch file1 file2 ; ls -l /home/$USER > file1 ; ls / > file2 ; mv file1 listhome ; mv file2 listroot ; cd .. ; tar cf directory.tar directory ; gzip directory.tar ; rm -rf directory ; gzip -d directory.tar.gz ; tar xf directory.tar ; cd directory ; cat listhome listroot > completion`' > MobileCommandCenter
lab46:~/closet/thelab/Experiment2$ ./MobileCommandCenter

lab46:~/closet/thelab/Experiment2$ ls
MobileCommandCenter  directory  directory.tar
lab46:~/closet/thelab/Experiment2$ cd directory
lab46:~/closet/thelab/Experiment2/directory$ ls
completion  listhome  listroot
lab46:~/closet/thelab/Experiment2/directory$ cat completion
total 4
drwxr-xr-x 2 escoute1 lab46    6 Sep  5 14:50 Desktop
drwxr-xr-x 2 escoute1 lab46    6 Sep  5 14:50 Documents
drwxr-xr-x 2 escoute1 lab46   21 Sep  5 15:07 Downloads
lrwxrwxrwx 1 escoute1 lab46   18 Sep  2 12:17 Maildir -> /var/mail/escoute1
drwxr-xr-x 2 escoute1 lab46    6 Sep  5 14:50 Music
drwxr-xr-x 2 escoute1 lab46    6 Sep  5 14:50 Pictures
drwxr-xr-x 2 escoute1 lab46    6 Sep  5 14:50 Public
drwxr-xr-x 2 escoute1 lab46    6 Sep  5 14:50 Templates
drwxr-xr-x 2 escoute1 lab46    6 Sep  5 14:50 Videos
drwxr-x--x 3 escoute1 lab46   79 Sep 21 14:32 archives
drwxr--r-- 4 escoute1 lab46 4096 Oct  3 16:21 closet
lrwxrwxrwx 1 escoute1 lab46   28 Sep  7 11:25 data -> /usr/local/etc/data/escoute1
drwxr-x--- 3 escoute1 lab46   38 Oct  3 13:39 naming
drwx-----x 2 escoute1 lab46    6 Aug 26  2009 public_html
drwx------ 6 escoute1 lab46   84 Sep 28 16:52 src
bin
boot
dev
etc
home
initrd.img
lib
lib32
lib64
lost+found
media
mnt
opt
proc
root
sbin
selinux
srv
sys
tmp
usr
var
vmlinuz

Analysis

Based on the data collected:

  • I was wrong to assume that the incantation would “trip over itself” or shoot off commands too fast.
  • The incantation generated the results I was only half expecting and I wish I could apply this further into a script, complete with options and actually useful data instead of just listings, possible Experiment 3?

Conclusions

As long as you can supply the semicolon and pipe properly, you can make your incantations as long as you please, in theory!

Projects

PuzzleBox2

First we started with a file dubbed minecraft.jar but do not be fooled, this is not what it seems! NO MINECRAFT FOR YOU!

Anyway so we check to see what file type this really is using the file command and are returned with information regarding the file.

lab46:~/closet/thelab/puzzlebox2/Opus$ file minecraft.jar
minecraft.jar: 7-zip archive data, version 0.3

As you can see, it tells us of a 7-zip archive file so that must mean that this file is expected to have a .7z file extension in order to be operated upon correctly. So we use the mv command to rename the minecraft.jar file to minecraft.7z and use ls to double check that it is indeed what we want.

lab46:~/closet/thelab/puzzlebox2/Opus$ mv minecraft.jar minecraft.7z
lab46:~/closet/thelab/puzzlebox2/Opus$ ls
minecraft.7z

Now we need to get the content out of this 7zip archive using the 7za command with the e option.

lab46:~/closet/thelab/puzzlebox2/Opus$ 7za e minecraft.7z

7-Zip (A) 9.04 beta  Copyright (c) 1999-2009 Igor Pavlov  2009-05-30
p7zip Version 9.04 (locale=en_US,Utf16=on,HugeFiles=on,2 CPUs)

Processing archive: minecraft.7z

Extracting  ls -l/result
Extracting  ls -l

Everything is Ok

Folders: 1
Files: 1
Size:       878
Compressed: 765
lab46:~/closet/thelab/puzzlebox2/Opus$ ls
ls -l  minecraft.7z  result

As you can see, we now have a directory known as ls -l and a result file. The directory has nothing in it, perhaps some sort of hint, I dont even know but the main show is in the return file. Lets cat this file.

lab46:~/closet/thelab/puzzlebox2/Opus$ cat result
#!/bin/b@ntehuiOUXUXUX@ash
#
# result - s@OUEUEIPYEDEYP@cript to finish up the task
#

echo -n "[p@OEUIDYPYDD@uzzlebox] "

if [ -x "${0@DPY445dyp.pd@}" ]; then
        echo -n @EUEOUEDUIDUIDIUED@"1 "
        if [ -L @EIDUIDIUDUIEDUID@"${0}" ] && [ "${0#**/}" = "solution" ]; then
                echo@UIDUIDIUDUIDUIEDUI@ -n "2 "
                if [@%>PI$F%DYP$F%DYPF$%@ "`tail -1 ${0} | grep \"^#${USER}:.*$\" | wc -l`" -eq 1 ]; then
                        @EUIOUIPD>YDYPH%@echo -n "YES, here is your token: "
                        @IDD6d64464665hyph@md5sum "${0}" | cut -d' ' -f1
                else@uideuydtnhiud@
                        @uidiuedud@echo "Very close."
                        @iudiudiudiudui@exit 1
                fi@uiduiduidiud@
        else@uiduiduiduidiu@
                echo@thndhtndthnth@ "Closer."
                exit@ngyncnycgcgcg@ 1
        fi@dhni887ngccg@
else@gf8y778utguddu@
        echo "No@uidhu7h6hf@t yet."
        exit 1@h7pp6h6h6h7@
fi@fhy890idu908@

exit 0@iuedidiuduid@
#username:@crg56rdhinthntiu@Fill out the previous field as appropriate

Holy craziness batman! Look at all that junk, what's a pattern however? Notice the @ signs and that in every instance of the @ sign, we have a bunch of junk. So we want to just remove all of the content inside these @ signs and the signs themselves in vi. result should now look like this when cated, I'm displaying it in script as it is going to be a script file of sorts.

#!/bin/bash
#
# result - script to finish up the task
#
 
echo -n "[puzzlebox] "
 
if [ -x "${0}" ]; then
        echo -n "1 "
        if [ -L "${0}" ] && [ "${0#**/}" = "solution" ]; then
                echo -n "2 "
                if [ "`tail -1 ${0} | grep \"^#${USER}:.*$\" | wc -l`" -eq 1 ]; then
                        echo -n "YES, here is your token: "
                        md5sum "${0}" | cut -d' ' -f1
                else
                        echo "Very close."
                        exit 1
                fi
        else
                echo "Closer."
                exit 1
        fi
else
        echo "Not yet."
        exit 1
fi
 
exit 0
#username:Fill out the previous field as appropriate

As you can see, we can easily recognize this as a script of some sort, waiting to be executed. But the file is a “normal readable file”, what do we do? Let's do the chmod command followed with 744 result to activate Owner's Executable with Read and Write, while Groups and World remain at Read. Now that our result file is now executable, we now run it with ./result (assuming you are in the directory it is in.

lab46:~/closet/thelab/puzzlebox2/Opus$ chmod 744 result
lab46:~/closet/thelab/puzzlebox2/Opus$ ls
ls -l  minecraft.7z  result
lab46:~/closet/thelab/puzzlebox2/Opus$ ./result
[puzzlebox] 1 Closer.

Our new result script seems to stop at our second if statement, let's disect what might be the cause of the intrusion, as we definately assume we have not reached our end with this puzzlebox. I pose the first question that you should wonder right away: What does the ${0} stand for? What does it mean? Well, take note that the $ indicates it is a variable. To what value or string is it? How do we find this out you may ask? Why not, echo our variables to see what they hide! Be sure to enter them before any if statement in order to prevent some issues. Of course, we edit in vi. ALSO notice that there are two variables.

lab46:~/closet/thelab/puzzlebox2/Opus$ vi result
lab46:~/closet/thelab/puzzlebox2/Opus$ cat result
#!/bin/bash
#
# result - script to finish up the task
#

echo -n "[puzzlebox] "
echo -n "${0} "
echo -n "${0#**/} "

if [ -x "${0}" ]; then
	echo -n "1 "
	if [ -L "${0}" ] && [ "${0#**/}" = "solution" ]; then
		echo -n "2 "
		if [ "`tail -1 ${0} | grep \"^#${USER}:.*$\" | wc -l`" -eq 1 ]; then
			echo -n "YES, here is your token: "
			md5sum "${0}" | cut -d' ' -f1
		else
			echo "Very close."
			exit 1
		fi
	else
		echo "Closer."
		exit 1
	fi
else
	echo "Not yet."
	exit 1
fi

exit 0
#username:Fill out the previous field as appropriate

And we run result once again..

lab46:~/closet/thelab/puzzlebox2/Opus$ ./result
[puzzlebox] ./result result 1 Closer.

Ah now that is interesting! We have been returned a (dot)/result and a result for our output along with the resulting if statement's output. That must mean that our variable {0} is the executable version of result, whilst our other variable is the file itself.

Now lets look at where we are getting our 1 Closer. Here's a better view of what if statement we are speaking of.

if [ -L "${0}" ] && [ "${0#**/}" = "solution" ]; then
		echo -n "2 "

Assuming you've done some research on the [ using the man, we would recognize the -L as a symbolic link. So the first part is a symbolic link of the executable result. The && indicates an AND operator, indicating this symbolic link is to fulfill both the executable and the file itself based on the second variable, and then we see an = “solution”, meaning it is looking for a symbolic link that is named solution that points to the result data file. With all that in mind, what do you think we should do? CREATE a symbolic link! (AYUAYAYAHAY!) We do this using ln -s [TARGET FILE] [SYMBOLIC LINK NAME] then we shall run our new symbolic link solution

lab46:~/closet/thelab/puzzlebox2/Opus$ ln -s result solution
lab46:~/closet/thelab/puzzlebox2/Opus$ ls
ls -l  minecraft.7z  result  solution
lab46:~/closet/thelab/puzzlebox2/Opus$ ./solution
[puzzlebox] ./solution solution 1 2 Very close.

NOTICE that our variable's values have changed in this instance? The symbolic link simply replaces the return name in all instances when ran from the symbolic link solution, so any variable that means to point at result is pointing at solution (or what I'd call, pseudo-result).

Lets move onto our next and last if statement to our final prize!

if [ "`tail -1 ${0} | grep \"^#${USER}:.*$\" | wc -l`" -eq 1 ]; then
			echo -n "YES, here is your token: "
			md5sum "${0}" | cut -d' ' -f1

The only part of this if statement we need to focus on is what tail -1 means. What does it indicate? It indicates or points to the end of the file result(or solution). So why don't we look at the end?

#username:Fill out the previous field as appropriate

Seems meaningless, but read what it says. We need to fill out the field(placeholder username) with our username, more specifically whatever username is connected to your personalized $USER, we figure this from the if statement itself where it greps for the $USER. So for this scenario, let's use jackrabbits as the username, just remember to use YOUR username or whatever is logged in when running this program.

#jackrabbits:Fill out the previous field as appropriate

Now that we filled that out, lets run our symbolic link solution.

lab46:~/closet/thelab/puzzlebox2/Opus$ ./solution
[puzzlebox] 1 2 YES, here is your token: 0a9563f07993a814e860c2c616db0413

Viola! The puzzlebox is solved! Congrats! I helped you cheat!

Part 3

Entries

Entry 1: November Day, 2012

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

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?

Remember that 4 is just the minimum number of entries. Feel free to have more.

Entry 2: November Day, 2012

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

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?

Remember that 4 is just the minimum number of entries. Feel free to have more.

Entry 3: November Day, 2012

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

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?

Remember that 4 is just the minimum number of entries. Feel free to have more.

Entry 4: November Day, 2012

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

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?

Remember that 4 is just the minimum number of entries. Feel free to have more.

Keywords

talk/ytalk

Let's talk.

Definition

talk is a program that provides visual communication between two parties via text through the terminal. ( talk person ) Using this command alone will prompt the second party with the following message:

  • Message from TalkDaemon@his_machine…
  • talk: connection requested by your_name@your_machine.
  • talk: respond with: talk your_name@your_machine

At this point, the terminal will be now a chat window between the two parties. Both parties can type at the same time since their text appears in different parts of the window. To exit the window, use CTRL + C

ytalk is a program that provides visual communication between multiple parties via text through the terminal. It's basically the same program as talk, only it allows for multiple connections. ( ytalk [-s] [-Y] [-E] [-i] [-q] [-v] [-h hostname_or_ip] username… )

The username portion can be formatted in the following ways:

  • name - some user on your machine
  • name@host - some user on a different machine
  • name#tty - some user on a particular terminal
  • name#tty@host - some user on a particular tty on a different machine
  • name@host#tty - same as “name#tty@host”
  • aliasname - an alias defined in your .ytalkrc

You can also specify multiple usernames on the command line with ytalk ( ytalk george fred@hissun.edu marc@grumpy.cc )

Say hello to the options:

  • -s option starts your YTalk window in a shell.
  • -Y option requires a capital Y or N as an answer to any yes/no question.
  • -E option requires you to press escape once before answering a yes/no question (for people who type looking at the keyboard).
  • -i option disables the auto-invite port (meaning you won't see “talk to blah@blah.com”, but your talk daemon will beep you instead).
  • -q option causes YTalk to prompt you before quitting.
  • -v option prints the program version and exits.
  • -h option specifies the name or address of the local machine; this is useful on multi-homed machines, or virtual hosts, to specify which network interface to use for communication.

More to be added with more awesome details to come.

References

unix Keyword 3 Phase 2

Tail

Definition

The tail command allows you to grab the last line(s) from the output of a previous command or from a file. Unless you specify the number of lines that you would like the command to grab, it will default to return the last ten lines. In order to specify the the number of lines, add -# (# being the actual number if lines you want to grab) to the command.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • Professor Haas, In class discussion - 11-9-12.

Demonstration

Demonstration of the indicated keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <stdio.h>
 
int main()
{
    return(0);
}

Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:

lab46:~$ cd src
lab46:~/src$ gcc -o hello hello.c
lab46:~/src$ ./hello
Hello, World!
lab46:~/src$ 

Experiment 3

Question

What is the question you'd like to pose for experimentation? State it here.

Resources

Collect information and resources (such as URLs of web resources), and comment on knowledge obtained that you think will provide useful background information to aid in performing the experiment.

Hypothesis

Based on what you've read with respect to your original posed question, what do you think will be the result of your experiment (ie an educated guess based on the facts known). This is done before actually performing the experiment.

State your rationale.

Experiment

How are you going to test your hypothesis? What is the structure of your experiment?

Data

Perform your experiment, and collect/document the results here.

Analysis

Based on the data collected:

  • Was your hypothesis correct?
  • Was your hypothesis not applicable?
  • Is there more going on than you originally thought? (shortcomings in hypothesis)
  • What shortcomings might there be in your experiment?
  • What shortcomings might there be in your data?

Conclusions

What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.

opus/fall2012/escoute1/start.txt · Last modified: 2012/12/31 09:33 by 127.0.0.1