Corey Forman Fall 2011 Opus
My mind trying to wrap itself around Linux and UNIX programing
I graduated from Twin Tiers Christian Academy. I plan to major in Computer Sciences. I play guitar and i am and avid gamer. I would also love to learn game programming at some point. I live in America but sometimes wish i lived in England. When playing on-line i find myself falling into the use of a British accent. That is all you are allowed to know.
Today is the start of the best class of the semester. We began to study basic Unix commands and began to discover the magic behind the commands. We learned some pretty useful commands:
ls - this allowed us to see all the files inside of a directory who - shows who is logged onto the lab 46 terminal screen -r - this allows us to reconnect to our class chat ctr -a tapD - this allows us to leave our chat without closing it.
Right now the whole Unix setting doesn't make any sense but soon I hope to have a better understanding of it. The challenges I may face are basically keeping track of my time and remembering commands.
Today we played with a new web browser and worked on our opus and first project “ Filesystem Safari”. We got a lot of help with our opus and I am finally able to start editing due to the fact that I had no idea how to edit one. At this point in time my biggest challenge will be keeping up with my opus and coming up with projects. I have really bad time management and need to start doing better with these areas.
We learned today how to script using for-loops. We learned a few commands today.
cut - which allows the removal -d'' - this is the delimiter. within the single quotes you place the delimiter which is the - seperater withing what your looking at. - ex filename.extension -d'.' makes it so that the delimiter is the "." --output-delimiter="..." - this changes the delimiter so that if needed you - can change it to coincide with other O.S.
we also learned about fields. A field is the part that you are looking at. When combined with a delimiter you can select certain field designated by the delimiter.
these three things in combination within a script allow for the echo of something cut out by selecting the field designated by a delimiter.
For now luckily I am understanding everything but my biggest challange with this course is time management.
Today we learned about ii which is also called irc improved. Using this we are able to create a bot.
We also spent a small amount of time playing with a very old Toshiba Satellite that ran on ms-dos and Windows 3.11; unfortunately it was broken at first but we fixed it by dropping it.
We explored bot programming and learned how to give our bots commands and have it take action on those commands.
One funny thing that happened was Wedges bot William thought we were flooding the irc chat when we tried to all activate our bots and it banned us all. even our teacher got banned thus proving we may have invented sky-net.
One concept that is eluding me is that a bot can be random like Wezlbot but has to be programmed to respond and I wish to learn how to make it random. <(^^,)>
The local host is the person or main page of whats running. If it is a website the local host will take you to the main page. In the lab 46 terminal we work on there are many users but the local host is the lab 46 terminal because it is hosting us as the users.
A remote host is something that allows the access of files or data from a distant location. Say you have a server with all your info and you go to access it from your home computer and retrieve the data. the server is the local host.
The home directory is the main start up of a UNIX terminal. It is where you start once you log on. This is usually your directory that you can edit yourself and change restrictions of the material to others.
lab46:~$ pwd /home/cforman lab46:~$ whoami cforman lab46:~$
This shows where I am … that is the home directory within my section. cforman means i can edit there making me the owner of that directory.
The working directory is the space that you are in. IT has a hierarchy system to it. there is one main directory and multiple directories within it. The directory you are in is the working directory. This can be seen using the pwd command.
lab46:~$ pwd /home/cforman
In Linux everything is a file. There are three types of files.
The first type is regular. This is the normal files that you edit with text. they can be edited using nano or vi.
The second type of file is a directory. This is more like a folder in Windows. You can store regular files and special files within the directory file. You can enter the directory file by using the command “cd 'directoryname'” Directories are colored blue on the terminal.
lab46:~$ cd tmp lab46:~/tmp$ ls file haha hola killyou mwajajaja testsubject lab46:~/tmp$
tmp is a directory and there are files within it.
Special files are the third type of file. This file is not text nor is it a directory. this is an executable files usually. It allows interaction with the hardware of the computer to complete a certain function. A text file can be turned into a special file by using the command, “ chmod u+x filename”
Simply what it says. listing files is using a command to display the files in a directory. the command ls or ls -l are the most used listing commands.
lab46:~$ ls Maildir cake irc public_html src tmp bin closet motd shellscripting src.orig vitest lab46:~$ ls -l total 12 lrwxrwxrwx 1 cforman lab46 17 Aug 28 10:37 Maildir -> /var/mail/cforman drwxr-xr-x 2 cforman lab46 124 Sep 29 16:49 bin -rw-r--r-- 1 cforman lab46 3 Sep 6 16:21 cake drwxr-xr-x 2 cforman lab46 69 Sep 15 16:11 closet drwx------ 4 cforman lab46 39 Sep 29 14:55 irc -rw-r--r-- 1 cforman lab46 1310 Sep 15 15:13 motd drwx-----x 2 cforman lab46 6 Aug 26 2009 public_html drwxr-xr-x 2 cforman lab46 6 Sep 22 15:21 shellscripting drwx------ 2 cforman lab46 6 Sep 6 14:31 src drwx------ 4 cforman lab46 45 Sep 4 21:29 src.orig drwxr-xr-x 2 cforman lab46 97 Sep 30 23:06 tmp -rw-r--r-- 1 cforman lab46 23 Sep 15 14:54 vitest lab46:~$ ls is a basic listing of the files in a directory. ls -l shows the permisions, owner, size, last edited time, name of the files.
There are many ways to copy a file. you can “echo $filename | 'other file'”, you can “cat 'filename' | 'anotherfilename'” or you can just “cp 'filename' 'newfile'” all three ways work.
This is easily done using the rm command a variation of rm “rmdir” allows for not just the removal of a file but a whole directory.
lab46:~$ ls Maildir cake data motd shellscripting src.orig vitest bin closet irc public_html src tmp lab46:~$ touch testfiel lab46:~$ ls Maildir cake data motd shellscripting src.orig tmp bin closet irc public_html src testfiel vitest lab46:~$ mkdir testdirectory lab46:~$ ls Maildir closet motd src testfiel bin data public_html src.orig tmp cake irc shellscripting testdirectory vitest lab46:~$ rm testfiel rm: remove regular empty file `testfiel'? y lab46:~$ rmdir testdirectory lab46:~$ ls Maildir cake data motd shellscripting src.orig vitest bin closet irc public_html src tmp lab46:~$
As seen above the commands mkdir makes directories and the command touch creates files. Files also can be created by opening the VI and saving the data inputted with a name and VI will create the file within the directory you were.
Ownership of a file is shown when the command ls -l is used.
lab46:~$ ls -l total 16 lrwxrwxrwx 1 cforman lab46 17 Aug 28 10:37 Maildir -> /var/mail/cforman drwxr-xr-x 2 cforman lab46 4096 Oct 6 16:22 bin -rw-r--r-- 1 cforman lab46 3 Sep 6 16:21 cake drwxr-xr-x 2 cforman lab46 69 Sep 15 16:11 closet lrwxrwxrwx 1 cforman lab46 27 Oct 4 14:36 data -> /usr/local/etc/data/cforman drwx------ 4 cforman lab46 39 Sep 29 14:55 irc -rw-r--r-- 1 cforman lab46 1310 Sep 15 15:13 motd drwx-----x 2 cforman lab46 6 Aug 26 2009 public_html drwxr-xr-x 2 cforman lab46 6 Sep 22 15:21 shellscripting drwx------ 2 cforman lab46 6 Sep 6 14:31 src drwx------ 4 cforman lab46 45 Sep 4 21:29 src.orig drwxr-xr-x 2 cforman lab46 97 Sep 30 23:06 tmp -rw-r--r-- 1 cforman lab46 23 Sep 15 14:54 vitest lab46:~$
The name of the user who created the file will show up in the line produced by the ls -l command.
I would like to test my ability to use and understand information displayed by the ls and ls -l commands.
I will enter the lab46 terminal and test my ability to see the files and then use the -l extension to elaborate on the information given by the ls command.
lab46:~$ ls -l total 16 lrwxrwxrwx 1 cforman lab46 17 Aug 28 10:37 Maildir -> /var/mail/cforman drwxr-xr-x 2 cforman lab46 4096 Oct 6 16:22 bin -rw-r--r-- 1 cforman lab46 3 Sep 6 16:21 cake drwxr-xr-x 2 cforman lab46 69 Sep 15 16:11 closet lrwxrwxrwx 1 cforman lab46 27 Oct 4 14:36 data -> /usr/local/etc/data/cforman drwx------ 4 cforman lab46 39 Sep 29 14:55 irc -rw-r--r-- 1 cforman lab46 1310 Sep 15 15:13 motd drwx-----x 2 cforman lab46 6 Aug 26 2009 public_html drwxr-xr-x 2 cforman lab46 6 Sep 22 15:21 shellscripting drwx------ 2 cforman lab46 6 Sep 6 14:31 src drwx------ 4 cforman lab46 45 Sep 4 21:29 src.orig drwxr-xr-x 2 cforman lab46 97 Sep 30 23:06 tmp -rw-r--r-- 1 cforman lab46 23 Sep 15 14:54 vitest lab46:/$ ls bin etc lib lost+found opt sbin sys var boot home lib32 media proc selinux tmp vmlinuz dev initrd.img lib64 mnt root srv usr lab46:/$ ls -l total 118 drwxr-xr-x 2 root root 4096 Sep 20 15:12 bin drwxr-xr-x 2 root root 4096 Oct 10 21:13 boot drwxr-xr-x 13 root root 2540 Oct 10 21:14 dev drwxr-xr-x 102 root root 12288 Oct 11 19:13 etc drwxr-sr-t 354 root staff 12288 Sep 20 11:05 home lrwxrwxrwx 1 root root 34 Jun 14 2010 initrd.img -> boot/initrd.img-2.6.32-5-xen-amd64 drwxr-xr-x 10 root root 12288 Aug 28 10:14 lib drwxr-xr-x 4 root root 12288 Oct 10 21:13 lib32 lrwxrwxrwx 1 root root 4 Jun 14 2010 lib64 -> /lib drwx------ 2 root root 16384 Jun 14 2010 lost+found drwxr-xr-x 2 root root 4096 Jun 14 2010 media drwxr-xr-x 2 root root 4096 Jun 1 2010 mnt drwxr-xr-x 2 root root 4096 Jun 14 2010 opt dr-xr-xr-x 111 root root 0 Oct 10 21:14 proc drwx------ 12 root root 4096 Oct 10 22:11 root drwxr-xr-x 2 root root 4096 Aug 28 10:14 sbin drwxr-xr-x 2 root root 4096 Mar 28 2010 selinux drwxr-xr-x 2 root root 4096 Jun 14 2010 srv drwxr-xr-x 13 root root 0 Oct 10 21:14 sys drwxrwxrwt 6 root root 6144 Oct 11 19:17 tmp drwxr-xr-x 12 root root 4096 Aug 28 2010 usr drwxr-xr-x 15 root root 4096 Aug 19 2010 var lrwxrwxrwx 1 root root 31 Jun 14 2010 vmlinuz -> boot/vmlinuz-2.6.32-5-xen-amd64
These two examples show the ls and ls -l examples. differeces include permisions on left, place is next, owned by and located at are the next two parts, number of charecters is next, last date edited and name.
Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.
If you run a program you made and you use a path to activate it from another location. Do you go to the program or does the program run where you are?
All information based on in class lectures.
I believe that the program will come to me.
Because I am opening a path to the program. We discussed in class that it is possible to form shells within the shell you are already in. I believe that the program will form around me and then leave after its completion.
I am going to test it by entering a directory not near my program and activate it using a path. Within the program i added 'pwd' which allows the program to display its current location.
lab46:~/bin$ script1 please enter your name: ls hi, ls, how are you?ls Oh so your ls . Well I don't GIVE a care :p /home/cforman/bin
this was a test to show what the program will do. once the program finishes it will display its location.
lab46:~/bin$ cd ../../../usr lab46:/usr$ ~/bin/script1 please enter your name: bob hi, bob, how are you?sad Oh so your sad . Well I don't GIVE a care :p /usr
This shows that I went to the usr directory and made a path to my script. It ran in usr although it was not made or saved there.
Based on the data collected:
It can be concluded that when you run a script from a different location using a path to its, that you will not go to it but it will come to you. One interesting discovery is that not only does it run at your location but will form a bubble around as it runs.
If we change location from within a script instead of just calling it to us, will we follow it to the area that it relocates to or stay where we were?
Used information gathered in class…. basic scripting and location checking.
I believe i will stay where I started the program based on the last experiment. Changing the location in a file unless it tells the user to move somewhere the program should just move to the area of affect like it formed a shell around the user when you make a path to it.
I am going to go to the usr directory and make a path to it
lab46:~$ cd tmp lab46:~/tmp$ touch testsubject.sts lab46:~/tmp$ ls file haha hola killyou mwajajaja testsubject.sts lab46:~/tmp$ cd lab46:~$ cd ../../usr lab46:/usr$ ~/bin/script4 mv: missing destination file operand after `.hi' Try `mv --help' for more information. mv: `file' and `file' are the same file mv: `haha' and `haha' are the same file mv: `hola' and `hola' are the same file mv: `killyou' and `killyou' are the same file mv: `mwajajaja' and `mwajajaja' are the same file `testsubject.sts' -> `testsubject' /home/cforman/tmp
This shows that in fact temporarily i did go to the temp file.
Based on the data collected:
In the end I was only half correct. I did not take into account that in the shell i could travel somewhere else then when the shell disappears I return to where I was.
What is the question you'd like to pose for experimentation? State it here.
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.
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.
How are you going to test your hypothesis? What is the structure of your experiment?
Perform your experiment, and collect/document the results here.
Based on the data collected:
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.
Today we learned about regular expressions.
^ - match beginning of line $ - match end of the line . - match any single character * - match 0 or more of the previous [] - match any one of the enclosed [^] - inverted character class ( do not include) \< - match beginning of word \> - match ending of word () - grouping | - or \(\) - grouping for substitution
This allows for more advanced searching or advanced functions with a bot. I'm having a hard time using the grouping for substitution part of regular expressions. Still having trouble with time management.
<(^^,)>
Today we played with regular expressions and worked on my bot.
My bot is now able to say “Hi” back to a user directly. He can do math and tell how many users are on the system. Still having trouble using regular expressions but slowly getting a hand on them.
<(^^,)>
Once again we had to restart the irc chat. We began to talk about the “c” language. We also learned about Programming Paradigms. The C language is very useful for programming because it allows you to be more specific with the details of your program.
&& - and || - or
This helps with decisions in a script. As for the class, so far everything is going very well.
Today we learned about wildcards. Wildcards are for files while RegEx is for text.
? - match any single charecter * - match 0 or more of anything [] - anyone of enclosed [^ ] - not only one of enclosed
I am having trouble with the RegEx and Wildcards still.
The command “mv” can be used in renaming and moving files.
lab46:~$ ls Maildir archives.tar.bz2 data shellscripting tmp archive1.tar.gz archives.zip irc src vitest archive2.zip bin motd src.orig archivecompilationfile cake public_html testdir archives closet puzzlebox testdir2 lab46:~$ touch testfile lab46:~/testdir$ lab46:~/testdir$ mv testdir2 lol lab46:~/testdir$ ls file lol testfile lab46:~/testdir$ lab46:~/testdir$ cd lab46:~$ ls Maildir archives.tar.bz2 data shellscripting testfile archive1.tar.gz archives.zip irc src tmp archive2.zip bin motd src.orig vitest archivecompilationfile cake public_html testdir archives closet puzzlebox testdir2 lab46:~$ mv vitest testdir lab46:~$ ls Maildir archives.tar.bz2 data shellscripting testfile archive1.tar.gz archives.zip irc src tmp archive2.zip bin motd src.orig archivecompilationfile cake public_html testdir archives closet puzzlebox testdir2 lab46:~$ cd testdir lab46:~/testdir$ ls file lol testfile vitest lab46:~/testdir$
copying a file is useful because it leaves the file in its location but also moves it to another location.
It's like taking a bunch of files and putting them all into one secured little box. Not that anyone can't just open the archived file but it allows for a much easier mode of transportation especially combined with compressing. In basic terms it allows for the easy transportation of a large amount of files. The most common archiving tool is “tar”. Tar has a lot of details so you can look them up to see all the variations but an example of one is provided bellow.
lab46:~$ ls Maildir archives.zip linktestfile testdir archive bin motd testdir2 archive1.tar.gz cake public_html testfile archive2.zip closet puzzlebox tmp archivecompilationfile courses shellscripting archives data src archives.tar.bz2 irc src.orig lab46:~$ tar -cvf testdir.tar testdir testdir/ testdir/file testdir/testfile testdir/lol testdir/vitest testdir/hahaha/ lab46:~$ ls Maildir archives.zip linktestfile testdir archive bin motd testdir.tar archive1.tar.gz cake public_html testdir2 archive2.zip closet puzzlebox testfile archivecompilationfile courses shellscripting tmp archives data src archives.tar.bz2 irc src.orig lab46:~$
“gzip” is a command that can be used to compress a file and “gunzip” is the opposite command that can decompress the file. This is useful in combination with archiving because it makes large masses of files really small and easy for transportation. As an example the archive archives.zip will be gzipped and gunzipped.
lab46:~$ ls Maildir archives closet public_html testdir archive archives.tar.bz2 courses puzzlebox testdir2 archive1.tar.gz archives.zip data shellscripting testfile archive2.zip bin irc src tmp archivecompilationfile cake motd src.orig lab46:~$ gzip archives.zip lab46:~$ ls Maildir archives closet public_html testdir archive archives.tar.bz2 courses puzzlebox testdir2 archive1.tar.gz archives.zip.gz data shellscripting testfile archive2.zip bin irc src tmp archivecompilationfile cake motd src.orig lab46:~$ gunzip archives.zip.gz lab46:~$ ls Maildir archives closet public_html testdir archive archives.tar.bz2 courses puzzlebox testdir2 archive1.tar.gz archives.zip data shellscripting testfile archive2.zip bin irc src tmp archivecompilationfile cake motd src.orig lab46:~$
It is a special file that points to another file. Like a shortcut on a normal desktop. One can be made by using the command “ln -s source_file myfile” Demonstration.
lab46:~$ ls Maildir archives closet public_html testdir archive archives.tar.bz2 courses puzzlebox testdir2 archive1.tar.gz archives.zip data shellscripting testfile archive2.zip bin irc src tmp archivecompilationfile cake motd src.orig lab46:~$ ln -s testfile linktestfile lab46:~$ ls Maildir archives.zip linktestfile testdir archive bin motd testdir2 archive1.tar.gz cake public_html testfile archive2.zip closet puzzlebox tmp archivecompilationfile courses shellscripting archives data src archives.tar.bz2 irc src.orig lab46:~$ cat linktestfile hi lab46:~$ cd linktestfile -bash: cd: linktestfile: Not a directory lab46:~$ ls -l total 60 lrwxrwxrwx 1 cforman lab46 17 Aug 28 10:37 Maildir -> /var/mail/cforman -rw-r--r-- 1 cforman lab46 10240 Oct 27 22:27 archive -rw-r--r-- 1 cforman lab46 237 Oct 20 16:05 archive1.tar.gz -rw-r--r-- 1 cforman lab46 584 Oct 20 16:06 archive2.zip -rw-r--r-- 1 cforman lab46 62 Oct 20 16:31 archivecompilationfile drwxr-x--x 3 cforman lab46 79 Oct 20 16:30 archives -rw-r--r-- 1 cforman lab46 318 Oct 25 15:03 archives.tar.bz2 -rw-r--r-- 1 cforman lab46 1168 Oct 20 16:45 archives.zip drwxr-xr-x 2 cforman lab46 4096 Oct 26 12:47 bin -rw-r--r-- 1 cforman lab46 3 Sep 6 16:21 cake drwxr-xr-x 2 cforman lab46 69 Sep 15 16:11 closet -rw-r--r-- 1 cforman lab46 10240 Oct 27 14:48 courses lrwxrwxrwx 1 cforman lab46 27 Oct 4 14:36 data -> /usr/local/etc/data/cforman drwx------ 4 cforman lab46 39 Sep 29 14:55 irc lrwxrwxrwx 1 cforman lab46 8 Oct 27 22:38 linktestfile -> testfile -rw-r--r-- 1 cforman lab46 1310 Sep 15 15:13 motd drwx-----x 2 cforman lab46 6 Aug 26 2009 public_html drwxr-x--- 3 cforman lab46 62 Oct 25 16:21 puzzlebox drwxr-xr-x 2 cforman lab46 6 Sep 22 15:21 shellscripting drwx------ 2 cforman lab46 6 Sep 6 14:31 src drwx------ 4 cforman lab46 45 Sep 4 21:29 src.orig drwxr-xr-x 3 cforman lab46 68 Oct 27 13:16 testdir drwxr-xr-x 2 cforman lab46 6 Oct 13 18:42 testdir2 -rw-r--r-- 1 cforman lab46 3 Oct 27 12:34 testfile drwxr-xr-x 2 cforman lab46 97 Sep 30 23:06 tmp lab46:~$
This shows that it just looks like any other file except a light blue color. when the command “ ls -l” is used it will show the user where the link points to and you can view the contents of the link by catting it.
Permissions are exactly as they sound. They say who is allowed to access a file.
position Meaning 1 directory flag, 'd' if a directory, '-' if a normal file, something else occasionally may appear here for special devices. 2,3,4 read, write, execute permission for User (Owner) of file 5,6,7 read, write, execute permission for Group 8,9,10 read, write, execute permission for Other value Meaning - in any position means that flag is not set r file is readable by owner, group or other w file is writeable. On a directory, write access means you can add or delete files x file is executable (only for programs and shell scripts - not useful for data files). Execute permission on a directory means you can list the files in that directory s in the place where 'x' would normally go is called the set-UID or set-groupID flag.
cli was used to preserve format ( taken from http://www.dartmouth.edu/~rc/help/faq/permissions.html because there is no better way to explain it)
lab46:~$ ls -l total 60 lrwxrwxrwx 1 cforman lab46 17 Aug 28 10:37 Maildir -> /var/mail/cforman -rw-r--r-- 1 cforman lab46 10240 Oct 27 22:27 archive -rw-r--r-- 1 cforman lab46 237 Oct 20 16:05 archive1.tar.gz -rw-r--r-- 1 cforman lab46 584 Oct 20 16:06 archive2.zip -rw-r--r-- 1 cforman lab46 62 Oct 20 16:31 archivecompilationfile drwxr-x--x 3 cforman lab46 79 Oct 20 16:30 archives -rw-r--r-- 1 cforman lab46 318 Oct 25 15:03 archives.tar.bz2 -rw-r--r-- 1 cforman lab46 1168 Oct 20 16:45 archives.zip drwxr-xr-x 2 cforman lab46 4096 Oct 26 12:47 bin -rw-r--r-- 1 cforman lab46 3 Sep 6 16:21 cake drwxr-xr-x 2 cforman lab46 69 Sep 15 16:11 closet -rw-r--r-- 1 cforman lab46 10240 Oct 27 14:48 courses lrwxrwxrwx 1 cforman lab46 27 Oct 4 14:36 data -> /usr/local/etc/data/cforman drwx------ 4 cforman lab46 39 Sep 29 14:55 irc lrwxrwxrwx 1 cforman lab46 8 Oct 27 22:38 linktestfile -> testfile -rw-r--r-- 1 cforman lab46 1310 Sep 15 15:13 motd drwx-----x 2 cforman lab46 6 Aug 26 2009 public_html drwxr-x--- 3 cforman lab46 62 Oct 25 16:21 puzzlebox drwxr-xr-x 2 cforman lab46 6 Sep 22 15:21 shellscripting drwx------ 2 cforman lab46 6 Sep 6 14:31 src drwx------ 4 cforman lab46 45 Sep 4 21:29 src.orig drwxr-xr-x 3 cforman lab46 68 Oct 27 13:16 testdir drwxr-xr-x 2 cforman lab46 6 Oct 13 18:42 testdir2 -rw-r--r-- 1 cforman lab46 3 Oct 27 12:34 testfile drwxr-xr-x 2 cforman lab46 97 Sep 30 23:06 tmp lab46:~$
an example of changing permissions for the group.
lab46:~$ ls -l total 60 lrwxrwxrwx 1 cforman lab46 17 Aug 28 10:37 Maildir -> /var/mail/cforman -rw-r--r-- 1 cforman lab46 10240 Oct 27 22:27 archive -rw-r--r-- 1 cforman lab46 237 Oct 20 16:05 archive1.tar.gz -rw-r--r-- 1 cforman lab46 584 Oct 20 16:06 archive2.zip -rw-r--r-- 1 cforman lab46 62 Oct 20 16:31 archivecompilationfile drwxr-x--x 3 cforman lab46 79 Oct 20 16:30 archives -rw-r--r-- 1 cforman lab46 318 Oct 25 15:03 archives.tar.bz2 -rw-r--r-- 1 cforman lab46 1168 Oct 20 16:45 archives.zip drwxr-xr-x 2 cforman lab46 4096 Oct 26 12:47 bin -rw-r--r-- 1 cforman lab46 3 Sep 6 16:21 cake drwxr-xr-x 2 cforman lab46 69 Sep 15 16:11 closet -rw-r--r-- 1 cforman lab46 10240 Oct 27 14:48 courses lrwxrwxrwx 1 cforman lab46 27 Oct 4 14:36 data -> /usr/local/etc/data/cf orman drwx------ 4 cforman lab46 39 Sep 29 14:55 irc lrwxrwxrwx 1 cforman lab46 8 Oct 27 22:38 linktestfile -> testfile -rw-r--r-- 1 cforman lab46 1310 Sep 15 15:13 motd drwx-----x 2 cforman lab46 6 Aug 26 2009 public_html drwxr-x--- 3 cforman lab46 62 Oct 25 16:21 puzzlebox drwxr-xr-x 2 cforman lab46 6 Sep 22 15:21 shellscripting drwx------ 2 cforman lab46 6 Sep 6 14:31 src drwx------ 4 cforman lab46 45 Sep 4 21:29 src.orig drwxr-xr-x 3 cforman lab46 68 Oct 27 13:16 testdir drwxr-xr-x 2 cforman lab46 6 Oct 13 18:42 testdir2 -rw-r--r-- 1 cforman lab46 3 Oct 27 12:34 testfile drwxr-xr-x 2 cforman lab46 97 Sep 30 23:06 tmp lab46:~$ chmod g+rw testfile lab46:~$ ls -l total 60 lrwxrwxrwx 1 cforman lab46 17 Aug 28 10:37 Maildir -> /var/mail/cforman -rw-r--r-- 1 cforman lab46 10240 Oct 27 22:27 archive -rw-r--r-- 1 cforman lab46 237 Oct 20 16:05 archive1.tar.gz -rw-r--r-- 1 cforman lab46 584 Oct 20 16:06 archive2.zip -rw-r--r-- 1 cforman lab46 62 Oct 20 16:31 archivecompilationfile drwxr-x--x 3 cforman lab46 79 Oct 20 16:30 archives -rw-r--r-- 1 cforman lab46 318 Oct 25 15:03 archives.tar.bz2 -rw-r--r-- 1 cforman lab46 1168 Oct 20 16:45 archives.zip drwxr-xr-x 2 cforman lab46 4096 Oct 26 12:47 bin -rw-r--r-- 1 cforman lab46 3 Sep 6 16:21 cake drwxr-xr-x 2 cforman lab46 69 Sep 15 16:11 closet -rw-r--r-- 1 cforman lab46 10240 Oct 27 14:48 courses lrwxrwxrwx 1 cforman lab46 27 Oct 4 14:36 data -> /usr/local/etc/data/cforman drwx------ 4 cforman lab46 39 Sep 29 14:55 irc lrwxrwxrwx 1 cforman lab46 8 Oct 27 22:38 linktestfile -> testfile -rw-r--r-- 1 cforman lab46 1310 Sep 15 15:13 motd drwx-----x 2 cforman lab46 6 Aug 26 2009 public_html drwxr-x--- 3 cforman lab46 62 Oct 25 16:21 puzzlebox drwxr-xr-x 2 cforman lab46 6 Sep 22 15:21 shellscripting drwx------ 2 cforman lab46 6 Sep 6 14:31 src drwx------ 4 cforman lab46 45 Sep 4 21:29 src.orig drwxr-xr-x 3 cforman lab46 68 Oct 27 13:16 testdir drwxr-xr-x 2 cforman lab46 6 Oct 13 18:42 testdir2 -rw-rw-r-- 1 cforman lab46 3 Oct 27 12:34 testfile drwxr-xr-x 2 cforman lab46 97 Sep 30 23:06 tmp lab46:~$
Viewing files can be done thought a couple of different ways. The “out of the way” way to view file contents is to open the file using “nano” or the “vi editor”. Both of these allow the appending of a file also rather then just viewing it. the easiest way to view a file is to use the “cat” command to pretty much echo the contents of the file onto the screen.
lab46:~$ ls Maildir archives.zip linktestfile testdir archive bin motd testdir.tar archive1.tar.gz cake public_html testdir2 archive2.zip closet puzzlebox testfile archivecompilationfile courses shellscripting tmp archives data src archives.tar.bz2 irc src.orig lab46:~$ cat cake 16 lab46:~$ cat testfile hi lab46:~$ cat src cat: src: Is a directory lab46:~$ cat linktestfile hi lab46:~$
“cat” can view text files and links to text files but it cant view directories, because they are not basic files they are many files. “cat” can open programs but this is not recomended because it does not like it and will freak out on your screen.
lab46:~/bin$ ls CliBash OpusResults datatypes hello.s script2 DOOMONUbot boscript datatypes.c password script3 DOOMONUbot2 cli.c hello script script4 Multiplicationprog commandline hello.c script1 script5 lab46:~/bin$ cat hello ELF>@@à @@@@@@@À@@@@ ` ÈÈ`È` @@DDPåtdüü@ü@$$Qåt/lib64/ld-linux-x86-64.so.2GNUGNUÛ-6I!#ÄSÚ¬ü9j;}Xk __gmon_start__libc.so.6puts__libc_start_mainGLIBC_2.2.5ui 1`HèkèúèÕHÃÿ5¢ ÿ%¤ @ÿ%¢ héàÿÿÿÿ% héÐÿÿÿ1íIÑ^HâHäðPTIÇÀ@HÇÁ@HÇÇä@èÇÿÿÿôHH1 H ÀtÿÐHÃUHåSH=H uK»¸`HB Hë°`HÁûHëH9Øs$fDHÀH ÿÅ°`H H9ØrâÆû H[ÉÃfff. %t Ll$èLt$ðL|$øH\$ÐHì8L)åAýIöHÁýI×ècþÿÿHÉÿàÉÃUHå¿ì@èîþÿÿ¸ÉÃóÃfffff. -{ L ít1Û@LúLöDïAÿÜHÃH9ërêH\Hl$Ld$Ll$ Lt$(L|$0HÄ8ÃUHåSHHð Høÿt» `DHÿÐHHøÿuñH[ÉÃHèoþÿÿHÃHello, World! èþÿÿ<ÿÿÿ\ÿÿÿtzRx ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ < þÿÿ$TþÿÿQ_@F Ø@`@õþÿo@¨@ = `0@p@ þÿÿoP@ÿÿÿoðÿÿoF@È`æ@ö@GCC: (Debian 4.4.5-8) 4.4.5GCC: (Debian 4.4.5-10) 4.4.5.symtab.strtab.shstrtab.interp.note.ABI-tag.note.gnu.build-id.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rela.dyn.rela.plt.init.text.fini.rodata.eh_frame_hdr.eh_frame.ctors.dtors.jcr.dynamic.got.got.plt.data.bss.comment#@ 1<@<$H`@`DöÿÿoN ¨@¨=^ÿÿÿoF@kþÿÿoP@Pzp@p ¸@¸Ð@Ð0@ØØ@Ø è@è¨ü@ü$¶ @ À `Ç°`ÎÀÓÈ`õ09þ / ¸ñ@@<@`@@¨F@ P@ p@ @ Ð@@Ø@è@ü@ @ `°`À`È````ñÿ `*°`8À`EP@[`jxÀ@ñÿ ¨`@À`« @ÁñÿÉ`ß`ð`È` `@'@. = QcØ@iè`¤`±¸`¾@Îñÿ`Úñÿ`ßñÿ`æä@ë ¸@call_gmon_startcrtstuff.c__CTOR_LIST____DTOR_LIST____JCR_LIST____do_global_dtors_auxcompleted.6341dtor_idx.6343frame_dummy__CTOR_END____FRAME_END____JCR_END____do_global_ctors_auxhello.c_GLOBAL_OFFSET_TABLE___init_array_end__init_array_start_DYNAMICdata_start__libc_csu_fini_start__gmon_start___Jv_RegisterClassesputs@@GLIBC_2.2.5_fini__libc_start_main@@GLIBC_2.2.5_IO_stdin_used__data_start__dso_handle__DTOR_END____libc_csu_init__bss_start_end_edatamain_initlab46:~/bin$ PuTTYTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTY -bash: PuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTY: command not found lab46:~/bin$
It sometimes works with bash language programs though.
It is a basic process of typing like you would do with any text editor. There is one catch. Unix does so much more with its text editing. There are two popular text editors and both are quite unique. The “nano” editor and the “VI” editor. Nano is a basic editor that allows for the compilation of data in the simplest way possible. All that is required is the user to type it in. There are tips at the bottom that give a few of the commands nano can perform to the text within it. VI is in some terms the “ultimate” text editor. VI has two modes: the command mode and the insert mode. The command mode allows for some pretty beast tricks. Once a document is completed you can use the command mode to copy lines in the text and then plunk them somewhere else in the document. You can also use a command to change a set of words into another word. ex, changing all the “hello”'s in the document to “babies must die”. its not a necessary change but it can be done and the VI editor can do so much more.
Identification and definition of the chosen keyword. Substitute “keyword” with the actual keyword.
If you want to demonstrate something on the command-line, you can do so as follows:
lab46:~$ vi ~ ~ ~ ~ ~ VIM - Vi IMproved ~ ~ version 7.2.445 ~ by Bram Moolenaar et al. ~ Modified by pkg-vim-maintainers@lists.alioth.debian.org ~ Vim is open source and freely distributable ~ ~ Sponsor Vim development! ~ type :help sponsor<Enter> for information ~ ~ type :q<Enter> to exit ~ type :help<Enter> or <F1> for on-line help ~ type :help version7<Enter> for version info ~ ~ ~ ~ ~ 0,0-1 All
This is the VI start up and you can get here by typing “vi” on the command line. To enter the the insert mode all that is needed is for the user to hit the “i” key. Simple right. to escape you hit the “esc” key and your back to the command mode. The word insert should appear in the bottom left corner of your screen. If its not there your in the command mode. Within the text editor you can use the arrow keys to navigate and the normal keys to type nothing tricky here. Text editing can also be used to create programs that can be executed if given the right properties.
This is where you can do all the fun stuff to a text document. Here a basic list of commands can be found.
http://www.eng.hawaii.edu/Tutor/vi.html
This list of commands allow the user to yank lines to place them somewhere else, copy lines, replace text and much much more.
If you don't know if you are in the command mode you can spam the ESC key to get there. Usually it take just one hit but the constant flow of beeping says you are where you need to be and you can now do some wicked editing.
The extended command mode allows for the searching of key words or letters within the text. It also allows for the replacing of such text. Usually within the command mode you can enter short commands but in the extended command mode you can enter in a whole string of commands that can be used to pinpoint a distinct piece of text or pieces of text through out the text by searching for them and then replacing them with whatever you with to replace them with.
The Unix shell is a GUI command-line interpreter. Basically it is a visual representation of code. It is like Windows but mostly text oriented visuals rather then picture icons and such that is provided by Windows.
This is a view of the Unix shell I work in. It has text art or pictures made from keys on the keyboard.
__ _ _ _ __ . . [ Type 'motd' to see the original motd ]. . . | | __ _| |__ / | |_/ / . Basic System Usage: Type 'usage' at prompt . | |__/ _` | '_ \\_ _/ _ \ . Events and News: Type 'news' at prompt . |_____\__,_|_.__/ |_|\___/ . Broken E-mail?_ Type 'fixmail' at prompt . --------------------------- . Check Lab46 Ma)\: Type 'alpine' at prompt . c o r n i n g -_c c . e d u . . . . . . ..'`--`'. . . . . . . . . . . . . . . Lab46 is the C)\_uter & Information Scie/ ^ ^ \ment's Student Development Server for .'`---`'.related coursework, \ \/\/\/ /and exp_J_ation. .. . . / <> <> \ . '------' .'`---`'. . . . .. . Lab46 W| A | http://lab46.corning_/)_ /.'b d \ . . Lab46 H\ <\_/> / http://lab46.corn.'`----`'. \: 0 |t . . Help E_?_._`"`_.' haas@corning-cc./.'<\ /> ||' V===V /ing-cc.edu . .. . .'`---`'.`` _/( /\. |:,___A___,| '._____.' . . . .. /.'a . a \.'`---`'. __(_(__ \' \_____/ / _?_ |: ___ /.'/\ /\ \ .-'._'-'_.'-:.______.'.'`"""`'. \' \_/ |: ^ | .'.' (o\'/o) '.'. / ^.^ \ '._____.'\' 'vvv' / / :_/_: A :_\_: \ \ `===` / '.__.__.' | : \'=...='/ : | `-------` \ : :'.___.': : / '-:__:__:__:__:-' You have new mail. Last login: Sat Oct 29 20:52:58 2011 from cpe-67-241-236-8.stny.res.rr.com lab46:~$ alpine Alpine finished -- Closed folder "INBOX". Kept all 25 messages. lab46:~$ alpine Alpine finished -- Closed folder "INBOX". Kept all 25 messages. lab46:~$
These are variables that change the processing environment. The commands “env, set, and printenv” display all environment variables and their values.
lab46:~$ env TERM=xterm SHELL=/bin/bash SSH_CLIENT=67.241.236.8 56619 22 SSH_TTY=/dev/pts/1 USER=cforman LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36: MAIL=/home/cforman/Maildir PATH=/home/cforman/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games LC_COLLATE=C PWD=/home/cforman LANG=en_US HISTCONTROL=ignoreboth SHLVL=1 HOME=/home/cforman LOGNAME=cforman SSH_CONNECTION=67.241.236.8 56619 10.80.2.38 22 _=/usr/bin/env lab46:~$ printenv TERM=xterm SHELL=/bin/bash SSH_CLIENT=67.241.236.8 56619 22 SSH_TTY=/dev/pts/1 USER=cforman LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36: MAIL=/home/cforman/Maildir PATH=/home/cforman/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games LC_COLLATE=C PWD=/home/cforman LANG=en_US HISTCONTROL=ignoreboth SHLVL=1 HOME=/home/cforman LOGNAME=cforman SSH_CONNECTION=67.241.236.8 56619 10.80.2.38 22 _=/usr/bin/printenv lab46:~$
These Variables can be changed by assigning a new value to a environment variable. Here is an example grabbed off of http://en.wikipedia.org/wiki/Environment_variable#Unix_2
ENVIRONMENT_VARIABLE=VALUE <command> notation. Examples of environment variables include: PATH - lists directories the shell searches, for the commands the user may type without having to provide the full path. HOME (Unix-like) and USERPROFILE (Microsoft Windows) - indicate where a user's home directory is located in the file system. HOME/{.AppName} (Unix-like) and APPDATA\{DeveloperName\AppName} (Microsoft Windows) - for storing application settings. Many open source programs incorrectly use USERPROFILE for application settings in Windows - USERPROFILE should only be used in dialogs that allow user to choose between paths like Documents/Pictures/Downloads/Music, for programmatic purposes APPDATA (roaming), LOCALAPPDATA or PROGRAMDATA (shared between users) is used. TERM (Unix-like) - specifies the type of computer terminal or terminal emulator being used (e.g., vt100 or dumb). PS1 (Unix-like) - specifies how the prompt is displayed in the Bourne shell and variants. MAIL (Unix-like) - used to indicate where a user's mail is to be found. TEMP - location where processes can store temporary files
I wish to test my ability to look at a peice of code and determine what each part is doing to the best of my ability before having to look up information.
I will use a previously made script and observe what I did explaining each line so anyone can understand it peice by piece. I will judge myself on the amount of data i have to look up.
#!/bin/bash # # a=0 echo -n "Please enter a number: " read number until [ $number -eq 0 ]; do n=0 until [ `echo "$number-2^$n" |bc` -lt 0 ]; do let n=$n+1 done let n=$n-1 let number=$number-`echo "2^$n"|bc` places="" for((i=0;i<$n;i++)); do places="${places}0" done places="1${places}" a=`echo "$a+$places" |bc` done echo "The Binary value is: $a" exit 0
I will be explaining this script line by line to test my ability to read script.
line one = that is the required start line for a bash script. Without this the program would cease to function in any other location besides a bash shell.
line 2 and 3 are just spaces and mean nothing. text can go after the # and the script will not think of it as script.
line 4 is a echo that promts the user for a digit to convert to bianary.
line 5 reads the inputed variable
line 6 begins a loop withthe boundries of until number is equal to 0 meaning the number the user inputed is equal to 0
line 7 asigns n with the value of 0
line 8 starts another loop in which the variable has 2 to n subtracted from it until it is less then 0
line 9 sets n so that each time the loop progresses it adds one to the value of n
line 10 ends the second loop
line 11 subtracts 1 from n because 2 to the n makes it less then 0 and you dont want to go that far.
line 12 sets number no as number - 2 to the n power.
line 13 creates the places variable
line 14 starts a for loop in which i is less then n
line 15 places is equal to places represented by 0
line 16 ends the for loop
line 17 puts a 1 infront of places representing the farthest binanary digit for that specific loop.
line 18 sets a equal to a + places which is a 1 and a bunch of 0s a is 0 at start
line 19 ends until loop 1 if bounds are met
line 20 echos the answer to the user … answer is the variable a
line 21 is end script call
Can I use Gzip to unzip the file courses.html?
http://en.wikipedia.org/wiki/Gzip I should just be able to use the command gunzip and unzip the file.
I believe i can unzip the archive without any issues.
I can do this because after using the command “file” i was able to see that it was a gzip file.g
How are you going to test your hypothesis? What is the structure of your experiment?
lab46:~$ file courses.html courses.html: gzip compressed data, was "courses.html", from Unix, last modified: Wed Oct 19 19:20:57 2011, max compression lab46:~$ gunzip courses.html gzip: courses.html: unknown suffix -- ignored lab46:~$ lab46:~$ mv courses.html courses.gz lab46:~$ ls Maildir archives.zip irc src.orig archive1.tar.gz bin motd testdir archive2.zip cake public_html testdir2 archivecompilationfile closet puzzlebox testfile archives courses.gz shellscripting tmp archives.tar.bz2 data src lab46:~$ gunzip courses.gz lab46:~$ ls Maildir archives.zip irc src.orig archive1.tar.gz bin motd testdir archive2.zip cake public_html testdir2 archivecompilationfile closet puzzlebox testfile archives courses shellscripting tmp archives.tar.bz2 data src
Based on the data collected:
It can be concluded that Gzip is a very useful tool to compress and decompress as long as the file name is correct.
While using the x11 terminal, what would happen if I changed the variable of $DISPLAY?
$DISPLAY is the variable that controls where the terminal displays the results of your actions on it. The variable mimics this pattern but varies from comp to comp. “flake0?.offbyone.lan:?” the ? is to replaced by the correct number corresponding to the display you wish to access.
I believe i can change my variable to display on some one's computer. State your rationale.
===Experiment=I M GOING TO change my DISPLAY variable and use xeyes and hopefully xeyes will appear on the other persons computer.
DISPLAAY=flake03.offbyone.lan:1 xeyes
I was not able to exactly demonstrate the results of these two line but they worked. the program xeyes worked on the other computer and not mine.
Based on the data collected:
It is very fun to change you DISPLAY variable and pop stuff up on other computers. This power though should no be abused because it can become very annoying.
If you're doing an experiment instead of a retest, delete this section.
If you've opted to test the experiment of someone else, delete the experiment section and steps above; perform the following steps:
Whose existing experiment are you going to retest? Prove the URL, note the author, and restate their question.
Evaluate their resources and commentary. Answer the following questions:
State their experiment's hypothesis. Answer the following questions:
Follow the steps given to recreate the original experiment. Answer the following questions:
Publish the data you have gained from your performing of the experiment here.
Answer the following:
Answer the following:
On this day we learned about X11. X11 is the graphical interface on the computers in the “Lair”. All the computers are connected and you can send things to other people's displays and troll them. You can do this by opening up a normal terminal which is connected to X11. After you are in one you can change your DISPLAY variable to their computer and use xcommands which you can look up to troll them.
Today we worked on data-mining the schools list of courses for next year. This is one of my favorite things to do when I'm not having a bad day and will take my time on it. Basically data-mining is the process of removing all the extra info from a file and retrieving the valuable data form the mess of information. We also learned about ASCII art or art made with characters found on the keyboard.
Today we learned a little about networking. A few basic directories and commands for these aspects are as follows
/sbin/ifcongig this will take you to network information netstat -nr this will show you the routing system netstat -l same thing just different format as the previous command ping this allows you to check for a computer and test teh connection traceroute follows a ping
Today one of our classmates came in with a project for work and it was huge. He asked the class for help so it can get done on time and we did because the teacher promised us project points for it. The project was to data-mine some information on companies and emails. I really enjoy data-mining and am trying to learn AWK which makes data-mining much easier and quicker. Data-mining is a great thing to put on your resume when searching for a job because almost every industry is focused around data.
The PATH is a list of locations that, when a command is issued, Unix searches to find the executable command in order to run it.
lab46:~$ echo $PATH /home/cforman/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
each area listed above is a possible location I can execute from. Since the PATH is a variable it can be changed. I changed mine so that I can type any name of a game and Unix will automatically run it for me without the necessity of me having to go to that directory. Since I added to my PATH it was o.k. but if I had removed it would result in errors because I would not be able to run programs instantly just by calling them.
lab46:~$ worm Well, you ran into something and the game is over. Your final score was 78 lab46:~$ OpusResults The total is 102 Your actual value is 76 74.50 The total for part 2 is 102 Your actual value is 91 89.21 your average is 81 lab46:~$
These are two commands that I executed from my home page but the commands are located in different directories one in my personal bin directory and the games directory. I can run them because as I said earlier they are part of my PATH.
Wildcars are a series of characters that when searching mean something other then what they normaly do when searching for files. (kinda vague huh)
Here is a list of Wildcards.
? - match any single character * - match 0 or more of this character/anything really [] - match any one of enclosed [^] - do not match any of the enclosed
EXAMPLE TIME
lab46:~$ ls 1275799069694.jpg funny-pictures-taco-cat-is-a-palindrome.jpg 250px-P2_glados.jpg goonies-musical.jpg Downloads irc InstNLP2.txt linktestfile InstNLP2Edited.txt minecraft-creeper-comic-600x694.png Maildir motd RageFaceBlackSS.png nom-nom-nom-babies.jpg archive public_html archive1.tar.gz puzzlebox archive2.zip shaco.jpg archivecompilationfile shellscripting archives spring2012-20111103.html archives.tar.bz2 src archives.zip src.orig bin testdir cake testdir.tar closet testdir2 corningcourses testfile corningcoursesorg tmp courses trollin data trolling-400x345.jpg emvideo-youtube-nd2rBWbvDbA_3.jpg veigar.jpg fiddlesticks.jpg wicked-witch.jpg lab46:~$ ls ??? bin: CliBash OpusResults commandline hello.c script script4 DOOMONUbot Searchcourses datatypes hello.s script1 script5 DOOMONUbot2 boscript datatypes.c password script2 Multiplicationprog cli.c hello s script3 irc: irc irc.freenode.net src: tmp: file haha hola killyou mwajajaja testsubject
o.k. that's kind of annoying you might say when looking at the results. Sure not everything you see is three characters long but Unix does this cool thing like you know being nice. if you wanted the directories that were three characters long in name it gives those and shows what they contain. Lets try this again but in a different way. Lets see how many files start with a number.
lab46:~$ ls [0-9]*|wc -l 2
when entering a command onto the command line it will let you tab complete it. When you are typing a command you can hit tab to auto complete it but if what you typed matches more then one command it will not auto complete but give you (if you hit tab twice) all the options of commands that match what you typed.
lab46:~$ ls 1275799069694.jpg closet shaco.jpg 250px-P2_glados.jpg corningcourses shellscripting Downloads corningcoursesorg spring2012-20111103.html InstNLP2.txt courses src InstNLP2Edited.txt data src.orig Maildir emvideo-youtube-nd2rBWbvDbA_3.jpg testdir RageFaceBlackSS.png fiddlesticks.jpg testdir.tar archive funny-pictures-taco-cat-is-a-palindrome.jpg testdir2 archive1.tar.gz goonies-musical.jpg testfile archive2.zip irc tmp archivecompilationfile linktestfile trollin archives minecraft-creeper-comic-600x694.png trolling-400x345.jpg archives.tar.bz2 motd veigar.jpg archives.zip nom-nom-nom-babies.jpg wicked-witch.jpg bin public_html cake puzzlebox lab46:~$ ec then hit tab lab46:~$ echo lab46:~$ echo fidd TAB lab46:~$ echo fiddlesticks.jpg lab46:~$ echo S THE DOUBLE TAB lab46:~$ echo s shaco.jpg spring2012-20111103.html src.orig/ shellscripting/ src/ lab46:~$ echo s
O.K. so say you have a program that is bugging the crap out of your terminal and you cant stop it. How will this trouble get solved. Easily just put a shotgun to its head (metaphorically speaking). Kill commands like “kill -9” are sure to blow off the head of any zombie program or out of control program. Just pray its not a Ninja Zombie (much like magical zombies that don't die from anything). If you have a program that is spazzing out and is disconnected from any control you can implement that is a ninja zombie and that is a losing situation. If its a normal zombie kill -9 will terminate it like a bad Arnold Schwarzenegger impression, “GET in ze chopper!”
SO SAY CAT IS ON BUT YOU WANT IF OFF BUT YOU DESIRE TO COMPLETELY OBLITERATE THE LITTLE KITTEN USE THIS. lab46:~$ cat THE EMPTY SPACE IS CAT WHEN IT IS ISSUED WITH NOTHING TO CAT lab46:~$ ps USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND cforman 4061 0.0 0.1 13632 2000 pts/28 SNs 22:27 0:00 -bash cforman 5193 0.0 0.0 5860 532 pts/19 SN+ 22:33 0:00 cat cforman 6573 0.0 0.0 8584 960 pts/28 RN+ 22:40 0:00 ps u cforman 14217 0.0 0.0 13664 8 pts/17 SNs Oct13 0:00 /bin/bash cforman 14222 0.0 0.1 42684 2036 pts/17 SN+ Oct13 6:52 irssi cforman 24154 0.0 0.1 13632 1968 pts/19 SNs 21:21 0:00 -bash lab46:~$ kill -9 5193 lab46:~$ CAT RESPONDS BY BEING KILLED .... IN A BLENDER LOL lab46:~$ cat Killed lab46:~$
A compiler is a program that turns source code into programs. With bash it automatically compiles the script to code but with “C”
lab46:~/bin$ ls CliBash OpusResults commandline hello.c script script4 DOOMONUbot Searchcourses datatypes hello.s script1 script5 DOOMONUbot2 boscript datatypes.c password script2 Multiplicationprog cli.c hello s script3 lab46:~/bin$ gcc -o babybackribs cli.c lab46:~/bin$ ls CliBash OpusResults cli.c hello s script3 DOOMONUbot Searchcourses commandline hello.c script script4 DOOMONUbot2 babybackribs datatypes hello.s script1 script5 Multiplicationprog boscript datatypes.c password script2 lab46:~/bin$
You want to use the gode between the two lists of programs. “gcc -o progname scriptname”
When I think of RegEx's I tend to think of data-mining. A lot of RegEx's are used in this process. You can use them to define certain peices of text when trying to remove repeated paterns and get information not defined by the RegEx's. Here is a list of RegEx's:
^ = match beginning of line $ = match end of line . = match any single character * = match 0 or more of previous character \< = match beginning of word \> = match end of word [] = match any of enclosed [^] = inverted character class (do not match) () = grouping | = or \(\) = grouping for substitution lab46:~$ cat InstNLP2.txt | sed 's/^$/^/g' | tr '\n' '$' | tr '^' '\n'|sed 's/-----------/unknown/g'|sed 's/^\$\(.*\)\$\(.*\)\$\(.*\)\$$/"\3","\2","\1"/g'|sed 's/email: //g'|less HERE IS A LINE OF REGEX THAT I USED TO DATA-MINE A FILE TO RETRIEVE THE USEFUL INFORMATION OUT OF IT.
Job control is controlling how a program or proces runs (in the foreground or background) and stopping active jobs without killing them and of course my favorite type of control. (in the words of a man name Jesse Cox) “John Wu style in you're face!” ( basic shotgun blast to the head, although John Wu used pistols …. it does not matter) Here is a list of job control commands.
control-z Stop (don't kill) the foreground job, and then return to the shell jobs Check the status of jobs in the current session ps -u username Check the status of processes, including those from other sessions. On BSD systems, use 'ps -gx'. kill -9 %1 Kill a job, by specifying its job number after the percent sign kill -9 123 Kill a process, by specifying its process id (PID) number bg Run the most recently stopped job in the background fg Bring most recently backgrounded job to the foreground fg %1 Bring a job to foreground by specifying its job number after the percent sign
A program is something you run instantly and see the results almost as fast as you started it. Like opening an application on your desktop. That is a program you are using. A function is also a program but it runs continually in the background usually unless you decide otherwise. A process is like the computer receiving and translating the sets of bits from the key board into ASCII text so you can read it. That is a process. Another process could be background security checks by your friendly neighborhood antivirus.
As explained above when something runs in the background you do not see it but it still runs. It does not have any effect until it finishes the process.
lab46:~$ sleep 10 echo hello lab46:~$ echo hello hello lab46:~$ sleep 10 echo hello ^Z [1]+ Stopped sleep 10 lab46:~$ bg [1]+ sleep 10 & lab46:~$ hi -bash: hi: command not found [1]+ Done sleep 10 lab46:~$ ps USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND cforman 4061 0.0 0.1 13632 2012 pts/28 SNs+ 22:27 0:00 -bash cforman 14217 0.0 0.0 13664 8 pts/17 SNs Oct13 0:00 /bin/bash cforman 14222 0.0 0.1 42684 2036 pts/17 SN+ Oct13 6:52 irssi cforman 18683 0.0 0.0 8584 964 pts/19 RN+ 23:44 0:00 ps u cforman 24154 0.0 0.1 13648 2016 pts/19 SNs 21:21 0:00 -bash lab46:~$
I stopped the sleep and echo commands and placed them in the background to run there. Using “ps” you can see that it is no longer running after it comes out of the background once it says done.
Foregrounding a process is the same as back grounding it. Just type “fg” and it comes back to the front of the actions you can perform.
lab46:~$ cat ^Z [1]+ Stopped cat lab46:~$ bg [1]+ cat & lab46:~$ adjf -bash: adjf: command not found [1]+ Stopped cat lab46:~$ adjfl -bash: adjfl: command not found lab46:~$ ajfldk -bash: ajfldk: command not found lab46:~$ fg cat helo helo
This has a lot to do with foregrounding and back grounding. Consider a program that will take quite a while and you want to do other things you can back ground it as seen in the key word back grounding and then do other stuff. Multitasking in UNIX is essential job control but working while a job is being controlled by the back ground.
Identification and definition of the chosen keyword. Substitute “keyword” with the actual keyword.
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$
I will look at a RegEx line and explain the results of it piece by piece to test my ability (not to data-mine) but to recognize the effects of RegEx's
I will examine a piece of code and tell what it is doing part by part.
cat spring2012-20111103.html| grep 'ddtitle'|sed 's/^<TH CLASS="ddtitle".*crn_in=.....">//g'|sed 's/<\/A/*$//g'|sed 's/^\(.*\) - \([0-9][0-9][0-9][0-9][0-9]\) - \(.*\) - \([0-9][0-9][0-9]\)$/\2:\3-\4:\1/g'|sort|less
ok so first things first. cat is reading the document spring 2012-20111103.html. grep is pulling out everything that has ddtitle and focusing on it. sed allows for pattern definition. sed is recognizing the exact phrase “<TH CLASS=“ddtitle”.*crn_in=…..”>“ which is a repeated pattern threw out. the ”…..“ each . represents a character. in this line there are different characters here but none are cared about so the pattern fits by putting the changing piece represented by periods. That line is then replaced by nothing. another sed locks onto the end of the line which is another pattern and it removes it all. the next said is different. instead of removing it describes the pattern by how it is exactly. This allows for sectors to be set up by the \ . the sectors are then rearranged and formatted in the way needed. the information is then sent to less and that is the end of the code.
Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.
Can I make a redstone-based ripple counter in Minecraft to light a torch or make a sound when it finishes counting from 0 to 16?
http://www.minecraftwiki.net/wiki/Redstone_Repeater - this site explains everything minecraft and more specifically minecraft redstone repeaters.
I believe i can make a redstone system that will count to 16 then activate a torch and or a sound box.
red stone repeaters allow for a stacking effect where they will send a signal down the line. this signal can be counted to create a counter or a special delay where it needs to run through the system enough times to activate the sound block.
I am going to build a redstone contraption that will function much like an actual program where it has a hardwired command and will run it until it is accomplished.
unfortunately i was not smart enough to solve it myself and the methods used to solve it do not function anymore on minecraft 1.0 here are links to two videos that explain how to do this in both binary and non- binary form. Results being i was unable to do this but someone was and it is possible. http://www.youtube.com/watch?v=81Janhiya-o http://www.youtube.com/watch?v=1O-DRgbD3ZI
Based on the data collected:
Red stone is a great learning tool for computers and fun to work with. it causes you to think outside the box and make applicable things to help you in minecraft just as it would in the real world.
Using ';'. can I run multiple commands on the same command-line?
none. I used basic knowledge from class.
I believe that i will be able to use multiple commands at the same time The ”;“ acts as a command separator which allows the user to act like he is on a new line.
i am going to enter it onto the command line and test it.
lab46:~$ wtf echo echo: echo (1) - display a line of text echo (3ncurses) - curses input options lab46:~$ echo "testfile";wtf echo testfile echo: echo (1) - display a line of text echo (3ncurses) - curses input options lab46:~$
Based on the data collected:
”;“ is a great way to string together commands when working on unix.
If you're doing an experiment instead of a retest, delete this section.
If you've opted to test the experiment of someone else, delete the experiment section and steps above; perform the following steps:
Whose existing experiment are you going to retest? Prove the URL, note the author, and restate their question.
Evaluate their resources and commentary. Answer the following questions:
State their experiment's hypothesis. Answer the following questions:
Follow the steps given to recreate the original experiment. Answer the following questions:
Publish the data you have gained from your performing of the experiment here.
Answer the following:
Answer the following: