This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
blog:spring2016:mpotapen:journal [2016/02/02 02:06] – mpotapen | blog:spring2016:mpotapen:journal [2016/05/11 15:51] (current) – mpotapen | ||
---|---|---|---|
Line 12: | Line 12: | ||
===Unix Philosophy=== | ===Unix Philosophy=== | ||
- | Matt delineated three principles that make up the Unix philosophy and they seem to make a lot of sense. However, he also insisted that the world began on January 1, 1970 which I think brings up a lot more questions than it answers. For example, if the world began on January 1st 1970, then who is John F. Kennedy? Anyway the three principles (in no particular order) are: | + | Matt delineated three principles that make up the Unix philosophy and they seem to make a lot of sense. However, he also insisted that the world began on January 1, 1970 which I think brings up a lot more questions than it answers. For example, if the world began on January 1st 1970, then who is John F. Kennedy? Anyway, the three principles (in no particular order) are: |
* Small is beautiful. | * Small is beautiful. | ||
Line 22: | Line 22: | ||
===Unix File Structure=== | ===Unix File Structure=== | ||
- | Imagine opening up a Russian nesting doll and instead of finding one awkwardly depicted grandmother, | + | Imagine opening up a Russian nesting doll and instead of finding one awkwardly depicted grandmother, |
* Regular files are actually quite regular (text files, executable binary files, etc.). | * Regular files are actually quite regular (text files, executable binary files, etc.). | ||
Line 31: | Line 31: | ||
Unix also has a permissions structure. Every sentient(?) being in the universe is determined to be either the owner (of a certain file), a member of the same " | Unix also has a permissions structure. Every sentient(?) being in the universe is determined to be either the owner (of a certain file), a member of the same " | ||
+ | ====Week 3==== | ||
+ | |||
+ | ===pbx0=== | ||
+ | |||
+ | pbx0 is the week three project. There was a practice section which was followed by the actual project, which in this case took the form of a puzzle. | ||
+ | |||
+ | ==Practice== | ||
+ | |||
+ | The procedure for the practice section was as such: | ||
+ | |||
+ | ^ ^|Do the following, and discuss the results in your Opus:| | ||
+ | | ^ a.|Copy **file.txt** into your home directory.| | ||
+ | |:::^ b.|Using **file**(**1**), | ||
+ | |:::^ c.|View the contents of this file using **cat**(**1**). Is it what it appears to be?| | ||
+ | |:::^ d.|Using **gzip**(**1**), | ||
+ | |:::^ e.|Uncompress the file, and recompress using arguments for fastest (not highest) compression. What does **file**(**1**) report now?| | ||
+ | |||
+ | The results of step b indicate that file.txt is an ascii text file. Cat can read the file which confirms this prediction. After compressing the file with gzip, file(1) reads | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | was " | ||
+ | </ | ||
+ | |||
+ | After uncompressing and compressing again, file(1) outputs | ||
+ | |||
+ | <cli> | ||
+ | file.txt.gz: | ||
+ | last modified: Tue Feb 2 17:11:17 2016, max speed, from Unix | ||
+ | </ | ||
+ | |||
+ | The only difference between the two outputs is that the second specifies the compression that was used on the file, quite informative. | ||
+ | |||
+ | ==Actual Project== | ||
+ | |||
+ | The project involved a file called " | ||
+ | |||
+ | ===Things learned in class=== | ||
+ | |||
+ | ==I/O redirection== | ||
+ | |||
+ | Giving a person a command means telling them to do something. Executing a command in Unix means telling the computer to do something. In many cases computers and people are poor substitutes for each other. In the case of Unix, commands always involve some input given by the user and some output given back by the computer. Different commands have different kinds of inputs and outputs and different ways that the inputs and outputs are handled. For instance, the ls(1) command requires a path as input (which may be given implicitly or explicitly) and prints it's output to the terminal by default. However the cp(1) command needs some explicit input by the user and instead of printing some output it outputs a file of some sort which can then be accessed by the user. The reason I'm going on about all this is that in class this week we learned how to redirect the input and output of commands to wherever you want. | ||
+ | |||
+ | The ">" | ||
+ | |||
+ | <cli> | ||
+ | lab46:$ ls > list | ||
+ | </ | ||
+ | |||
+ | redirects the output of the list command into a file called list. The ">>" | ||
+ | |||
+ | Additionally, | ||
+ | |||
+ | <cli> | ||
+ | lab46:$ history | less | ||
+ | </ | ||
+ | |||
+ | Redirects the output of the history command into the input of the less command, which allows you to page through your command history. | ||
+ | ====Week 4==== | ||
+ | |||
+ | This week was spent learning about VI. VI, of course, stands for vertical integration. Hold on, 8th grade social studies is leaking, let me just fix that. Okay, VI actually is short for " | ||
+ | |||
+ | The beauty of VI is that it was created before the invention of the mouse which, If you agree with Matt, is a humiliating and debasing thing for a human to have to use. Cursor keys didn't exist either and neither did many amenities that we're used to nowadays like volume buttons and delete keys. People had to be clever and economical with their keystrokes and needed a lot of functionality to be commanded by only a small number of actual buttons. The thing that appeals to me about VI is that it gives you the tools to have the computer do your work for you instead of having to scroll through documents yourself like some kind of animal. Using a computer well is a beautiful thing. Honestly speaking, it does put me off how different it is and I'm not entirely convinced that some of its appeal isn't just based on nostalgia but I have an open mind I look forward to becoming more proficient with it. | ||
+ | |||
+ | So what are the basics of VI? The first thing to know is how to type actual things to the document. It seems simple, and it is. But you have to be in insert mode. One of many ways to enter insert mode is to simply press the " | ||
+ | |||
+ | For example, let's say you want to copy 4 words adjacent to your cursor. Are you going to spend time trying to highlight exactly what you want with your mouse? No, because you're not a barbarian. You simply, like a gentleman, press " | ||
+ | |||
+ | I can't remember much else you can do with VI right now but believe me, there' | ||
+ | |||
+ | ====Week 5==== | ||
+ | |||
+ | In week 5, Matt taught us about wildcards and a variety of things about Linux in general. | ||
+ | |||
+ | ===Wildcards==== | ||
+ | |||
+ | Wildcards are characters that the computer interprets as a substitute for a certain class of character. Using a wildcard allows you to specify your search criteria with greater Flexibility. Matt showed us 4 wildcard characters. You can do a lot with those four. The * represents any number of any character. It's not super specific but it gets a large amount of its importance from being in combination with the other characters. ? represents one or more of any character. It's slightly more specific and as far as I can see so far its main functionality is to determine the size of the token that you're seeking. Putting characters inside of square brackets tells the computer to search for any of those characters. For example [aeiouy] can be used to search for vowels. [A-Z] can be used to search for capital letters. The fourth wildcard character is [^]. That is referred to as the inverted char class character and searches for everything not included in the brackets. [^aeiouy] searches for any character that's not a vowel. | ||
+ | |||
+ | Combining these wildcards can result in some very powerful searches but more importantly, | ||
+ | |||
+ | The in class examples concerned counting the number of files with certain attributes in their names. By using ls in combination with the wildcard characters and then piping (or if you're in on this joke, passing the joint) to wc you count files based on their file names. For example the command | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | returns the number of files that have file names of exactly three characters. The command | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | Returns the number files with at least three characters in their file name. I wonder if there' | ||
+ | |||
+ | ====A Variety of Things About Linux in General==== | ||
+ | |||
+ | Matt talked about the environment variable $PATH. $PATH tells the computer which directory to search through when trying to match what's in STDIN with possible commands. When typing ls, for example, and pressing enter, the computer will search through the directory specified by $PATH and see if it finds a file called " | ||
+ | |||
+ | Matt also mentioned that starting a file name with " | ||
+ | |||
+ | | Ctrl key |Function| | ||
+ | |c|exits process| | ||
+ | |d|exits process more nicely| | ||
+ | |h|backspace| | ||
+ | |j|enter| | ||
+ | |l|clear screen| | ||
+ | |a|move cursor to start of command line| | ||
+ | |e|move cursor to end of command line| | ||
+ | |k|kill command from the cursor to the end of the command line| | ||
+ | |s|transmit off| | ||
+ | |v|ctrl character escape| | ||
+ | |w|cut| | ||
+ | |y|paste| | ||
+ | |||
+ | |||
+ | ====Week 6==== | ||
+ | |||
+ | ===Killing Things=== | ||
+ | |||
+ | This week Matt taught us how to kill things like a ninja. The Unix operating system supports various signals that can be sent to programs. I've had some experience with signals when programming with the gtk package in my previous adventures in which I attempted to create windowed programs. The code must be written in order to handle the signals and act on them properly. In Unix, there are 64 signals that can be sent to programs and many of them kill the program by default. Again, it depends on how the program is written to handle those signals. Signals can be sent using the kill command. "kill -l" lists all 64 signals. | ||
+ | |||
+ | SIGHUP, number 1 on the list, stands for signal hang up. Hanging up on a stopped process results in the termination of that process. SIGINT, for Signal interrupt, is what is sent out when one presses the control c key. SIGILL generally gets sent out in the event of an illegal operation being performed. SIGTRAP is similar to SIGINT. SIGKILL is the agent 47 of kill signals. It never fails. SIGSTOP sends a stop signal to programs and when followed with a SIGCONTINUE effectively backgrounds the program. SIGSEGV is the signal sent out to kill programs that are seg faulting. | ||
+ | |||
+ | ===Scripting=== | ||
+ | Typing commands into the command line and watching the computer do your work for you while you laugh maniacally and pet your cat is all well and good, but isn't there sometimes even more efficient ways to implement your evil plans? The answer is "yes, scripting" | ||
+ | |||
+ | There are some trick that Matt taught us about scripting. Curly braces isolate variable names in situations where the computer may misunderstand whether you are referring to a variable or the string you assigned to the variable name. Bash isn't really meant to complex calculations but it does have a command called " | ||
+ | |||
+ | < | ||
+ | [" | ||
+ | </ | ||
+ | |||
+ | compares the value of the " | ||
+ | |||
+ | < | ||
+ | for ((x=0; | ||
+ | echo "x is $x" | ||
+ | done | ||
+ | </ | ||
+ | |||
+ | It's generally considered good practice to end scripts with an exit 0 command. | ||
+ | |||
+ | ===HTML=== | ||
+ | This week's project involved the use of HTML to create web pages and as a result was my first use of HTML. I learned a lot in the short time that I used it. HTML is used to toggle various properties of web pages (font of text, buttons, images) on and off. HTML works with tags that are placed around the object you want to toggle the property of. For example the < | ||
+ | |||
+ | I also ran into CSS, which is a product of the modern internet that people use within HTML code to gain further functionality and organization. For example with out the css command " | ||
+ | |||
====MONTH Day, YEAR==== | ====MONTH Day, YEAR==== | ||
- | 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. | + | 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: | As an aid, feel free to use the following questions to help you generate content for your entries: |