User Tools

Site Tools


opus:spring2012:jpettie:unixpart1

unix Keywords

unix Keyword: The VI Editor

Definition

The VI Editor, one of the greats, nano on steroids. VI Editor is a text editor with much more to bring to the table, between its tools and its unique style of dealing with the editing of text. It is in simple a text editor with extras.

Demonstration

To demonstrate the VI Editor, I will show a fully functional VI Interface with the extra of line numbers and syntax highlighting:

lab46:~$ install vim
lab46:~$ vi test.c
  1 #include <stdio.h>
  2 #include <stdlib.h>
  3 #include <stdbool.h>
  4
  5 int main(int argc, char **argv){
  6         int input;
  7         bool check = false;
  8         unsigned char i;
  9         while (check == false){
 10                 printf("Enter a value (0-4):");
 11                 scanf("%d", &input);
 12                 if (input > 4 || input < 0){
 13                         printf("You have entered an incorrect value.\n");
 14                         check = false;
 15                 }else{
 16                         for (i = 0; i < argc; i++){
 17                                 printf("argv[%hhu][%hhu]: %c\n", i, input, *(*(argv+i)+input));
 18                         }
 19                         check = true;
 20                 }
 21         }
 22         return(0);
 23 }
 24

unix Keyword: Local host

Definition

Local host is the computer you are working on, it is the web address of the computer you are working on, it is a loopback in networking. Although local host can take many forms, it is simply your computer's identifier.

Demonstration

If you were to type: http://localhost into your web browser, you would be returned with the local web service of your computer.

unix Keyword: Remote host

Definition

Remote hosts are computers that are not locally accessed, rather are at a distance from where you are. They are still accessible and you can retrieve data from them, but they are a distance away.

Demonstration

Remote hosts are usually thought of as network servers or just servers in general, where you would ssh into. An example of this to me would be:

lab46:~$ ssh root@vm31.student.lab

unix Keyword: Home directory

Definition

The way I believe a home directory works, is that it can be a supply source for many users, who can separately have their own subsystems of directories but all refer back to a starting point. Even though it can be used by many, each is very different in its own right, different files and directories based on the user.

Demonstration

This demonstration will show a Home directory with many users.

lab46:~$ cd /home
lab46:/home$ ls
ab000126  bdevaul    cmcavoy   drobie2   haas        jhall40   jvanott1  lmcconn4  nrounds     rrichar8  tdoud
abranne1  bewanyk    cmille37  ds000461  hansolo     jhammo13  jwalrat2  lmerril3  nsano       rsantia4  tedmist1
abrunda1  bfarr2     cmulkeri  ds003420  hclark9     jj001572  jwhitak3  mallis3   nsr1        rshaw8    tfitch1
acanfie1  bh011695   cnicho13  dschoeff  hepingerjj  jjansen4  jwilli30  mbeschle  nvergaso    rthatch2  tgalpin2
acarpen5  bherrin2   comeaubk  dshadeck  hhabelt     jjohns43  jwilso39  mbonacke  nwebb       ryoung12  thakes3
acrocker  bhuffner   cpainter  dsherbur  hps1        jjohnst8  jwood36   mbrigham  oppenheim   sblake3   thatcher
adexter   bkenne11   critten1  dshreve   hramsey     jkingsle  jzimmer5  mbw6      pclose      sc000826  tjohns22
adilaur1  bkrishe3   csit2310  dstorm3   hshaikh     jkremer1  kamakazi  mcantin3  pcremidi    sclayton  tkane1
aettenb3  bnichol7   csleve    dtalvi    hwarren1    jlantz4   kbell1    mclark35  pdowd       sedward9  tkiser
afassett  bobpauljr  cspenc12  dtaylo15  ian         jlazaar   kboe      mcooper6  plindsa1    sjankows  tl009536
agardin4  bort       csteve16  dtennent  imaye       jluedema  kc017344  mdecker3  pm004968    sjelliso  tmizerak
ahazen    bowlett1   cwagner1  dtravis4  jandrew9    jm010967  kcard2    mdittler  pmcconn1    skinney1  tmong
ajernig2  brian      cwilder1  dwalrat1  javery9     jmanley3  kcaton    mearley1  qclark      smacombe  tp001498
ajoensen  brobbin4   cwoolhis  dwells6   jbaez       jmille59  kcook6    mfailing  radams4     smalik2   triley2
alius     bstoll     darduini  dwrigh18  jbamper     jmitch22  kcornel6  mfaucet2  rberry3     smatusic  ts004985
amorich1  btaber2    dates     eberdani  jbarne13    jmunson   kdenson   mgough    rbuchan7    smclaug3  vcordes1
anarde    bwheat     db010905  efarley   jbesecke    jmyers7   kgarrah1  mguthri2  rcaccia1    smd15     wag2
anorthr3  bwilso23   dchilso3  egarner   jblaha      jo009612  kgaylord  mhenry9   redsting3d  smilfor3  wedge
anowaczy  bwilson3   dcicora1  egleason  jblanch1    jpettie   kinney    mkellogg  reedkl      spetka    wezlbot
ap016986  cacquah    ddragoo   emorris4  jbrant      jphill17  kkrauss1  mkelsey1  rfinney2    spline    wfischba
appelthp  cas21      dfoulk1   en007636  jbrizzee    jr018429  klynch3   mmatt     rglover     squires   wknowle1
aradka    caustin8   dgirard3  erava     jburlin1    jrampul1  kpryslop  mowens3   rhender3    squirrel  wroos
aromero   ccaccia    dh002925  erebus    jc006215    jsabin1   kreed11   mp018526  rhensen     srk3      ystebbin
as012495  ccarpe10   dh018304  eryan3    jcardina    jschira1  kscorza   mpage9    rj005436    srog      zlittle
ascolaro  cchandan   dherman3  estead    jcavalu3    jshare1   ksisti2   mpaul6    rjohns41    ssmith85  zmccann
asmedley  ccranda2   dlalond1  eveilleu  jcosgro4    jshort6   kwalker2  mpresto4  rkapela     sswimle1  zward
asowers   cderick    dm005264  ewester1  jdavis34    jsmit176  lburzyns  mshort3   rlott       strego
astrupp   cdewert    dmagee3   ezajicek  jdawson2    jstrong4  lcrowley  mtaft4    rm002127    svrabel
atoby     cforman    dmay5     fclark1   jdrew       jsulli34  ld010818  mwagner3  rmatsch     swarren4
atownsle  cgoodwin   dmckinn2  gc007950  jeisele     jsulliv3  leckley   mwarne11  rmoses      sweller5
atreat2   ckelce     dmurph14  gcalkin3  jellis15    jt011443  lgottsha  mwitter3  rnewman     swilli31
awalke18  ckuehner   dpadget8  ggamarra  jferrito    jtongue2  lh000592  nandre    rosenbll    syang
bblack1   clawren2   dparson3  gr015546  jfrail      jtreacy   lhubbar3  nbaird    rpage3      synack
bboaz     cmace1     dpotter8  groush1   jfurter2    jtripp    llaughl3  nblancha  rpetzke1    ta018998
bbrown17  cmahler    dprutsm2  gsnyder   jh001093    jv001406  lleber    ngraham2  rraplee     tcolli12
lab46:/home$ 

unix Keyword: Current working directory

Definition

A current working directory to me is a folder a person has created and uses for files depending on the purpose of the folder and can access with cd issued commands and can change permissions on files inside of the folder.

Demonstration

Here is a current working directory of my own:

lab46:~$ cd src/cprog
lab46:~/src/cprog$ ls
bigNum    cipher.c      file      ftypes     functions.c  icprog    linkedlist.h  out.txt    prog1x5.c  prog4         prog5    prog6.c  prog8         prog9    test.c  var2
bigNum.c  cipher.txt    file.c    ftypes.c   hint1        icprog.c  message.in    plain.txt  prog3      prog4.c       prog5.c  prog7    prog8.c       prog9.c  var1    var2.c
cipher    decipher.txt  file.txt  functions  hint1.c      key.txt   nofile.txt    prog1x5    prog3.c    prog4.c.save  prog6    prog7.c  prog8.c.save  test     var1.c
lab46:~/src/cprog$ ls -l
total 268
-rwxr-xr-x 1 jpettie lab46  9521 Mar  1 21:05 bigNum
-rw-r--r-- 1 jpettie lab46  1832 Mar  1 21:05 bigNum.c
-rwxr-xr-x 1 jpettie lab46  9452 Feb 28 14:20 cipher
-rw-r--r-- 1 jpettie lab46  2323 Mar  1 19:55 cipher.c
-rw-r--r-- 1 jpettie lab46    34 Feb 24 20:04 cipher.txt
-rw-r--r-- 1 jpettie lab46    34 Feb 28 17:44 decipher.txt
-rwxr-xr-x 1 jpettie lab46  7481 Feb  7 16:48 file
-rw-r--r-- 1 jpettie lab46   372 Feb  7 16:48 file.c
-rw-r--r-- 1 jpettie lab46    15 Feb  7 16:45 file.txt
-rwxr-xr-x 1 jpettie lab46  8275 Mar  1 15:18 ftypes
-rw-r--r-- 1 jpettie lab46  1007 Mar  1 16:10 ftypes.c
-rwxr-xr-x 1 jpettie lab46  8058 Feb 24 15:09 functions
-rw-r--r-- 1 jpettie lab46  1061 Feb 24 11:55 functions.c
-rwxr-xr-x 1 jpettie lab46  7754 Feb 27 11:58 hint1
-rw-r--r-- 1 jpettie lab46   692 Feb 28 10:43 hint1.c
-rwxr-xr-x 1 jpettie lab46  7136 Feb 16 16:14 icprog
-rw-r--r-- 1 jpettie lab46   481 Feb 16 16:30 icprog.c
-rw-r--r-- 1 jpettie lab46    19 Feb 24 21:48 key.txt
-rw-r--r-- 1 jpettie lab46   509 Mar  1 21:01 linkedlist.h
-rw-r--r-- 1 jpettie lab46    42 Feb 27 09:57 message.in
-rw-r--r-- 1 jpettie lab46     0 Mar  1 23:42 nofile.txt
-rw-r--r-- 1 jpettie lab46    14 Feb  7 16:48 out.txt
-rw-r--r-- 1 jpettie lab46     0 Mar  1 23:42 plain.txt
-rwxr-xr-x 1 jpettie lab46 11673 Mar  1 23:42 prog1x5
-rw-r--r-- 1 jpettie lab46  1165 Mar  1 23:42 prog1x5.c
-rwxr-xr-x 1 jpettie lab46  6771 Jan 31 15:07 prog3
-rw-r--r-- 1 jpettie lab46   267 Jan 31 15:07 prog3.c
-rwxr-xr-x 1 jpettie lab46  7031 Jan 31 16:02 prog4
-rw-r--r-- 1 jpettie lab46   452 Jan 31 16:02 prog4.c
-rw-r--r-- 1 jpettie lab46   300 Feb 14 12:17 prog4.c.save
-rwxr-xr-x 1 jpettie lab46  7039 Jan 31 16:36 prog5
-rw-r--r-- 1 jpettie lab46   246 Feb  2 11:07 prog5.c
-rwxr-xr-x 1 jpettie lab46  7738 Feb  2 15:42 prog6
-rw-r--r-- 1 jpettie lab46   589 Feb 16 16:58 prog6.c
-rwxr-xr-x 1 jpettie lab46  7453 Feb  7 16:24 prog7
-rw-r--r-- 1 jpettie lab46   338 Feb  7 16:24 prog7.c
-rwxr-xr-x 1 jpettie lab46  7632 Feb 14 14:31 prog8
-rw-r--r-- 1 jpettie lab46   458 Feb 28 10:56 prog8.c
-rw-r--r-- 1 jpettie lab46   459 Feb 14 12:17 prog8.c.save
-rwxr-xr-x 1 jpettie lab46  6965 Feb 14 15:40 prog9
-rw-r--r-- 1 jpettie lab46   384 Feb 28 11:06 prog9.c
-rwxr-xr-x 1 jpettie lab46  7465 Feb 24 21:46 test
-rw-r--r-- 1 jpettie lab46   484 Feb 24 21:46 test.c
-rwxr-xr-x 1 jpettie lab46  6786 Jan 26 15:49 var1
-rw-r--r-- 1 jpettie lab46   305 Jan 26 15:49 var1.c
-rwxr-xr-x 1 jpettie lab46  6794 Jan 26 16:41 var2
-rw-r--r-- 1 jpettie lab46   256 Jan 26 16:41 var2.c
lab46:~/src/cprog$

unix Keyword: Text Processing

Definition

The way I think of Text Processing is a technique or device used to edit, and save text into files or from files but can also be used just on plain text as well to change it (for example: to change the color of text).

Demonstration

A tool used to process text I've used in the past and would be a good demonstration would be “nano”

lab46:~/src/cprog$ nano prog3.c 
#include <stdio.h>
 
int main(){
        int v = 17;
        int *p1 = NULL;
        printf("v is %u \n", v);
        p1 = &v;
        printf("*p1 is %u\n", *p1);
        *p1 = 53;
        printf("v is %u\n", v);
        printf("*p1 is %u\n", *p1);
        v = 7;
        printf("v is %u\n", v);
        printf("p1 is %u\n", *p1);
        return(0);
}

unix Keyword: Job Control

Definition

To me, Job Control is just another way of saying multitasking, but to multitask efficiently. To control the outcome and resources needed by each job to complete its task and to give the right results along with being able to run them both at the same time.

Demonstration

An example of Job Control to me, is using more than one windows in a screen session and having one be a tail to log files, and the other to run a bnetd file for a pvpgn server.

tail: invalid option -- *                                                                                              jpettie@lab46:~$ ssh root@vm31.student.lab
Try `tail --help' for more information.                                                                                Warning: Permanently added 'vm31.student.lab,10.80.3.31' (RSA) to the list of known hosts.
vm31:/usr/local/var# tail --help                                                                                       root@vm31.student.lab's password:
Usage: tail [OPTION]... [FILE]...                                                                                      Linux vm31 2.6.26-2-xen-686 #1 SMP Wed Sep 21 09:56:47 UTC 2011 i686
Print the last 10 lines of each FILE to standard output.
With more than one FILE, precede each with a header giving the file name.                                              The programs included with the Debian GNU/Linux system are free software;
With no FILE, or when FILE is -, read standard input.                                                                  the exact distribution terms for each program are described in the
                                                                                                                       individual files in /usr/share/doc/*/copyright.
Mandatory arguments to long options are mandatory for short options too.
      --retry              keep trying to open a file even if it is                                                    Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
                           inaccessible when tail starts or if it becomes                                              permitted by applicable law.
                           inaccessible later; useful when following by name,                                          Last login: Sat Mar  3 02:57:33 2012 from lab46.offbyone.lan
                           i.e., with --follow=name                                                                    vm31:~# cd /usr/local
  -c, --bytes=N            output the last N bytes; alternatively, use +N to                                           vm31:/usr/local# cd sbin
                           output bytes starting with the Nth of each file                                             vm31:/usr/local/sbin# ls
  -f, --follow[={name|descriptor}]                                                                                     bnetd  bntrackd  d2cs  d2dbs
                           output appended data as the file grows;                                                     vm31:/usr/local/sbin#
                           -f, --follow, and --follow=descriptor are
                           equivalent
  -F                       same as --follow=name --retry
  -n, --lines=N            output the last N lines, instead of the last 10;
                           or use +N to output lines starting with the Nth
      --max-unchanged-stats=N
                           with --follow=name, reopen a FILE which has not
                           changed size after N (default 5) iterations
                           to see if it has been unlinked or renamed
                           (this is the usual case of rotated log files)
      --pid=PID            with -f, terminate after process ID, PID dies
  -q, --quiet, --silent    never output headers giving file names
  -s, --sleep-interval=S   with -f, sleep for approximately S seconds
                           (default 1.0) between iterations.
  -v, --verbose            always output headers giving file names
      --help     display this help and exit
      --version  output version information and exit

If the first character of N (the number of bytes or lines) is a `+',
print beginning with the Nth item from the start of each file, otherwise,
print the last N items in the file.  N may have a multiplier suffix:
b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,
GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.

With --follow (-f), tail defaults to following the file descriptor, which
means that even if a tail'ed file is renamed, tail will continue to track
its end.  This default behavior is not desirable when you really want to
track the actual name of the file, not the file descriptor (e.g., log
rotation).  Use --follow=name in that case.  That causes tail to track the
named file by reopening it periodically to see if it has been removed and
recreated by some other program.

Report bugs to <bug-coreutils@gnu.org>.
vm31:/usr/local/var# tail -f .log
tail: cannot open `.log' for reading: No such file or directory
tail: no files remaining
vm31:/usr/local/var# tail -f *.log
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Emperor-2"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Red Alert 2-1"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Red Alert 2-2"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Nox Quest-1"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Yuri's Revenge-1"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Yuri's Revenge-2"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Lob 38 0"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Lob 39 0"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Lob 40 0"
Mar 01 23:43:34 [info ] main: server has shut down

unix Keyword: Regular Expressions

Definition

When I think of Regular Expressions, I tend to think of if statements, comparing two things and seeing if they match, depending on type of course.

Demonstration

Here is a while statement to show Regular Expressions:

while (check == false){
    some sort of code to execute here
}

unix Objective

unix Objective

Exposure to command-line tools and utilities

Definition

In my own thoughts, I would consider the completion of this objective as using tools such as vi to accomplish a task, or even produce a program in c.

Method

The method I will use to show the completion of this objective is an example of vi editing of a program.

Measurement

Here is an example of vi after adding line numbers and syntax highlighting:

  1 #include <stdio.h>
  2 #include <stdlib.h>
  3 #include <stdbool.h>
  4
  5 int main(int argc, char **argv){
  6         int input;
  7         bool check = false;
  8         unsigned char i;
  9         while (check == false){
 10                 printf("Enter a value (0-4):");
 11                 scanf("%d", &input);
 12                 if (input > 4 || input < 0){
 13                         printf("You have entered an incorrect value.\n");
 14                         check = false;
 15                 }else{
 16                         for (i = 0; i < argc; i++){
 17                                 printf("argv[%hhu][%hhu]: %c\n", i, input, *(*(argv+i)+input));
 18                         }
 19                         check = true;
 20                 }
 21         }
 22         return(0);
 23 }
 24

Analysis

I believe I have showed use of a tool or utility from the command line. I think there is always room to grow, especially when you are running low on time and waited to long to complete your opus. The method seems pretty solid, it shows an example of a working tool. Employing this enhancement will work because the program will run. I believe the course objective is very vital and strong as it stands.

opus/spring2012/jpettie/unixpart1.txt · Last modified: 2012/03/02 22:15 by jpettie