What is the Shell. Whenever you login to a Unix system you are placed in a program called the shell. All of your work is done within the shell.

Size: px
Start display at page:

Download "What is the Shell. Whenever you login to a Unix system you are placed in a program called the shell. All of your work is done within the shell."

Transcription

1 What is the Shell Whenever you login to a Unix system you are placed in a program called the shell. All of your work is done within the shell. The shell is your interface to the operating system. It acts as a command interpreter; it takes each command and passes it to the operating system. It then displays the results of this operation on your screen. There are several shells in widespread use. The most common ones are described below. Bourne shell (sh) Original Unix shell written by Steve Bourne of Bell Labs. Available on all UNIX systems. Does not have the interactive facilities provided by modern shells such as the C shell and Korn shell. The Bourne shell does provide an easy to use language with which you can write shell scripts. C shell (csh) Written at the University of California, Berkeley. As it name indicates, it provides a C like language with which to write shell scripts. Korn shell (ksh) Written by David Korn of Bell Labs. It is now provided as the standard shell on Unix systems. Provides all the features of the C and TC shells together with a shell programming language similar to that of the original Bourne shell. TC Shell (tcsh) Available in the public domain. It provides all the features of the C shell together with EMACS style editing of the command line. Bourne Again Shell (bash) Public domain shell written by the Free Software Foundation under their GNU initiative. Ultimately it is intended to be a full implementation of the IEEE POSIX Shell and Tools specification. Widely used within the academic community. Provides all the interactive features of the C shell (csh) and the Korn shell (ksh). Its programming language is compatible with the Bourne shell (sh). Your login shell is usually established by the local System Administrator when your userid is created. You can determine your login shell with the command: echo $SHELL Each shell has a default prompt. For the 5 most common shells: $ (dollar sign) - sh, ksh, bash % (percent sign) - csh, tcsh 1

2 Depending upon the shell, certain features will be available. The table below summarizes the features available with the 5 most common shells. Note: these features will be described in detail later. Bourne C TC Korn BASH sh csh tcsh ksh bash Programming language Yes Yes Yes Yes Yes Shell variables Yes Yes Yes Yes Yes Command alias No Yes Yes Yes Yes Command history No Yes Yes Yes Yes Filename completion No Yes* Yes Yes* Yes Command line editing No No Yes Yes* Yes Job control No Yes Yes Yes Yes * not the default setting for this shell Processes Whenever you enter a command at the shell prompt, it invokes a program. While this program is running it is called a process. Your login shell is also a process, created for you upon logging in and existing until you logout. UNIX is a multi-tasking operating system. Any user can have multiple processes running simultaneously, including multiple login sessions. As you do your work within the login shell, each command creates at least one new process while it executes. Process id: every process in a UNIX system has a unique PID - process identifier. ps - displays information about processes. Note that the ps command differs between different UNIX systems - see the local ps man page for details. To see your current shell's processes: % ps PID TTY TIME CMD pts/9 0:00 ps pts/9 0:00 -csh To see a detailed list of all of your processes on a machine (current shell and all other shells): % ps uc USER PID %CPU %MEM SZ RSS TTY STAT STIME TIME COMMAND jsmith pts/9 R 21:01:14 0:00 ps jsmith pts/76 S 19:18:31 0:00 elm jsmith pts/9 S 20:49:20 0:00 csh jsmith pts/76 S Mar 03 0:00 csh 2

3 To see a detailed list of every process on a machine: % ps ug USER PID %CPU %MEM SZ RSS TTY STAT STIME TIME COMMAND root S Feb 08 32:57 swapper root S Feb 08 39:16 /etc/init root R Feb :05 kproc root S Feb 08 65:14 kproc root S Feb 08 0:00 kproc { lines deleted } root S Mar 07 0:00 -ncd19:0 kdr pts/87 S Mar 06 0:00 -ksh manfield S 10:12:52 0:00 mwm kelly S 08:18:10 0:00 twm sjw S Mar 06 0:00 rlogin kanaha mkm S Feb 08 0:00 xterm ishley pts/106 S Mar 06 0:00 xedit march2 tusciora S Mar 06 0:05 xterm -e dilfeath S 07:32:45 0:00 xclock tusciora S Mar 06 0:41 twm kill - use the kill command to send a signal to a process. In most cases, this will be a kill signal, hence the command name. However, other types of signals are usually supported. Note that you can only kill processes which you own. The command syntax is: Examples: kill [-signal] process_identifier(pid) kill kills process kill kills (kills!) process Use if simple kill doesn't work. kill -STOP stops process 2339 kill -CONT continues stopped process 2339 kill -l - list the supported kill signals You can also use CTRL-C to kill the currently running process. Suspend a process: Use CTRL-Z. Background a process: Normally, commands operate in the foreground - you can not do additional work until the command completes. Backgrounding a command allows you to continue working at the shell prompt. To start a job in the background, use an ampersand (&) when you invoke the command: myprog & To put an already running job in the background, first suspend it with CRTL-Z and then use the "bg" command: myprog CTRL-Z bg - execute a process - suspend the process - put suspended process in background Foreground a process: To move a background job to the foreground, find its "job" number and then use the "fg" command. In this example, the jobs command shows that two processes 3

4 are running in the background. The fg command is used to bring the second job (%2) to the foreground. jobs [1] + Running xcalc [2] Running find / -name core -print fg %2 Stop a job running in the background: Use the jobs command to find its job number, and then use the stop command. You can then bring it to the foreground or restart execution later. jobs [1] + Running xcalc [2] Running find / -name core -print stop %2 Kill a job running in the background, use the jobs command to find its job number, and then use the kill command. Note that you can also use the ps and kill commands to accomplish the same task. jobs [1] + Running xcalc [2] Running find / -name core -print kill %2 Some notes about background processes: If a background job tries to read from the terminal, it will automatically be stopped by the shell. If this happens, you must put it in the foreground to supply the input. The shell will warn you if you attempt to logout and jobs are still running in the background. You can then use the jobs command to review the list of jobs and act accordingly. Alternately, you can simply issue the logout command again and you will be permitted to exit. Redirection Redirection refers to changing the shell's normal method of handling standard output (stdout), standard input (stdin) and standard error (stderr) for processes. By default, all of these are from/to your screen. The following symbols are used on the shell command line to redirect a process's stdin, stdout and/or stderr to another location, such as a file or device. > - redirect stdout (overwrite) >> - redirect stdout (append) < - redirect stdin 2> - redirect stderr (sh,ksh,bash) >& - redirect stdout and stderr (csh,tcsh) 4

5 Examples: mail tony < memo - uses the file memo as input to the mail program ls -l > my.directory - redirects output of ls -l command to a file called my.directory. If the file already exists, it is overwritten cat Mail/jsmith >> Oldmail - appends the contents of Mail/jsmith to the file Oldmail (does not overwrite) myprog >& output - redirects stdout and stderr from myprog's execution to a file called output (csh,tcsh) (myprog > out) >& err - redirects stdout from myprog's execution to a file called out and stderr to the file err (csh,tcsh) myprog 2> runtime.errors - redirects stderr from myprog's execution to a file called runtime.errors (sh,ksh,bash) myprog > output 2>& - redirects stderr and stdout from myprog's execution to a file called output (sh,ksh,bash) myprog > out 2> err - redirects stdout from myprog's execution to a file called out and stderr to the file err (sh,ksh,bash) Pipes A pipe is used by the shell to connect the stdout of one command directly to the stdin of another command. The symbol for a pipe is the vertical bar ( ). The command syntax is: command1 [arguments] command2 [arguments] Pipes accomplish with one command what otherwise would take intermediate files and multiple commands. For example, operation 1 and operation 2 are equivalent: Operation 1 who > temp sort temp Operation 2 who sort 5

6 Pipes do not affect the contents of the input files. Two very common uses of a pipe are with the "more" and "grep" utilities. Some examples: ls -al more who more ps ug grep myuserid who grep kelly Filters A filter is a command that processes an input stream of data to produce an output stream of data. Command lines which use a filter will include a pipes to connect it to the stdout of one process and the stdin of another process. For example, the command line below takes the output of "who" and sorts it. The sorted output is then passed to the lp command for printing. In this example, sort is a filter. who sort lp Both filters and pipes demonstrate a basic UNIX principle: Expect the output of every program to become the input of another, yet unknown, program to combine simple tools to perform complex tasks. Features (csh) Each shell has its own set of features. Those of the C Shell are discussed below. Command history: The history mechanism maintains a list of recently used command lines, called events. Provides a shorthand for re-executing previous commands. To use history: 1. Set the history variable: set history = Issue the history command and view the output: history 35 12:34 sort < unsorted > sorted.list 36 12:34 cat sorted.list 37 12:35 ls * > unsorted 38 12:35 cat unsorted 39 12:35 ls 40 13:06 history 41 13:08 alias 42 13:11 ls 43 13:11 vi.cshrc 6

7 3. To save history events across all login sessions, set the savehistory variable: set savehistory = 50 Event re-execution: Allows you to specify a shorthand for re-executing a previous event. Works with the history list.!! - repeats last command!number - repeats numbered command from history list!string - repeats last command starting with string Modifying previous events: Allows you to correct typos in previous command, or modify it to create a new command. ^old^new!number:s/old/new/ - changes the string "old" to the string "new" in the last command issued - changes numbered command from history list; substitutes the string "old" with the string "new". Note that there is no space between number and : Aliases: The alias command allows you to define new commands. Useful for creating shorthands for longer commands. The syntax is. alias entered_command executed_command Some examples: alias m more alias rm "rm -i" alias h "history -r more" alias xpvm /source/pd/xpvm/src/rs6k/xpvm To view all current aliases: alias To remove a previously defined alias: unalias alias_name Filename Generation: When you give the shell abbreviated filenames which contain special characters (metacharacters), it can generate filenames which match existing files. Some examples appear below: ls *.txt - list files with.txt suffix ls [abc]* - list files with names that start with a, b or c 7

8 lpr prog?.c cd ~jsmith - print files named prog?.c where? is any character - change to user jsmith's home directory You can "turn off" filename generation by setting the noglob variable. This will permit special characters to be interpreted literally. For example: set noglob Filename Completion: The shell will complete a filename for you if you type in only enough characters to make the name unique. This feature is a great time saver and helps to prevent typos when trying to type long filenames. To use filename completion, you need to set filec, either on the command line or in one of your initialization files. set filec Then, when specifying a filename, type the part which is unique and hit the escape key (C shell) or tab key (TC Shell). For example, if you had a directory with a long name, such as "Introduction.UNIX.Filesystems", you could cd to that directory by using the cd command with only a portion of the file's name, provided that the portion you specify is unique (no other files have similar names) cd Intro<ESC> Note: typing a portion of a filename and then hitting CTRL-D instead of ESCape or TAB will display a list of the filenames which match. Variables (csh) Each shell has its own set of variables and rules for using variables. Those associated with the C Shell are discussed below. The shell has variables which are predefined as well as variables which you define (user defined). Shell variables control many aspects of how your shell environment behaves. Modifying these variables (and creating new ones) allows you to customize your shell environment. Shell variables are used extensively when creating shell scripts (covered later). Variables can be local - current shell only global - current shell and child processes/shells string - treated as character numeric - treated as numbers arrays - contain more than one value 8

9 Commands used to declare and manipulate shell variables: set - assigns non-numeric string variables locally unset - removes a previously "set" variable set - shows all "set" variables setenv - assigns non-numeric string variables globally unsetenv - removes a previously setenv variable setenv - shows all setenv - assigns numeric variables locally echo $variable - displays value of variable Examples set name=fred - Sets variable name to value of fred unset name - Unsets the variable name set path=($path. ~/bin) - Adds to current setting of string array variable path setenv DISPLAY makena:0 - Sets environment variable DISPLAY echo $HOME - Displays value of variable HOME set colors=(red green blue) - Assigns three values to the string array variable count = 1 - Sets numeric variable count to count = ($count + 1) - Adds one to numeric variable count set counts = ( ) - Assigns 4 values to numeric array variable counts[2] = 5 - Assigns values to second element of numeric array variable echo $counts[3] - Displays value of third element of numeric array variable counts Predefined Shell Variables. A number of shell variables are predefined by the shell itself or inherited from the system environment. Some of the more common ones are described below. $ Contains the process id of the current shell argv Contains the command line arguments for an invoked command. argv is an array, with $argv[0] set to the name of the invoked command, $argv[1] set to the first argument, $argv[2] set to the second argument...and so on. $argv[*] can be used to specify all arguments. You may also use the shorthand $n where n is the number of the argument. #argv Set to the actual number of arguments in argv, excluding argv[0] 9

10 cdpath Expands the search path for the cd command. By default, the cd command issued with a simple filename will search only the working directory. Use cdpath to increase the number of directories searched. set cdpath=(/usr/jenny /usr/jenny/mail../) CWD or cwd Holds that name of the working/current directory. echo Causes the shell to echo the command before executing it. Use set/unset to turn this on/off. filec Enables file completion. Use set/unset to turn this on/off. history Controls the size of the history list. 100 is recommended as safe size. If the number is too large, the shell may run out of memory. HOME or home The pathname of your home directory ignoreeof Prevents exiting the shell by typing CTRL-D, and thus, prevents accidentally logging off. Use set/unset to turn this on/off. noclobber Prevents you from accidentally overwriting a file when you redirect output. Use set/unset to turn this on/off. noglob Prevents the shell from generating/expanding ambiguous filenames. Use set/unset to turn this on/off. notify Tells the shell to notify you immediately when a background job completes. Ordinarily, notification will wait until the next shell prompt to prevent interruption of work. Use set/unset to turn this on/off. PATH or path Specifies the path that the shell searches when asked to execute a command. If an executable is not found in the path, you must specify its full pathname. prompt Allows you to customize the shell prompt. By default, the C shell prompt is simply a percent sign (%). For example, to display the machine name you are logged into as part of your prompt: set prompt = "`hostname -s`% " savehist Specifies how many the number of command events to save as history after you logout. These events are saved in a file called.history in your home directory. The shell uses these as your initial history after you login again. 10

11 shell Contains the pathname of the shell status Contains the exit status of the last executed command USER or user Contains you login userid verbose Causes the shell to display each command after a history substitution. Use set/unset to turn this on/off. Initialization Files System-wide shell initialization files are common on UNIX systems. These files can be "sourced" automatically by the shell and are typically setup by the System Administrator for the local environment. Some examples of system-wide initialization files might be: /etc/environment /etc/profile /etc/cshrc /etc/login Every shell provides a means for the user to customize certain aspects of the shell's behavior. These customizations usually permit you to augment and/or override the system-wide defaults. User customizations are specified in initialization files located in the top level of your home directory. Naming: Depending upon the shell, you must name your initialization file(s) accordingly. Executed during interactive login.login - csh, tcsh.profile - sh, ksh, bash.bash_profile - bash (alternative 1).bash_login - bash (alternative 2) Executed for every new shell.cshrc - csh, tcsh.tcshrc - tcsh.kshrc - ksh.bashrc - bash The C shell uses two files to set user preferences:.cshrc runs at each login before the.login file runs whenever another shell is created runs when a new window is opened runs when many utilities are invoked typically sets alias information, path variable, filec, prompt, etc. 11

12 .login runs at invocation of login shell, after the.cshrc file typically sets terminal characteristics and one time shell options and environment variables After changing your.login or.cshrc files, you must "source" them for the changes to take effect: source.login source.cshrc The system administrator may/may not provide you with default.cshrc and.login files when you first obtain your userid. If they are provided, be careful about modifying them - especially removing specifications which are required for your local system. Example.cshrc and.login files are provided. Logout Files You are able to specify commands which the shell will execute upon logout. These commands are kept in a file located in the top level of your home directory..logout.bash_logout - csh, tcsh - bash 12

Introduction to UNIX Shell Exercises

Introduction to UNIX Shell Exercises Introduction to UNIX Shell Exercises Determining Your Shell Open a new window or use an existing window for this exercise. Observe your shell prompt - is it a $ or %? What does this tell you? Find out

More information

ACS Unix (Winter Term, ) Page 21

ACS Unix (Winter Term, ) Page 21 ACS-294-001 Unix (Winter Term, 2016-2017) Page 21 The Shell From the beginning, Unix was designed so that the shell is an actual program separated from the main part of the operating system. What is a

More information

Standard. Shells. tcsh. A shell script is a file that contains shell commands that perform a useful function. It is also known as shell program.

Standard. Shells. tcsh. A shell script is a file that contains shell commands that perform a useful function. It is also known as shell program. SHELLS: The shell is the part of the UNIX that is most visible to the user. It receives and interprets the commands entered by the user. In many respects, this makes it the most important component of

More information

The Online Unix Manual

The Online Unix Manual ACS-294-001 Unix (Winter Term, 2018-2019) Page 14 The Online Unix Manual Unix comes with a large, built-in manual that is accessible at any time from your terminal. The Online Manual is a collection of

More information

5/20/2007. Touring Essential Programs

5/20/2007. Touring Essential Programs Touring Essential Programs Employing fundamental utilities. Managing input and output. Using special characters in the command-line. Managing user environment. Surveying elements of a functioning system.

More information

System Programming. Unix Shells

System Programming. Unix Shells Content : Unix shells by Dr. A. Habed School of Computer Science University of Windsor adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Introduction 2 Interactive and non-interactive

More information

EECS2301. Lab 1 Winter 2016

EECS2301. Lab 1 Winter 2016 EECS2301 Lab 1 Winter 2016 Lab Objectives In this lab, you will be introduced to the Linux operating system. The basic commands will be presented in this lab. By the end of you alb, you will be asked to

More information

5/8/2012. Specifying Instructions to the Shell Chapter 8

5/8/2012. Specifying Instructions to the Shell Chapter 8 An overview of shell. Execution of commands in a shell. Shell command-line expansion. Customizing the functioning of the shell. Employing advanced user features. Specifying Instructions to the Shell Chapter

More information

CST Algonquin College 2

CST Algonquin College 2 The Shell Kernel (briefly) Shell What happens when you hit [ENTER]? Output redirection and pipes Noclobber (not a typo) Shell prompts Aliases Filespecs History Displaying file contents CST8207 - Algonquin

More information

Linux Command Line Interface. December 27, 2017

Linux Command Line Interface. December 27, 2017 Linux Command Line Interface December 27, 2017 Foreword It is supposed to be a refresher (?!) If you are familiar with UNIX/Linux/MacOS X CLI, this is going to be boring... I will not talk about editors

More information

Unix Processes. What is a Process?

Unix Processes. What is a Process? Unix Processes Process -- program in execution shell spawns a process for each command and terminates it when the command completes Many processes all multiplexed to a single processor (or a small number

More information

Unix Shell Environments. February 23rd, 2004 Class Meeting 6

Unix Shell Environments. February 23rd, 2004 Class Meeting 6 Unix Shell Environments February 23rd, 2004 Class Meeting 6 Shell Characteristics Command-line interface between the user and the system Automatically starts when you log in, waits for user to type in

More information

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute Shells The UNIX Shells How shell works Fetch command Analyze Execute Unix shells Shell Originator System Name Prompt Bourne Shell S. R. Bourne /bin/sh $ Csh Bill Joy /bin/csh % Tcsh Ken Greer /bin/tcsh

More information

Bashed One Too Many Times. Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009

Bashed One Too Many Times. Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009 Bashed One Too Many Times Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009 What is a Shell? The shell interprets commands and executes them It provides you with an environment

More information

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell:

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell: Shells A shell is a command line interpreter that is the interface between the user and the OS. The shell: analyzes each command determines what actions are to be performed performs the actions Example:

More information

Introduction to the Shell

Introduction to the Shell [Software Development] Introduction to the Shell Davide Balzarotti Eurecom Sophia Antipolis, France What a Linux Desktop Installation looks like What you need Few Words about the Graphic Interface Unlike

More information

Assignment clarifications

Assignment clarifications Assignment clarifications How many errors to print? at most 1 per token. Interpretation of white space in { } treat as a valid extension, involving white space characters. Assignment FAQs have been updated.

More information

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1 Review of Fundamentals Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 GPL the shell SSH (secure shell) the Course Linux Server RTFM vi general shell review 2 These notes are available on

More information

Sperimentazioni I LINUX commands tutorial - Part II

Sperimentazioni I LINUX commands tutorial - Part II Sperimentazioni I LINUX commands tutorial - Part II A. Garfagnini, M. Mazzocco Università degli studi di Padova 24 Ottobre 2012 Streams and I/O Redirection Pipelines Create, monitor and kill processes

More information

Introduction to Linux

Introduction to Linux Introduction to Linux January 2011 Don Bahls User Consultant (Group Leader) bahls@arsc.edu (907) 450-8674 Overview The shell Common Commands File System Organization Permissions Environment Variables I/O

More information

Introduction to Linux Organizing Files

Introduction to Linux Organizing Files Introduction to Linux Organizing Files Computational Science and Engineering North Carolina A&T State University Instructor: Dr. K. M. Flurchick Email: kmflurch@ncat.edu Arranging, Organizing, Packing

More information

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs Summer 2010 Department of Computer Science and Engineering York University Toronto June 29, 2010 1 / 36 Table of contents 1 2 3 4 2 / 36 Our goal Our goal is to see how we can use Unix as a tool for developing

More information

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p. Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p. 2 Conventions Used in This Book p. 2 Introduction to UNIX p. 5 An Overview

More information

Chapter 9. Shell and Kernel

Chapter 9. Shell and Kernel Chapter 9 Linux Shell 1 Shell and Kernel Shell and desktop enviroment provide user interface 2 1 Shell Shell is a Unix term for the interactive user interface with an operating system A shell usually implies

More information

Review of Fundamentals

Review of Fundamentals Review of Fundamentals 1 The shell vi General shell review 2 http://teaching.idallen.com/cst8207/14f/notes/120_shell_basics.html The shell is a program that is executed for us automatically when we log

More information

Appendix A GLOSSARY. SYS-ED/ Computer Education Techniques, Inc.

Appendix A GLOSSARY. SYS-ED/ Computer Education Techniques, Inc. Appendix A GLOSSARY SYS-ED/ Computer Education Techniques, Inc. $# Number of arguments passed to a script. $@ Holds the arguments; unlike $* it has the capability for separating the arguments. $* Holds

More information

CSC UNIX System, Spring 2015

CSC UNIX System, Spring 2015 CSC 352 - UNIX System, Spring 2015 Study guide for the CSC352 midterm exam (20% of grade). Dr. Dale E. Parson, http://faculty.kutztown.edu/parson We will have a midterm on March 19 on material we have

More information

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29 UNIX The Very 10 Short Howto for beginners Soon-Hyung Yook March 27, 2015 Soon-Hyung Yook UNIX March 27, 2015 1 / 29 Table of Contents 1 History of Unix 2 What is UNIX? 3 What is Linux? 4 How does Unix

More information

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo UNIX COMMANDS AND SHELLS UNIX Programming 2015 Fall by Euiseong Seo What is a Shell? A system program that allows a user to execute Shell functions (internal commands) Other programs (external commands)

More information

CSCI 2132 Software Development. Lecture 3: Unix Shells and Other Basic Concepts

CSCI 2132 Software Development. Lecture 3: Unix Shells and Other Basic Concepts CSCI 2132 Software Development Lecture 3: Unix Shells and Other Basic Concepts Instructor: Vlado Keselj Faculty of Computer Science Dalhousie University 10-Sep-2018 (3) CSCI 2132 1 Introduction to UNIX

More information

Processes and Shells

Processes and Shells Shell ls pico httpd CPU Kernel Disk NIC Processes Processes are tasks run by you or the OS. Processes can be: shells commands programs daemons scripts Shells Processes operate in the context of a shell.

More information

Unix Shells and Other Basic Concepts

Unix Shells and Other Basic Concepts CSCI 2132: Software Development Unix Shells and Other Basic Concepts Norbert Zeh Faculty of Computer Science Dalhousie University Winter 2019 Shells Shell = program used by the user to interact with the

More information

Shells and Shell Programming

Shells and Shell Programming Shells and Shell Programming 1 Shells A shell is a command line interpreter that is the interface between the user and the OS. The shell: analyzes each command determines what actions are to be performed

More information

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1 Review of Fundamentals Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 The CST8207 course notes GPL the shell SSH (secure shell) the Course Linux Server RTFM vi general shell review 2 Linux

More information

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

CSC209H Lecture 1. Dan Zingaro. January 7, 2015 CSC209H Lecture 1 Dan Zingaro January 7, 2015 Welcome! Welcome to CSC209 Comments or questions during class? Let me know! Topics: shell and Unix, pipes and filters, C programming, processes, system calls,

More information

UNIX Kernel. UNIX History

UNIX Kernel. UNIX History UNIX History UNIX Kernel 1965-1969 Bell Labs participates in the Multics project. 1969 Ken Thomson develops the first UNIX version in assembly for an DEC PDP-7 1973 Dennis Ritchie helps to rewrite UNIX

More information

Crash Course in Unix. For more info check out the Unix man pages -orhttp://www.cs.rpi.edu/~hollingd/unix. -or- Unix in a Nutshell (an O Reilly book).

Crash Course in Unix. For more info check out the Unix man pages -orhttp://www.cs.rpi.edu/~hollingd/unix. -or- Unix in a Nutshell (an O Reilly book). Crash Course in Unix For more info check out the Unix man pages -orhttp://www.cs.rpi.edu/~hollingd/unix -or- Unix in a Nutshell (an O Reilly book). 1 Unix Accounts To access a Unix system you need to have

More information

Appendix B WORKSHOP. SYS-ED/ Computer Education Techniques, Inc.

Appendix B WORKSHOP. SYS-ED/ Computer Education Techniques, Inc. Appendix B WORKSHOP SYS-ED/ Computer Education Techniques, Inc. 1 Introduction There are no workshops for this chapter. The instructor will provide demonstrations and examples. SYS-ED/COMPUTER EDUCATION

More information

bash, part 3 Chris GauthierDickey

bash, part 3 Chris GauthierDickey bash, part 3 Chris GauthierDickey More redirection As you know, by default we have 3 standard streams: input, output, error How do we redirect more than one stream? This requires an introduction to file

More information

M2PGER FORTRAN programming. General introduction. Virginie DURAND and Jean VIRIEUX 10/13/2013 M2PGER - ALGORITHME SCIENTIFIQUE

M2PGER FORTRAN programming. General introduction. Virginie DURAND and Jean VIRIEUX 10/13/2013 M2PGER - ALGORITHME SCIENTIFIQUE M2PGER 2013-2014 FORTRAN programming General introduction Virginie DURAND and Jean VIRIEUX 1 Why learning programming??? 2 Why learning programming??? ACQUISITION numerical Recording on magnetic supports

More information

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen Introduction to Unix The Windows User perspective Wes Frisby Kyle Horne Todd Johansen What is Unix? Portable, multi-tasking, and multi-user operating system Software development environment Hardware independent

More information

Linux shell scripting Getting started *

Linux shell scripting Getting started * Linux shell scripting Getting started * David Morgan *based on chapter by the same name in Classic Shell Scripting by Robbins and Beebe What s s a script? text file containing commands executed as a unit

More information

System Programming. Introduction to Unix

System Programming. Introduction to Unix Content : by Dr. B. Boufama School of Computer Science University of Windsor Instructor: Dr. A. Habed adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Introduction 2 3 Introduction

More information

Shells and Shell Programming

Shells and Shell Programming Shells and Shell Programming Shells A shell is a command line interpreter that is the interface between the user and the OS. The shell: analyzes each command determines what actions are to be performed

More information

Processes. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms:

Processes. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms: Processes The Operating System, Shells, and Python Shell Commands a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms: - Command prompt - Shell - CLI Shell commands

More information

22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University

22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University Lecture 8 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control 22-Sep-2017 Location: Goldberg CS 127 Time: 14:35 15:25 Instructor:

More information

Systems Programming/ C and UNIX

Systems Programming/ C and UNIX Systems Programming/ C and UNIX Alice E. Fischer Lecture 6: Processes October 9, 2017 Alice E. FischerLecture 6: Processes Lecture 5: Processes... 1/26 October 9, 2017 1 / 26 Outline 1 Processes 2 Process

More information

Introduction to UNIX Part II

Introduction to UNIX Part II T H E U N I V E R S I T Y of T E X A S H E A L T H S C I E N C E C E N T E R A T H O U S T O N S C H O O L of H E A L T H I N F O R M A T I O N S C I E N C E S Introduction to UNIX Part II For students

More information

Creating a Shell or Command Interperter Program CSCI411 Lab

Creating a Shell or Command Interperter Program CSCI411 Lab Creating a Shell or Command Interperter Program CSCI411 Lab Adapted from Linux Kernel Projects by Gary Nutt and Operating Systems by Tannenbaum Exercise Goal: You will learn how to write a LINUX shell

More information

CSC209F Midterm (L5101) Fall 1998 University of Toronto Department of Computer Science

CSC209F Midterm (L5101) Fall 1998 University of Toronto Department of Computer Science CSC209F Midterm (L5101) Fall 1998 University of Toronto Department of Computer Science Date: November 2 nd, 1998 Time: 6:10 pm Duration: 50 minutes Notes: 1. This is a closed book test, no aids are allowed.

More information

Lab 2: Linux/Unix shell

Lab 2: Linux/Unix shell Lab 2: Linux/Unix shell Comp Sci 1585 Data Structures Lab: Tools for Computer Scientists Outline 1 2 3 4 5 6 7 What is a shell? What is a shell? login is a program that logs users in to a computer. When

More information

Perl and R Scripting for Biologists

Perl and R Scripting for Biologists Perl and R Scripting for Biologists Lukas Mueller PLBR 4092 Course overview Linux basics (today) Linux advanced (Aure, next week) Why Linux? Free open source operating system based on UNIX specifications

More information

UNIX Quick Reference

UNIX Quick Reference UNIX Quick Reference This card represents a brief summary of some of the more frequently used UNIX commands that all users should be at least somewhat familiar with. Some commands listed have much more

More information

Advanced UNIX. 2. The Shell (Ch.5, Sobell) Objectives. to supplement the Introduction to UNIX slides with extra information about the Shell

Advanced UNIX. 2. The Shell (Ch.5, Sobell) Objectives. to supplement the Introduction to UNIX slides with extra information about the Shell Advanced UNIX CIS 218 Advanced UNIX 2. The Shell (Ch.5, Sobell) Objectives to supplement the Introduction to UNIX slides with extra information about the Shell CIS 218 Advanced UNIX 1 Overview 1. Redirection

More information

CS 307: UNIX PROGRAMMING ENVIRONMENT REVIEW FOR EXAM 2

CS 307: UNIX PROGRAMMING ENVIRONMENT REVIEW FOR EXAM 2 CS 307: UNIX PROGRAMMING ENVIRONMENT REVIEW FOR EXAM 2 Prof. Michael J. Reale Fall 2014 EXAM 2 OVERVIEW Exam 2 Material Exam 2 will cover the following: REVIEW slides from (8) to (17) (INCLUSIVE) THIS

More information

Study Guide Processes & Job Control

Study Guide Processes & Job Control Study Guide Processes & Job Control Q1 - PID What does PID stand for? Q2 - Shell PID What shell command would I issue to display the PID of the shell I'm using? Q3 - Process vs. executable file Explain,

More information

Introduction: What is Unix?

Introduction: What is Unix? Introduction Introduction: What is Unix? An operating system Developed at AT&T Bell Labs in the 1960 s Command Line Interpreter GUIs (Window systems) are now available Introduction: Unix vs. Linux Unix

More information

S E C T I O N O V E R V I E W

S E C T I O N O V E R V I E W INPUT, OUTPUT REDIRECTION, PIPING AND PROCESS CONTROL S E C T I O N O V E R V I E W In this section, we will learn about: input redirection; output redirection; piping; process control; 5.1 INPUT AND OUTPUT

More information

Unix Internal Assessment-2 solution. Ans:There are two ways of starting a job in the background with the shell s & operator and the nohup command.

Unix Internal Assessment-2 solution. Ans:There are two ways of starting a job in the background with the shell s & operator and the nohup command. Unix Internal Assessment-2 solution 1 a.explain the mechanism of process creation. Ans: There are three distinct phases in the creation of a process and uses three important system calls viz., fork, exec,

More information

Implementation of a simple shell, xssh

Implementation of a simple shell, xssh Implementation of a simple shell, xssh What is a shell? A process that does command line interpretation Reads a command from standard input (stdin) Executes command corresponding to input line In the simple

More information

Unix/Linux: History and Philosophy

Unix/Linux: History and Philosophy Unix/Linux: History and Philosophy History and Background Multics project Unix Linux Multiplexed Information and Computing Service Collaborative venture between General Electric, Bell Telephone Labs, and

More information

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes CSE 390a Lecture 2 Exploring Shell Commands, Streams, Redirection, and Processes slides created by Marty Stepp, modified by Jessica Miller & Ruth Anderson http://www.cs.washington.edu/390a/ 1 2 Lecture

More information

Implementation of a simple shell, xssh

Implementation of a simple shell, xssh Implementation of a simple shell, xssh What is a shell? A process that does command line interpretation Reads a command from standard input (stdin) Executes command corresponding to input line In simple

More information

Introduction to the Linux Command Line January Presentation Topics

Introduction to the Linux Command Line January Presentation Topics 1/22/13 Introduction to the Linux Command Line January 2013 Presented by Oralee Nudson ARSC User Consultant & Student Supervisor onudson@alaska.edu Presentation Topics Information Assurance and Security

More information

Unix tutorial. Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based.

Unix tutorial. Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based. Unix tutorial Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based. Terminal windows You will use terminal windows to enter and execute

More information

S E C T I O N O V E R V I E W

S E C T I O N O V E R V I E W PROGRAM CONTROL, FILE ARCHIVING, ENVIRONMENT AND SCRIPTS S E C T I O N O V E R V I E W Continuing from last section, we are going to learn about the following concepts: controlling programs; working with

More information

Lab 2: Implementing a Shell COMPSCI 310: Introduction to Operating Systems

Lab 2: Implementing a Shell COMPSCI 310: Introduction to Operating Systems Lab 2: Implementing a Shell COMPSCI 310: Introduction to Operating Systems 1 Shells are cool Unix [3] embraces the philosophy: Write programs that do one thing and do it well. Write programs to work together.

More information

Introduction to Shell Scripting

Introduction to Shell Scripting Introduction to Shell Scripting Evan Bollig and Geoffrey Womeldorff Presenter Yusong Liu Before we begin... Everyone please visit this page for example scripts and grab a crib sheet from the front http://www.scs.fsu.edu/~bollig/techseries

More information

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines Introduction to UNIX Logging in Basic system architecture Getting help Intro to shell (tcsh) Basic UNIX File Maintenance Intro to emacs I/O Redirection Shell scripts Logging in most systems have graphical

More information

Command-line interpreters

Command-line interpreters Command-line interpreters shell Wiki: A command-line interface (CLI) is a means of interaction with a computer program where the user (or client) issues commands to the program in the form of successive

More information

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze EECS 2031 Software Tools Prof. Mokhtar Aboelaze Footer Text 1 EECS 2031E Instructor: Mokhtar Aboelaze Room 2026 CSEB lastname@cse.yorku.ca x40607 Office hours TTH 12:00-3:00 or by appointment 1 Grading

More information

Oxford University Computing Services. Getting Started with Unix

Oxford University Computing Services. Getting Started with Unix Oxford University Computing Services Getting Started with Unix Unix c3.1/2 Typographical Conventions Listed below are the typographical conventions used in this guide. Names of keys on the keyboard are

More information

UNIX Shell Programming

UNIX Shell Programming $!... 5:13 $$ and $!... 5:13.profile File... 7:4 /etc/bashrc... 10:13 /etc/profile... 10:12 /etc/profile File... 7:5 ~/.bash_login... 10:15 ~/.bash_logout... 10:18 ~/.bash_profile... 10:14 ~/.bashrc...

More information

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi Lezione 8 Bioinformatica Mauro Ceccanti e Alberto Paoluzzi Dip. Informatica e Automazione Università Roma Tre Dip. Medicina Clinica Università La Sapienza Sommario Shell command language Introduction A

More information

ACS Unix (Winter Term, ) Page 92

ACS Unix (Winter Term, ) Page 92 ACS-294-001 Unix (Winter Term, 2016-2017) Page 92 The Idea of a Link When Unix creates a file, it does two things: 1. Set space on a disk to store data in the file. 2. Create a structure called an inode

More information

Shell Scripting. With Applications to HPC. Edmund Sumbar Copyright 2007 University of Alberta. All rights reserved

Shell Scripting. With Applications to HPC. Edmund Sumbar Copyright 2007 University of Alberta. All rights reserved AICT High Performance Computing Workshop With Applications to HPC Edmund Sumbar research.support@ualberta.ca Copyright 2007 University of Alberta. All rights reserved High performance computing environment

More information

85321, Systems Administration Chapter 6: The shell

85321, Systems Administration Chapter 6: The shell Chapter 6 Introduction The Shell You will hear many people complain that the UNIX operating system is hard to use. They are wrong. What they actually mean to say is that the UNIX command line interface

More information

Configuring Your Login Session

Configuring Your Login Session Last revised: 5/18/99 Configuring Your Login Session When you log into UNIX, you are running a program called a shell. The shell is the program that provides you with the prompt and that submits to the

More information

Bamuengine.com. Chapter 7. The Process

Bamuengine.com. Chapter 7. The Process Chapter 7. The Process Introduction A process is an OS abstraction that enables us to look at files and programs as their time image. This chapter discusses processes, the mechanism of creating a process,

More information

UNIX Basics by Peter Collinson, Hillside Systems. The Korn Shell

UNIX Basics by Peter Collinson, Hillside Systems. The Korn Shell by Peter Collinson, Hillside Systems BEK SHAKIROV W ell, nobody s perfect. I created an incorrect impression about the Korn shell in my article Over revisited (SW Expert August 2000). I said that the source

More information

Topic 2: More Shell Skills

Topic 2: More Shell Skills Topic 2: More Shell Skills Sub-topics: 1 quoting 2 shell variables 3 sub-shells 4 simple shell scripts (no ifs or loops yet) 5 bash initialization files 6 I/O redirection & pipes 7 aliases 8 text file

More information

An Introduction to Unix Power Tools

An Introduction to Unix Power Tools An to Unix Power Tools Randolph Langley Department of Computer Science Florida State University August 27, 2008 History of Unix Unix Today Command line versus graphical interfaces to COP 4342, Fall History

More information

Chap2: Operating-System Structures

Chap2: Operating-System Structures Chap2: Operating-System Structures Objectives: services OS provides to users, processes, and other systems structuring an operating system how operating systems are designed and customized and how they

More information

Operating Systems, Unix Files and Commands SEEM

Operating Systems, Unix Files and Commands SEEM Operating Systems, Unix Files and Commands SEEM 3460 1 Major Components of Operating Systems (OS) Process management Resource management CPU Memory Device File system Bootstrapping SEEM 3460 2 Programs

More information

Lab Week02 - Part I. Shell Commands. Professional Training Academy Linux Series

Lab Week02 - Part I. Shell Commands. Professional Training Academy Linux Series Lab Week02 - Part I Shell Commands Professional Training Academy Linux Series Commands: Manipulation cp : copy a file To copy a file you need to give a source and then a destination e.g. to copy the file

More information

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell Lezione 8 Bioinformatica Mauro Ceccanti e Alberto Paoluzzi Esercitazione Introduzione al linguaggio di shell Dip. Informatica e Automazione Università Roma Tre Dip. Medicina Clinica Università La Sapienza

More information

CSCI2467: Systems Programming Concepts

CSCI2467: Systems Programming Concepts CSCI2467: Systems Programming Concepts Class activity: bash shell literacy Instructor: Matthew Toups Fall 2017 Today 0 Shells History Usage Scripts vs. Programs 1 Bash shell: practical uses for your systems

More information

CSE II-Sem)

CSE II-Sem) 1 2 a) Login to the system b) Use the appropriate command to determine your login shell c) Use the /etc/passwd file to verify the result of step b. d) Use the who command and redirect the result to a file

More information

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems. Copyleft 2005, Binnur Kurt 3 Operating Systems Copyleft 2005, Binnur Kurt Content The concept of an operating system. The internal architecture of an operating system. The architecture of the Linux operating system in more detail.

More information

Introduction to Linux Workshop 1

Introduction to Linux Workshop 1 Introduction to Linux Workshop 1 The George Washington University SEAS Computing Facility Created by Jason Hurlburt, Hadi Mohammadi, Marco Suarez hurlburj@gwu.edu Logging In The lab computers will authenticate

More information

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing Content 3 Operating Systems The concept of an operating system. The internal architecture of an operating system. The architecture of the Linux operating system in more detail. How to log into (and out

More information

Environment Variables

Environment Variables Environment Variables 1 A shell is simply a program that supplies certain services to users. As such, a shell may take parameters whose values modify or define certain behaviors. These parameters (or shell

More information

CHAPTER 2 THE UNIX SHELLS

CHAPTER 2 THE UNIX SHELLS CHAPTER 2 THE UNIX SHELLS The layers in a UNIX system is shown in the following figure. system call interface library interface user interface Users Standard utility programs (shell, editors, compilers,

More information

Linux shell programming for Raspberry Pi Users - 2

Linux shell programming for Raspberry Pi Users - 2 Linux shell programming for Raspberry Pi Users - 2 Sarwan Singh Assistant Director(S) NIELIT Chandigarh 1 SarwanSingh.com Education is the kindling of a flame, not the filling of a vessel. - Socrates SHELL

More information

Vi & Shell Scripting

Vi & Shell Scripting Vi & Shell Scripting Comp-206 : Introduction to Week 3 Joseph Vybihal Computer Science McGill University Announcements Sina Meraji's office hours Trottier 3rd floor open area Tuesday 1:30 2:30 PM Thursday

More information

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples EECS2301 Title Unix/Linux Introduction These slides are based on slides by Prof. Wolfgang Stuerzlinger at York University Warning: These notes are not complete, it is a Skelton that will be modified/add-to

More information

CHAPTER 3 SHELL PROGRAMS: SCRIPTS

CHAPTER 3 SHELL PROGRAMS: SCRIPTS CHAPTER 3 SHELL PROGRAMS: SCRIPTS Any series of commands may be stored inside a regular text file for later execution. A file that contains shell commands is called a script. Before you can run a script,

More information

I/O and Shell Scripting

I/O and Shell Scripting I/O and Shell Scripting File Descriptors Redirecting Standard Error Shell Scripts Making a Shell Script Executable Specifying Which Shell Will Run a Script Comments in Shell Scripts File Descriptors Resources

More information

UNIX shell scripting

UNIX shell scripting UNIX shell scripting EECS 2031 Summer 2014 Przemyslaw Pawluk June 17, 2014 What we will discuss today Introduction Control Structures User Input Homework Table of Contents Introduction Control Structures

More information

Linux Refresher (1) 310/ Fourth Workshop on Distributed Laboratory Instrumentation Systems (30 October - 24 November 2006)

Linux Refresher (1) 310/ Fourth Workshop on Distributed Laboratory Instrumentation Systems (30 October - 24 November 2006) 310/1779-4 Fourth Workshop on Distributed Laboratory Instrumentation Systems (30 October - 24 November 2006) Linux Refresher (1) Razaq Babalola IJADUOLA These lecture notes are intended only for distribution

More information