+ All Categories
Home > Documents > UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969...

UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969...

Date post: 14-Dec-2015
Category:
Upload: jocelin-fitzgerald
View: 218 times
Download: 0 times
Share this document with a friend
Popular Tags:
26
UNIX UNIX An Introduction An Introduction
Transcript
Page 1: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

UNIXUNIX

An IntroductionAn Introduction

Page 2: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

Brief HistoryBrief History

UNIXUNIX Created at Bell Labs, 1969Created at Bell Labs, 1969 BSD during mid 70sBSD during mid 70s AT&T began offering System II in early 80sAT&T began offering System II in early 80s

Linux Linux defined in 1991defined in 1991 Red Hat, 1995Red Hat, 1995

http://www.computerhope.com/history/unix.htmhttp://www.computerhope.com/history/unix.htm

Page 3: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

UNIX PhilosophyUNIX Philosophy

SimplicitySimplicity ReusabilityReusability FiltersFilters Open FormatsOpen Formats FlexibilityFlexibility

Page 4: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

What is the shell?What is the shell?

Utility program loaded when a user Utility program loaded when a user logs in logs in

init

getty

login

sh (bash)

startup

Page 5: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

Shell’s ResponsibilitiesShell’s Responsibilities

Shell

Program Execution variable and

filenamesubstitution

I/ORedirection

pipelinehookup

environmentcontrol

interpretedprogramming

languages

Page 6: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

Shell SubstitutionsShell Substitutions Certain characters are interpreted by the Certain characters are interpreted by the

various Unix shells as “wildcards” for various Unix shells as “wildcards” for filenames, also known as metacharactersfilenames, also known as metacharacters* - matches 0 or more of any characters* - matches 0 or more of any characters

ls *.cls *.c

? - matches any single character? - matches any single characterls file0?.cls file0?.c

[...] - matches any single character if it is in [...] - matches any single character if it is in the list providedthe list provided

ls file[0-9].cls file[0-9].c

Page 7: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

Regular ExpressionsRegular Expressions

A formalized way to specify stringsA formalized way to specify strings File names (shell commands)File names (shell commands) Strings in text files (during editing)Strings in text files (during editing) Compilers (future topic)Compilers (future topic) SedSed

Unfortunately, each use defines its Unfortunately, each use defines its own special metacharactersown special metacharacters

Page 8: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

Regular ExpressionsRegular Expressions

LS – which files match A*[0-9]?.cLS – which files match A*[0-9]?.c AboutTime.cAboutTime.c AboutTimeAboutTime A2.cA2.c A2i.cA2i.c A211x.cA211x.c AllFilesGreaterThan12.cAllFilesGreaterThan12.c A2char.cA2char.c

Page 9: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

Regular ExpressionsRegular Expressions

Write a regular expressions for:Write a regular expressions for: All files with an ‘X’ in the nameAll files with an ‘X’ in the name All files with an ‘X’ and a following ‘Y’All files with an ‘X’ and a following ‘Y’ All file names with exactly 6 charactersAll file names with exactly 6 characters All file names with more than 6 charactersAll file names with more than 6 characters All files that start with ‘a’ and end with ‘x’All files that start with ‘a’ and end with ‘x’ All files names including an ‘a’ but fewer All files names including an ‘a’ but fewer

than 10 characters (this one is TOUGH!)than 10 characters (this one is TOUGH!)

Page 10: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

The ManualThe Manual

The The manman command command man gccman gcc SpacebarSpacebar for next page and for next page and returnreturn for for

next linenext line qq to quit to quit

Also try Also try infoinfo info gccinfo gcc

Page 11: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

Linux CommandsLinux Commands

File manipulationFile manipulation rm, mv, cat, cp, chmodrm, mv, cat, cp, chmod

NavigationNavigation cd, pushd, popdcd, pushd, popd

System informationSystem information ls, wc, top, psls, wc, top, ps

Page 12: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

File ManipulationFile Manipulation

vi (or your editor of choice)vi (or your editor of choice) touchtouch mkdir, rmdirmkdir, rmdir cp, rmcp, rm chmod, chownchmod, chown PermissionsPermissions

read, write, execute; owner, group, userread, write, execute; owner, group, user -rw-r--r-- = 644-rw-r--r-- = 644

Page 13: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

File InformationFile Information

lsls moremore wcwc catcat headhead tailtail dudu df df

Page 14: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

File SystemFile System

Directory Structure is a treeDirectory Structure is a tree All items in hierarchy are files All items in hierarchy are files Files represented by inode – ls –IFiles represented by inode – ls –I Multiple “files” (names) to an inodeMultiple “files” (names) to an inode

Page 15: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

Example File TreeExample File Tree/

/home /dev /usr

/home/akl /home/sweany

public classes

3600

Page 16: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

Moving between locationsMoving between locations

The cd command changes directoryThe cd command changes directory cd cd cd pathnamecd pathname pushd pathnamepushd pathname popd pathnamepopd pathname

Page 17: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

PathnamesPathnames Two ways to specifyTwo ways to specify::

Absolute pathnames start with a slash (/).Absolute pathnames start with a slash (/). Relative pathnames don’t. Relative pathnames don’t. Example absolute pathnamesExample absolute pathnames::

/home/s3/Empdata/dbs/home/s3/Empdata/dbs /etc/passwd/etc/passwd

Example relative pathnamesExample relative pathnames programs/tsp.cprograms/tsp.c .. .... ../../programs/tsp.c../../programs/tsp.c ~~

Page 18: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

File PermissionsFile Permissions

chmod mode filename(s)chmod mode filename(s) umask – specifies default file permissionsumask – specifies default file permissions ls –l displays detailed file informationls –l displays detailed file information

$ $ ls -lls -l-rwxr-xr-x 1 s3 students 892 Feb 8 10:15 memo-rwxr-xr-x 1 s3 students 892 Feb 8 10:15 memodrwxrwxrwx 1 s3 students 1024 Dec 10 8:05 progsdrwxrwxrwx 1 s3 students 1024 Dec 10 8:05 progs

Page 19: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

Special FilesSpecial Files

Dot files – filename starts with ‘.’Dot files – filename starts with ‘.’ ls -als -a .bash_history.bash_history .bash_login.bash_login .profile – MAY not be writeable by .profile – MAY not be writeable by

useruser

Page 20: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

My .profileMy .profile

alias rm’/bin/rm’alias rm’/bin/rm’

PATH=.:/usr/local/bin:/usr/bin:/home/sweany/PATH=.:/usr/local/bin:/usr/bin:/home/sweany/binbin

Page 21: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

sort Commandsort Command sort sort format:format:

sort sort [options] filename[options] filename Options:Options:

-d-d alphabetic, ignore punctuation alphabetic, ignore punctuation -f-f ignore case for sortingignore case for sorting -r-r reverse sort order reverse sort order -o -o outfile output to file, not stdoutoutfile output to file, not stdout -n-n arithmetic orderarithmetic order -t-tcc use ‘c’ to separate fields; default is use ‘c’ to separate fields; default is

whitespacewhitespace

Page 22: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

grep Commandsgrep Commands

grep, egrep, fgrepgrep, egrep, fgrep grepgrep format: format:

grep grep [options] search_string filename(s)[options] search_string filename(s) Options:Options:

-c-c Prints the count of matching lines rather than Prints the count of matching lines rather than the actual linesthe actual lines

-l-l prints the name of each file containing matching prints the name of each file containing matching lines, rather than the actual lineslines, rather than the actual lines

-n-n precedes each line with a line numberprecedes each line with a line number -v-v inverse search, shows all lines that do not inverse search, shows all lines that do not

match patternmatch pattern

Page 23: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

find Commandfind Command findfind format: format:

find directory_name search_criteria actionfind directory_name search_criteria action

Search Criteria:Search Criteria: name filenamename filename files that match filenamefiles that match filename atime +-natime +-n files last accessed in days files last accessed in days mtime +-nmtime +-n files last modified in days files last modified in days followfollow follow symbolic linksfollow symbolic links

Page 24: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

find Command find Command

Actions:Actions:-print-print print the files foundprint the files found

-exec cmd-exec cmd execute command on files execute command on files foundfound

-ok cmd-ok cmd like exec, but prompts to like exec, but prompts to execute execute command firstcommand first

Page 25: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

Find ExamplesFind Examples

ix% find programs –name “*.c” –printix% find programs –name “*.c” –print

ix% find . -name “*.c” –exec rm –rf ix% find . -name “*.c” –exec rm –rf {} \;{} \;

ix% find . -mtime -3 -printix% find . -mtime -3 -print

Page 26: UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.

Type Conversion Type Conversion

doubledouble atof (char *nptr)atof (char *nptr)

longlong atol (char *str)atol (char *str)

intint atoi (char *str)atoi (char *str)


Recommended