Presentation is loading. Please wait.

Presentation is loading. Please wait.

Welcome to CSE459.11  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office.

Similar presentations


Presentation on theme: "Welcome to CSE459.11  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office."— Presentation transcript:

1 Welcome to CSE459.11  Name: Di Cao  Email: caod@cse.ohio-state.edu caod@cse.ohio-state.edu  Classroom: DL357  Class Time: T 8:30am - 9:18am  Office : DL680  Office Hours: 9:30am -10:30am(T)

2 Lecture 1: Introduction to Unix Shell  Brief Unix History  Running Model and System Calls  Unix Shell & Flavor

3 Unix History and Motivation  The first version of Unix came from AT&T in the early 1970s (Unix is old!).  Unix was developed by programmers and for programmers.  Unix is designed so that users can extend the functionality To build new tools easily and efficiently To build new tools easily and efficiently To customize the shell and user interface. To customize the shell and user interface. To string together a series of Unix commands to create new functionality. To string together a series of Unix commands to create new functionality. To create custom commands that do exactly what we want. To create custom commands that do exactly what we want.

4 What is Shell?  Shell is Command Interpreter that turns text that you type (at the command line) in to actions: Command Interpreter that turns text that you type (at the command line) in to actions: Shell is a process; Shell is a process; User Interface: take the command from user User Interface: take the command from user

5 Flavors of Unix Shells  Two main flavors of Unix Shells Bourne (or Standard Shell): sh, ksh, bash, zsh Bourne (or Standard Shell): sh, ksh, bash, zsh AT&T shellAT&T shell FastFast $ for command prompt$ for command prompt C shell : csh, tcsh C shell : csh, tcsh Berkley ShellBerkley Shell better for user customization and scriptingbetter for user customization and scripting %, > for command prompt%, > for command prompt  To check shell: % echo $SHELL (shell is a pre-defined variable) % echo $SHELL (shell is a pre-defined variable)  To switch shell: % exec shellname (e.g., % exec bash) % exec shellname (e.g., % exec bash)

6 Popular Shells  sh Bourne Shell  ksh Korn Shell  csh,tcsh C Shell (for this course)  bash Bourne-Again Shell

7 Uses of Shell  Programming Shell can do Interpret Commands: Parse, Evaluate Interpret Commands: Parse, Evaluate Customization of a Unix session Customization of a Unix session Scripting: Interpreted Programming Language Scripting: Interpreted Programming Language

8 Customization of a Session  Each shell supports some customization. User prompt User prompt Where to find mail Where to find mail Shortcuts (alias) Shortcuts (alias)  The customization takes place in startup files Startup files are read by the shell when it starts up Startup files are read by the shell when it starts up The Startup files can differ for different shell The Startup files can differ for different shell

9 Startup files  sh,ksh: /etc/profile (system defaults) ~/.profile  bash: ~/.bash_profile~/.bashrc ~/.bash_logout ~/.bash_logout  csh: ~/.login: executed when you logon ~/.login: executed when you logon ~/.cshrc: executed when a new shell is spawned ~/.cshrc: executed when a new shell is spawned ~/.logout: executed at logout ~/.logout: executed at logout

10 Running Model  User Mode A process running in this mode can’t access kernel data structures and procedures A process running in this mode can’t access kernel data structures and procedures  Kernel Mode A process running in this mode can access kernel data structures and procedures A process running in this mode can access kernel data structures and procedures  System call Can be looked as the interface between user mode and kernel mode Can be looked as the interface between user mode and kernel mode

11 Layout of address space Of A Process (linux)

12 Creating Processes  fork() Create a duplicate of the calling process Create a duplicate of the calling process  exec() Create a duplicate of the calling process Create a duplicate of the calling process Load an executable program whose name is one of arguments of exec() into the address space of the new process Load an executable program whose name is one of arguments of exec() into the address space of the new process  wait()- Cause a parent process to sleep until one of its child processes terminates  exit()

13 Your Best Friend  % man command (e.g., % man ls) shows information about the command shows information about the command usually space or ↓ for more information usually space or ↓ for more information q to quit q to quit % man man % man man

14 Some Common Commands   ls –l   mv src dst // rename a file   rm file // delete files or directories   cp src dst // copy files   mail   write sb // send an message to sb   lpr // print something   wc file // word counting for a file   tail –n file // print out the last n lines of file   tail +n file // print out file starting from nth line   mkdir dir_name // create a directory   rmdir dir_name // delete a directory

15 Recommended Reading  Chapter 1, sections 1.1 – 1.5


Download ppt "Welcome to CSE459.11  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office."

Similar presentations


Ads by Google