======Part 3====== =====Entries===== ====November 15th, 2011==== Today I learned how to compress and decompress a file in Linux/UNIX. Using the command line utilities gzip, and gunzip I successfuly compressed a file and decompressed it. This is significat to me because while working on my Opus I found myself to be strugling with the concept. ====November 17th, 2011==== Today I dove into the wonderful and exciting world of data mining! We performed a class project by taking different file formats and extracting specific strings of characters using command line utilities like grep and sed. This was very significant for me being that the data we were manipulating was real world data. I helped perform magical spells to extract data and now... I am amazing! ====November 22nd, 2011==== Today we learned about some networking tools in UNIX like netstat and ifconfig. This was very significant to me being that my new found passion in life is the world of networking. It has always been very easy for me to execute network commands in a dos shell, but it was really very interesting and rewarding to say that I now could navigate the command prompt networking utilities in Linux/UNIX. ====November 29th, 2011==== Today I spent a lot of time playing with regular expressions. This was significant to me because the entire concept of regular expressions was like a foreign language. After banging my head several times, bothering the professor, and pulling some hair out I was able to accomplish the task at hand! Yeah baby! I was very excited about the achievement! =====unix Topics===== **Part 3:** **Keywords:** - Compiler - Regular Expressions - Ownership - Permissions - Moving/Renaming - VI Extended Command Mode - C - Compressing/Decompressing - Shell Scripting - Text Processing - Object Code - Linker ====Keyword 1==== **Compiler:** A compiler is a computer program that translates programming language into machine language the computer can understand and execute. Most compiler programs will also create a executable file that will allow the end-user to execute or run the translated program. For this example I used the chmod program as a compiler for a password program called password.sh. I first created the shell script using the Vi text editor and then executed the chmod command using the code chmod 700 password.sh. This compiled the program and made it an executable file. lab46:~$cd example lab46:~/example$ ls password.sh lab46:~/example$ chmod 700 password.sh lab46:~/example$ ./password.sh Enter the magic Pass-phrase: bob Access Granted What's going on? lab46:~$ ====Keyword 2==== **Regular Expression:** Regular expressions provide the ability for "matching strings of text" whether the text is characters, words, or specific patterns of text. Each assigned expression character will match characters specifically and uniquely. For example: the "^" symbol will match the beginning of a line, the "$" will match the end of the line, the "." symbol will match any single character, and the "*" will match zero or more of the previous. Each regular expression symbol has a specific matching purpose. The command line below uses many utilities and regular expressions to extract specifically matched data to output. lab46:~$ cat spring 2012-20111103.html | grep 'ddtitle' | sed 's/^\(.*\) ---> Regular Expressions used: / * ^ \ . \( \) ====Keyword 3==== **Ownership:** Ownership is what tells the end-user who has administrative ownership of a specific file within a directory. You can view the ownership properties by using the "ls -l" command from your working directory. In the example below I have opened a directory named closet. Within that directory there are three regular text files. The third field, named ccaccia in the example, indicates who has administrative ownership or rights of the files. lab46:~$ cd closet lab46:~/closet$ ls -l -rw------ 1 ccaccia lab46 56 Sep 6 16:37 cake -rw------ 1 ccaccia lab46 752 Sep 6 16:11 df -rw-r--r-- 1 ccaccia lab46 26 Sep 6 15:45 skelton lab46:~/closet ====Keyword 4==== **Permissions:** Permissions in the UNIX filesystem determine who can read, write, or execute a file. When the command "ls -l" is typed and executed at a command prompt it will list the properties of the current working directory. The first field in the output of the command is the file type and permission block. There are a total of ten digits, one for the filetype and nine for the permission block. These nine digits are divided evenly and respectively between three categories called user, group, and other. The "user" category is the file permission for the directory owner, the "group" category is the file permission for the group, and the "other" category is the file permission for the world. Each three digit category can be assigned a file permission to either read (r), write (w), or execute (x). In the example below you will notice three files in a directory called closet. For the file named "skeleton", you will notice that the file permission is, rw-r--r--. This defines the user is having permission to read and write. The group has permission to only read, and the other also only has permission to only read. The file named "cake" you will notice that the user has the only permission to read and write the file. lab46:~$ cd closet lab46:~/closet$ ls -l -rw------ 1 ccaccia lab46 56 Sep 6 16:37 cake -rw------ 1 ccaccia lab46 752 Sep 6 16:11 df -rw-r--r-- 1 ccaccia lab46 26 Sep 6 15:45 skelton lab46:~/closet ====Keyword 5==== **Moving/Renaming:** Moving and renaming files in Linux/UNIX is really a very simple file. As you can see in the example below, I have opened a directory named "closet" and executed the "ls" command. There are four text files and two directories located within this directory. The first text file is called "aples" and needs to be renamed to the correct spelling of "apples". To perform this daunting task we will need to use the Linux/UNIX "mv" command. By typing: //mv aples apples//, at the command prompt you essentially rename the aples file to apples. If we wanted to move a file to another directory, we also need to use the "mv" command. In the example below I typed: //mv mvme tacocat//, at the command prompt and the file "mvme" was moved to the directory, "tacocat". This is how you move or rename files in Linux/UNIX. lab46:~$ cd closet lab46:~/closet$ ls aples cake help mvme skeleton tacocat trickery lab46:~/closet$ mv aples apples ---> Renamed aples to apples lab46:~/closet$ ls apples cake help mvme skeleton tacocat trickery lab46:~/closet$ lab46:~/closet$ mv mvme tacocat ---> Moved file: mvme to directory: tacocat lab46:~/closet$ ls apples cake help skeleton tacocat trickery lab46:~/closet$ cd tacocat lab46:~/closet/tacocat$ ls mvme wand wang ---> File: mvme new location lab46:~/closet/tacocat$ ====Keyword 6==== **VI Extended Command Mode:** The VI text editor, as covered earlier, is the best text editor ever! Extended command mode is achieved from regular command mode, and cannot be initiated from Insert mode. To enter extended command mode you hold down the shift key and press the semicolon/colon key. Once in extended command mode, the text editor can save your file and exit the program. Pressing the "w" key will save your file, and typing the "q" key will exit the text editor. These keys can be typed individually or at the same time to accomplish the command execution. Below I have duplicated a VI text editor box. At the bottom-left you will notice the colon followed, respectively by the "w" and "q" characters. This will save the current file and exit VI Text Editor. ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ :wq ====Keyword 7==== **C:** C is a lower level programming language developed for creating programs. C was designed and developed between 1969 and 1973 by the famous Dennis Ritchie. C has had the biggest impression on the development of programming languages. It is considered by many to be the root for many other programming languages. Below I have included the first program that I wrote in C called "hello". When the program is called at the command prompt the source code instructs the program to output or return the phrase, "Hello, World!". I have also executed the program to show the result. lab46:~$ cd c lab46:~/c$ ls a.out datatypes datatypes.c hello hello.c test lab46:~/c$ cat hello.c #include int main(_) { print("Hello, World!\n"); return(0); } lab46:~/c$ lab46:~/c$ lab46:~/c$ ./hello Hello, World! lab46:~/c$ ====Keyword 8==== **Compressing/Decompressing:** Compressing and decompressing files basically take a file and make it smaller than the original size. This is done to help conserve on hard drive space as well as conserving bandwidth if being sent over a network. Decompressing a file is taking a smaller compressed file and extracting it back to its original size. In Linux/UNIX a file can be compressed using the "gzip" command. Typing this command followed by the name of the file being compressed will wrap the file up into a smaller compressed file. Using the "gunzip" command followed by the file name will decompress the file and return to the original file size. Below I have compressed and decompressed a file in a directory called closet. lab46:~$ cd closet lab46:~/closet$ ls apples cake help skeleton tacocat trickery lab46:~/closet$ gzip apples apples.gz cake help skeleton tacocat trickery lab46:~/closet$ gunzip apples.gz lab46:~/closet$ ls apples cake help skeleton tacocat trickery lab46:~/closet$ ====Keyword 9==== **Shell Scripting:** Shell scripting is programming code written in a terminal or shell at a command line prompt. Shell scripts are programs that are created to make something happen at the command prompt. Below I have written a shell script using the VI text editor and bash. This program when executed at a command prompt will ask me for the magic pass-phrase. If the incorrect pass-phrase is typed then the shell script will notify me with a "Access Denied" statement. If I type the correct pass-phrase when prompted then I will receive a message stating that access was granted and then the script will return to standard output the word "hi". lab46:~$ cd bash lab46:~/bash$ ls script3.sh script4.sh script5.sh lab46:~/bash$ cat script3.sh #!/bin/bash echo echo echo -n "Enter the magic pass-phrase: " read passphrase if [ "$passphrase" = "bob" ]; then echo "Access Granted" else echo "Access Denied" exit 1 fi echo "hi" exit 0 lab46:~/bash$ lab46:~/bash$ ====Keyword 10==== **Text Processing:** Text processing is the act of creating a document or file using a word processing program. Linux/UNIX has two primary text processing programs, nano, and VI text editor. Processing text is achieved by opening a word processing program, typing text, and then saving the typed text as a file name. In the example I have created a sample VI text editor program and have typed some text. lab46:~$ vi text Hello, this is a test! We are typing text into a word processing program and demonstrating text processing! Weee... this is fun! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ --INSERT-- lab46:~$ ====Keyword 11==== **Object Code:** Object Code is produced when a compiler transforms a program into an executable file. Object code is code created by the compiler to serve the purpose of translating source code into machine language so that an executable file can be created. It is considered to be very close to machine language and is also the last step in creating an executable program. ====Keyword 12==== **Linker:** A linker is a program involved with the program compiling process. A linker is a program that links source code with object code to form a executable program. Also programmers can split large programs into modules for more efficient development. Eventually these modules will have to be linked or connected back together to create a final executable program. The linker is the program that connects all the modules back together. =====unix Objective===== ====Objective==== Exposure to command-line tools and utilities. Command line utilities and tools are commands entered at the command prompt that accomplish some task within the terminal session. ===Method=== The method I will use for measuring successful academic/intellectual achievement of this objective is compressing and decompressing a file, viewing the file, renaming the file, and finally moving the file into a different directory. Once I compress the file I will move it to another directory, decompress the file and then view it. ===Measurement=== lab46:~$ cd closet lab46:~/closet$ ls apples cake help skeleton tacocat trickery lab46:~/closet$ cat cake 1)kit 2)sugar 3)va jay jay Louis Armstrong is best friends with tacocat! lab46:~/closet$ gzip cake lab46:~/closet$ ls apples cake.gz help skeleton tacocat trickery lab46:~/closet$ mv cake.gz trickery lab46:~/closet$ ls apples help skeleton tacocat trickery lab46:~/closet$ cd trickery lab46:~/closet/trickery$ ls cake.gz hugebluepen secret lab46:~/closet/trickery$ gunzip cake.gz lab46:~/closet/trickery$ ls cake hugebluepen secret lab46:~/closet/trickery$ cat cake 1)kit 2)sugar 3)va jay jay Louis Armstrong is best friends with tacocat! lab46:~/closet/trickery$ ===Analysis=== Well things really seemed to go well with this objective. I don't see much room for improvement at this point, but I suppose there is always room to complicate this further. I really feel that I demonstrated UNIX utilities in a command-line. =====Experiments===== ====Experiment 1==== ===Question=== Can I rename more than one file at a time? ===Resources=== "mv" manual page http://www.tuxfiles.org/linuxhelp/fileman.html ===Hypothesis=== Based on what I've read I do not think that I will be able to rename two files at the same time. After searching the manual page I don't see an argument I could add to accomplish this either. ===Experiment=== I am going to test my hypothesis in the lab46 command line prompt. ===Data=== lab46:~$ cd closet lab46:~/closet$ ls apples help skeleton test1 test2 tacocat trickery lab46:~/closet$ mv test1 test3 test2 test4 mv: target `test4' is not a directory lab46:~/closet$ ===Analysis=== Based on the data collected: * My hypothesis was correct! * There is really not anymore going on than I thought after researching. * I'm not really sure this was the best experiment to perform but it was a legitmate question, and even though the result wasn't what I hoped... it was a legitmate result. ===Conclusions=== My conclusion in this experiment was that other than answering a question it was a failure. ====Experiment 2==== ===Question=== Can I change file permissions to read, write, and execute for the user, but only read privilege for the group and other category? ===Resources=== manual page on chmod ===Hypothesis=== Based on what I have read, there should be no problem executing the chmod command followed by the number 744 and the file name to change the file permissions. ===Experiment=== I am going to test my experiment in a cli command prompt terminal in lab46 ===Data=== lab46:~$ cd closet lab46:~/closet$ ls -l -rw------- 1 ccaccia lab46 57 Nov 30 22:24 apples -rw------- 1 ccaccia lab46 752 Sep 6 16:11 help drwxr-xr-x 1 ccaccia lab46 39 Nov 30 21:09 tacocat lab46:~/closet$ chmod 744 help lab46:~/closet$ ls -l -rw------- 1 ccaccia lab46 57 Nov 30 22:24 apples -rwxr--r-- 1 ccaccia lab46 752 Sep 6 16:11 help drwxr-xr-x 1 ccaccia lab46 39 Nov 30 21:09 tacocat lab46:~/closet$ ===Analysis=== Based on the data collected: * Yes... my hypothesis was correct and applicable * There was a little more going on than I expected. When I changed the permission for user to make the file read, write, and execute the file name color turned green. It seems that by allowing the user to have execution privilege's it has also compiled the program. Neat! ===Conclusions=== I can conclude that as long as you have ownership of a given file, it is very easy to change the permissions for the user, group, and other categories. ====Experiment 3==== ===Question=== Can I install a Linux/UNIX opensource operating system on my personal laptop? ===Resources=== http://www.ubuntu.com/download/ubuntu/download Matthew Haas ===Hypothesis=== Based on my research this should really be an exciting experiment. I should be able to install a Linux based operating system on my personal laptop without a hitch. ===Experiment=== I am going to download a full install .iso image to a usb drive and install the operating system ===Data=== It took a few attempts to install the operating system. I didn't have any problems with the .iso image or booting from the USB device, but I did have a few video driver glitches, possibly driver problems. After the third time formating the hard drive and installing Ubuntu, eveything finaly seemed to fire off. I did have a problem with the laptop wireless card driver but with some help from the proffessor, we were able to get that working by placeing a device driver code in the appropriate directory. I believe the wireless NIC driver installed by default with Ubuntu was not compatable with the laptop manufacturer. ===Analysis=== Based on the data collected: * Yes... my hypothesis was correct and applicable * As I stated within the data field, I did have a few video driver issues that finally worked themselves out and also the wireless NIC card would not work at first * There is room for improvement. I will have to play with the Linux OS to become more comfortable with it. ===Conclusions=== In conclusion I would feel comfortable stating that Linux/UNIX is really for a end-user with some computer knowledge. It seems that to be effective in troubleshooting simple problems, you really need to be comfortable in front of a command line terminal prompt.