SSH Server Cygwin - UNIX Beginers Tutorial

30
Install and configure OpenSSH We're going to use the free Unix emulator Cygwin to get the Open SSH suite installed on your Windows machine. Cygwin is(emulator de Unix pe windows) a collection of tools which pro!ide a "inux loo# and feel en!ironment for Windows. a $"" (cygwin%.dll) which acts as a "inux & layer pro!iding sustantial "inux & functionality.  The Cygwin tools are por ts of the popular GNU developme nt tools for Micr osoft Windows. They run thanks to the Cygwin library which provides the !"#$ system calls and environment these programs e%pect. Complete the Cygwin setup and restart if necessary. *hen+ launch a Cygwin command line window and type ssh-host-config . When the script as#s you aout ,pri!ilege separation+, answer yes. When the script as#s to ,create local user sshd+, answer yes. When the script as#s to ,install sshd as a ser!ice+, answer yes. When the script stops and as#s you for ,C-W/0, your answer is ntsec tty. (*han#s to the author of this page for the help here.). Disable SSH protocol 1 On a particularly loc#ed1down networ# spend a lot of time on+ the admins as#ed me to disale SSH's rotocol % on my SSH ser!er for security reasons. *his goes a it eyond my le!el of SSH expertise (so networ# admins+ feel free to 2ump in here)+ ut apparently some !ulnerailities ha!e een identified with rotocol %+ which you don't need for your ser!er anyway. *o disale it+ open SSH$'s configuration file in a text editor+ located at c:\cygwin\etc\defaults\etc\sshd_config . Change the line that reads #Protocol 2,1 *o Protocol 2. So you're 2ust remo!ing the 3 and the +%. Sa!e the file. Run your SSH server  /ow it's time to get your SSH ser!er runnin g. Since we're on Windows we'll start it as a ser!ice. t will use your Windows login names and passwords to authenticate users. (4a#e sure all your C login's ha!e strong passwords associated with them5) &t the Cygwin prompt+ type

Transcript of SSH Server Cygwin - UNIX Beginers Tutorial

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 1/30

Install and configure OpenSSH

We're going to use the free Unix emulator Cygwin to get the Open SSH suite installed on your Windows machine.

Cygwin is(emulator de Unix pe windows)

• a collection of tools which pro!ide a "inux loo# and feel en!ironment for Windows.

• a $"" (cygwin%.dll) which acts as a "inux & layer pro!iding su stantial "inux &functionality.

The Cygwin tools are ports of the popular GNU development tools for MicrosoftWindows. They run thanks to the Cygwin library which provides the !"#$ system

calls and environment these programs e%pect.

Complete the Cygwin setup and restart if necessary.

*hen+ launch a Cygwin command line window and type ssh-host-config . When the scriptas#s you a out ,pri!ilege separation+, answer yes. When the script as#s to ,create local usersshd+, answer yes. When the script as#s to ,install sshd as a ser!ice+, answer yes. When thescript stops and as#s you for ,C- W /0, your answer is ntsec tty . (*han#s to the authorof this page for the help here.).

Disable SSH protocol 1

On a particularly loc#ed1down networ# spend a lot of time on+ the admins as#ed me todisa le SSH's rotocol % on my SSH ser!er for security reasons. *his goes a it eyond myle!el of SSH expertise (so networ# admins+ feel free to 2ump in here)+ ut apparently some!ulnera ilities ha!e een identified with rotocol %+ which you don't need for your ser!eranyway. *o disa le it+ open SSH$'s configuration file in a text editor+ located atc:\cygwin\etc\defaults\etc\sshd_config . Change the line that reads

#Protocol 2,1

*o

Protocol 2 .

So you're 2ust remo!ing the 3 and the +%. Sa!e the file.

Run your SSH server

/ow it's time to get your SSH ser!er running. Since we're on Windows we'll start it as aser!ice. t will use your Windows login names and passwords to authenticate users. (4a#esure all your C login's ha!e strong passwords associated with them5)

&t the Cygwin prompt+ type

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 2/30

net start sshd

-ou should get

The CYG !" sshd ser ice is starting$ The CYG !" sshd ser ice was startedsuccessfully$

/ow you're roc#in' and rolling5

/ote that you can also start and stop the Cygwin SSH ser!er in the Ser!ices panel. n Controlanel+ &dministrati!e *as#s+ choose Ser!ices. 6ight1clic# on the ,C- W / sshd, item to

start+ stop+ disa le or edit other properties of the ser!ice+ as shown.

Open SSH port 22

/ow that your ser!er's running+ you ha!e to open a port on your firewall to let clients connectto it. f you're ehind a router7firewall+ here's a refresher on how to access a home ser!er

ehind it. 6emem er+ SSH runs on port 88+ so that's the port you want to forward.

9or fol#s running the regular Windows 9irewall+ add the SSH port to your list of exceptions.n Control anel+ clic# on Windows 9irewall+ and on the :xceptions ta + clic# ,&dd ort, and

enter ssh and port 88+ as shown.

/ow you're ready to log in.

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 3/30

Connect to your server

*here are se!eral ways to connect to your new SSH ser!er. -ou 2ust need the ser!er's address (internal for local networ#s+ external from out on the internet+ or perhaps yourdynamic $/S name.)

9rom the command line on the other machine+ type

ssh %i&address' -l userna(e

(*hat's a dash lower1case "+ not % efore username.) Once you're logged in+ you're sitting atthe command line of the remote machine with freedom to do whate!er you want at the

prompt.

9or a graphical user interface that transfers files+ download and install the excellent+ freeWinSC . Create a new connection to your ser!er+ as shown (replace ,localhost, with your

ser!er's address.) (Clic# to enlarge.)

Once you connect+ rowse the ser!er's files+ download and upload the documents you need.

9inally+ you can 2ust use a regular 9* client that supports S9* + or secure 9* . 9or example+*ransmit on the 4ac can S9* to your SSH ser!er and transfer files that way.

&nd you're all set5 -ou can connect to your SSH ser!er with WinSC on aWindows machine or 2ust at the Cygwin74ac *erminal command line as well.

Once your SSH ser!er is up and running+ you may not want to ha!e to remem er its address all the time. Chec# out this tutorial on how to assign a memora le domain name toyour home ser!er .

$aca ser!erul SSH(sau ruterul(/&*) in spatele caruita se afla daca nu are acces direct la) ;are adresa pu lica alocata dinamic atunci tre sa aple<i la un ser!iciu de $inamic$/S ; pt al

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 4/30

putea accesa din nternet cu acelasi nume chiar daca 1ul pu lic se schim a (ca doar nu ai deunde sa stii daca din diferite moti!e ruterul cu /&* si1a alocat alt de la S )

How to assign a domain name to your home web serverby Gina Trapani

On Wednesday we co!ered how to set up a we ser!er on your home computer . *oday we'llgo o!er how to assign a domain name to your home we ser!er li#e yourname.com 1 for aneasy1to1remem er+ oo#mar#a le+ professional we address.

Why do you want to assign a domain name to your home we ser!er= 4ay e you want tostart a log that you're going to host at home instead of uying a we hosting plan. 4ay eyou want to set up a personal home page at yourname.com for usiness purposes or so thatfol#s can find you on the we . 4ay e your home computer's address changes and you don'twant to ha!e to worry a out #eeping trac# to access your ser!er.

*his tutorial assumes you already ha!e a we ser!er running at home. f you don't+ read thisfirst to get caught up. &ll set= "et's get started.

& dynamic $/S ser!ice is a constantly updated data ase of addresses and domain names.$yn$/S.com is one pro!ider of this ser!ice. 9or free+ you can get one of the a!aila le$yn$/S domain names plus a custom su domain (li#e lifehac#er.getmyip.net)+ or for a smallfee you can register your own domain (li#e 2oesmith.com) and ha!e it resol!e to your home

computer we ser!er with $yn$/S.

Here's how

Step 1. Set up your DynDNS.co account.

6egister for a free account at $yn$/S . &gree to the site's terms+ and use a legitimate emailaddress to complete registration. Once in awhile+ $yn$/S will email you at that addressas#ing you to confirm that it continue your ser!ice.

"og into your new account. o to the ,4y Ser!ices, area on the left side. Under ,Host "e!elSer!ices, clic# ,&dd Host Ser!ices., *here+ clic# ,&dd $ynamic $/S Host., $yn$/S willautofill your address (if you're doing this from your home computer). Choose a domain andtype in a custom su domain+ which can e anything from lifehac#er.#ic#s1ass.org or 2ohn.is1a1gee#.com or gtrapani.dyndns.org+ li#e elow

Step 2. Set up your co puter to update DynDNS.

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 5/30

/ow that your computer is registered with $yn$/S+ each time your computer's addresschanges+ it has to let $yn$/S #now. *his can e done either with free updater client softwareor through your router.

f your computer is connected directly to the nternet+ download the $yn$/S updater clientfor 4ac or Windows here. nstall and enter your $yn$/S information so that your computercan update $yn$/S's data ase regularly.

f you are ehind a router+ you're in luc#. 4ost modern routers support dynamic $/Sser!ices. Here's a screenshot from my router's interface (yours will loo# different) for with$yn$/S settings

Step !. "ou#re done. $ive your new do ain a spin%

*ype your new domain name y entering it in your we rowser's address ar. t shouldresol!e to your home ser!er . 9rom here you can pu lici<e or oo#mar# your ser!er's newdomain name no matter how often your address changes.

Notes& $yn$/S has a few ad!anced options to consider.

• &'nable wildcard& lets you set up sub(subdomains. )or e%ample*blog.+ohnsmith.mine.nu can resolve to a weblog* where

+ukebo%.+ohnsmith.mine.nu can resolve to a music directory. ,irtual hostsmust be con-gured for your pache web server to display the right sitewhen addressed by di/erent subdomains.

• "et up an M$ record to handle email handling to your home server.

• Upgrade your account assign a custom domain name or your choosing toyour home server as well* for about 01 bucks a year. "ee more info onCustom 2N" .

.

Cygwin 3 howto

Cygwin is a Windows command line on steroids which runs tons of well(known*age(old* useful 4inu% Uni% commands. 5ut Cygwin* like much open sourcesoftware* seems scary* ine%plicable and nearly unusable until you6ve had somesort of & h(7 8& moment after hours of bleary(eyed digging through pages ofcryptic documentation. 4et me save you the work.

When installing9

/ow you're at the Select ac#ages screen+ which is the most confounding part of theinstallation for new ies. Why= -eah+ #now. How a out a pac#age called ,W*9,= What

you're loo#ing at here is a list of Unix programs (most of which loo# li#e alien hieroglyphs toWindows fol#s) all grouped together under certain categories. f you expand the ,>ase,category y clic#ing on the plus sign+ for instance+ you'll get a list that contains such mystery

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 6/30

meat items as , ash+, ,gaw#+, ,grep, and ,man., $on't let this list scare you off. f you'recurious+ you can toggle the ,?iew, utton to see the full list sans categories. don'trecommend doing this your first time. t 2ust might ma#e you @uestion e!ery computer s#illyou thought you had.

5asic Commands

/ow you're ready to roc# the command line li#e the Unix adass you're destined to e.$ou le1clic# on that new Cygwin icon to get yourself to a ,shell, prompt+ which will loo#li#e this (clic# to enlarge)

*he first few lines (,Copying s#eleton files...,+ etc) will only appear your first time. 9romhere on in+ when you launch Cygwin you'll get the standard greenyourusernameAyourcomputernameB greeting.

*he dollar sign is the Cygwin prompt where you can unleash all sorts of command line power.We're going to start with some !ery asic commands to get you going. *hese will feel andsound strange at first+ ut once you get used to them+ they'll e second nature.

9irst+ we want to see where in the filesystem we are. When Cygwin launches+ you start inyour home directory+ ut where's that= We'll use the Unix ,pwd, (print wor#ing directory)command to see

&enelo&e)scully * + &wd ho(e &enelo&ereat+ ut where is this ,7home7, directory= t's the Cygwin ase directory which you set

during installation 1 ,c DcygwinD, y default. So in my case+ 'm in the,c DcygwinDhomeDpenelopeD, directory. "et's ma#e sure. *o create an empty file in Unix+ usethe ,touch, command

&enelo&e)scully * + touch honey-i(-ho(e$t tn Windows :xpolorer+ if rowse to c DcygwinDhomeDpenelopeD+ see a file created there

called ,honey1im1home.txt., O#+ good. >ut what if ha!e to switch to another dis# dri!e+ li#e$ or H = Cygwin's a Unix emulator+ see+ and Unix doesn't #now 4icrosoft's dri!e letter+colon+ slash notation. So to change to (cd) the $ DdataD directory in Cygwin+ you'd do

&enelo&e)scully * + cd cygdri e d data &enelo&e)scully cygdri e d data+

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 7/30

*hat 7cygdri!e7d7 represents the $ dri!e in Cygwin. Update: Reader Bojan points out youcan just type cd d: to switch to the d drive! I stand corrected. Thanks, Bojan!

/otice a o!e that the path of the current directory is listed next to the userAcomputernotation. t was listed there efore as well+ with the tilde (B)+ which in Unix+ represents yourhome directory. So+ to change directory (cd) ac# to your home directory from anywhere inthe file tree+ you'd type

&enelo&e)scully cygdri e d data + cd * &enelo&e)scully * + &wdho(e &enelo&ef you'd li#e to see a listing (ls) of all the files in your home directory+ 2ust type ,ls,

&enelo&e)scully cygdri e d data + ls honey-i(-ho(e$t tStill with me= ood.

/ow+ Cygwin ena les you to do all sorts of neat text manipulation+ search+ and networ#ingfun+ ut 'm going to get into that in part two. 9or now want to tac#le the most fre@uentCygwin @uestion that's appeared in the "ifehac#er in ox

7ow the heck do # get this todo.t%t thing to work in Cygwin:

6ight clic# on this todo script .<ip file and sa!e it to the c DcygwinDhomeDyrnameD folder(where yrname is your username).

/ow+ in Windows :xplorer+ rowse to c DcygwinDhomeDyrnameD and un<ip the todo.<ip files.

Using a text editor li#e /otepad+ open the .todo file. :dit the Eth line to read*O$OF$ 60,c 7cygwin7home7username, ut replace username with your+ you guessed it+username.

9inally+ ma#e the todo script executa le y changing its mode (chmod). &t the Cygwincommand line in your home directory+ type

&enelo&e)scully * + ch(od .// todo$sh-ou're good to go todo.txt'ing now. *ype .7todo.sh and get the todo usage message+ as shown(truncated for space reasons.) Geep in mind that dot slash .7 efore the todo script tells

Cygwin+ ,Hey+ run this here executa le script.,

&enelo&e)scully * + $ todo 0sage: $ todo$sh CT!3"4 3PT!3"4$$$ctions: add 5T6!"G ! "778 T3 83 &:&ro9ect )conte t5

*o start adding to your todo list+ type

&enelo&e)scully * + $ todo$sWelcome ac#+ Windows1using command line lo!ers5 art and art of this introduction toCygwin co!ered installation+ asic Unix commands and other recipes for command linegoodness. *his third and final installment will tac#le adding pac#ages to your Cygwininstallation+ creating scripts from a set of commands+ and a few Cygwin and Unix resourceswhere you can learn more.

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 8/30

dding packages to Cygwin

&s discussed in part + the setup.exe file located at the Cygwin homepage not only does theinitial command shell install+ ut it can also e used to add pac#ages or programs to yourCygwin setup.

Say for instance you heard somewhere a out this great little command called wtf+ whichdefines acronyms for you at the shell prompt. So you fire up Cygwin and type wtf+ and get the, ash wtf command not found, in response. t's time to add the wtf pac#age to your install.

$ownload setup.exe and launch. When you get to the ,Select ac#ages screen+, toggle the!iew mode to either the ,9ull, or ,/ot nstalled, alpha etical list of pac#ages. When you getto the ,wtf, listing+ clic# on the ,S#ip, item in the ,/ew=, column to add it to the download.-ou might get the choice of a couple of !ersions of a program 1 li#e+ say+ . .E1I or . .E1J. usually go with the newest !ersion 2ust to e safe. *he chec# ox in the ,>in=, column will efilled in+ and that's what you want. $on't worry a out ,Src=, (source code) which can e leftunchec#ed+ as shown. (Clic# to enlarge.)

Complete the setup and relaunch Cygwin. /ow+ if you type wtf wtf+ you'll get

gina)scully * + wtf wtf wtf: ho or hat, de&ending on the conte t$0sually i(&lies a uestion (ar;$ The 5T<5 is really &adding, to (a;e this athree-letter acrony(, (eaning so(ething li;e 5&ray tell5$ lso the na(e ofa ery useful Cygwin &ac;age gina)scully * +

They6re pretty funny* those Cygwin WT) package developers. Use wtf to look upacronyms like wtf afaik* or wtf ymmv.

Networking Utilities

This section covers ,';< old hat for anyone e%perience with Uni%. 5ut assomeone who grew up in Windows* # remember the -rst time # logged into aremote server at the command line. # thought it was magic. !ne of Uni%6s

greatest strength are the powerful and secure networking utilities built into it.Using Cygwin* you can remotely login to another machine running an ""7 =secure

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 9/30

shell> server and control it* all from the comfort of your local command line. )orinstance* if your Mac at ?@0.?AB.0.? has &;emote 4ogin& enabled in the "haring

references* from the Cygwin prompt* you can use ssh to remotely control it* likesoD

gina)scully * + ssh gina)1=2$1>?$2$1@ Password: Aast login: Thu Bun 1/22: ?: @ 2@@> elco(e to 8arwinD a(elia:* gina+9rom there you can execute commands on your 4ac *erminal as usual from Cygwin. &nother useful networ#ing utility is scp+ which securely copies files from one machine to another+ li#eso

gina)scully * + sc& gina)1=2$1>?$2$1@:* todo$t t todo$t t Password:todo$t t 1@@E 2?@$@F s @@:@@ gina)scully * +*hat command gra ed the todo.txt in the home directory of the 4ac (or any SSH ser!errunning at the %K8.%IL.8.% address) and copied it to my local machine.

-ou can do all sorts of Unix networ#ing magic with Cygwin+ li#e running a Cygwin1 asedSSH ser!er on your C+ port forwarding and secure tunneling with ssh.

"cript common tasks

/ow that you #now how to craft Cygwin command line tas#s+ there may e multi1commandoperations you want to perform o!er and o!er 1 or automate . *his is when you should create ascript.

Say for instance+ you li#e to email your phone your shopping list from J text files todo.txt+grocerylist.com and giftideas.txt. Create a new text file called ,listtophone, and enter thefollowing into it

# Put all the stuff you ha e to Huy into a single te t file, toHuy$t tgre& )sho&&ing todo$t t ' toHuy$t t cat giftideas$t t grocerylist$t t ''toHuy$t t # Iend the list to your cell &hone ia e(ail for reference atthe store e(ail -t ///1212)telefli&$co( -s Jstuff to Huy todayJ % toHuy$t t# 8elete the te(&orary file r( toHuy$t t*he commented lines (that start with a 3) explain a little it a out what's going on. >asically+you're grepping out your Ashopping context items in todo.txt and all the items in giftideas.txt

and grocerylist.txt and dropping them into to uy.txt. *hen+ you're emailing your phoneto uy.txt. When that's done+ you clean up y deleting to uy.txt. 4a#e sure you replace theMMM8%8%8Ateleflip.com your phone or $&'s email address.

Sa!e your ,listtophone, file+ and ma#e it an executa le script. *o do so+ use the chmod(change permissions) command

gina)scully * + ch(od .// listto&hone9rom there on in+ 2ust efore you head out to the store+ run your script from the directorywhere it li!es+ li#e so

gina)scully * + $ listto&hone

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 10/30

See also pre!iously1posted article+ 4astering wget + for some neat scripta le wget recipes thatwor# well at the Cygwin prompt.

UNIX Tutorial Three

3.1 Redirection4ost processes initiated y U/ N commands write to the standard output (that is+ they writeto the terminal screen)+ and many ta#e their input from the standard input (that is+ they read itfrom the #ey oard). *here is also the standard error+ where processes write their errormessages+ y default+ to the terminal screen.

We ha!e already seen one use of the cat command to write the contents of a file to the screen.

/ow type cat without specifing a file to read

cat

*hen type a few words on the #ey oard and press the P Return Q #ey.

9inally hold the P Ctrl Q #ey down and press PdQ (written as 'D for short) to end the input.

What has happened=

f you run the cat command without specifing a file to read+ it reads the standard input (the#ey oard)+ and on recei!ing the 'end of file' ( 'D )+ copies it to the standard output (the screen).

n U/ N+ we can redirect oth the input and the output of commands.

3.2 Redirecting the ut!utWe use the R sym ol to redirect the output of a command. 9or example+ to create a file calledlist1 containing a list of fruit+ type

cat R list%

*hen type in the names of some fruit. ress P Return Q after each one.

pear ananaapple

$ Tthis means press PCtrlQ and PdQ to stop

What happens is the cat command reads the standard input (the #ey oard) and the R redirectsthe output+ which normally goes to the screen+ into a file called list1

*o read the contents of the file+ type

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 11/30

cat list%

"#ercise 3aUsing the a o!e method+ create another file called list2 containing the following fruit orange+

plum+ mango+ grapefruit. 6ead the contents of list2

3.2.1 $!!ending to a %le*he form RR appends standard output to a file. So to add more items to the file list1 + type

cat RR list%

*hen type in the names of more fruit

peachgrapeorange

$ (Control $ to stop)

*o read the contents of the file+ type

cat list%

-ou should now ha!e two files. One contains six fruit+ the other contains four fruit.

We will now use the cat command to 2oin (concatenate) list1 and list2 into a new file calledbiglist . *ype

cat list% list8 R iglist

What this is doing is reading the contents of list1 and list2 in turn+ then outputing the text tothe file biglist

*o read the contents of the new file+ type

cat iglist

3.3 Redirecting the In!utWe use the V sym ol to redirect the input of a command.

*he command sort alpha etically or numerically sorts a list. *ype

sort

*hen type in the names of some animals. ress P6eturnQ after each one.

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 12/30

dogcat

irdape

$ (control d to stop)

*he output will e

ape irdcatdog

Using V you can redirect the input to come from a file rather than the #ey oard. 9or example+

to sort the list of fruit+ type

sort V iglist

and the sorted list will e output to the screen.

*o output the sorted list to a file+ type+

sort V iglist R slist

Use cat to read the contents of the file slist

3.& 'i!es*o see who is on the system with you+ type

who

One method to get a sorted list of names is to type+

who R names.txt

sort V names.txt

*his is a it slow and you ha!e to remem er to remo!e the temporary file called names whenyou ha!e finished. What you really want to do is connect the output of the who commanddirectly to the input of the sort command. *his is exactly what pipes do. *he sym ol for a pipeis the !ertical ar

9or example+ typing

who sort

will gi!e the same result as a o!e+ ut @uic#er and cleaner.

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 13/30

*o find out how many users are logged on+ type

who wc 1l

"#ercise 3bUsing pipes+ display all lines of list1 and list2 containing the letter 'p'+ and sort the result.

&nswer a!aila le here

(ummary

)ommand *eaning

command E fle redirect standard output to a -le

command EE fle append standard output to a -le

command F fle redirect standard input from a -le

command1 command2

pipe the output of command? to the input ofcommand0

cat fle1 fle2 E fle0 concatenate -le? and -le0 to -le

sort sort data

who list users currently logged in

+.1 ,ile system security -access rightsn your uni(stuff directory+ type

ls 1l (l for long listing5)

-ou will see that you now get lots of details a out the contents of your directory+ similar to theexample elow.

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 14/30

:ach file (and directory) has associated access rights+ which may e found y typing ls 1l.

&lso+ ls 1lg gi!es additional information as to which group owns the file ( engKM in thefollowing example)

1rwxrw1r11 % eeM%a engKM 8EM Sept8K %% M8 file%

n the left1hand column is a % sym ol string consisting of the sym ols d+ r+ w+ x+ 1+ and+occasionally+ s or S. f d is present+ it will e at the left hand end of the string+ and indicates adirectory otherwise 1 will e the starting sym ol of the string.

*he K remaining sym ols indicate the permissions+ or access rights+ and are ta#en as three

groups of J.

• The left group of H gives the -le permissions for the user that owns the -le=or directory> =ee1?ab in the above e%ample>I

• the middle group gives the permissions for the group of people to whomthe -le =or directory> belongs =eebeng@1 in the above e%ample>I

• the rightmost group gives the permissions for all others.

*he sym ols r+ w+ etc.+ ha!e slightly different meanings depending on whether they refer to asimple file or to a directory.

$ccess rights on %les.

• r =or (>* indicates read permission =or otherwise>* that is* the presence orabsence of permission to read and copy the -le

• w =or (>* indicates write permission =or otherwise>* that is* the permission=or otherwise> to change a -le

• % =or (>* indicates e%ecution permission =or otherwise>* that is* thepermission to e%ecute a -le* where appropriate

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 15/30

$ccess rights on directories.

• r allows users to list -les in the directoryI

• w means that users may delete -les from the directory or move -les into

itI• % means the right to access -les in the directory. This implies that you may

read -les in the directory provided you have read permission on theindividual -les.

So+ in order to read a file+ you must ha!e execute permission on the directory containing thatfile+ and hence on any directory containing that directory as a su directory+ and so on+ up thetree.

(ome e#am!les

(rw%rw%rw% a -le that everyone can read* write and e%ecute =and delete>.

(rw(((((((a -le that only the owner can read and write ( no(one elsecan read or write and no(one has e%ecution rights =e.g. yourmailbo% -le>.

+.2 )hanging access rights

chmod -changing a %le modeOnly the owner of a file can use chmod to change the permissions of a file. *he options ofchmod are as follows

(ymbol *eaning

u user

g group

o other

a all

r read

w write =and delete>

% e%ecute =and access directory>

J add permission

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 16/30

( take away permission

9or example+ to remo!e read write and execute permissions on the file biglist for the groupand others+ type

chmod go1rwx iglist

*his will lea!e the other permissions unaffected.

*o gi!e read and write permissions on the file biglist to all+

chmod aXrw iglist

"#ercise +a

*ry changing access permissions on the file science.t(t and on the directory bac)ups

Use ls 1l to chec# that the permissions ha!e changed.

+.3 'rocesses and /obs& process is an executing program identified y a uni@ue $ (process identifier). *o seeinformation a out your processes+ with their associated $ and status+ type

ps

& process may e in the foreground+ in the ac#ground+ or e suspended. n general the shelldoes not return the U/ N prompt until the current process has finished executing.

Some processes ta#e a long time to run and hold up the terminal. >ac#grounding a long process has the effect that the U/ N prompt is returned immediately+ and other tas#s can ecarried out while the original process continues executing.

Running bac0ground !rocesses*o ac#ground a process+ type an * at the end of the command line. 9or example+ thecommand sleep waits a gi!en num er of seconds efore continuing. *ype

sleep %

*his will wait % seconds efore returning the command prompt . Until the command prompt is returned+ you can do nothing except wait.

*o run sleep in the ac#ground+ type

sleep % Y

P%Q I8MK

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 17/30

*he * runs the 2o in the ac#ground and returns the prompt straight away+ allowing you dorun other programs while waiting for that one to finish.

*he first line in the a o!e example is typed in y the userZ the next line+ indicating 2o num er and $+ is returned y the machine. *he user is e notified of a 2o num er (num ered from%) enclosed in s@uare rac#ets+ together with a $ and is notified when a ac#ground processis finished. >ac#grounding is useful for 2o s which will ta#e a long time to complete.

ac0grounding a current oreground !rocess&t the prompt+ type

sleep %

-ou can suspend the process running in the foreground y typing '+ + i.e.hold down the PCtrl Q

#ey and type P , Q. *hen to put it in the ac#ground+ type

g

/ote do not ac#ground programs that re@uire user interaction e.g. !i

+.& isting sus!ended and bac0ground !rocessesWhen a process is running+ ac#grounded or suspended+ it will e entered onto a list alongwith a 2o num er. *o examine this list+ type

2o s

&n example of a 2o list could e

P%Q Suspended sleep %P8Q 6unning netscapePJQ 6unning matla

*o restart (foreground) a suspended processes+ type

fg jobnumber

9or example+ to restart sleep % + type

fg %

*yping fg with no 2o num er foregrounds the last suspended process.

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 18/30

+.+ 4illing a !rocess

0ill -terminate or signal a !rocesst is sometimes necessary to #ill a process (for example+ when an executing program is in an

infinite loop)

*o #ill a 2o running in the foreground+ type 'C (control c). 9or example+ run

sleep %C

*o #ill a suspended or ac#ground process+ type

#ill jobnumber

9or example+ run

sleep % Y 2o s

f it is 2o num er E+ type

#ill E

*o chec# whether this has wor#ed+ examine the 2o list again to see if the process has eenremo!ed.

!s -!rocess status&lternati!ely+ processes can e #illed y finding their process num ers ( $s) and using #ill

I "number

sleep % Y ps

$ ** S * 4: CO44&/$8 [[ pts7M S M sleep %8%MIJ pts7M * netscape8%L[J pts7M S 8M nedit

*o #ill off the process sleep 1--- + type

#ill 8 [[

and then type ps again to see if it has een remo!ed from the list.

f a process refuses to e #illed+ uses the / option+ i.e. type

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 19/30

#ill 1K 8 [[

/ote t is not possi le to #ill off other users' processes 555

(ummary

)ommand *eaning

ls (lag list access rights for all -les

chmod K options L fle change access rights for named -le

command run command in background

C kill the +ob running in the foreground

O suspend the +ob running in the foreground

bg background the suspended +ob

+obs list current +obs

fg P? foreground +ob number ?

kill P? kill +ob number ?

ps list current processes

kill 0A?10 kill process number 0A?10

ther use ul UNIX commands

5uota&ll students are allocated a certain amount of dis# space on the file system for their personalfiles+ usually a out % 4 . f you go o!er your @uota+ you are gi!en [ days to remo!e excessfiles.

*o chec# your current @uota and how much of it you ha!e used+ type

@uota 1!

d

*he df command reports on the space left on the file system. 9or example+ to find out howmuch space is left on the fileser!er+ type

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 20/30

df .

du*he du command outputs the num er of #ilo yes used y each su directory. Useful if youha!e gone o!er @uota and you want to find out which directory has the most files. n yourhome1directory+ type

du 1s \

*he s flag will display only a summary (total si<e) and the \ means all files and directories.

g6i!*his reduces the si<e of a file+ thus freeing !alua le dis# space. 9or example+ type

ls 1l science.txt

and note the si<e of the file using ls 1l . *hen to compress science.txt+ type

g<ip science.txt

*his will compress the file and place it in a file called science.t(t.g,

*o see the change in si<e+ type ls 1l again.

*o expand the file+ use the gun<ip command.

gun<ip science.txt.g<

6cat<cat will read g<ipped files without needing to uncompress them first.

<cat science.txt.g<

f the text scrolls too fast for you+ pipe the output though less .

<cat science.txt.g< less

%lefile classifies the named files according to the type of data they contain+ for example ascii(text)+ pictures+ compressed data+ etc.. *o report on all files in your home directory+ type

file \

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 21/30

di7 *his command compares the contents of two files and displays the differences. Suppose youha!e a file called file1 and you edit some part of it and sa!e it as file2 . *o see the differencestype

diff file% file8

"ines eginning with a 0 denotes file%+ while lines eginning with a denotes file8.

%nd*his searches through the directories for files and directories with a gi!en name+ date+ si<e+ orany other attri ute you care to specify. t is a simple command ut with many options 1 youcan read the manual y typing man find.

*o search for all fies with the extention .t(t + starting at the current directory (.) and wor#ingthrough all su 1directories+ then printing the name of the file to the screen+ type

find . 1name ,\.txt, 1print

*o find files o!er %4 in si<e+ and display the result as a long listing+ type

find . 1si<e X%4 1ls

history

*he C shell #eeps an ordered list of all the commands that you ha!e entered. :ach commandis gi!en a num er according to the order it was entered.

history (show command history list)

f you are using the C shell+ you can use the exclamation character ( %) to recall commandseasily.

55 (recall last command)

51J (recall third most recent command)

5M (recall Mth command in list)

5grep (recall last command starting with grep)

-ou can increase the si<e of the history uffer y typing

set history0%

#nstalare softwareQpachete py Uni%

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 22/30

8.1 )om!iling UNIX so tware !ac0agesWe ha!e many pu lic domain and commercial software pac#ages installed on our systems+which are a!aila le to all users. Howe!er+ students are allowed to download and install smallsoftware pac#ages in their own home directory+ software usually only useful to them

personally.

*here are a num er of steps needed to install the software.

• 4ocate and download the source code =which is usually compressed>

• Unpack the source code

• Compile the code

• #nstall the resulting e%ecutable

• "et paths to the installation directory

Of the a o!e steps+ pro a ly the most difficult is the compilation stage.

)om!iling (ource )ode&ll high1le!el language code must e con!erted into a form the computer understands. 9orexample+ C language source code is con!erted into a lower1le!el language called assem lylanguage. *he assem ly language code made y the pre!ious stage is then con!erted intoo 2ect code which are fragments of code which the computer understands directly. *he final

stage in compiling a program in!ol!es lin#ing the o 2ect code to code li raries which containcertain uilt1in functions. *his final stage produces an executa le program.

*o do all these steps y hand is complicated and eyond the capa ility of the ordinary user. &num er of utilities and tools ha!e een de!eloped for programmers and end1users to simplifythese steps.

ma0e and the *a0e%le*he ma#e command allows programmers to manage large programs or groups of programs. taids in de!eloping large programs y #eeping trac# of which portions of the entire programha!e een changed+ compiling only those parts of the program which ha!e changed since thelast compile.

*he ma#e program gets its set of compile rules from a text file called a)efile which residesin the same directory as the source files. t contains information on how to compile thesoftware+ e.g. the optimisation le!el+ whether to include de ugging info in the executa le. talso contains information on where to install the finished compiled inaries (executa les)+manual pages+ data files+ dependent li rary files+ configuration files+ etc.

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 23/30

Some pac#ages re@uire you to edit the 4a#efile y hand to set the final installation directoryand any other parameters. Howe!er+ many pac#ages are now eing distri uted with the /Uconfigure utility.

con%gure&s the num er of U/ N !ariants increased+ it ecame harder to write programs which couldrun on all !ariants. $e!elopers fre@uently did not ha!e access to e!ery system+ and thecharacteristics of some systems changed from !ersion to !ersion. *he /U configure and

uild system simplifies the uilding of programs distri uted as source code. &ll programs are uilt using a simple+ standardised+ two step process. *he program uilder need not install anyspecial tools in order to uild the program.

*he configure shell script attempts to guess correct !alues for !arious system1dependent!aria les used during compilation. t uses those !alues to create a a)efile in each directory

of the pac#age.

*he simplest way to compile a pac#age is

?. cd to the directory containing the package6s source code.

0. Type .Qcon-gure to con-gure the package for your system.

H. Type make to compile the package.

R. !ptionally* type make check to run any self(tests that come with thepackage.

1. Type make install to install the programs and any data -les anddocumentation.

A. !ptionally* type make clean to remove the program binaries and ob+ect-les from the source code directory

*he configure utility supports a wide !ariety of options. -ou can usually use the 3elp optionto get a list of interesting options for a particular configure script.

*he only generic options you are li#ely to use are the prefi( and e(ec prefi( options.*hese options are used to specify the installation directories.

*he directory named y the prefi( option will hold machine independent files such asdocumentation+ data and configuration files.

*he directory named y the e(ec prefi( option+ (which is normally a su directory of theprefi( directory)+ will hold machine dependent files such as executa les.

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 24/30

8.2 9ownloading source code9or this example+ we will download a piece of free software that con!erts etween differentunits of measurements.

9irst create a download directory

m#dir download

$ownload the software here and sa!e it to your new download directory.

8.3 "#tracting the source codeo into your download directory and list the contents.

cd download

ls 1l

&s you can see+ the filename ends in tar.g<. *he tar command turns se!eral files anddirectories into one single tar file. *his is then compressed using the g<ip command (to createa tar.g< file).

9irst un<ip the file using the gun<ip command. *his will create a .tar file.

gun<ip units1%.[E.tar.g<

*hen extract the contents of the tar file.

tar 1x!f units1%.[E.tar

&gain+ list the contents of the download directory+ then go to the units 1.45 su 1directory.

cd units1%.[E

8.& )on%guring and creating the *a0e%le*he first thing to do is carefully read the R67D 6 and INS8799 text files (use the lesscommand). *hese contain important information on how to compile and run the software.

*he units pac#age uses the /U configure system to compile the source code. We will needto specify the installation directory+ since the default will e the main system area which youwill not ha!e write permissions for. We need to create an install directory in your homedirectory.

m#dir B7units%[E

*hen run the configure utility setting the installation path to this.

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 25/30

.7configure 11prefix0 HO4:7units%[E

/O*: *he :HO 6 !aria le is an example of an en!ironment !aria le. *he !alue of:HO 6 is the path to your home directory. ]ust type

echo HO4:

to show the contents of this !aria le. We will learn more a out en!ironment !aria les in alater chapter.

f configure has run correctly+ it will ha!e created a 4a#efile with all necessary options. -oucan !iew the 4a#efile if you wish (use the less command)+ ut do not edit the contents of this.

8.+ uilding the !ac0age

/ow you can go ahead and uild the pac#age y running the ma#e command.

ma#e

&fter a minute or two (depending on the speed of the computer)+ the executa les will ecreated. -ou can chec# to see e!erything compiled successfully y typing

ma#e chec#

f e!erything is o#ay+ you can now install the pac#age.

ma#e install

*his will install the files into the ;<units145 directory you created earlier.

8.: Running the so tware-ou are now ready to run the software (assuming e!erything wor#ed).

cd B7units%[E

f you list the contents of the units directory+ you will see a num er of su directories.

bin The binary e%ecutables

info GNU info formatted documentation

man Man pages

share "hared data -les

*o run the program+ change to the bin directory and type

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 26/30

.7units

&s an example+ con!ert I feet to metres.

-ou ha!e I feet-ou want metres

\ %.L8LL

f you get the answer %.L8LL+ congratulations+ it wor#ed.

*o !iew what units it can con!ert etween+ !iew the data file in the share directory (the list is@uite comprehensi!e).

*o read the full documentation+ change into the info directory and type

info 11file0units.info

8.8 (tri!!ing unnecessary codeWhen a piece of software is eing de!eloped+ it is useful for the programmer to includede ugging information into the resulting executa le. *his way+ if there are pro lemsencountered when running the executa le+ the programmer can load the executa le into ade ugging software pac#age and trac# down any software ugs.

*his is useful for the programmer+ ut unnecessary for the user. We can assume that the pac#age+ once finished and a!aila le for download has already een tested and de ugged.Howe!er+ when we compiled the software a o!e+ de ugging information was still compiledinto the final executa le. Since it is unli#ey that we are going to need this de ugginginformation+ we can strip it out of the final executa le. One of the ad!antages of this is amuch smaller executa le+ which should run slightly faster.

What we are going to do is loo# at the efore and after si<e of the inary file. 9irst change intothe bin directory of the units installation directory.

cd B7units%[E7 in ls 1l

&s you can see+ the file is o!er % # ytes in si<e. -ou can get more information on the typeof file y using the file command.

file units

units :"9 J81 it "S> executa le+ ntel L JLI+ !ersion %+ dynamically lin#ed (uses sharedli s)+ not stripped

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 27/30

*o strip all the de ug and line num ering information out of the inary file+ use the stripcommand

strip units ls 1l

&s you can see+ the file is now JI # ytes 1 a third of its original si<e. *wo thirds of the inaryfile was de ug code555

Chec# the file information again.

file units

units :"9 J81 it "S> executa le+ ntel L JLI+ !ersion %+ dynamically lin#ed (uses shared

li s)+ stripped

Sometimes you can use the ma#e command to install pre1stripped copies of all the inary fileswhen you install the pac#age. nstead of typing ma#e install+ simply type ma#e install1strip

;.1 UNIX <ariables?aria les are a way of passing information from the shell to programs when you run them.

rograms loo# ,in the en!ironment, for particular !aria les and if they are found will use the!alues stored. Some are set y the system+ others y you+ yet others y the shell+ or any

program that loads another program.

Standard U/ N !aria les are split into two categories+ en!ironment !aria les and shell!aria les. n road terms+ shell !aria les apply only to the current instance of the shell and areused to set short1term wor#ing conditionsZ en!ironment !aria les ha!e a farther reachingsignificance+ and those set at login are !alid for the duration of the session. >y con!ention+en!ironment !aria les ha!e U :6 C&S: and shell !aria les ha!e lower case names.

;.2 "nvironment <ariables&n example of an en!ironment !aria le is the OS*- : !aria le. *he !alue of this is the

current operating system you are using. *ype

echo OS*- :

4ore examples of en!ironment !aria les are

• U"'; =your login name>

• 7!M' =the path name of your home directory>

• 7!"T =the name of the computer you are using>

• ;C7 =the architecture of the computers processor>

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 28/30

• 2#" 4 < =the name of the computer screen to display $ windows>

• ;#NT'; =the default printer to send print +obs>

• T7 =the directories the shell should search to -nd a command>

,inding out the current values o these variables.:/? 6O/4:/* !aria les are set using the seten! command+ displayed using the printen! or en! commands+ and unset using the unseten! command.

*o show all !alues of these !aria les+ type

printen! less

;.3 (hell <ariables

&n example of a shell !aria le is the history !aria le. *he !alue of this is how many shellcommands to sa!e+ allow the user to scroll ac# through all the commands they ha!e

pre!iously entered. *ype

echo history

4ore examples of shell !aria les are

• cwd =your current working directory>

• home =the path name of your home directory>

• path =the directories the shell should search to -nd a command>

• prompt =the te%t string used to prompt for interactive commands shell yourlogin shell>

,inding out the current values o these variables.SH:"" !aria les are oth set and displayed using the set command. *hey can e unset yusing the unset command.

*o show all !alues of these !aria les+ type

set less

(o what is the di7erence between '$TH and !ath =n general+ en!ironment and shell !aria les that ha!e the same name (apart from the case) are

distinct and independent+ except for possi ly ha!ing the same initial !alues. *here are+howe!er+ exceptions.

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 29/30

:ach time the shell !aria les home+ user and term are changed+ the correspondingen!ironment !aria les HO4:+ US:6 and *:64 recei!e the same !alues. Howe!er+ alteringthe en!ironment !aria les has no effect on the corresponding shell !aria les.

&*H and path specify directories to search for commands and programs. >oth !aria lesalways represent the same directory list+ and altering either automatically causes the other to

e changed.

;.& Using and setting variables:ach time you login to a U/ N host+ the system loo#s in your home directory for initialisationfiles. nformation in these files is used to set up your wor#ing en!ironment. *he C and *Cshells uses two files called .login and .cshrc (note that oth file names egin with a dot).

&t login the C shell first reads .cs3rc followed y .login

.login is to set conditions which will apply to the whole session and to perform actions thatare rele!ant only at login.

.cs3rc is used to set conditions and perform actions specific to the shell and to eachin!ocation of it.

*he guidelines are to set :/? 6O/4:/* !aria les in the .login file and SH:"" !aria les inthe .cs3rc file.

=7RNIN$& /:?:6 put commands that run graphical displays (e.g. a we rowser) inyour .cshrc or .login file.

;.+ (etting shell variables in the .cshrc %le9or example+ to change the num er of shell commands sa!ed in the history list+ you need toset the shell !aria le history. t is set to % y default+ ut you can increase this if you wish.

set history 0 8

Chec# this has wor#ed y typing

echo history

Howe!er+ this has only set the !aria le for the lifetime of the current shell. f you open a newxterm window+ it will only ha!e the default history !alue set. *o :64&/:/*"- set the!alue of history+ you will need to add the set command to the .cshrc file.

9irst open the .cs3rc file in a text editor. &n easy+ user1friendly editor to use is nedit.

nedit B7.cshrc

7/24/2019 SSH Server Cygwin - UNIX Beginers Tutorial

http://slidepdf.com/reader/full/ssh-server-cygwin-unix-beginers-tutorial 30/30

&dd the following line &9*:6 the list of other commands.

set history 0 8

Sa!e the file and force the shell to reread its .cshrc file uy using the shell source command.

source .cshrc

Chec# this has wor#ed y typing

echo history

;.: (etting the !athWhen you type a command+ your path (or &*H) !aria le defines in which directories theshell will loo# to find the command you typed. f the system returns a message saying,command Command not found,+ this indicates that either the command doesn't exist at allon the system or it is simply not in your path.

9or example+ to run units+ you either need to directly specify the units path(;<units145<bin<units )+ or you need to ha!e the directory ;<units145<bin in your path.

-ou can add it to the end of your existing path (the :pat3 represents this) y issuing thecommand

set path 0 ( path B7units%[E7 in)

*est that this wor#ed y trying to run units in any directory other that where units is actuallylocated.

cd units

*o add this path :64&/:/*"-+ add the following line to your .cshrc &9*:6 the list ofother commands.

set path 0 ( path B7units%[E7 in)