Академический Документы
Профессиональный Документы
Культура Документы
Introduction to UNIX
July 28, 2001
Anup Gangwar
IIT Delhi
Overview
Prerequisites and goals of this course Differences between UNIX and Windows Overview of unices Basic UNIX commands and utilities Lunch Break File editors in UNIX Programming and Shell Scripting Document formatting using UNIX References and further study Thank You
IIT Delhi
IIT Delhi
IIT Delhi
Overview of Unices-1
The ?original? UNIX The AT&T SVR and BSD Others: HP-UX, Solaris, Linux, AIX, IRIX etc. Why are there so many unices? Vendor Wars! How do I understand all of them? POSIX! Tips:
Learn the common set of commands for all the unices Linux utilities will contain enhancements not found in others Try to clear trivial doubts like command syntax yourself
IIT Delhi
Overview of Unices-2
HP-UX
Processors: HP PA-RISC and Intel Itanium Vendors: HP Markets: High End Servers and Workstations
Solaris/SunOS
Processors: Sun Ultra Sparc Vendors: Sun Microsystems Markets: All ranges of Servers and Workstations
IIT Delhi
Overview of Unices-3
Linux/GNU Systems
Processors: Intel 386 and up, Sun Ultra Sparc, IBM PowerPC etc. Vendors: Free/GNU GPL Markets: Low End Servers and Workstations
IIT Delhi
Overview of Unices-4
IRIX
Processors: MIPS Vendors: SGI (Silicon Graphics International) Markets: High End Graphics Servers and Workstations
Others
BeOS, FreeBSD etc. RTOSs: PSoS, QNX, RTEMS, ?RTLinux? etc.
IIT Delhi
What we have
Philips VLSI Design Lab
HP Server running HP-UX Sun Workstation Linux Workstations
VDTT Lab
Linux Workstations Windows NT Workstations
IIT Delhi
Tips:
UNIX doesnt have a recycle bin! Try not to make the mistake of rm -rf * command Embedded Systems Group IIT Delhi
IIT Delhi
dot-rhosts (.rhosts), xon Moving files between computers: FTP (?anonymous? FTP login) Tips:
Graphics performance suffers in remote graphics execution xhost+ is the worst thing to do! Ncftp is a better ftp client than the vanilla default UNIX ftp
IIT Delhi
Taking backups
Tarring, zipping, gzipping and compressing Comparison with winzip and common filename extensions
Tips:
Do not issue the command tar -cvf <file-name> * Acroread just might be a better program to open pdf files Embedded Systems Group IIT Delhi
Working with files with special characters in names The file utility finger, who and rwho ps and kill Mail and mail clients, netscape, pine, emacs and mail startx, .Xclients and .xinitrc files
Tips:
Instead of asking someone try man -k It is a good practice to stick to one shell (csh is available on all)
IIT Delhi
Lunch Break
IIT Delhi
Editors in UNIX-1
What all is available, Vi, Emacs, Pico, Joe?, Nedit? Vi: The king of all editors? Tutorial?
Why learn vi? Getting in and out? Basic keys for editing
Moving around, deleting, joining lines Repeating commands Search and replace
Tips:
Vim is not Vi Learn the keypad scroll key combinations instead of arrow keys Vi is fast, try to make the best use of its capabilities
IIT Delhi
Editors in UNIX-2
Emacs: Much more than an editor?
Why learn Emacs? History, Tutorial Getting in and out? Basic keys for editing
Moving around, deleting a line Search and replace Formatted text, postscript spooling mail in emacs
IIT Delhi
Editors in UNIX-3
Pico: Is there really a need?
Pico and Pine Editor Keys
Joe?, Nedit?
Keys similar to Norton Editor Nedit has some features similar to Emacs
Tips:
Dont fall for Pico or Nedit Learn Vi and Emacs if you really want to get into UNIX In the end it is a matter of choice
IIT Delhi
Programming on UNIX-1
Is programming on UNIX tough? What all is available? Concept of IDE and differences with TurboC++ Compilers, Linkers, Debuggers and front-ends Managing big projects: make and comparison with TC project file Example of a simple makefile GUI development on UNIX Java Tips:
UNIX is a programmers paradise Embedded Systems Group IIT Delhi
Programming on UNIX-2
Gcc, The GNU C/C++ compiler
Simplest possible way to use: gcc <file-name> Common options
output filename: -o compile only: -c Warnings: -Wall optimizations: -O{1,2,3,4} Debug: -g Linking: -l<library-name>
Tips:
Not every UNIX systems will have gcc Turning on optimization makes the compilation slow Debugging and optimizing donot go together
IIT Delhi
Programming on UNIX-3
Ld, The Linker
What exactly are libraries? Shared and static libraries Is there a need to call Ld explicitly? Passing options to Ld from gcc
The -l option The -L option The LD_LIBRARY_PATH environment variable The LD_RUN_PATH environment variable
Tips:
Always check the Ld on the system, HP-UX doesnt use GNU Ld Environment variables are different with non GNU Ld
IIT Delhi
Programming on UNIX-4
Gdb, The GNU C/C++ debugger
Why is a debugger needed? gdb and ?core? File Common commands
list run, break, resume backtrace and where
Tips:
Using gdb directly might be tedious Try the various front-ends to gdb: emacs, xxgdb, mxgdb etc. Not every system will have gdb, you just might have to use ?dbx?
IIT Delhi
Programming on UNIX-5
Gmake or GNU make What is the need for a Makefile?
Dependencies Targets in a makefile Patterns in makefile Automatic variables in a makefile Pattern substitution Common target names: all, clean, docs
Tips:
Never forget the TAB Make is language independent! Embedded Systems Group IIT Delhi
Programming on UNIX-6
Example of a makefile
CC=gcc COPTS= -g -Wall TARGET=run.x SRCS=hello.c junk.c OBJS=$(SRCS:.c=.o) all:$(OBJS) $(CC) $(COPTS) $(OBJS) -o $(TARGET) clean: rm -f $(OBJS) core %.o:%.c $(CC) $(COPTS) -c $<
IIT Delhi
Programming on UNIX-7
GUI in UNIX?
Differences with TurboC++ Vanilla X windows programming, why not? TCL/Tk Widget libraries
Motif GTK QT, etc.
Tips:
Always provide a command line interface to your programs Using a GUI is slow
IIT Delhi
Programming on UNIX-8
Java
What is really different with the windows version? Is Jfc, Java2D, Java3D available? IDEs for Java over UNIX?
Tips:
Dont try to use a %.class dependency with make If you run Java from a server, graphics would be slow
IIT Delhi
Tips:
Perl just might be a better option Dont forget ?sed? and ?awk?
IIT Delhi
IIT Delhi
IIT Delhi
Before wrapping up
IIT Delhi
Wrapping up
Self help is the best help!
The UNIX man pages. ?Manual sections? Using man, whatis etc. Experiment. You can never kill the system.
Links
http://www.gnu.org, for GNU tools and manuals http://sunsite.unc.edu, worlds largest collection of free software http://upavan.cse.iitd.ernet.in, Philips Lab. internal page http://poorvi.cse.iitd.ernet.in/local, Intel cluster archives
Books
The UNIX programming environment, Kernighan & Pike Embedded Systems Group IIT Delhi
Thank You
IIT Delhi