User Tools

Site Tools


opus:fall2012:ks010285:part3

Part 3

Entries

Entry 1: November 2, 2012

Today we experimented with running something on one system but displaying it on another system. We did this by using variations of the xterm command. For example we ran xeyes, on our own terminal but would send the output to a different terminal with the following command line:

lab46:~$ xeyes -display flake01.2

When you run a process like this in the foreground, you cannot work on anything else until you Ctrl C out of the process. However, there is an option to run processes in the background. If you use the & at the end of a command line, this will put the process in the background so that you can work on other items.

lab46:~$ xeyes -display flake01.2 &

It is important to remember, that you can't Ctrl C out of a a process that is running in the background. You have to kill the process in the command line.

lab46:~$ kill xeyes

Entry 2: November 09, 2012

Today we discussed the tail and head commands. The tail command allows you to grab the last lines of a file or a previous command output. The default number of lines that the tail command grabs is ten, however you can specify how many of the end lines you want to grab by adding -n to the tail command.

Example

 lab46:~$ last | cat -n | tail -5
   906	lalexan3 pts/33       10.100.60.118    Thu Nov  1 11:03 - 12:06  (01:03)    
   907	jpettie  pts/29       rrcs-184-74-43-2 Thu Nov  1 09:59 - 12:21  (02:21)    
   908	wedge    pts/19       10.80.81.2       Thu Nov  1 07:22 - 11:10  (03:47)    
   909	
   910	wtmp begins Thu Nov  1 07:22:52 2012 

The head command does just the opposite. It grabs the first lines.

Example

 lab46:~$ last | cat -n | head -5
     1	csimon1  pts/83       grrasp.offbyone. Wed Nov 14 15:46   still logged in   
     2	wedge    pts/79       grrasp.offbyone. Wed Nov 14 15:42   still logged in   
     3	jcavalu3 pts/77       caprisun.offbyon Wed Nov 14 15:39   still logged in   
     4	dsherbur pts/33       grrasp.offbyone. Wed Nov 14 15:37   still logged in   
     5	wedge    pts/76       grrasp.offbyone. Wed Nov 14 15:36   still logged in 

As seen above, the cat -n command, numbers the lines of output. This is extremely useful in order to search and grab lines.

We were also given a list of other helpful commands to look up and research.

  1. paste
  2. comm
  3. diff : compares files line by line and can create a patch
  4. join : concatenate file
  5. patch : can apply the patch created by diff to a file
  6. sort:
  7. uniq:

Entry 3: November 16, 2012

Today we discussed networking, with networking being defined as communication among devices between a common medium using common protocols.

  1. Standard: The way things should be done (Ex. OSI)
  2. Protocol : Set of Rules or the actual instantiation of a process. (Ex. TCP / IP)
    1. Actual: TCP / IP
    2. Layers: Distinct Protocols
      1. Application
      2. Transport
      3. Networking
      4. Data Link

A computer needs consistency and therefore needs to adhere to protocols.

Every computer on a network has a unique IP address.

Example: 10.80.2.83

  1. The first number defines wether or not the address is accessible over the internet (public) or not (private). Private IP's tend to start with 10, 172, 127, or 192.
  2. The second number is a location number (i.e.. lair, campus)
  3. The third number is a subnet for organizing resources (admin, project, general project)
  4. The last number is the unique node # of the computer.

Entry 4: November 30, 2012

With this being the last official class for November, I leave this class with just the final project left to accomplish. I definitely feel like I have gained a vast amount of information about the Unix system. I feel that I am well equipped to continue experimenting with the Unix system, however there are still some areas in which I struggle. I tend to make things more complicated then they are, so with the simplistic philosophy of the Unix system, I feel that there must be more efficient ways to accomplish tasks then the way that I am trying to do them. I still need to learn the most simplistic ways to combine commands in order to accomplish a task. I guess with time and practice, I will get the hang of it.

Keywords

unix Keyword 3

Tail

Definition

The tail command allows you to grab the last line(s) from the output of a previous command or from a file. Unless you specify the number of lines that you would like the command to grab, it will default to return the last ten lines. In order to specify the the number of lines, add -# (# being the actual number if lines you want to grab) to the command.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • Professor Haas, In class discussion - 11-9-12.

unix Keyword 3 Phase 2

mesg/write/wall

Definition

Definition (in your own words) of the chosen keyword.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • Reference 1
  • Reference 2
  • Reference 3

Demonstration

Demonstration of mesg

To check current mesg access on terminal:

lab46:~$ mesg
is n

To turn mesg access on and check that it is turned on:

lab46:~$ mesg y
lab46:~$ mesg
is y

To turn mesg access off and check that it is turned off:

lab46:~$ mesg n
lab46:~$ mesg
is n

Demonstration of write

I opened two terminals for this demonstration. One at pts/49 and the other at pts/63.

From my terminal on pts/63

lab46:~$ write ks010285 pts/49
HI Kate on pts 49, this is just a test to show how the write command works! Pretty neat. I will hit the CTRL and D character after this line in order to get the EOF symbol. -o
lab46:~$ 

On the pts/49 terminal, I received this message:

Message from ks010285@lab46 on pts/63 at 14:52 ...
HI Kate on pts 49, this is just a test to show how the write command works! Pretty neat. I will hit the CTRL and D character after this line in order to get the EOF symbol. -o
EOF

Demonstration of wall

lab46:~$ wall testwall
-bash: /usr/bin/wall: Permission denied

Experiment 3

Question

How does the tail command with the -f option work?

Resources

Unix Man Page : The -f option allows you to follow a file and receive updated output as the file gets bigger.

Harley Hahn's Guide to Unix and Linux: You can use the -f option of tail either in the foreground or background. If you run in the foreground, you cannot enter anymore commands in the command line until the tail command is halted. An option here is to run the tail command in the foreground of a separate terminal window and Ctrl C when you wish to end the command. If you run in the background with the &… you can monitor a growing file while you work on something else. You have to use the kill command to end the tail process.

Hypothesis

Based on what I have read, the tail -f command monitors a file for changes in the number of lines in the file, and outputs changes as lines are added to a file, therefore, I believe that when I run the command on a file that I create for monitoring, it will initially spit out the last lines of the file. When I update the file, it will display the new lines that I add to the file.

Experiment

How are you going to test your hypothesis? What is the structure of your experiment?

  • - I am going to open two terminal screens.
  • - In the first terminal window, I will create a file named lastExp, and enter information into that file
lab46:~$ cat > finalExp
  • - In the second terminal window, I will run the tail -f command on the lastExp.
lab46:~$ tail -f lastExp
  * I will then update the lastExp file in the first terminal window, and watch the second terminal window for updates. 
  * When I have finished updating the lastExp file, I will Ctrl D out of the first terminal window, and Ctrl C to end the tail -f process in the second terminal window. 

Data

First terminal session

lab46:~$ cat > finalExp
This is just a test file to test the tail -f command and follow option. 
I will be running the tail -f command in the foreground, so I will have two terminal windows open.
I hope that this works the way I am hoping. 
lab46:~$ cat >> finalExp
Okay, now I am adding additional lines to my file. Hopefully this line will appear on the other terminal screen. 
It worked!
Everything that I am typinng on this screen is appearing on the other terminal screen!
Yes!
Experiment Completed for tonight!
^D

Second terminal session

lab46:~$ tail -f finalExp
This is just a test file to test the tail -f command and follow option. 
I will be running the tail -f command in the foreground, so I will have two terminal windows open.
I hope that this works the way I am hoping. 
Okay, now I am adding additional lines to my file. Hopefully this line will appear on the other terminal screen. 
It worked!
Everything that I am typinng on this screen is appearing on the other terminal screen!
Yes!
Experiment Completed for tonight!
^C

Analysis

Based on the data collected:

  • My hypothesis was correct! The lines that were being added to the file in the first terminal session were updated in the second terminal session with the tail -f command/option.

Conclusions

The tail -f option could be a useful tool for monitoring logins and updates to files. However, as it appears to only give additional lines to a file, it would only be useful for monitoring appends or additions to files, and not for monitoring internal changes to existing information.

opus/fall2012/ks010285/part3.txt · Last modified: 2012/11/30 16:32 by ks010285