Table of Contents

unix Keywords

9. Tab Completion

Definition

Tab completion is being able to auto-complete typing a command by hitting tab.

Demonstration

If you have a program called thebiggestnumberis, and you want to execute it, you would type ./thebiggestnumberis

But using tabcompletion you can just type ./thebi [hit tab] and it will automatically fill it.

If there is another program in the directory that is called thebiggestloseris, then this won't work because there are possible combinations. you will have to type out even more of the program name before the tab completion will work.

10. Wildcards

Definition

The wildcard is the * in unix, and basically means (anything or whatever can do here).

Demonstration

lab46:~/src/unix/Labs$ ls la ls: cannot access la: No such file or directory lab46:~/src/unix/Labs$ ls la* lab0.txt lab1.txt lab2.txt lab3.txt lab4.txt lab5.txt lab6.txt lab46:~/src/unix/Labs$

See how the wildcard enabled the ls command to actually work.. and it gave all names that began with the la[insert anything here]. Cool.

11. Job Control

Definition

Job control is basically multitasking. It gives you the power to perform actions and run them in the background, leaving you free to do whatever else you want. It also allows you to kill these other processes.

Demonstration

We can display current running processes with ps

We can tell a command to run in the background by adding a & to the end of the command. Running fg #(process number) will bring that thing back to the foreground.

You can also use kill commands to kill the process, or using ctrl + C

12. The UNIX Shell

Definition

The UNIX shell is the way that the user uses the OS, called a Command Line Interpreter (CLI).

Demonstration

The shell is the command prompt. Whoa!

13. Environment variable

Definition

An Environment variable is basically a thing that stores some useful piece of information. An example would be how $HOME holds the users home directory.

Demonstration

lab46:~$ echo $PATH
/home/smalik2/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
lab46:~$

14. $PATH

Definition

The $PATH variable holds the locations of executable programs.

Demonstration

smalik2@lab46:~$ echo $PATH
/home/smalik2/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
smalik2@lab46:~$ ls /usr/games
adventure   caesar     gomoku   nethack          primes  snake        worms
arithmetic  canfield   hack     nethack-console  quiz    snscore      wtf
atc         cfscores   hangman  number           rain    teachgammon  wump
backgammon  countmail  hunt     phantasia        random  tetris-bsd
battlestar  cribbage   mille    pig              robots  trek
bcd         dab        monop    pom              rot13   wargames
boggle      go-fish    morse    ppt              sail    worm
smalik2@lab46:~$

Based off this, we can see that /usr/games is in $PATH. I ran ls on that directory, and sure enough, the games listed there can be run as commands from my home directory.

15. The UNIX Programming Environment

Definition

The UNIX programming environment is basically just the ability to create programs using a UNIX operation system.. doesn't seem like there's much else to it.

Demonstration

16. Shell Scripting

Definition

I see shell scripting as 'programming' commands. You make a file and basically use bash to 'code' a series of commands and whatnot that the shell will run if you run the file.

Demonstration

echo enter your birth year
read birthyear
currentyear=$(date +%Y)
let birthyear=$currentyear-$birthyear
echo $birthyear
smalik2@lab46:~/src/unix/scripts$ ./age.sh
enter your birth year
1993
19
smalik2@lab46:~/src/unix/scripts$

unix Objective

unix Objective

The ability to accomplish/automate tasks.

Definition

Given a problem, one would be able to carry out the solution. Or be able to write a script to automate tasks to accomplish the goal - solving the problem.

Method

How easily I can do the labs.

Measurement

Normal stuff I can take care of reasonably easily. When it comes to scripting however, I have difficulty. It isn't impossible for me though.

Analysis

I can solve problems pretty effectively, especially with the help of google. Scripting was very difficult for me to get a grasp on, but now I am moderately comfortable with it. Overall I think I am pretty good at accomplishing/automating tasks - I would give myself a B in my capability.