1 / 15

Welcome to CSE459.11

Welcome to CSE459.11. Name: Di Cao Email: caod@cse.ohio-state.edu Classroom: DL357 Class Time: T 8:30am - 9:18am Office : DL680 Office Hours: 9:30am -10:30am(T). Lecture 1: Introduction to Unix Shell. Brief Unix History Running Model and System Calls Unix Shell & Flavor.

danyl
Download Presentation

Welcome to CSE459.11

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Welcome to CSE459.11 • Name: Di Cao • Email: 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 customize the shell and user interface. • To string together a series of Unix commands to create new functionality. • 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: • Shell is a process; • 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 • AT&T shell • Fast • $ for command prompt • C shell : csh, tcsh • Berkley Shell • better for user customization and scripting • %, > for command prompt • To check shell: • % echo $SHELL (shell is a pre-defined variable) • To switch shell: • % 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 • Customization of a Unix session • Scripting: Interpreted Programming Language

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

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

  10. Running Model • User Mode • 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 • System call • 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 • exec() • 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 • 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 • usually space or ↓ for more information • q to quit • % 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

More Related