======UNIX/Linux Fundamentals Journal====== =====January 22, 2014===== At approximately 4:50pm yesterday, January 21st, ended the first of many of the best class I may ever experience. What class am I referring to? Well Unix/Linux fundamentals of course, with the one and only Mathew Haas. This will be my first online class I have ever taken, so I hope that does not propose any problems in the future. This class will truly be my first true hands on experience with Unix and Linux, and I cannot wait. Even day one of class which consisted of mostly going over the syllabus was a blast! I have also set my first goal, to find out who "satan" and "satanne" are in our class chat secretly typing from outside of the classroom walls. I am very excited to see what this class holds in the future. =====January 28, 2014===== Finished the second class lecture earlier today. Since I haven't done any small journal posts recently I will do a summary of what I have learned from class and labs. I have been becoming much more familiar with the basic terminal commands. Although, it is still very frustrating when you get lost in the terminal and have multiple screens open without knowing how to terminate them. Firstly, there is the change directory command, cd "directory", which takes you to that folder/directory. Then there is the listing commands, either "ls" or "ls -l" for the long listing. This displays all of the current files in the directory you are in, as well as the abilities you are allowed to use. Also, there is the "mkdir" command, which is short for "Make Directory", and does as it sounds, creates a new directory. To remove you use the "rmdir" command. To see who is currently online you use the "who" command. I also learned from the labs how to access email and send new emails using the "alpine". A few other good commands to note that I have learned are copy (cp), move (mv), remove (rm), and link (ln). These are used to copy, move, and remove files in/to directories. Then there is the manual, which was used in lab01, using the "man" command followed by the correct manual name. All in all, the first two labs and assignments and lectures were a good time. A great learning experience, getting down the fundamentals of the terminal, and the common linux commands. Lab02 was all about permissions and accessing directories using the directory tree rather than shortcuts. File permissions are split up into 3 groups, "user", "group", and "world". Each contain their own read, write, and excute/search permissions. Indicated by letters, r for read, w for write, and x for execute/search. As practice, I made the lab 2 folder in my home directory and used the "chmod 701 lab2/" command to apply the permissions I wanted. ^ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / /secretspot \ / \ / /innercloset/ \ / \ / /closet/ \ / \ / /lellis3/ \ / \ / /home/ \ / \ / *root*/ \ / \ <___________________ ___________________> | | | | | | | | (___________) Looking forward to the future in this class. =====February 3, 2014===== Starting on Project "Archives" first things first, I had to locate the files. Which were in the var/public/unix/projects/archive_handling directory. And yes, I originally used the wrong files and had to completely restart. Anyway, I had made two directories in my home folder to store the two separate files and then copied the two archives into their own folders in my home directory. From there I used the "unzip filename" and "tar -xjvf filename" commands to open the content within the archives. I then used the "ls -l" and "cat" commands to see what was in the files, and image1.jpg in Archive2.tar.bz2 was empty so I deleted it. In Archive2.zip both image2.gif and image4.txt were empty so I deleted both of those, with the "rm" command. After this, I needed to find out which file was corrupt, so I moved the files over to my public_html folder and made all permissions 777, so it was readable to the global web, and more. Then I found that image3.png was corrupt, and removed it. From there I checked all file sizes with the "ls -l" command and renamed them accordingly. From there I moved them into my new "myarchive.tar" directory and compressed it like instructed with the "tar -pczf name_of_your_archive.tar.gz /path/to/directory" command and............ Submit. __Archive2.tar.bz2__ image1.jpg (empty) image2.gif image3.png (corrupt) image4.txt __Archive2.zip__ image1.jpg image2.gif (empty) image3.png image4.txt (empty) I can definitely see how this was a problem solving project, definitely required a lot of google'ing, questions, and experimentation. All in all it was fun, a good way to get those basic commands drilled into your brain and learned a lot of new things. =====February 4, 2014===== __VIM Commands:__ __Insert__
i - insert mode at cursor esc- command mode a - append after cursor I - insert at start of line A - append at end of line o - insert new line below current position O - insert new lines above current position
__Navigation__
h,j,k,l - single character movement w,b - word movement W,B - dunno "Carrot"- start of line "Dollar"- end of line 3G *dollar*G 1G
__Manipulation__
J - join lines x - delete X - backspace dw,db - deletes dW,dB - deletes d*carrot*,d*dollar* - deletes dd - deletes whole line p,P - pastes last edit cw,cb - change cW,cB - c*carrot*,c*dollar* - u,U - Undo / - search for string n - next match N - previous match
__Extended Command Mode(:)__
w - save w filename - save as w! - force saves q - quit q! - force quit wq - save and quit
=====February 5, 2014===== Starting on the puzzlebox project, I located the file.txt and copied it to my home directory. Using the file(1) command it states that it is an ASCII file, and it is. After using gzip to compress the file it shows that it was compressed for highest compression. After unzipping using the "gunzip" command and re-compressing using the "gzip -1" command it states that it is now compressed for fastest compression. After moving the puzzle.txt file and trying to read it using the "cat" command, it does not appear to be a .txt file. Firstly, I had to rename the file to unzip it, then go through several layers of different types of compressing and decompress them accordingly, to get the finale .txt file, and done :) =====February 19, 2014===== First day back to school after the long weekend and I will be honest and say I slacked off over the last four days, completely forgot about the permissions practice we were doing, but I do have it almost completed and will be completed in time. Simple stuff, count the place values of the ones that are on which are - - - (4 2 1), do it over and over and you're done. Anticipation is building for next weeks session in the Lair. =====February 24, 2014===== Day before class after having a good amount of time off from the lecture class and I realized I missed a lab. Anyway, after creating the 8 files using the "touch" command (touch filename) I used the "ls file*" command which displayed all 8 files: file1, file2, file3, file4, file1234, fileZZZ, file41, and filea. Then I used the "ls file?" command which displayed 5 of the 8: file1, file2, file3, file4, and filea. I am not entirely sure why it displayed the ones it did but they all only had 1 character after "file" which could be the reason. Next I used the argument "file[23]" which displayed file2 and file3 which means it displayed the two characters in the bracket. Lastly I used the "file[24a]*" which displayed file2, file4, file41, and filea because it displays all characters used in the brackets after "file". In the next part after redirecting the MOTD STDOUT to "file1" it put the MOTD in "file1". After using the echo command with the append command ">>" it added the text to the end of the file. Next the STDOUT redirection replaced everything in the file with the new text. Using the "ls file* | grep "file1" > file2" command it placed "file1" and "file1234" into "file2". The "ls file555 2> /dev/null" removed the error message but it did not change anything in file2. Yes pipe'ing the ls -l command made it stop so you can press enter to go through the lines after using "less". Using the "echo $PATH" commands you have to use ' to display $PATH because ' has no expansion, just literal quotes. =====February 24, 2014===== __**Lab 0x6**__ After creating the "script1.sh" file with VI text editor I used the "ls -l" command to view the file permissions, which was read only. I then used the "chmod 777 script1.sh" command to give the file full permissions, even though it did not need full permissions. After running the script this time around it did in fact work. To create my age script I used the following in vi text editor:
echo "What year were you born?" read stdio echo "What is the current year?" read year let age=$year-$stdio echo $age
This got the job done. To create my guessing script I used the following script:
#!/bin/bash pick=$(($RANDOM % 20)) echo "Pick a number 1 and 20: " read var1 if [ "$var1" -lt "$pick" ]; then echo "$var1 is too low" elif [ "$var1" -gt "$pick" ]; then echo "$var1 is too high" else echo "$var1 and $pick are the same, good guess!" fi
In part six of the lab I used the following script to get the job done:
touch file1 file2 file3 file4 file5 file6 file7 file8 echo "1" >> file1 echo "2" >> file2 echo "3" >> file3 echo "4" >> file4 echo "5" >> file5 echo "6" >> file6 echo "7" >> file7 echo "8" >> file8 echo " Pick a number between 1 and 8: " read pick touch file9 echo "$pick" >> file9
=====March 4, 2014===== Roughly the mid-way mark in the semester today's class consisted of: * Using the jobs command you can see the current tasks running in the background of the terminal, good for multitasking. * Using the "bg" command, which is the background command followed by the job number, it will put that task into the background. * Using the "fg" command is another option (fg followed by the job number). * Starting a program makes a process: program in action * Using the "ps" command it shows the default view of all of the current running background processes and displays the usage of those processes. The "ps x" command shows you all of your own processes whether or not they are attached to the terminal. The "ps aux" shows EVERYTHING running on the system. * You can use the "kill PID#" command to terminate a process. But this is the standard method that just tries to end it. All of the other "kill SIG" commands are different methods of killing a process, there are 64 in total which can be seen with the "kill -l" command. The "kill -9" destroys ANYTHING. :) * We learned the "top" command which displays all of the current processes from everyone and it is a live feed of the current data usage of the processes in order from greatest to least. To view your own processes type "u" in top then input your own or the username processes you wish to view. * "nice" and "renice" commands allow you to change and adjust the priority levels. * Using the "whowatch" command and choosing the user you want to view shows the parent-child relationships going on, as in branches of the process. * We used "watch -n2 ls -l /tmp/thing which displayed the "thing" file and updates as the file is updated (character count and permissions). In other words, you can watch a file update. =====March 6, 2014===== Webpages project...... Where to start. I would definitely say it was a lot of fun at first, learning HTML and refreshing my memory with VI and HTML coding. But it did get very repetitive and took A LOT OF TIME. I chose to do my adventure game on a WW2 Paratrooper, based on the Mini-Series "//Band of Brothers//". The coding was pretty simple. I used "" and "" for the body information of the page. I used "

,

" for the title of the page (or heading to be specific to the code). To customize my font colors and style I used things like "

INFO HERE

". The same applies to the heading, using "

" instead of "

". Using the "" command. To do my tables I used the

    (ordered list) commands with the
  1. commands which created lists. Also I used the table commands
    and the box sizes and outlines to create my table in the game. It was definitely a good HTML experience. =====March 11,2014===== Class Learnings: Every programming language is a part of a high level ---> low level organization. Programs that have far less feature and give you less access are considered high level, where as the opposite are considered low level.
    __High Level__ -bash -python,javascript -Java -C++ -Machine Language __Low Level__
    __Paradigns:__ -Structured -Object Oriented -Logical -Functional
    =====March 12, 2014===== Lab8: To start the lab I copied the desired files to my directory using the command "cp filename /home/lellis3/Labs/lab8". Then as requested I compiled each of the 3 files using the "gcc -o desiredname filename" command for the .c text file. I used "g++ -o desiredname filename" for the .cc file. And last, I used the "as -o desiredname.o filename" and "ld -o desiredname filename" commands to compile the final file. They all worked and displayed the same thing, "Hello, World!". I had to use the "./filename" command rather than just typing the filename because you have to tell it to go to the specific file.
    3. - It appears to be a C program file. - The "file" command says it is an ASCII C program text file. - The helloCPP.cc is a C++ program file, and "file helloCPP.cc" indicates that as well. The helloASM.S appears to be aeesmly program text, and "file helloASM.S" says it is ASCII assembler program text.
    4. * c. There is a new file titled helloC.s * d. file(1) says it is ASCII assembler program text * f. The helloC.s code appears to be much more complex, different language where as the C code looks like C code and makes some sense.
    5. * c. Yes, there is a new file titled "hello.o" * d. File(1) says it is an "ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped". * e. It is in object form and it does not look anything like C.
    6. * c. It searches through the system libraries to find the compiler matching the file type you ran in the link.sh program, and it compiles it to make it executable.
    7. * b. ELF 64-bit LSB executable * d. Yes, both had the same output. * e. I used "./hello" to run it and it displayed "Hello, World!".
    8. * a. I used "cp helloC.c /home/lellis3/src" to copy it over. * b. I see both * d. I used "make helloC" and it did it.
    9. * a. I used the command "cp -r multifile /home/lellis3/devel/lab8". * c. I am not sure what this is asking me to do.
    10. * a. HelloASM is 935 characters. helloC is 6546 characters. helloCPP is 8369 characters. * b. They seem to execute at the same speed, but when compiling larger files it usually takes longer. * c. The helloJAVA size is 42 characters after being compiled, 846 before. * d. Yes it is probably doing more than just displaying an output of "Hello, World!".
    =====March 18, 2014===== __Symbol(Basic RegEx)__ . = Match any single character * = Match 0 or more of the previous crrt= Match start of the line $ = Match end of the line [ ] = Match any one of enclosed (character class) [^ ]= do not match " " " " (inverted char class) \< = Match beginning of word \> = Match end of word =====March 19, 2014===== Lab 0x9 was a somewhat fun lab. I find the grep utility very unique and fun to play with. We touched base with these commands in class by filtering out words starting with specific letters, ending with letters, containing specific letters, capitalization, you name it, you can probably filter it out of a list of thousands of words with the grep utility. I played around with the lab and am pretty comfortable with the standard grep commands and how to use them, and I can see how it could be very helpful if you have huge lists and you are trying to find something or some things of a specific nature. I guess I will have to get all of the Regular expressions down pat so I do not have to refer to sources to remember them. Alas :) =====March 24, 2014===== __Lab 0xA__ This was a very helpful lab in learning the things we went over in class and how to manipulate information coming out of files.
    1. * Eric Vincent, John Doe, Alan Wilson, Jill Ashley, Sarah Billings "Cat sample.db | grep Freshman" * Alan Wilson, Eric Vincent, Jill Ashley, John Doe, Sarah Billings "Cat sample.db | grep Freshman | sort" * Yes, Eric Vincent - Removed one. * 6 "cat sample.db | grep Freshman | sort | wc -l"
    2. * This will display "is" because it is the 3rd field of value. * (echo "hello there:this:is:a:bunch of: text." | cut -d":" -f1,6) This displays "Hello there: text." * It somewhat worked, it displayed a ":" between there and text.
    3. * Yes it does. * At the end I would put " 's/t/T/g' ". * I thought it would look like " 's/./*/g' ". * It displayed "******************".
    4. * To convert I used ( tr "\r" "\n\r" < file.mac > file.unix ) and inside was a hateful lawyer joke. * I swapped the r's and n's and changed the filename, inside it said bad fiction contest. * I used ( tr "\r" "\n\r" < dos.txt > dos.mac ), inside were elephant killing jokes.
    6. * There are 16 unique students, I used "cat sample.db | wc -l" and subtracted 2. * There are 11 (or 12 with unknown) unique majors, I used "cat sample.db | cut -d":" -f3 | sort". * There are 13 unique favorite candies, I used "cat sample.db | cut -d":" -f5 | sort | sed -e 's/*/ /g'" for the code.
    6. * head -22 pelopwar.txt * tail -4 pelopwar.txt * head -48 pelopwar.txt | tail -16 * tail -12 pelopwar.txt | head -4
    =====Lab 0xB===== Using the Data Dump command and the Diff() command I copied, moved, and compared the files as instructed... From what I could see use the file() and cat commands they seem very identical, as well as in binary because they are unreadable, at least for now they are.