Title: Orientation for fresh VDTT Students Introduction to UNIX
1Orientation for fresh VDTT StudentsIntroduction
to UNIX
Anup Gangwar
2Overview
- 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
3Prerequisites and Goals
- What you should know
- Basic familiarity with computers
- Working Knowledge of atleast one operating system
- A will to learn
- What you will know
- This is not a complete UNIX tutorial
- Dont try to learn the whole UNIX in one day
- How to do the most common set of tasks with UNIX
- Self-Help is the best help
- Pointers for further information
4Differences UNIX and Windows
- The UNIX and Windows philosophies
- Client-Server model of Computation
- Multi-User and Multi-Tasking. Login?
- Concept of the Kernel and User Shell
- Concept of file ownership and groups
- GUI on UNIX and X windows
- Tips
- UNIX is the most used OS in scientific and
industrial community - Instead of avoiding UNIX take it heads on
- Learning UNIX now will help you save precious
time later on
5Overview of Unices-1
- The ?original? UNIX
- The ATT 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
6Overview 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
7Overview 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
- AIX (Advanced UNIX)
- Processors IBM Power PC
- Vendors IBM
- Markets All ranges of Servers and Workstations
8Overview 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.
9What we have
- Philips VLSI Design Lab
- HP Server running HP-UX
- Sun Workstation
- Linux Workstations
- VDTT Lab
- Linux Workstations
- Windows NT Workstations
- New VLSI Lab
- Sun Workstations
- Windows NT Workstations
10Basic UNIX Commands and Utilities-1
- Files and Directories
- File Types Windows and UNIX
- File and Directory creation (Editors, mkdir, ln
etc.) - Listing contents of a directory (ls)
- File and Directory deletion (rmdir, rm etc.)
- File and Directory permissions (chmod)
- File and Directory ownership (chown, chgrp)
- Organizing your work in directories (mv)
- Tips
- UNIX doesnt have a recycle bin!
- Try not to make the mistake of rm -rf command
11Basic UNIX Commands and Utilities-2
- Managing your account
- What is meant by managing your account?
- Concept of setup files
- Why are there so many different Shells?
- Environment variables
- .bashrc and .cshrc files
- Customizing your environment with .bashrc and
.cshrc files - Example The TERM environment variable and stty
- Tips
- Try an environment variable on command-line first
- Always set the PATH variable properly
12Basic UNIX Commands and Utilities-3
- Remote process execution
- Why do we need remote process execution?
- Telnet and rlogin
- Remote execution of graphics programs
- X-Security, granting permissions and colormap
- The DISPLAY environment variable
- 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
13Basic UNIX Commands and Utilities-4
- Taking printouts
- Concept of network and local printers
- Printer languages Postscript and PCL
- GhostView and Acroread programs
- Spooling, Deleting and Checking a printer job
- Duplex printing and mpage
- Taking backups
- Tarring, zipping, gzipping and compressing
- Comparison with winzip and common filename
extensions - Tips
- Do not issue the command tar -cvf ltfile-namegt
- Acroread just might be a better program to open
pdf files
14Basic UNIX Commands and Utilities-5
- Miscellaneous stuff
- Forcing a process in background (, fg, bg)
- Setting aliases
- Online manual pages, man
- Concept of NIS and NFS
- Changing password, passwd (?yppasswd?)
- Searching for patterns, grep and regular
expressions - 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)
15Lunch Break
16Editors 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
17Editors 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
- Syntax highlighting and templates
- Tips
- Emacs recognizes 20 languages out of the box
- Emacs is slow
- Emacs is not available by default on all unices
18Editors 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
19Programming 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
20Programming on UNIX-2
- Gcc, The GNU C/C compiler
- Simplest possible way to use gcc ltfile-namegt
- Common options
- output filename -o
- compile only -c
- Warnings -Wall
- optimizations -O1,2,3,4
- Debug -g
- Linking -lltlibrary-namegt
- Tips
- Not every UNIX systems will have gcc
- Turning on optimization makes the compilation
slow - Debugging and optimizing donot go together
21Programming 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
22Programming 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?
23Programming 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!
24Programming on UNIX-6
- Example of a makefile
- CCgcc
- COPTS -g -Wall
- TARGETrun.x
- SRCShello.c junk.c
- OBJS(SRCS.c.o)
- all(OBJS)
- (CC) (COPTS) (OBJS) -o (TARGET)
- clean
- rm -f (OBJS) core
- .o.c
- (CC) (COPTS) -c lt
25Programming 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
26Programming 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
27Introduction to Shell Programming-1
- What is the need for shell programming?
- Bourne shell (sh, ksh, zsh and bash)
- c shell (csh, tcsh)
- Examples of shell programming
- Moving all a.i.txt files to a.i1.txt
- Cleaning up your directory at the end of a day
- Tips
- Perl just might be a better option
- Dont forget ?sed? and ?awk?
28Introduction to Shell Programming-2
- Moving files script
- !/bin/sh -f
- FILE_LISTls grep "\.0-9\."
- for CURR_FILE in FILE_LIST do
- FIRST_NMecho CURR_FILE cut -d'.' -f1
- NUMecho CURR_FILE cut -d'.' -f2
- SECOND_NMecho CURR_FILE cut -d'.' -f3
- NUM_PLUSexpr NUM 1
- mv -i CURR_FILE FIRST_NM.NUM_PLUS.SECOND_
NM - done
29Introduction to Shell Programming-3
- Cleanup directory script
- !/bin/csh -f
- Assume that ps, pdf etc. directories are
present - set FILE_LISTls
- foreach CURR_FILE ( FILE_LIST )
- set TSTecho CURR_FILE grep \.pdf\
- if( TST ! "" ) then
- mv CURR_FILE pdf
- endif
- set TSTecho CURR_FILE grep \.ps\
- if( TST ! "" ) then
- mv CURR_FILE ps
- endif
- end
30Text formatting using UNIX-1
- What is the need for text formatting?
- WYSWYG or NOT?
- LaTeX Emacs PS renderer
- LaTeX WYSWYG front-end Lyx
- Other text formatters ?troff?
- How to make Presentations? Slides?
- Tips
- PowerPoint is still the best software for making
presentations - It is easy to convert PowerPoint slides to html
31Text formatting using UNIX-2
- LaTeX
- origin LaTeX and TeX
- usage
- LaTeX tutorials and manuals
- A not so short introduction to LaTeX
- The LaTeX manual
- LaTeX by Lesslie Lamport
- Lyx a WYSWIG interface to LaTeX
- Emacs ps-renderer and troff
- Tips
- For small formatted text Emacs is still the best
32Before wrapping up
Any questions/doubts which you would like to
clarify?
33Wrapping 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
34Thank You