User Tools

Site Tools


opus:spring2012:skinney1:unixpart3

unix Keywords

  1. Source Code, Object Code, Binary Code, Library (done)
  2. Pattern Matching(done)
  3. Regular Expressions(done)
  4. Filtering(done)
  5. Shell Scripting(done)
  6. networking, UNIX Networking Tools(done)
  7. Security(done)
  8. X Window System(done)

unix Keyword 17

Source Code, Object Code, Binary Code, Library

Definition

The source code for a program is the raw, un-processed by the compiler, file. Written in a programming language and used to further develop the software. The object code is produced by the compiler. It is generally a sequence of instruction that is used within the running the code. The Binary code is the machine language that is the final output of the compiler. This is actually was produces the desired results by the source code. The Library is the standard set or characters used in the correct syntax to tell the compiler what is needed to do.

Demonstration

Source Code example

#include<stdio.h>

int main()
{
 printf("yo dude");

return(0);
}

unix Keyword 18

Pattern Matching

Definition

Pattern matching is using the syntax of search programs to find conditions that meet the requested quarry. The most commonly used program for searching is the grep command. Taken from the man pages, Grep is defines as, “Grep searches the named input FILEs (or standard input if no files are named, or the file name - is given) for lines containing a match to the given PATTERN”.

Demonstration

Syntax for grep

grep 'word' filename
grep 'string1 string2'  filename
cat otherfile | grep 'something'
command | grep 'something'
command option1 | grep 'data'
grep --color 'data' fileName

Example taken from another source

grep -v bash /etc/passwd | grep -v nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
news:x:9:13:news:/var/spool/news:
mailnull:x:47:47::/var/spool/mqueue:/dev/null
xfs:x:43:43:X Font Server:/etc/X11/fs:/bin/false
rpc:x:32:32:Portmapper RPC user:/:/bin/false
nscd:x:28:28:NSCD Daemon:/:/bin/false
named:x:25:25:Named:/var/named:/bin/false
squid:x:23:23::/var/spool/squid:/dev/null
ldap:x:55:55:LDAP User:/var/lib/ldap:/bin/false
apache:x:48:48:Apache:/var/www:/bin/false

unix Keyword 19

Regular Expressions

Definition

The term regular expressions is speaking about a set of characters that make up the words of patterns of a search. These are used when looking for specific strings of text that match the quarry. This is very much like the explained grep command earlier but focuses us into the actual, expression, wording used.

Demonstration

For example

grep -i man heroes.txt

We are searching for any string that meets the expression “man” in the text file “heroes.txt”. The output is the following.

Catwoman
Batman
Spider Man
Wonder Woman
Ant Man
Aquaman
Martian Manhunter

unix Keyword 20

Filtering

Definition

In Unix a filter is a way of using commands and pipes command that can manipulate the output of file. Two of the most powerful and popular Unix filters are the sed and awk commands.

Demonstration

The “sed” command allows us to look search a file and replace characters. For example in the following junk file. I have call cat to present the contents of the file. I then use a pipe to link in the sed command. Sed then looks as what is being outputted by cat and finds anything that is an “e” and replaces it with “E”.

$ cat junk.txt | sed -e "s/e/E/"
corE
worm sEed
jEwel

unix Keyword 21

Shell Scripting

Definition

Shell scripting is a way that you can automate routine tasks. It allows the user more flexibility and control over the operation of the system.

Demonstration

Following example from the SSH manual. You can see by this example, that the more complex shell scripts take on the look and feel of the C programming language. We have presented a list and are going to work through the list.

#!/bin/sh
fruitlist="Apple Pear Tomato Peach Grape"
for fruit in $fruitlist
do
   if [ "$fruit" = "Tomato" ] || [ "$fruit" = "Peach" ]
   then
      echo "I like ${fruit}es"
   else 
      echo "I like ${fruit}s"
   fi
done

Output of the script

I like Apples
I like Pears
I like Tomatoes 
I like Peachs
I like Grapes

Resource: https://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/unixscripting/unixscripting.html

unix Keyword 22

networking, UNIX Networking Tools

Definition

I love networking.. and there are many flexible tools with unix. Networking is the communication between computers. It is bringing those computers together to share resources, make work groups or just set up a game of QuakeIII.

Some common commands

  • finding host/domain name and IP address - hostname
  • test network connection – ping
  • getting network configuration – ifconfig
  • Network connections, routing tables, interface statistics – netstat
  • query DNS lookup name – nslookup
  • communicate with other hostname – telnet
  • outing steps that packets take to get to network host – traceroute
  • view user information – finger
  • checking status of destination host - telnet

Demonstration

Examples from the lab46 side

ab46:~$ hostname
lab46
lab46:~$ ifconfig
-bash: ifconfig: command not found
lab46:~$ nslookup
-bash: nslookup: command not found
lab46:~$ telnet
telnet> lab46:~$
lab46:~$ finger
Login     Name              Tty      Idle  Login Time   Office     Office Phone
jdavis34  Joshua Davis      pts/22     1d  Mar  6 12:57 (cpe-67-252-69-1:S.0)
jdavis34  Joshua Davis      pts/88     5d  Mar 29 16:18 (cpe-67-252-69-1:S.3)
jjohns43  Jeffrey Johnson   pts/24    18d  Jan 23 12:18 (cpe-74-65-82-173:S.0)
jjohns43  Jeffrey Johnson   pts/82    18d  Feb 27 11:03 (cpe-74-65-82-173:S.0)
jpettie   Jacob Pettie      pts/5          Mar  8 18:05 (pool-96-247-148-158:S.0)
jpettie   Jacob Pettie      pts/31    46d  Mar  6 14:35 (pool-96-247-148-158:S.1)
jpettie   Jacob Pettie      pts/35     5d  Mar 20 14:43 (pool-96-247-148-158:S.8)
jpettie   Jacob Pettie      pts/44    38d  Mar  6 16:39 (pool-96-247-148-158:S.3)
jpettie   Jacob Pettie      pts/77    47d  Mar 13 11:22 (pool-96-247-148-158:S.4)
jpettie   Jacob Pettie      pts/75    56d  Mar  6 15:17 (pool-96-247-148-158:S.2)
jpettie   Jacob Pettie      pts/95   1:31  Mar  8 11:00 (pool-96-247-148-158:S.7)
jpettie   Jacob Pettie      pts/91    40d  Mar  8 10:58 (pool-96-247-148-158:S.5)
jpettie   Jacob Pettie      pts/92    40d  Mar  8 10:59 (pool-96-247-148-158:S.6)
mfaucet2  Mason Faucett     pts/65   1:06  Mar 22 13:17 (172:S.0)
skinney1  Shane Kinney      pts/55         May  1 11:54 (65-124-85-125.dia.static.qwest.net)
squirrel  Pressly Dowler    pts/8     12d  Apr 19 22:53 (softscope.lair.lan)
tgalpin2  Tyler Galpin      pts/12     11  Jan 30 21:25 (:pts/72:S.0)
tgalpin2  Tyler Galpin     *pts/72     11  May  2 11:06 (172.16.192.234)
thakes3   Thomas Hakes      pts/41     2d  Apr 27 22:48 (172.16.198.198:S.0)
thakes3   Thomas Hakes      pts/62      2  May  2 10:43 (172.16.198.198:S.2)
thakes3   Thomas Hakes      pts/68     17  May  2 10:44 (172.16.198.198:S.3)
thakes3   Thomas Hakes      pts/2       3  Apr 30 11:36 (172.16.198.198:S.1)
wedge     Matthew Haas     *pts/14      1  May  2 08:49 (telstar.lair.lan)
lab46:~$ finger wedge
Login: wedge                            Name: Matthew Haas
Directory: /home/wedge                  Shell: /bin/bash
On since Wed May  2 08:49 (EDT) on pts/14 from telstar.lair.lan
   1 minute 34 seconds idle
     (messages off)
Mail last read Wed May  2 09:49 2012 (EDT)
Plan:
----------------------------------------------------------------------------
 Lab46 System Administrator

FYI, that is a pointing finger.. not the one that goes up but strait out… lol

unix Keyword 23

Security

Definition

Security on a Unix system comes from a few areas of concentration. Using permissions for users and groups is one way to keep key areas of the system out of the reach of unwanted side effects. Another way is to use smart passwords. Insuring that passwords are change every 3 months, are unique and have both alpha and numeric elements. When it comes to a Unix server patching is the most frequently used method. Finding exploits and deploying methods to fix the seen threat. Other best practices are firewalls, iptables, white/black lists etc.

Demonstration

Use of the lsof commands that shows a list of open files and what or who opened them.

lab46:~$ lsof | less
COMMAND     PID       USER   FD      TYPE  DEVICE SIZE/OFF     NODE NAME
init          1       root  cwd   unknown                           /proc/1/cwd (readlink: Permission denied)
init          1       root  rtd   unknown                           /proc/1/root (readlink: Permission denied)
init          1       root  txt   unknown                           /proc/1/exe (readlink: Permission denied)
init          1       root NOFD                                     /proc/1/fd (opendir: Permission denied)
kthreadd      2       root  cwd   unknown                           /proc/2/cwd (readlink: Permission denied)
kthreadd      2       root  rtd   unknown                           /proc/2/root (readlink: Permission denied)
kthreadd      2       root  txt   unknown                           /proc/2/exe (readlink: Permission denied)
kthreadd      2       root NOFD                                     /proc/2/fd (opendir: Permission denied)
migration     3       root  cwd   unknown                           /proc/3/cwd (readlink: Permission denied)
migration     3       root  rtd   unknown                           /proc/3/root (readlink: Permission denied)
migration     3       root  txt   unknown                           /proc/3/exe (readlink: Permission denied)

Use of the netstat command showing current connected protocols and their state.

lab46:~$ netstat -a
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 *:ssh                   *:*                     LISTEN
tcp        0      0 *:35801                 *:*                     LISTEN
tcp        0      0 *:nfs                   *:*                     LISTEN
tcp        0      0 *:3939                  *:*                     LISTEN
tcp        0      0 *:3333                  *:*                     LISTEN
tcp        0      0 lab46.offbyone.lan:5000 *:*                     LISTEN
tcp        0      0 lab46.offbyone.lan:5007 *:*                     LISTEN
tcp        0      0 *:59343                 *:*                     LISTEN
tcp        0      0 *:sunrpc                *:*                     LISTEN
tcp        0      0 *:csync2                *:*                     LISTEN
tcp        0      0 lab46.offbyone.lan:4242 *:*                     LISTEN
tcp        0      0 lab46.offbyone.la:60002 irc.offbyone.lan:ircd   ESTABLISHED
tcp        0      0 lab46.offbyone.la:41572 auth1.offbyone.lan:ldap ESTABLISHED
tcp        0      0 lab46.offbyone.la:47089 irc.offbyone.lan:ircd   ESTABLISHED
tcp        0      0 lab46.offbyone.la:47998 irc.offbyone.lan:ircd   ESTABLISHED
tcp        0      0 lab46.offbyone.la:42140 auth1.offbyone.lan:ldap ESTABLISHED

unix Keyword 24

X Window System

Definition

The X Window System, X11, is the basic graphical user interface (GUI). X11 sits between the computer and the user acting like a translator. Taking the input from the user in the form of the mouse and keyboard and translating it to changes within the system.

Demonstration

Example of a GUI

unix Objective

unix Objective

Utilize the ntpq command

Definition

The ntpq command is a utility program that monitors the NTP deamon, ntpd. NTPQ stands for Network Time Protocol Query. It runs and interactive mode by using the command line and can write variables. “Ntpq uses NTP mode 6 packets to communicate with the NTP server, and hence can be used to query any compatible server on the network which permits it”, Man pages.

Method

Research, discover and implement.

Measurement

The ntpq command give and output requesting arguments.

lab46:~$ ntpq
ntpq>

Check to make sure that the deamon is monitor is running. The following pgrep will feed back the process code ot ntpq.

lab46:~$ pgrep ntpd
961

The -p arguments shows the servers and their sink…

lab46:~$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*juicebox.lair.l 116.204.3.124    2 u  385 1024  377    0.742   -0.054   4.615
 caprisun.offbyo .STEP.          16 u    - 1024    0    0.000    0.000   0.000

Analysis

Well… nothing really amazing with ntpq. I did find out a fun new command so mission done.

Resource List

unix Retest

Retest 7

Perform the following steps:

State Experiment

I am going to reinact the double connection by thakes.

http://lab46.corning-cc.edu/opus/spring2012/thakes3/start#experiment_4

Resources

Evaluate their resources and commentary. Answer the following questions:

  • Do you feel the given resources are adequate in providing sufficient background information?
  • This experiment is not heavy in the research need. Knowledge of ssh is all that is needed.
  • Are there additional resources you've found that you can add to the resources list?
  • The man pages and wiki
  • Does the original experimenter appear to have obtained a necessary fundamental understanding of the concepts leading
  • yes
  • If you find a deviation in opinion, state why you think this might exist.
  • none found

Hypothesis

State their experiment's hypothesis. Answer the following questions:

  • Do you feel their hypothesis is adequate in capturing the essence of what they're trying to discover?
  • yes it stated the needed direction and walked through the goal
  • What improvements could you make to their hypothesis, if any?
  • This was a simple state the desired outcome and shoot project. Nothing really to build on.

Experiment

Follow the steps given to recreate the original experiment. Answer the following questions:

  • Are the instructions correct in successfully achieving the results?
  • yes i was able to follow without any unknowns.
  • Is there room for improvement in the experiment instructions/description? What suggestions would you make?
  • well… he could have given us his password… lol… no it was good.
  • screen shots are always nice and he presented that.
  • Would you make any alterations to the structure of the experiment to yield better results? What, and why?
  • nope

Data

Analysis

Answer the following:

  • Does the data seem in-line with the published data from the original author?
  • yes
  • Can you explain any deviations?
  • none
  • How about any sources of error?
  • nope
  • Is the stated hypothesis adequate?
  • yup

Conclusions

Answer the following:

  • What conclusions can you make based on performing the experiment?
  • That i have a double connection and could keep in going… maybe a single script used a lot could cause the server some issues… bad thought… nvm
  • Do you feel the experiment was adequate in obtaining a further understanding of a concept?
  • yes
  • Does the original author appear to have gotten some value out of performing the experiment?
  • he had fun and so did I, so yes he learned how to use ssh and find another way to play with the server
  • Any suggestions or observations that could improve this particular process (in general, or specifically you, or specifically for the original author).
  • I like it, good deal.

Retest 8

Perform the following steps:

State Experiment

I am going to do asowers xfc4 panel experiment.

http://lab46.corning-cc.edu/opus/spring2012/asowers/start#experiment_1

Resources

Evaluate their resources and commentary. Answer the following questions:

  • Do you feel the given resources are adequate in providing sufficient background information?
  • I was lost… there are terms that he knows that are not listed or given any explanation for.
  • Are there additional resources you've found that you can add to the resources list?
  • Does the original experimenter appear to have obtained a necessary fundamental understanding of the concepts leading up to their stated experiment?
  • for the user it met what he needed
  • If you find a deviation in opinion, state why you think this might exist.
  • I just need more to be able to implement and at this point do not know what it is.

Hypothesis

State their experiment's hypothesis. Answer the following questions:

  • Do you feel their hypothesis is adequate in capturing the essence of what they're trying to discover?
  • I understand what he is after and that he reached the goal.
  • What improvements could you make to their hypothesis, if any?
  • Explain more about what he is going to do and what tool he is going to use to do it with.

Experiment

Follow the steps given to recreate the original experiment. Answer the following questions:

  • Are the instructions correct in successfully achieving the results?
  • no, i am unable to complete the expirment
  • Is there room for improvement in the experiment instructions/description? What suggestions would you make?
  • Need more thought about tool needed and how it is to be done.
  • Would you make any alterations to the structure of the experiment to yield better results? What, and why?
  • His set up was fine

Data

Analysis

First I needed to attain my IP then I attempted to bring me up

lab46:~$ ssh -X skinney1@192.168.1.112
ssh: connect to host 192.168.1.112 port 22: Connection timed out

attempt to bring panel

lab46:~$ sudo xfce4-panel
[sudo] password for skinney1:
skinney1 is not in the sudoers file.  This incident will be reported.
  • Does the data seem in-line with the published data from the original author?
  • unable to complete
  • Can you explain any deviations?
  • I attempted by using my IPv4 Add and my Default gateway on port 22 with not use.
  • How about any sources of error?
  • just need more information
  • Is the stated hypothesis adequate?
  • yes

Conclusions

Answer the following:

  • What conclusions can you make based on performing the experiment?
  • Maybe i need to be at the comp lab or a strait unix machine
  • Do you feel the experiment was adequate in obtaining a further understanding of a concept?
  • For the author, yes.
  • Does the original author appear to have gotten some value out of performing the experiment?
  • yes
  • Any suggestions or observations that could improve this particular process (in general, or specifically you, or specifically for the original author).
  • already noted

Retest 9

Perform the following steps:

State Experiment

I am going to retest Brain Robbins play on the break command.

http://lab46.corning-cc.edu/opus/spring2012/brobbin4/start#experiment_1

Resources

Evaluate their resources and commentary. Answer the following questions:

  • Do you feel the given resources are adequate in providing sufficient background information?
  • Brain did a really good job explaining the concepts and walking the idea from conceptual to completion.
  • Are there additional resources you've found that you can add to the resources list?
  • Nope
  • Does the original experimenter appear to have obtained a necessary fundamental understanding of the concepts leading up to their stated experiment?
  • Yes
  • If you find a deviation in opinion, state why you think this might exist.
  • None

Hypothesis

State their experiment's hypothesis. Answer the following questions:

  • Do you feel their hypothesis is adequate in capturing the essence of what they're trying to discover?
  • yes, nothing wrong with what is listed.
  • What improvements could you make to their hypothesis, if any?

Experiment

Follow the steps given to recreate the original experiment. Answer the following questions:

  • Are the instructions correct in successfully achieving the results?
  • Yes, completed without issues
  • Is there room for improvement in the experiment instructions/description? What suggestions would you make?
  • None
  • Would you make any alterations to the structure of the experiment to yield better results? What, and why?
  • none

Data

Publish the data you have gained from your performing of the experiment here.

No additional research was needed.

Analysis

Answer the following:

  • Does the data seem in-line with the published data from the original author?
  • yes
  • Can you explain any deviations?
  • none
  • How about any sources of error?
  • none
  • Is the stated hypothesis adequate?
  • yes

Conclusions

Answer the following:

  • What conclusions can you make based on performing the experiment?
  • Using the break command does a better job then exit when you need a break command.
  • Do you feel the experiment was adequate in obtaining a further understanding of a concept?
  • yes
  • Does the original author appear to have gotten some value out of performing the experiment?
  • yes
  • Any suggestions or observations that could improve this particular process (in general, or specifically you, or specifically for the original author).
  • none, good job dude.
opus/spring2012/skinney1/unixpart3.txt · Last modified: 2012/05/06 23:06 by skinney1