User Tools

Site Tools


opus:fall2011:swilli31:part1

Part 1

Entries

September 15, 2011

Today in the class we played more with the VI Editor. We also did more with the control keys and learned of tab completion.

Things have finally really started to click for me in the class. Everything is mostly logic based and isn't some strange mythical thing that appears to do magic. This is significant because I am gaining valuable understanding and insight into the course. Some concepts that I am struggling with are some of the commands and the new things gone over in class today. With proper fiddling, I should, and will, be able to master this material. The challenges I am facing this week is the time to sit down and play with the Unix environment and VI editor.

September 20, 2011

Today we learned shell scripting in the class. I understood most of what we talked about. The few issues I have with shell scripting is knowing precisely what it is that I want to do and how I want to do it. I know that I can gain better knowledge and understanding as I become more familiar and comfortable with the Unix environment. I plan to try and practice more scripts in the coming weeks of my own accord.

September 27, 2011

Today in class we wrote a shell script to convert a decimal number into a binary number. This is very relevant to me because of the topics covered in other classes. In two of my other classes we have been driving at converting decimal to binary. I am capable of converting these numbers by hand but was not to confident about a program. One class in particular asked students to write pseudocode for this process.

This is relevant not only to this class but all classes as it bridged all of them together and showed the relevance of the material. This is especially relevant to this class because we used shell scripting and delved deeper into the syntax and how bash operates as well as learned the program bc.

September 30, 2011

As we end September, some valuable commands were learned during classes and through investigations of my own. I learned that I can copy files and directories into my home directory and sub-directories. I also started the filesystem safari project to learn more about the directories and different file types in Unix. We also did shell scripting and made bots.

This is all relevant to the course due to the learning that has taken place over the month. All things that we have learned will be built upon in the coming weeks. Without these fundamental basics, the coming weeks will most likely be even more difficult than necessary.

Topics

Home directory

The home directory is where all of your specific files and data is located. Anything that the user has created will be saved here. Everything that the user created can be accessed from here. It is the default directory you sign into.

lab46:~$ pwd
lab46:~$ /home/swilli31

Listing

This is a function that can be typed into the command prompt that will show what is located in a directory

lab46:~$ ls
lab46:~$ **Maildir** bin closet **data** public_html src src.bak

Note: The starred directories are symbolic link directories

Current Working Directory

This is the directory that you are located in. Whatever is located in that directory is accessible.

The command prompt will show what directory you are currently working in. The “~” sign after lab46: shows you are in the home directory.

lab46:~$ pwd
 /home/swilli31

This shows I'm in my home directory.

lab46:~$ cd ..
lab46:/home$ pwd
/home

This shows I'm outside my home directory.

lab46:~$ cd ..
lab46:/home$ pwd
/

This shows I'm in the / directory.

Killing a process

this is when you terminate a command using the kill command. kill -9 is the ultimate kill signal

lab46:~$ kill -1 process

Permissions

This sets the parameters for who can read, write, or execute a file or directory that has been created. The permission blocks are split into three categories: user, group, and world. Each block can be given separate permissions.

lab46~/closet$: ls -l
total 12
-rw------- 1 swilli31 lab46 117 Sep 6 16:20 cake
-rw-r--r-- 1 swilli31 lab46 73 Sep 13 15:57 limerick
-rw------- 1 swilli31 lab46 53 Sep 8 16:16 skeleton  

The -rw——- is the permission block for cake and skeleton which is readable and writable by me only. limerick has a permission block which can be read by the group and by the world but can only be written by me.

The VI Editor

This is a moded text editor. It can be used to write shell scripts and other comments and notes and the like.

lab46:~$ vi

This will take the user into the vi environment.

Regular file

A regular file is any type of file that you would expect to see. These are similar to files that maybe created in a GUI system. In the Unix environment they appear gray in color and can be read.

lab46:~$ nano cake

This will bring up another text editor to edit this file

Directory

This is another type of file that has other file located within. They are the storage places of various files and also other directories. Directories are also the work spaces the user works from. They are usually dark blue or cyan in color.

lab46:~$ cd src
lab46:~/src$ gcc -o hello hello.c
lab46:~/src$ ./hello
Hello, World!
lab46:~/src$ 

This demonstrates a program executed from the src directory.

Special file

These are files of things that one would not usually consider a file. They are more like things than an actual file. Special files can be yellow in color or purple. Yellow files are device files and purple files are sockets.

lab46:~$ cd /dev
lab46:/dev$

This directory contains most of the device files that are useful for exploring Unix.

Tab Completion

This is a type of shortcut to bring up files and directories or previous commands without typing the whole word. It can come in handy when you can't remember the entire name you are looking for.

lab46:~$ touch iamthewalrusandyouareallmonkeys
lab46:~$ cat iam (press TAB) thewalrusandyouareallmonkeys
lab46:~$ 

Ownership

This tells the user who wons files in that directory.

lab46:~/closet$ ls -l
total 12
-rw------- 1 swilli31 lab46 117 Sep 6 16:20 cake
-rw-r--r-- 1 swilli31 lab46 73 Sep 13 15:57 limerick
-rw------- 1 swilli31 lab46 53 Sep 8 16:16 skeleton
lab46:~/closet$ 

The third column shows that swilli31 is the owner of these files

Removing a file

If the user no longer wants to have a certain file in their directory, than can choose to remove that file. In other words, erase the file from existence.

lab46:~$ rm iamthewlrusandyouareallmonkeys
rm: remove regular empty file `iamthewalrusandyouareallmonkeys`? yes
lab46:~$ 

If you run ls again the file is no longer there.

Objectives

Objective 1

Become familiar with Unix Environment

Method

Look up manual pages in Unix environment and try some things. Read various books about Unix. Do filesystem safari project

Measurement

I followed my method and now have a better feel for the Unix environment. I can now look at information output screen and understand what they are saying more comfortably. I can also navigate commands with relative ease. It is just a matter of memory.

Analysis

I did fairly well at achieving my goal. There is still much room for improvement. I need to practice the commands a little more so that I have them committed to memory where it is all second nature.The measurement process could be enhanced by setting specifics of things that I want to become better at in the Unix environment. It would be effective to employ as I would be able to focus on something and once mastered move on the the next thing on my list to fully understand. The objective could also be altered to reflect this method by breaking the main Unix environment into smaller subsets to make it easier to understand and learn.

Experiments

Experiment 1

Question

What will happen if I input a negative number into the number conversion script we wrote in class?

Resources

A negative binary number is expressed as having a leading bit value of 1. This I learned in Computer essentials.

Hypothesis

The program will not return a value.

Rationale: The program wasn't written with negative numbers in mind.

Experiment

I will test my hypothesis by picking a negative number and entering it into the program.

Data

I input the number -42 into the script. When enter was pressed, nothing happened. I then tried -23 and got the same result. I had to use ctrl-c to exit. I then input a positive number, 33, to verify the program was still working and received an answer of 100001.

Analysis

Based on the data collected:

My hypothesis was correct. The value 100001 in binary is not necessarily a negative number as would be indicated by resources.

Conclusions

I have found that the program is only valid for a positive integer entered at the prompt. The program may be modified to calculate a negative binary number if not for the rule that there are no negative signs and therefore no negative numbers in binary. Some form of two's compliment may be integrated into script to fix this problem.

Experiment 2

Question

Will I be able to copy the games into a directory under my personal home directory?

Resources

I read the section on copying files from the book Learning the Unix Operating System.

Hypothesis

I will be able to create a symbolic link to the games in a directory in my home directory.

Rationale: I have permissions to these files

Experiment

I will test my hypothesis by using the cp -R command to copy the directory games into my home directory

Data

I was able to copy the games directory into my home directory while still maintaining the original copy in its original location under the /usr directory.

Analysis

Based on the data collected:

My hypothesis was almost correct. Instead of a symbolic link I was able to just copy the entire directory into my home directory.

Conclusions

Based on this experiment, I can conclude that, so long as I have permission, I can copy an existing file into one of my own directories. This does also include full directory trees.

Experiment 3

Question

Can you make ls list programs in chronological order?

Resources

The manual page for ls will be useful.

Hypothesis

I will be able to list programs and files chronologically.

Rationale: ls is a listing file and you should be able to say how you would like your list to be formed.

Experiment

I will look up the man page and then type the proper commands to do what I want.

Data

I first typed the ls command to get an alphabetical list of directories and files. I then looked up the man page and found the commands –sort=time and –time=atime. I tried both of these and the –time=atime provided my files in the order I most recently accessed.

Analysis

Based on the data collected:

My hypothesis was correct; I was able to list the most recently accessed or modified files. The ls program was simply taking the time and date of the long function and sorting them by that parameter.

Conclusions

This argument to ls can be very useful if looking for a file that was recently modified and you weren't sure of the name. It can also be useful in looking up something someone else on the system may have modified and you need information from that file.

opus/fall2011/swilli31/part1.txt · Last modified: 2011/10/01 03:08 by swilli31