Table of Contents

unix Keywords

Text Processing

Definition

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

The creation and manipulations of a file.

Demonstration

Demonstration of the chosen keyword.

lab46:~$ 
lab46:~$ cat > file.c
Any text can go here
^D (command to end operation)
lab46:~$ 
lab46:~$ cat file.c
Any text can go here
lab46:~$ 

The VI Editor

Definition

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

Screen-oriented text editor originally created for the Unix operating system.

Demonstration

Demonstration of the chosen keyword.

Lets use file.c from the previous topic.

Syntax: vi [-rR][file…]

Exiting and Entering VI:

ZZ save file and exit VI
:wq same as above
:e! return to last saved version of current file
:q quit without save, (Note :q! is required if changes have been made)
:w write without exit (:w! to force write)
lab46:~$ vi file.c
* enters VI program

Any text can go here
~
~
"file.c" 2L, 22C                 1,1    ALL
:q
lab46:~$

The Unix Shell: Environment Variable

Definition

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

Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.

Demonstration

Demonstration of the chosen keyword.

Environment Variables include:
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)

env: Display environment variables.

lab46:~$ env
Term=xterm
SHELL=/bin/bash
SSH_CLIENT=67.252.199.108 61408 22
SSH_TTY=/dev/pts/74
USER=tedmist1
MAIL=/home/tedmist1/Maildir
PATH=/usr/lcoal/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
LC_COLLATE=C
PWD=/home/tedmist1
HISTCONTROL=ignoreboth
SHLVL=1
HOME=/home/tedmist1
LOGNAME=tedmist1
SSH_CONNECTION=67.252.119.108 61408 10.80.2.38 22
_=/usr/bin/env
OLDPWD=/usr/local/bin
lab46:~$

The UNIX Shell: $PATH

Definition

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

PATH is an environment variable on Unix-like operating systems. This path specifies a set of directories where executable programs are located.

Demonstration

Demonstration of the chosen keyword.

Examples of SHELL variables are:

cwd (your current working directory)

home (the path name of your home directory)

path (the directories the shell should search to find a command)

prompt (the text string used to prompt for interactive commands shell your login shell)

SHELL variables are both set and displayed using the set command.
lab46:~$ set
BASH=/bin/bash
HOME=/home/tedmist1
LOGNAME=tedmist1
PWD=/home/tedmist1
SHELL=/bin/bash
USER=tedmist1
lab46:~$

The UNIX Shell: Wildcards

Definition

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

A special character usually used in the middle of a search term in a keyword search to retrieve results containing words with any character or no character in the position.

Demonstration

Demonstration of the chosen keyword.

Syntax:
? Matches any one character in a filename.
* Matches any character or characters in a filename.
[ ] Matches one of the characters included inside the [ ] symbols.
lab46:~$ 
lab46:~$  cd script
lab46:~/script$ ls
file1 file2 file3 file4 file5 file6 file8 script8 typescript
lab46:~/script$ ls file?
file1 file2 file3 file4 file5 file6 file7 file8
lab46:~/script$ ls file*
file1 file2 file3 file4 file5 file6 file7 file8
lab46:~/script$ ls [f]*
file1 file2 file3 file4 file5 file6 file7 file8
lab46:~/script$

The UNIX Shell: Tab Completion

Definition

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

Tab completion is a common feature of command line interpreters, in which the program automatically fills in partially typed commands.

Demonstration

Demonstration of the chosen keyword.

Changing directories into your home directory.

If you haven't provided unique enough information to the command-line, the tab completion cannot complete. Hitting tab a second time will give you a list of possible choices.
lab46:~$ cd ho <-- hit tab
lab46:~$ cd home/ <-- this is what should appear after hitting the tab command
<hit return>
lab46:~/home$
lab46:~$ cd home/ <-- if you hit the tab command twice the next prompt should appear:
lab46:~$ cd home/
.swp    username/

Job Control

Definition

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

The ability to suspend an interactive job and resume it at a later time, or send it into the “background”.

Demonstration

Demonstration of the chosen keyword.

Need to know information:

Process ID (PID): a unique number assigned to each running process on the system.
Foreground Process: a process that is running in the foreground (currently using STDIN/STDOUT/STDERR).
Background Process: a process that is running independently in the background, allowing you to use your shell (which is in your foreground) or start additional applications.
Killing a Process: in UNIX, you can terminate processes with the kill(1) utility.
The ps(1) utility is used to list the running processes on the system. Running with no arguments will show the current processes attached to your login session.

The kill(1) utility is used to terminate certain PID numbers running.
lab46:~$ ps
USER      PID    %CPU %MEM VSZ    RSS   TTY     STAT START  TIME COMMAND
tedmist1  13123  1.0  0.1  13628  1956  pts/74  SNs  12:53  0:00  -bash
tedmist1  13126  0.0  0.0   8588   996  pts/74  RN+  12:53  0:00  ps u
lab46:~$ kill 13123
lab46:~$

The UNIX Programming Environment: Compiler

Definition

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

A program that decodes instructions written in a higher order language and produces an assembly language program.

Demonstration

Demonstration of the chosen keyword.

The Unix command for compiling C/C++ code is gcc.
Where hello is the name of the desired executable, and hello.c is the name of the text file containing the program source.
The -o argument to gcc indicates the name of the output file.
C Compiler
lab46:~$ gcc -o hello hello.c
lab46:~$ ls
hello (green coloration indicating it as a special file)
hello.c
lab46:~$
C++ Compiler
Where hello1 is the name of the desired executable, and hello.cc is the name of the text file containing the program source.
The -o argument to g++ indicates the name of the output file.
lab46:~$ g++ -o hello1 hello.cc
lab46:~$ ls
hello1 (green coloration indicating it as a special file)
hello.cc
lab46:~$

unix Objective

The Ability to Accomplish/Automate Tasks

State the course objective

The ability to accomplish/automate tasks

Definition

In your own words, define what that objective entails.

The ability to create ones own task, and have it run at a certain point of time on each day you so wish it to run.

Method

State the method you will use for measuring successful academic/intellectual achievement of this objective.

Such an objective can be accomplished using the cron command. Cron the name of a program that enables Unix users to execute commands or scripts automatically at a specified time/date.
 *     *     *   *    *        command to be executed
 -     -     -   -    -
 |     |     |   |    |
 |     |     |   |    +----- day of week (0 - 6)
                                           (Sunday=0)
 |     |     |   +------- month (1 - 12)
 |     |     +--------- day of month (1 - 31)  
 |     +----------- hour (0 - 23)
 +------------- min (0 - 59)

Measurement

Follow your method and obtain a measurement. Document the results here.

The method of measurement would be the times in which your task will be occurring. If the task only runs for a week the measurement of that task will be a week.

Analysis

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

Good, in this objective I learned how to automate tasks to my wanting.

* Is there room for improvement?

Yes, by learning all the commands and proper syntax involved.

* Could the measurement process be enhanced to be more effective?

No, it will just take time to learn such things.

* Do you think this enhancement would be efficient to employ?

Yes, by running tasks on certain days, thus you would not forget to run them on that day.

* Could the course objective be altered to be more applicable? How would you alter it?

The course objective is just fine the way it is. It is already applicable, thus no changes needed to be made.