2 Introduction What is Unix An operation system OS similar to Windows MacOS X Why learn Unix Greatest Software Ever Written httpwwwinformationweekcomsharedprintableArticlejhtmlarticleID191901844 ID: 759781
Download Presentation The PPT/PDF document "1 SEEM3460 Tutorial Unix Introduction" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
1
SEEM3460 Tutorial
Unix Introduction
Slide22
Introduction
What is Unix?
An operation system (OS), similar to Windows, MacOS X
Why learn Unix?
Greatest Software Ever Written!!
http://www.informationweek.com/shared/printableArticle.jhtml?articleID=191901844
Freely available clone/distributions are under rapid development (e.g. Linux & FreeBSD)
Slide33
Using Unix
Shell: a program that acts as a middleman between you and the UNIX OS
Terms
similar to shell:
Terminal / virtual terminal
Console
A shell
allows users to
Run
programs
Manage I/O of processes easily
A Unix shell interprets a programming language (sometimes called the shell script)
Slide4A shell command
ls -lp ~ls: program name“ls” is the utility to list files-lp: options/switches, starting with a hyphen“l” means list in long format“p” means putting a slash after directory names~: remaining parameters actual meaning depends on the program usedfor ls, the remaining parameters are the files or directories to be listed“~” means the home directory of the current user
4
Slide5Utilities
Unix utilities are the basic programs supporting the user to control the systemExamples:date: shows the system dateman -s 1 ls: shows help on ls from the built-in manual section 1pwd: prints the working directoryecho: prints a message
5
Slide66
Unix file system in brief
A hierarchy of directories
To locate a file in the system, a
pathname
is needed
Command:
pwd
print your current working directory
Pathnames
Absolute pathnames
Starting from the root
(with a beginning “/”)
Relative pathnames
Starting from the current working directory
Slide7Managing Files on Unix (1)
Creating an empty filetouch <newFileName>Creating (making) a directorymkdir <newDirName>Moving (renaming) a filemv <aFileName> <aDirectoryName>mv <oldFileName> <newFileName>
7
Slide8Managing Files on Unix (2)
Change working directorycd <aDirName>List files in a directory or fits the patternls <directories/filename patterns>View the content of a filecat <file paths>more <file paths>less <file paths>head <file path>tail <file path>
8
Slide9Managing Files on Unix (3)
Copying a filecp <oldFileName> <newFileName>Remove a filerm <aFileName>Remove a non-empty directoryrm –r <aDirName>Remove a whole directory without promptrm –rf <aDirName>
9
Slide1010
Editing a file
nano
Adv: simple, easy to learn and use
Dis
: no GUI
emacs
Adv: has GUI, easy for beginners
Dis
: relatively slow
vi/vim (vim stands for Vi Improved)
Adv: fast for advance users
Dis
: text-version is quite difficult to learn
GUI version:
gvim
,
rgvim
To learn, type “
vitutor
” in console
Check
their “man” page for detail usages
Slide1111
Compiling C programs in Unix
Compiler:
cc – the native C compiler under Unix
gcc – C compiler under GNU project
Usage is the same, gcc is more popular
To compile a C source code file, say example.c, type in:
cc example.c
gcc example.c
The output of both compilers (i.e. the executable) would be “a.out” by default
To override the default executable name, use “-o” flag
cc example.c –o example
gcc example.c –o example
You can name the executable as .exe or .bin file to remind yourself the nature of the file
One more tip, use “-Wall” to get some warning messages
Warning message usually indicate hidden bugs
Try to understand the error messages and warning messages.
For other flags, “man cc” or “man gcc”
Slide1212
Compiling C programs in Unix
If there are so many compilation errors that it cannot fit into one screen. One way is to compile by the following command:
cc example.c |& more
It means that the compilation errors will be displayed screen by screen.
That is, it will display the first screen of errors and wait.
After the user examines the errors, he/she can choose to display the next screen of errors by hitting RETURN or quit by hitting Control-C. Then, the user can go back to modify the source code.