User Tools

Site Tools


opus:fall2011:qclark:part1

Part 1

Entries

September 13, 2011

On this day i had experienced more of what one might call a simple text editor. But this text editor was not your ordinary text editor you see. This text editor was greater then your common text editors such as Microsoft Word. I can see but what i have said that you are in pure disbelief. But what i say is true. Behold, VI! The vi text editor is one of the greatest tools in the known and Linux/Unix universe. There are many commands to this text editor, but if you practice these commands you will be able to harness the skills of VI. I look forward to learning this. VI will be just so much more helpful and quicker than Microsoft Word. I WON'T HAVE TO USE THE MOUSE!!! But like i said before i have to practice the commands before i can become a master like the Great Haas.

September 15, 2011

Today in Unix/Linux we learned about process id's (PID). They are basically a small id for any process that happens to be running. So anything you are doing at that moment has a PID. With that you can go in and maniupulate it in some way. Thats when we learned the kill commands. We take the PID of the process we want to kill and we just kill it with a any kill command that we want. There are numerous kill command options but 'kill -9' is the deadliest of them all. It's basically the equivalent of dropping a NUCLEAR WARHEAD on the command you do not want existing anymore. We also learned that there is such thing as zombies in the UNIX/Linux universe (not to say that there aren't zombies in the human plane of existence.) Expected zombies we can take care of but an unexpected zombie is something we do not want period. So we learned how to make expected zombies, find processes with any specifics and a little more on the VI editor.

September 22, 2011

In linux today we learned shell scripting. You basically run the system from the outside instead of the inside. We wrote some simple scripts, for example one will ask for our name and say a message. Then another one asks for a password. Either the password was in the script or it called another file with the password we wanted. We learned what we needed to do, what means what like # stands for a comment. #! this is a shhh bang! And we made them executable with a new way of changing permissions. He gave us one more program which took any files in a directory and got rid of any extensions and made them all just regular files, no extensions.

September 20, 2011

Today we worked on our first project called FILESYSTEM SAFARI. Haas pretty much put this in our projects so that we could get started on them because everybody is lazy in the class (guilty). Any-who, the project is still underway, it isn't too hard but it is cumbersome. It's taking a bit of time to finish it.

Unix Topics

Localhost

Localhost is the standard hostname given to the address of the loopback network interface. The name is also a reserved top-level domain name set aside to avoid confusion with the narrower definition as a hostname.

Home directory

A Home directory is a file system directory on a multi-user operating system containing files for a given user of the system.

Regular File

A Regular File is the simplest of files being a read only file.

Directory

The Directory is the most common special file. The layout of a directory file is defined by the filesystem used. As several filesystems, both native and non-native, are available under Unix, there is not one directory file layout. Within a directory you can store many files or other directories.

Special File

A Special File cannot be regularly accessed through basic means. It has to be opened with a certain command. Some special files include Socket Files and Device Files.

File Listing

File Listing can be carried out by the ls command. If there you want to find out more about the ls command you can look up its arguments in its manual pages.

lab46:~$ ls
Desktop    age.sh        burninator.c        hello.c            public_html
Documents  archive1.tar  closet              hello.s            shell
Downloads  archive2.zip  data                lab1.text          src
Maildir    archives      extravagentpiranha  list-basedloop.sh  tmp
Music      ascii         file.txt            motd               trog3
Pictures   badname       filecreat.sh        numericloop.sh     trog3.c
Public     badname.tar   guess1.sh           password           unix.text
Templates  bin           hellisharmadillo    prog2
Videos     burninator    hello               prog2.c

Copying Files

Copying Files is carried out by the cp command. However, in order to fully copy a file to a new area you have to type the file you want and then type the area you want it to reside in.

lab46:~$ cp burninator bin
lab46:~$

Creating

Creating a file requires the touch command. When you touch a file that you have just named it creates it in the current directory you are in.

lab46:~$ touch file1
lab46:~$

Removing

Removing a file requires the rm command. When you type rm make sure you type the file you want removed and that you are in the directory in which it is located. After that you will be prompted with a question for removing the file because Unix cares.

lab46:~$ rm file1
rm: remove regular empty file `file1'? y
lab46:~$

Permissions

There are 3 different Permissions for files:

  • Read - which allows the user to “read” the file
  • Write - which allows the user to type on the file whatever pleases them
  • Execute - which allows the user to run the file

Of course these permissions can be turned on/off for each class by the user who created the file in the first place. These permissions are indicated by 'r' for Read, 'w' for Write, and 'x' for Execute.

-rwxr--r-- 1 qclark lab46   202 Sep 27 14:33 extravagentpiranha
-rw-r--r-- 1 qclark lab46    52 Mar 25  2011 file.txt
-rwx------ 1 qclark lab46   201 Apr 29 16:50 filecreat.sh
-rwx------ 1 qclark lab46  1019 Apr 25 17:53 guess1.sh
-rwxr--r-- 1 qclark lab46   365 Sep 27 16:41 hellisharmadillo
-rwxr-xr-x 1 qclark lab46  6625 Oct 12  2010 hello

Tab Completion

Tab Completion is a handy little trick if you feel lazy and don't feel like writing out you entire file. Just type the first few letters of the file and hit TAB, your file should appear automatically.

Moving

Moving a file requires the mv command. Type this command, then the file that you want moved, and then the location of where you want it move to.

lab46:~$ mv extravagentpiranha bin
lab46:~$
lab46:~$ cd bin
lab46:~/bin$ ls
bin  burninator  corpseshark  extravagentpiranha  lethalbadger  whitetiger

Objectives

Familiarity with the structure of UNIX systems

Familiarity with the structure of UNIX systems; what this objective entails is to have an understanding of things that correlate with the UNIX/Linux system.

Method

One can demonstrate a basic knowledge and understanding of the UNIX system.

Measurement

A measurement can consist of the topics and experiments that i have performed above.

Analysis

Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.

  • How did you do? - I believe it did this to the best of my ability.
  • Room for improvement? - There is definitely a whole lot of room for improvement.
  • Could the measurement process be enhanced to be more effective? - Yes. I believe i may have the basis of the measurement secured but other things could be added in as well.
  • Do you think this enhancement would be efficient to employ? - Yes. In fact i think it would be more efficient.
  • Could the course objective be altered to be more applicable? - No I don't believe so.

Experiments

Experiment 1

Question

#!/bin/bash
cd ~/tmp
for file in `/bin/ls -1A ~/tmp`;do
        fname="`echo $file | cut -d'.' -f1`"
        mv -v $file $fname
done
exit 0

Is it possible to replace the -f1 with a -f2 and get that field instead?

Resources

My brain, curiosity, Matt Haas

Hypothesis

I believe that if i change the f1 to an f2 then it will show me the field that occurs after the '.'

Experiment

To test my hypothesis I shall replace f1 with f2.

Data

#!/bin/bash
cd ~/tmp
for file in `/bin/ls -1A ~/tmp`;do
        fname="`echo $file | cut -d'.' -f2`"
        mv -v $file $fname
done
exit 0
lab46:~/bin$ ./corpseshark
mv: `chimera' and `chimera' are the same file
`derp.ent' -> `ent'
mv: `dragon' and `dragon' are the same file
mv: `filealpha' and `filealpha' are the same file
mv: `filebeta' and `filebeta' are the same file
mv: `griffin' and `griffin' are the same file
`herp.txt' -> `txt'
mv: `kraken' and `kraken' are the same file
mv: `scorpion' and `scorpion' are the same file
mv: `spider' and `spider' are the same file

Analysis

Based on the data collected:

My hypothesis was correct!

Conclusions

In conclusion, with how many delimiters you have in the file you can choose and whatever comes before it or after are the fields. You can change the field you want by choosing the number that corresponds to where the field is.

Experiment 2

Question

Is it possible to do the same experiment above but instead taking more then one field out?

Resources

My brain, curiosity and Matt Haas

Hypothesis

I believe that replacing the single number with a number-number, for instance 5-7, will take out those fields.

Experiment

I am going to replace the current field with 5-7 and perform this action in the lab46 terminal.

Data

#!/bin/bash
cd ~/tmp
for file in `/bin/ls -1A ~/tmp`;do
        fname="`echo $file | cut -d'.' -f5-7`"
        mv -v $file $fname
done
exit 0
lab46:~/bin$ ./corpseshark
`file.herp.derp.nyan.cat.fyi.uti.txt.blops.fable.gears' -> `cat.fyi.uti'

Analysis

Based on the data collected:

It works!

Conclusions

This conclusion is basically the same premise as the previous experiment. The only difference here is that you can take out multiple sections of fields.

Experiment 3

Question

Is it possible to only take out the exact fields you want out, even if they may be a few fields apart?

Resources

My brain and curiosity

Hypothesis

I believe that i can take out only the fields i want by using 'commas'.

Experiment

I'm going to type in the necessary actions in order to carry out my hypothesis.

Data

#!/bin/bash
cd ~/tmp
for file in `/bin/ls -1A ~/tmp`;do
        fname="`echo $file | cut -d'.' -f1,3,6,8,9`"
        mv -v $file $fname
done
exit 0
lab46:~/bin$ ./corpseshark
`file.herp.derp.nyan.cat.fyi.uti.txt.blops.fable.gears' -> `file.derp.fyi.txt.blops'

Analysis

Based on the data collected:

It worked!

Conclusions

In conclusion we can take out any field we want as long as we know the actions to take them out. Otherwise it will yell at you

opus/fall2011/qclark/part1.txt · Last modified: 2011/10/27 20:20 by qclark