Table of Contents

unix Keywords

■The UNIX Shell

■ Environment variable

■ Source Code, Object Code, Binary Code, Library……x

■ Source Code, Object Code, Binary Code, Library

■ Filtering

■ networking, UNIX Networking Tools

■ Security

■ X Window System

Filtering (Unix)

Definition

filtering is a way to process text in a usable manner for the goal that is in mind.

Demonstration

some filtering utilities

  cat(1) - concatenate files
  cut(1) - cut text
  grep(1) - globally search for regular expression and print
  head(1) - print first “n” lines of output
  sed(1) - stream editor
  sort(1) - sort output
  tail(1) - print last “n” lines of output
  tr(1) - translate characters
  uniq(1) - filter out duplicate lines from sorted file
  wc(1) - word count
lab46:~$ cat sample.db
name:sid:major:year:favorite candy*
Jim Smith:105743:Economics:Sophomore:Lollipops*
Adelle Wilson:594893:Sociology:Junior:Ju-Ju Fish*
Sarah Billings:938389:Accounting:Freshman:Tic-Tacs*
Eric Vincent:1001119:Biology:Freshman:Lollipops*
Linus Torvalds:4432001:Computer Science:Senior:Snickers*
Alan Cox:40049300:Computer Science:Senior:Whoppers*
Alan Turing:40030333:Computer Science:Senior:Rock Candy*
Eric Vincent:1001119:Biology:Freshman:Lollipops*
John Doe:0000000:Unknown:Freshman:unknown*
Leet Haxzor:31337:Business:Sophomore:Gobstoppers*
Matthew Green:439478:Philosophy:Junior:Necco Wafers*
Megan Tanner:372233:Physics:Junior:Zero Bar*
Junior Mint:2228484:Liberal Arts:Junior:Junior Mints*
Alan Wilson:22908948:Economics:Freshman:Whoppers*
Kris Warner:8383833:Biology:Senior:Mars Bar*
Jill Ashley:9939392:Chemistry:Freshman:Warheads*
Francois Laroux:93938383:Anthropology:Sophomore:Bubblegum*

lab46:~$ cat sample.db | grep Biology
Eric Vincent:1001119:Biology:Freshman:Lollipops*
Eric Vincent:1001119:Biology:Freshman:Lollipops*
Kris Warner:8383833:Biology:Senior:Mars Bar*

lab46:~$ cat sample.db | grep Biology | grep Lollipops
Eric Vincent:1001119:Biology:Freshman:Lollipops*
Eric Vincent:1001119:Biology:Freshman:Lollipops*

lab46:~$ echo "hello there:this:is:a:bunch of:text." | cut -d":" -f1
hello there
lab46:~$ echo "hello there:this:is:a:bunch of:text." | cut -d":" -f2
this
lab46:~$ echo "hello there:this:is:a:bunch of:text." | cut -d":" -f3
is
lab46:~$ echo "hello there:this:is:a:bunch of:text." | cut -d":" -f1,6 | sed -e 's/:/ /g'
hello there text.
lab46:~$ sort sample.db sorts alphabetically
Adelle Wilson:594893:Sociology:Junior:Ju-Ju Fish*
Alan Cox:40049300:Computer Science:Senior:Whoppers*
Alan Turing:40030333:Computer Science:Senior:Rock Candy*
Alan Wilson:22908948:Economics:Freshman:Whoppers*
Eric Vincent:1001119:Biology:Freshman:Lollipops*
Eric Vincent:1001119:Biology:Freshman:Lollipops*
Francois Laroux:93938383:Anthropology:Sophomore:Bubblegum*
Jill Ashley:9939392:Chemistry:Freshman:Warheads*
Jim Smith:105743:Economics:Sophomore:Lollipops*
John Doe:0000000:Unknown:Freshman:unknown*
Junior Mint:2228484:Liberal Arts:Junior:Junior Mints*
Kris Warner:8383833:Biology:Senior:Mars Bar*
Leet Haxzor:31337:Business:Sophomore:Gobstoppers*
Linus Torvalds:4432001:Computer Science:Senior:Snickers*
Matthew Green:439478:Philosophy:Junior:Necco Wafers*
Megan Tanner:372233:Physics:Junior:Zero Bar*
Sarah Billings:938389:Accounting:Freshman:Tic-Tacs*
name:sid:major:year:favorite candy*

lab46:~$ head -5 sample.db "print first 5 lines" tail does opposite prints last -n lines of file specified 
name:sid:major:year:favorite candy*
Jim Smith:105743:Economics:Sophomore:Lollipops*
Adelle Wilson:594893:Sociology:Junior:Ju-Ju Fish*
Sarah Billings:938389:Accounting:Freshman:Tic-Tacs*
Eric Vincent:1001119:Biology:Freshman:Lollipops*

Security (UNIX)

Definition

Security is ability to allow and/or deny access to information that is vital to any multi-user system.

Demonstration

To be able to change permissions, allow access for new directories created along with new files is just some of the basic but must be taken into account. below is a command line which will display the umask

lab46:~$ umask
0022
lab46:~$ touch newfile
lab46:~$ ls -l newfile
-rw-r--r-- 1 rmatsch lab46 0 Apr 21 12:18 newfile
lab46:~$

This means your default umask is set to this meaning that any files you make will have this minused the full permissions so a normal file full permission would be 666 but now when a new file is created thanks to umask the permissions on the file in octal are 644 which mean the owner can read and write to the file and everyone else can only read and same for group.

lab46:~$ mkdir newdirect
lab46:~$ ls -ld newdirect
drwxr-xr-x 2 rmatsch lab46 6 Apr 21 12:19 newdirect

full permission on a directory is 777 so 777 -22 = 755 which is show above with the owner having read write execute and group and world having only read and execute privileges.so umask is a very important thing to know if you are considering security of the system and users.

When you don't have access:

lab46:~$ cd /root
-bash: cd: /root: Permission denied
lab46:~$ chmod 077 newdirect "change newdirect's permissions to 077"
lab46:~$ cd newdirect
-bash: cd: newdirect: Permission denied

The unix shell (unix)

Definition

The Unix shell is a command-line interpreter that provides a user interface for Unix/linus operating systems. Users directly operate with the computer by entering commands execute, create, delete, and various other operation. There is no “ button clicking like windows computers”

Demonstration

At a command line interpreter such as bash or various other you can search through files, list files,create new files, copy files, delete files, make directories, and so on.Below is a demonstration of the various nothing i talked about just showing you that all task or “moving around the sytem is done through commands.

lab46:~$ ls
2              badname.tgz             newdirect
CCC.sh         bin                     phenny
CCCclasses.sh  class_notes             phenny.tar.bz2
Desktop        classlog.c              regex.html
Documents      count.c                 sample.db
Downloads      data                    spring2010-20091022.html
Maildir        fall2010-20100315.html  spring2010-20101113.html
Music          fall2010-20101113.html  spring2011-20101105.html
Pictures       fall2011-20110417.html  spring2011-20101113.html
Public         file                    spring2012-20111103.html
Templates      index.html              src
Videos         lab1                    stdout
archives       labD.sh                 winter2011-20101113.html
badname        motd
lab46:~$ cp count.c count.xxxxxxxxxxxxxx
lab46:~$ rm count.c
rm: remove regular file `count.c'? y
lab46:~$ mkdir newdirect2
lab46:~$ touch newfile
lab46:~$ ls
2              bin                     newfile
CCC.sh         class_notes             phenny
CCCclasses.sh  classlog.c              phenny.tar.bz2
Desktop        count.xxxxxxxxxxxxxx    regex.html
Documents      data                    sample.db
Downloads      fall2010-20100315.html  spring2010-20091022.html
Maildir        fall2010-20101113.html  spring2010-20101113.html
Music          fall2011-20110417.html  spring2011-20101105.html
Pictures       file                    spring2011-20101113.html
Public         index.html              spring2012-20111103.html
Templates      lab1                    src
Videos         labD.sh                 stdout
archives       motd                    winter2011-20101113.html
badname        newdirect
badname.tgz    newdirect2
lab46:~$ grep hey regex.html
<td NOSAVE><b><u><font size=+1>Objective:</font></u></b> To become familiar with the UNIX command line through exposure to some simple commands. The student will also be presented with traditional UNIX conventions they are expected to become familiar with and use throughout the semester.</td>
How have they changed?</td>

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

bherrin2   dh018304  hshaikh     jsmit176  mdecker3  rmatsch     tp001498
bhuffner   dherman3  hwarren1    jstrong4  mdittler  rmoses      triley2
bkenne11   dlalond1  ian         jsulli34  mearley1  rnewman     ts004985
bobpauljr  dmay5     javery9     jtongue2  mgough    rpetzke1    wedge
bort       dmckinn2  jbaez       jtreacy   mguthri2  rraplee     wezlbot
bowlett1   dmurph14  jbamper     jtripp    mhenry9   rrichar8    wfischba
brian      dpadget8  jbarne13    jv001406  mkellogg  rsantia4    wknowle1
brobbin4   dparson3  jbesecke    jvanott1  mkelsey1  rshaw8      wroos
bstoll     dpotter8  jblaha      jwalrat2  mmatt     rthatch2    ystebbin
btaber2    dprutsm2  jblanch1    jwhitak3  mowens3   ryoung12    zlittle
bwheat     drobie2   jbrant      jwilli30  mp018526  sblake3     zmccann
bwilso23   ds000461  jbrizzee    jwilso39  mpage9    sc000826    zward
lab46:/home$ cd rmatsch
lab46:~$ cd src
lab46:~/src$ ls
Makefile  cprog  hello1  hello1.c  helloC  helloC.c  submit  unix
lab46:~/src$ cd unix
lab46:~/src/unix$ ls
arc.tar.gz    cs4.txt  cs9.txt  lab0.txt  lab5.txt  laba.txt
contact.info  cs5.txt  csA.txt  lab1.txt  lab6.txt  link.sh
cs1.txt       cs6.txt  csB.txt  lab2.txt  lab8.txt  scripting
cs2.txt       cs7.txt  csC.txt  lab3.txt  lab9.txt  shell
cs3.txt       cs8.txt  devel    lab4.txt  labC.txt  unix_html_stuff
lab46:~/src/unix$

Environment Variables

Definition

environment variables are significant and can be thought of in a sense to create the operating environment in which a process runs. environment variables set at login are valid for the duration of the session. Environment variables have UPPER CASE as opposed to lower case which are shell variables.

Demonstration

  USER (your login name)
  HOME (the path name of your home directory)
  HOST (the name of the computer you are using)
  ARCH (the architecture of the computers processor)
  DISPLAY (the name of the computer screen to display X windows)
  PRINTER (the default printer to send print jobs)
  PATH (the directories the shell should search to find a command)
lab46:~$ echo $HOME
/home/rmatsch
lab46:~$ echo $PATH
/home/rmatsch/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
lab46:~$ echo $OSTYPE
linux-gnu
lab46:~$ echo $USER
rmatsch
lab46:~$ echo $home
lab46:~$

X window system

Definition

a software system which provides a basis for GUI's and has good input device capability for computers. basically it is used to build graphical user interfaces for unix like operating systems originally designed for network connection.

unix networking tools

Definition

tools used to gain networking information such as the host you are connected to and various other network data that may be useful.

Demonstration

some of the two most important networking tools i think are netstat, ping below are example of them to find information on dns server to see if packets or being sent and network information.

lab46:~$ ping localhost
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost.localdomain (127.0.0.1): icmp_req=1 ttl=64 time=0.045 ms
64 bytes from localhost.localdomain (127.0.0.1): icmp_req=2 ttl=64 time=0.037 ms
64 bytes from localhost.localdomain (127.0.0.1): icmp_req=3 ttl=64 time=0.038 ms
64 bytes from localhost.localdomain (127.0.0.1): icmp_req=4 ttl=64 time=0.036 ms
^C
--- localhost.localdomain ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2997ms
rtt min/avg/max/mdev = 0.036/0.039/0.045/0.003 ms

netstat 
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 lab46.offbyone.la:60002 irc.offbyone.lan:ircd   ESTABLISHED
tcp        0      0 lab46.offbyone.lan:ssh  mobile-198-228-20:58895 ESTABLISHED
tcp        0      0 lab46.offbyone.la:47089 irc.offbyone.lan:ircd   ESTABLISHED


lab46:~$ netstat -ta
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.lan:ssh  mobile-198-228-20:58895 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
tcp        0      0 lab46.offbyone.la:45645 irc.offbyone.lan:ircd   ESTABLISHED
tcp        0      0 lab46.offbyone.la:58347 vm31.student.lab:ssh    ESTABLISHED
tcp        0      0 lab46.offbyone.la:44392 irc.offbyone.lan:ircd   ESTABLISHED
tcp        0      0 lab46.offbyone.la:51839 auth1.offbyone.lan:ldap ESTABLISHED
tcp        0      0 lab46.offbyone.la:47426 irc.offbyone.lan:ircd   ESTABLISHED
tcp        0      0 lab46.offbyone.la:33595 auth1.offbyone.lan:ldap ESTABLISHED
tcp        0      0 lab46.offbyone.la:44549 irc.offbyone.lan:ircd   ESTABLISHED


netstat -s |less

Ip:
    44800188 total packets received
    2 with invalid addresses
    280120 forwarded
    0 incoming packets discarded
    44488743 incoming packets delivered
    58096734 requests sent out
    7068 outgoing packets dropped
Icmp:
    10051 ICMP messages received
    28 input ICMP message failed.
    ICMP input histogram:
        destination unreachable: 9389
        echo requests: 250
        echo replies: 412
    9622 ICMP messages sent
    0 ICMP messages failed
    ICMP output histogram:
        destination unreachable: 659
        redirect: 7068
        echo request: 1645
        echo replies: 250
IcmpMsg:
        InType0: 412
        InType3: 9389
        InType8: 250
        OutType0: 250
        OutType3: 659
        OutType5: 7068
        OutType8: 1645
Tcp:
    80063 active connections openings
    38145 passive connection openings
    26780 failed connection attempts
    4252 connection resets received
    85 connections established
    44040550 segments received
    57184990 segments send out
    96026 segments retransmited
    0 bad segments received.
    30648 resets sent
Udp:
    388512 packets received

Compiler, Assembler, Linker, Loader

Definition

Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <stdio.h>
 
int main()
{
    return(0);
}

Alternatively (or additionally), 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$ 

Source Code, Object Code, Binary Code, Library

Definition

source code is code written by a programmer in a text editor, object code is the source code compiled and ready to be linked to the binary code which is the binary executable the processor reads. library can be thought of as a place where header files are located.

Demonstration

lab46:~$ vi hello.c
lab46:~$ file hello.c
hello.c: ASCII C program text
lab46:~$ gcc -c hello.c
lab46:~$ ls
hello.c
hello.o
lab46:~$ file hello.o
hello.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
lab46:~$ gcc -o helo hello.o
lab46:~$ file helo
helo: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
lab46:~$ file hello.o
hello.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
lab46:~$ file hello.c
hello.c: ASCII C program text

unix Objective

unix Objective

students should be able to set permissions on file directories ad be able to filter text using utilities

Definition

the objective entails using reg expression cut(1),tr(1), and many more tools to filter text and be familiar with unix security.

Method

Tell students to find what the default file and directory access is set to and how to change that default permission using umask and have an understanding of what is happening. ask students to search through a document and put the information into a useable manner by filtering the document or database. students should also be asked to change the permissions using chmod utility and demonstrate a clear understanding in permissions and security

Measurement

lab46:~$ umask
0022
lab46:~$ touch file
lab46:~$ ls -l file
-rwxr-xr-x 1 rmatsch lab46 7481 Apr 21 16:21 file
lab46:~$ umask 000
lab46:~$ touch file2
lab46:~$ ls -l file2
-rw-rw-rw- 1 rmatsch lab46 0 Apr 21 16:21 file2
lab46:~$ umask 22
lab46:~$ mkdir newd
lab46:~$ ls -ld
drwx-----x 30 rmatsch lab46 4096 Apr 21 16:23 .
lab46:~$ ls -ld newd
drwxr-xr-x 2 rmatsch lab46 6 Apr 21 16:23 newd
lab46:~$ umask 22
lab46:~$ chmd
-bash: chmd: command not found
lab46:~$ chmod 777 newd
lab46:~$ ls -ld newd
drwxrwxrwx 2 rmatsch lab46 6 Apr 21 16:23 newd
lab46:~$

1 is execute read is 4 and write is 2

Analysis

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