Linux System Administration

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "Linux System Administration"

Transcription

1 Shell Scripts Objective As system administrators it is often necessary to write or modify a script to automate administrator duties We should have a basic understating of the syntax of some basic script statements In this course you will not be expected to write scripts in this lab, but you will have to enter and modify scripts using a text editor save them in a UNIX format make them executable Shell Scripts 2 1

2 Shell Characteristics Provides command line as an interface between the user and the system Simply a program that starts automatically when you login Uses a command language Allows programming (shell scripting) within the shell environment Uses variables, loops, conditionals, etc. Shell Scripts 3 Shell Features The shell command processor provides the following features: Command Line Processing Redirection Pipes and Filters Variable Definition Script Processing Shell Scripts 4 2

3 UNIX shells sh (Bourne shell) ksh(kornshell) csh (C shell) tcsh bash (Bourne again shell) Differences primarily in scripting detail You can initiate a new shell by invoking the command name of the shell you would like to use. To change to the C shell, simply enter csh To return to the prior shell or logoff, press <Ctrl-D> or enter the command exit. The default shell is typically defined in the file /etc/password. The chsh (CHange SHell) command can be used to change the default logon shell Shell Scripts 5 The Bourne Shell (sh) has the following advantage over the C and Korn Shells: The standard AT&T shell -- it is found on almost all UNIX systems Compact and requires minimal resources Executes quickly Widely accepted (portable scripts) The file.profile located in your home directory is executed each time you login if you are using the Bourne (and Korn) Shell You can customize your default working environment by placing environmental definitions in this file Shell Scripts 6 3

4 C Shell csh includes features that make it more suitable for interactive applications than the Bourne shell: Extended Setup Files.login.cshrc (set, history, and alias commands).logout Command Alias Command History Process (Job) Control (BSD only) Script Syntax Similar to C Language The script language of the C Shell is not compatible with Bourne and Korn Shells. Shell Scripts 7 Features of the C shell environment Some of the features of the C shell are: Customizable environment. Abbreviate commands. (Aliases.) History. (Remembers commands typed before.) Job control. (Run programs in the background or foreground.) Shell scripting. (One can write programs using the shell.) Keyboard shortcuts. The C shell provides programming features are: Control constructs. (For example, loop and conditional statements.) File permissions/existence checking. Variable assignment. Built-in Variables. Shell Scripts 8 4

5 KORN Shell designed and developed by David G. Korn at AT&T Bell Laboratories It is an interactive command language that provides access to the UNIX system and to many other systems, on the many different computers and workstations is also a complete, powerful, high-level programming language for writing applications, often more easily and quickly than with other high-level languages. There are two other widely used shells the Bourne shell developed by Steven Bourne at AT&T Bell Laboratories the C shell developed by Bill Joy at the University of California. ksh has the best features of both, plus many features of its own Shell Scripts 9 Bourne Again Shell Bash is the shell for the GNU operating system The name is an acronym for the Bourne-Again SHell, a pun on Stephen Bourne, the author of the direct ancestor of the current Unix shell /bin/sh, which appeared in the Seventh Edition Bell Labs Research version of Unix. Bash is largely compatible with sh and incorporates useful features from the Korn shell ksh and the C shell csh offers functional improvements over sh for both interactive use and programming Bash is quite portable It runs on nearly every version of Unix and a few other operating systems - independently supported ports exist for MS-DOS, OS/2, Windows 95/98, and Windows NT. Although the GNU operating system provides other shells, Bash is the default shell Shell Scripts 10 5

6 Shell Boot Scripts All shells read the /etc/profile file at start up to set system wide environmental variables Next, your system reads individual user environment files depending on your default shell. For Bourne and Korn shell logins, the shell executes /etc/profile and $HOME/.profile, if it exists. For C shell logins, the shell executes /etc/.login, $HOME/.cshrc, and $HOME/.login The default /etc/profile and /etc/.login files check quotas, prints /etc/motd, and checks for mail No messages are printed if the file $HOME/.hushlogin exists The name of the command interpreter is set to - (dash), followed by the last component of the interpreter's path name Shell Scripts 11 Shell Boot Scripts If your default login shell is: bourne shell the system reads $HOME/.profile and.shrc korn shell the system reads $HOME/.profile and.kshrc bash shell the system reads $HOME/.bash_profile and.bashrc C-shell the system reads $HOME/.login and.cshrc $HOME/.cshrc - initial commands for each csh $HOME/.hushlogin - suppresses login messages $HOME/.login - user's login commands for csh $HOME/.profile - user's login commands for sh and ksh $HOME/.rhosts - private list of trusted hostname/username combinations Shell Scripts 12 6

7 BASH Shell environment customization The BASH shell reads the.bash_profile file after it has read the.bashrc file This file is read once only for login shells This file may be used to set up terminal settings, for example, backspace, suspend, and interrupt characters The.logout file contains commands that are run when the user logs out of the system. Shell Scripts 13 Sample.bashrc file #.bashrc # User specific aliases and functions alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' # Source global definitions if [ -f /etc/bashrc ]; then. /etc/bashrc fi Shell Scripts 14 7

8 Sample.bash_profile file #.bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then. ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME:$HOME/bin export PATH unset USERNAME alias p='pwd' alias dir='ls -l' alias copy='cp' alias cls='clear' alias x= 'startx' Shell Scripts 15 # ~/.bash_logout clear Sample.bash_logout file Shell Scripts 16 8

9 Shell Scripts A Shell Script is a series of shell commands placed in an ASCII text file The commands include: Anything you can type on the command line Shell variables or functions Control statements (if, while, for) When writing scripts containing Linux and UNIX commands, there are two types of variables that are used: 1. System variables these are created and maintained by the operating system itself System variables are always typed in UPPERCASE. 2. User defined variables (UDV) - these are created and maintained by the user User defined variables are always typed in lowercase. Shell Scripts 17 System Variables Three commonly used system variables are: $USER your login $PATH the list of directories that the OS should search when you request the execution of a program. $HOME your home directory, which is /home/username You check your PATH using the command: echo $PATH To see your current login, enter echo $USER To see your home directory, enter echo $HOME Before we modify an important existing file, we must have root privilege, and make a backup of the original file. An easy way make a backup copy of a file is with the copy command as follows: # cp /etc/fstab /etc/fstab.orig Shell Scripts 18 9

10 Setting Environment Variables Set a variable with <name>=<value> Examples: TERM=vt100 PS1=myprompt> PS1= multiple word prompt> PATH=$PATH:$HOME DATE=`date` Shell Scripts 19 Aliases Aliases are used as shorthand for frequently used commands Syntax: alias <shortcut>=<command> Examples: alias ll= ls -lf alias la= ls -la alias m=more alias up= cd.. alias prompt= echo $PS1 Shell Scripts 20 10

11 Login Scripts We don t want to enter aliases, set environment variables, set up command line editing, etc. each time we log in All of these things can be done in a script that is run each time the shell is started For bash: ~/.bash_profile - is read for a login shell ~/.bashrc - is read for login and other interactive shells Shell Scripts 21 Create a Script In your home directory, create a file named hello using vi The first line of a Bash shell script should start with: #!/bin/bash This indicates that the script should be run in the bash shell regardless of which interactive shell the user has chosen Comments begin with # and continue to the end of the line We will enter a script that will: echo $USER will identify your current logon ls la more to list the contents of the current directory finger list all users logged on, where they are logged on from, and other information whoami identifies your current logon Shell Scripts 22 11

12 Using Quotes in Scripts Quoting is necessary to use special characters in a variable s value or string - shell only interprets $ and and \ $ - variable substitution ` - Command substitution \ - Literal double quote \ is used to escape characters echo `date +%D` will print: 10/06/03 - shell doesn t interpret special characters echo `date +%D` will print: `date +%D` Shell Scripts 23 Shell Variables Numeric Command line arguments Strings Functions Arrays Read only Names begin with alpha characters and include alpha, numeric, or underscore var refers to a name $var refers to the value t = 100 #Sets var t to value 100 echo \$t = $t #will print: $t = 100 Remove a variable with unset var The export command allows child processes of the shell to access the variable Shell Scripts 24 12

13 Conditional Statements Sometimes, it is necessary to check a program for conditions This is done with a conditional statement if condition then statement1 else statement2 fi if identifies condition at the beginning of the conditional statement such as if x > 7 then contains one or more statements that are executed only if the condition is true else contains zero or more statements that are executed only if the condition is false fi identifies the end of the conditional statements Shell Scripts 25 Sample Scripts #!/bin/bash echo "Hello $USER." ls -la less finger echo "I am logged on as `whoami`. After you type the script, write and exit You must make it executable chmod u+x hello Execute the script with the command hello Shell Scripts 26 13

14 Script Execution Make the script executable using chmod Make sure the PATH includes the current directory If you receive a file not found when you execute a script from your /home directory, it is because it is not in your PATH To put your current directory in the PATH, from the command line enter the commands PATH=$PATH:$HOME export PATH Run the script from the command line Instead of $HOME, you can just place a period after the colon like this PATH=$PATH:. You still need the export PATH statement so the new path is known to the system Shell Scripts 27 Modifying Default Profile for New Users Change to the /etc/skel directory Use vi to open the file.bash_profile Change the files PATH statement as follows: PATH=$PATH:$HOME:$HOME/bin Go to the end of the file and add the following three lines: alias p='pwd' alias dir='ls -l' alias copy='cp' alias cls='clear' alias x='startx' Save the file and exit You can go to you home directory and to root and make the same changes to the same file Shell Scripts 28 14

Chapter 8: Shell Scripting. Chapter 8 Shell Scripting

Chapter 8: Shell Scripting. Chapter 8 Shell Scripting Chapter 8: Shell Scripting Chapter 8 Shell Scripting Last revised: 20/6/2004 Chapter 8 Outline In this chapter we will learn how to: Create shell scripts Use variables and environment variables Pass parameters

More information

Module Eight Shell Scripting in Linux

Module Eight Shell Scripting in Linux Postgraduate course, Covenant University Ota, Nigeria Oyelade, O. J., PhD ola.oyelade@covenantuniversity.edu.ng Isewon, I. itunu.isewon@covenantuniversity.edu.ng Module Eight Shell Scripting in Linux 8.1

More information

Which shell? Shells. Common shell facilities. bash versus sh

Which shell? Shells. Common shell facilities. bash versus sh 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

Unix Shell Scripts. Contents. 1 Introduction. Norman Matloff. July 30, 2008. 1 Introduction 1. 2 Invoking Shell Scripts 2

Unix Shell Scripts. Contents. 1 Introduction. Norman Matloff. July 30, 2008. 1 Introduction 1. 2 Invoking Shell Scripts 2 Unix Shell Scripts Norman Matloff July 30, 2008 Contents 1 Introduction 1 2 Invoking Shell Scripts 2 2.1 Direct Interpretation....................................... 2 2.2 Indirect Interpretation......................................

More information

Linux shell scripting intro/review

Linux shell scripting intro/review Linux shell scripting intro/review David Morgan You should already know how to log in run programs at the command line use pipelines and redirection ( < > ) put jobs in the background ( & ) create and

More information

Using Linux Six rules of thumb in using Linux EVERYTHING ls -l ls /bin ctrl-d Linux Kernel Shell Command Interpretation shell myfile myfile

Using Linux Six rules of thumb in using Linux EVERYTHING ls -l ls /bin ctrl-d Linux Kernel Shell Command Interpretation shell myfile myfile Using Linux In this section we cover some background Linux concepts including some general rules of thumb when using Linux, the operating system kernel, the shell command interpreter, and the file system.

More information

The Linux Operating System

The Linux Operating System The Linux Operating System Charles Abzug, Ph.D. Department of Computer Science James Madison University Harrisonburg, VA 22807 Voice Phone: 540-568-8746; Cell Phone: 443-956-9424 E-mail: abzugcx@jmu.edu

More information

Shell Scripting. 2014/10/09 Victor Eijkhout

Shell Scripting. 2014/10/09 Victor Eijkhout Shell Scripting 2014/10/09 Victor Eijkhout What is a shell? Command interpreter: listens for your commands, executes, shows output Toolbox: chain together commands with pipes Programming language: Variables

More information

A Crash Course on UNIX

A Crash Course on UNIX A Crash Course on UNIX UNIX is an "operating system". Interface between user and data stored on computer. A Windows-style interface is not required. Many flavors of UNIX (and windows interfaces). Solaris,

More information

Beginners Shell Scripting for Batch Jobs

Beginners Shell Scripting for Batch Jobs Beginners Shell Scripting for Batch Jobs Evan Bollig and Geoffrey Womeldorff 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

Basic C Shell. helpdesk@stat.rice.edu. 11th August 2003

Basic C Shell. helpdesk@stat.rice.edu. 11th August 2003 Basic C Shell helpdesk@stat.rice.edu 11th August 2003 This is a very brief guide to how to use cshell to speed up your use of Unix commands. Googling C Shell Tutorial can lead you to more detailed information.

More information

HP-UX Essentials and Shell Programming Course Summary

HP-UX Essentials and Shell Programming Course Summary Contact Us: (616) 875-4060 HP-UX Essentials and Shell Programming Course Summary Length: 5 Days Prerequisite: Basic computer skills Recommendation Statement: Student should be able to use a computer monitor,

More information

Introduction to shell programming using bash Part I

Introduction to shell programming using bash Part I Introduction to shell programming using bash Part I Deniz Savas and Michael Griffiths 2005-2011 Corporate Information and Computing Services The University of Sheffield Email M.Griffiths@sheffield.ac.uk

More information

Hands-On UNIX Exercise:

Hands-On UNIX Exercise: Hands-On UNIX Exercise: This exercise takes you around some of the features of the shell. Even if you don't need to use them all straight away, it's very useful to be aware of them and to know how to deal

More information

UNIX/Linux: Notes on Sobell, Chapter 9, Bourne Again Shell

UNIX/Linux: Notes on Sobell, Chapter 9, Bourne Again Shell These are some notes to help you through Chapter 9 of A Practical Guide to Linux, by Mark Sobell. This is the chapter on the BASH shell, and it is long, complicated, and difficult. But it covers how the

More information

The Bourne Again Shell

The Bourne Again Shell 08.bash2.fm Page 257 Tuesday, November 8, 2005 6:49 PM 8 The Bourne Again Shell In This Chapter Startup Files................. 259 Redirecting Standard Error...... 262 Writing a Simple Shell Script....

More information

UNIX Commands. COMP 444/5201 Revision 1.4 January 25,

UNIX Commands. COMP 444/5201 Revision 1.4 January 25, UNIX Commands COMP 444/5201 Revision 1.4 January 25, 2005 1 Contents Shell Intro Command Format Shell I/O Command I/O Command Overview 2 Shell Intro A system program that allows a user to execute: shell

More information

What is Shell Script?

What is Shell Script? Linux Shell Scripts What is Shell Script? We have seen some basic shell commands, it s time to move on to scripts. There are two ways of writing shell programs. You can type a sequence of commands and

More information

What is UNIX? A Little Bit about UNIX and User Interfaces

What is UNIX? A Little Bit about UNIX and User Interfaces What is UNIX? A Little Bit about UNIX and User Interfaces Copyright 2006 Stewart Weiss What is UNIX? It is a multi-user, multi-tasking operating system. An operating system is a program or collection of

More information

Introduction to Linux Basics

Introduction to Linux Basics Introduction to Linux Basics Part-II Shell Scripting Georgia Advanced Computing Resource Center University of Georgia Zhuofei Hou, HPC Trainer zhuofei@uga.edu Outline What is GACRC? What are Linux Shell

More information

LSN 10 Linux Overview

LSN 10 Linux Overview LSN 10 Linux Overview ECT362 Operating Systems Department of Engineering Technology LSN 10 Linux Overview Linux Contemporary open source implementation of UNIX available for free on the Internet Introduced

More information

Command Line - Part 1

Command Line - Part 1 Command Line - Part 1 STAT 133 Gaston Sanchez Department of Statistics, UC Berkeley gastonsanchez.com github.com/gastonstat Course web: gastonsanchez.com/teaching/stat133 GUIs 2 Graphical User Interfaces

More information

Shell Scripting Crash Course

Shell Scripting Crash Course Shell Scripting Crash Course Travis Phillips JAX LUG Overview What is a shell script What can I do with a shell script How to build shell scripts Syntax basics Basic useful shell commands Pipes and redirectors

More information

Environment Variables. Command Line. Environment Variables. Variables. csh/tcsh:

Environment Variables. Command Line. Environment Variables. Variables. csh/tcsh: Overview Shell Scripting Tom Logan (Slides from Kate Hedstrom & Don Bahls) Variables Scripting Basics Bash Shell Scripts Other Scripting Advanced Command Line Appendix (C-Shell Scripts) Shells Bash There

More information

Outline. Unix shells Bourne-again Shell (bash) Interacting with bash Basic scripting References

Outline. Unix shells Bourne-again Shell (bash) Interacting with bash Basic scripting References Ryan Hulguin Outline Unix shells Bourne-again Shell (bash) Interacting with bash Basic scripting References Unix shells This lets users issue commands to the Unix operating system Users can interact with

More information

INFORMATION SYSTEMS SERVICES

INFORMATION SYSTEMS SERVICES INFORMATION SYSTEMS SERVICES Further Exercises in Unix This document contains a series of exercises which provide examples of Unix commands and is intended for existing Unix users AUTHOR: Information Systems

More information

BASH Shell Scripting. Adapted from:

BASH Shell Scripting. Adapted from: BASH Shell Scripting Adapted from: http://www.eecs.wsu.edu/~cs302/notes/shprogramming.html http://steve-parker.org/sh The basics A shell script is a collection of Unix commands, with a little bit of programming

More information

Unix Sampler. PEOPLE whoami id who

Unix Sampler. PEOPLE whoami id who Unix Sampler PEOPLE whoami id who finger username hostname grep pattern /etc/passwd Learn about yourself. See who is logged on Find out about the person who has an account called username on this host

More information

Shell Script & Advance Features of Shell Programming

Shell Script & Advance Features of Shell Programming Available Online at www.ijcsmc.com International Journal of Computer Science and Mobile Computing A Monthly Journal of Computer Science and Information Technology IJCSMC, Vol. 4, Issue. 4, April 2015,

More information

Session 2: Shell Scripting

Session 2: Shell Scripting Session 2: Shell Scripting Craig A. Struble, Ph.D. July 14, 2010 1 Introduction Shell scripts are a way to automate the execution of a series of Linux commands. Essentially, any command you can run from

More information

Linux Shells. Linux Shells. Book Chapter 5. What is a shell? Examples: Linux default shell /bin/bash. How do I know what shell I am running?

Linux Shells. Linux Shells. Book Chapter 5. What is a shell? Examples: Linux default shell /bin/bash. How do I know what shell I am running? Linux Shells Book Chapter 5 What is a shell? Examples: bash Bourne Again shell ksh tcsh Korn shell C shell 1 Linux Shells Linux default shell /bin/bash How do I know what shell I am running? echo $SHELL

More information

KORN SHELL PROGRAMMING CHEAT SHEET

KORN SHELL PROGRAMMING CHEAT SHEET KORN SHELL PROGRAMMING CHEAT SHEET Special Characters Metacharacters have special meaning to the shell unless quoted (by preceding it with a \ or enclosing it in ` `) Inside double quotes parameter and

More information

Lab Manual. Unix and Linux Programming (Pr) COT-218 and IT-214

Lab Manual. Unix and Linux Programming (Pr) COT-218 and IT-214 Lab Manual Unix and Linux Programming (Pr) COT-218 and IT-214 Lab Instructions Several practicals / programs? Whether an experiment contains one or several practicals /programs One practical / program

More information

Unix Scripts and Job Scheduling

Unix Scripts and Job Scheduling Unix Scripts and Job Scheduling Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh spring@imap.pitt.edu http://www.sis.pitt.edu/~spring Overview Shell Scripts

More information

A Brief Introduction to the Use of Shell Variables

A Brief Introduction to the Use of Shell Variables A Brief Introduction to the Use of Shell Variables Norman Matloff July 25, 2001 Contents 1 Two Popular Shells: tcsh and bash 1.1 Overview There are many different shells available for Unix systems. Here

More information

San Francisco State University School of Engineering Nano-electronics & Computing Research Center BASIC UNIX/LINUX COMMANDS

San Francisco State University School of Engineering Nano-electronics & Computing Research Center BASIC UNIX/LINUX COMMANDS San Francisco State University School of Engineering Nano-electronics & Computing Research Center BASIC UNIX/LINUX COMMANDS Introduction A short paper that briefly describes the UNIX shell, environment

More information

Shell Scripts (1) For example: #!/bin/sh If they do not, the user's current shell will be used. Any Unix command can go in a shell script

Shell Scripts (1) For example: #!/bin/sh If they do not, the user's current shell will be used. Any Unix command can go in a shell script Shell Programming Shell Scripts (1) Basically, a shell script is a text file with Unix commands in it. Shell scripts usually begin with a #! and a shell name For example: #!/bin/sh If they do not, the

More information

Cisco Networking Academy Program Curriculum Scope & Sequence. Fundamentals of UNIX version 2.0 (July, 2002)

Cisco Networking Academy Program Curriculum Scope & Sequence. Fundamentals of UNIX version 2.0 (July, 2002) Cisco Networking Academy Program Curriculum Scope & Sequence Fundamentals of UNIX version 2.0 (July, 2002) Course Description: Fundamentals of UNIX teaches you how to use the UNIX operating system and

More information

The Command Line. Matthew Bender. Friday 9 th October, CMSC Command Line Workshop

The Command Line. Matthew Bender. Friday 9 th October, CMSC Command Line Workshop The Command Line Matthew Bender CMSC Command Line Workshop Friday 9 th October, 2015 Matthew Bender (2015) The Command Line Friday 9 th October, 2015 1 / 22 Functions Section 1 Functions Matthew Bender

More information

SCR. Scripting. Goals of this lab: Prerequisites: LXB

SCR. Scripting. Goals of this lab: Prerequisites: LXB SCR Scripting Goals of this lab: To learn the basics of writing shell scripts. To gain insight in the gains with automating administrative work. To gain practical experience of automating administrative

More information

CS2720 Practical Software Development

CS2720 Practical Software Development Page 1 Rex Forsyth CS2720 Practical Software Development CS2720 Practical Software Development Scripting Tutorial Srping 2011 Instructor: Rex Forsyth Office: C-558 E-mail: forsyth@cs.uleth.ca Tel: 329-2496

More information

2. To see the contents of DOG variable, you must proceed the name of the variable with a $ operator.

2. To see the contents of DOG variable, you must proceed the name of the variable with a $ operator. CPSC 2800 - Lab #6: Shell Script Programming Project 6-1 Before setting one or more environment variables, it is a good idea to view their current configurations. In this project, you use the printenv

More information

CS2043 - Unix Tools & Scripting Lecture 9 Shell Scripting

CS2043 - Unix Tools & Scripting Lecture 9 Shell Scripting CS2043 - Unix Tools & Scripting Lecture 9 Shell Scripting Spring 2015 1 February 9, 2015 1 based on slides by Hussam Abu-Libdeh, Bruno Abrahao and David Slater over the years Announcements Coursework adjustments

More information

New Lab Intro to KDE Terminal Konsole

New Lab Intro to KDE Terminal Konsole New Lab Intro to KDE Terminal Konsole After completing this lab activity the student will be able to; Access the KDE Terminal Konsole and enter basic commands. Enter commands using a typical command line

More information

The Basics of the bash shell

The Basics of the bash shell The Basics of the bash shell Phil Spector September 4, 2009 The bash shell is the program that Linux and Mac systems use to actually communicate with the computer. When you type a command into the shell,

More information

Automating admin tasks using shell scripts and cron Vijay Kumar Adhikari. vijay@kcm

Automating admin tasks using shell scripts and cron Vijay Kumar Adhikari. vijay@kcm Automating admin tasks using shell scripts and cron Vijay Kumar Adhikari vijay@kcm kcm.edu.np How do we go? Introduction to shell scripts Example scripts Introduce concepts at we encounter them in examples

More information

LINUX SHELL SCRIPTING

LINUX SHELL SCRIPTING LINUX SHELL SCRIPTING @Copyright 2015 1 1. Chapter 1: Quick Introduction to Linux What Is Linux? Who created Linux? Where can I download Linux? How do I Install Linux? Linux usage in everyday life What

More information

Origins of scripting languages

Origins of scripting languages Scripting on Linux Origins of scripting languages Learning scripting languages A simple example of a shell script A script with a loop and debugging Processing a table of data by selecting rows and columns

More information

Internet Traffic Measurements. Shell Scripts. School of Electrical Engineering AALTO UNIVERSITY

Internet Traffic Measurements. Shell Scripts. School of Electrical Engineering AALTO UNIVERSITY Internet Traffic Measurements Shell Scripts School of Electrical Engineering AALTO UNIVERSITY Page 1 Contents What is a shell script?... 2 Useful Linux commands... 2 Useful commands for data manipulation...

More information

Unix/Linux basics Operating systems lab Gergely Windisch room 4.12

Unix/Linux basics Operating systems lab Gergely Windisch room 4.12 Unix/Linux basics 0001 Operating systems lab Gergely Windisch windisch.gergely@nik.bmf.hu room 4.12 http://nik.bmf.hu/gwindisch/os_2010 And now: the test Assignment test 20 minutes Grade together Is of

More information

Shell Scripts in UNIX

Shell Scripts in UNIX Shell Scripts in UNIX Prof. P.C.P. Bhatt P.C.P Bhatt OS/M13/V1/2004 1 Unix System Shell Organization In the below figure we show how a user interacts with UNIX shell. P.C.P Bhatt OS/M13/V1/2004 2 Facilities

More information

Raspbian (Linux) VNC Linux History Overview Shell Commands File system

Raspbian (Linux) VNC Linux History Overview Shell Commands File system Raspbian (Linux) VNC Linux History Overview Shell Commands File system A new way to connect the Pi: VNC http://quaintproject.wordpress.com/2013/03/24/establish-a-vnc-connection-to-you r-raspberry-pi-from-a-linux-pc

More information

Introduction to C Programming in Linux Environment

Introduction to C Programming in Linux Environment Introduction to C Programming in Linux Environment Ibrahim Korpeoglu Department of Computer Engineering Bilkent University Spring 2004 This document includes information about the followings: Logging to

More information

Ashell program combines Linux commands in such a way as to perform a specific

Ashell program combines Linux commands in such a way as to perform a specific Shell Programming 1 2 Red Hat Linux: The Complete Reference Ashell program combines Linux commands in such a way as to perform a specific task. The Linux shell provides you with many programming tools

More information

GNU Bash. An Introduction to Advanced Usage. James Pannacciulli (mt) Media Temple

GNU Bash. An Introduction to Advanced Usage.  James Pannacciulli (mt) Media Temple GNU Bash http://talk.jpnc.info/bash_scale11x.pdf An Introduction to Advanced Usage James Pannacciulli Sysadmin @ (mt) Media Temple Notes about the presentation: This is a talk about Bash, not about GNU/Linux

More information

Introduction to shell scripting

Introduction to shell scripting Introduction to shell scripting Thomas Röblitz thomas.roblitz@usit.uio.no Research Infrastructure Services Group Department for Research Computing (DRC) DRC Course Week, April 16-18, 2013 Outline What

More information

Laboratory Manual. For OPERATING SYSTEM (140702) B.E. (COMPUTER) SEM IV. January 2013

Laboratory Manual. For OPERATING SYSTEM (140702) B.E. (COMPUTER) SEM IV. January 2013 Laboratory Manual For OPERATING SYSTEM (140702) B.E. (COMPUTER) SEM IV January 2013 Shree Swami Atmanand Saraswati Institute of Technology Shree Swami Atmanand Vidya Sankul, Kapodra, Varachha Road, Surat

More information

Week 1 Lesson 2: Creating Shell Scripts, Linux Commands

Week 1 Lesson 2: Creating Shell Scripts, Linux Commands Week 1 Lesson 2: Creating Shell Scripts, Linux Commands 1 Chapter Objectives In this chapter, you will: Learn how to create Shell Scripts Commenting / Making Portable Shell Scripts Making Shell Scripts

More information

AN INTRODUCTION TO UNIX

AN INTRODUCTION TO UNIX AN INTRODUCTION TO UNIX Paul Johnson School of Mathematics September 24, 2010 OUTLINE 1 SHELL SCRIPTS Shells 2 COMMAND LINE Command Line Input/Output 3 JOBS Processes Job Control 4 NETWORKING Working From

More information

Navigating within the GNU/Linux Filesystem

Navigating within the GNU/Linux Filesystem Navigating within the GNU/Linux Filesystem The purpose of this section is to provide a few basic GNU/Linux commands to aide new users locate areas on the ODU Turing cluster. The commands presented are

More information

Unix the Bare Minimum

Unix the Bare Minimum Unix the Bare Minimum Norman Matloff September 27, 2005 c 2001-2005, N.S. Matloff Contents 1 Purpose 2 2 Shells 2 3 Files and Directories 4 3.1 Creating Directories.......................................

More information

Question Bank 10CS44: UNIX & SHELL PROGRAMMING

Question Bank 10CS44: UNIX & SHELL PROGRAMMING Question Bank 10CS44: UNIX & SHELL PROGRAMMING CHAPTER 1 : UNIX OS AND SOME BASIC COMMANDS,FILE SYSTEM OBJECTIVE: UNIX Born in the dark and somber portals of Bell Labs, it was a dream that one man nurtured

More information

Automating Tasks Using bash

Automating Tasks Using bash Overview Automating Tasks Using bash David McCaughan, HPC Analyst SHARCNET, University of Guelph dbm@sharcnet.ca Introduction to command shells & bash bash fundamentals I/O redirection, pipelining, wildcard

More information

LINUX SHELL SCRIPTING Sagar MungsE------

LINUX SHELL SCRIPTING Sagar MungsE------ LINUX SHELL SCRIPTING ------Sagar MungsE------ Shell Scripting Text files that contain sequences of UNIX commands, created by a text editor No compiler required to run a shell script, because the UNIX

More information

Linux commands 12 th Sept. 07 By Fabian

Linux commands 12 th Sept. 07 By Fabian Advanced Systems and Network Course @ UCC Linux commands 12 th Sept. 07 By Fabian 1 Overview UNIX Linux Simple Linux commands Linux text editors 2 UNIX UNIX is an operating system, originally written at

More information

Linux command line. An introduction to the Linux command line for genomics. Susan Fairley

Linux command line. An introduction to the Linux command line for genomics. Susan Fairley Linux command line An introduction to the Linux command line for genomics Susan Fairley Aims Introduce the command line Provide an awareness of basic functionality Illustrate with some examples Provide

More information

ICS 351: Today's plan

ICS 351: Today's plan ICS 351: Today's plan routing protocols linux commands Routing protocols: overview maintaining the routing tables is very labor-intensive if done manually so routing tables are maintained automatically:

More information

CS 153 Lab1. Kishore Kumar Pusukuri

CS 153 Lab1. Kishore Kumar Pusukuri Outline Overview of Linux/Unix Linux is a variant of UNIX (with only small deviations). Linus Torvalds. 1991. Monolithic kernel rather than Micro-kernel. Linux is free, this license, the GPL (GNU Public

More information

Unix tutorial. Introduction to Unix. VI, March Page 1

Unix tutorial. Introduction to Unix.  VI, March Page 1 Unix tutorial Introduction to Unix http://linux.oreilly.com/ Page 1 Unix tutorial Outline Basic background in Unix structure Directories and files I (listing, navigation, filenames) Directories and files

More information

Using the Shell. UIC Linux Users Group. September 9, 2010

Using the Shell. UIC Linux Users Group. September 9, 2010 September 9, 2010 About the Presenter Hold Your Comments Alias: eviljoel (or ej) Name: Joel Luellwitz 7 Years of Linux Experience. UIC Alumni Management Information Systems Masters from the CBA. Works

More information

Introduction to Shell Programming

Introduction to Shell Programming Introduction to Shell Programming what is shell programming? about cygwin review of basic UNIX TM pipelines of commands about shell scripts some new commands variables parameters and shift command substitution

More information

UNIX / Linux commands Basic level. Magali COTTEVIEILLE - September 2009

UNIX / Linux commands Basic level. Magali COTTEVIEILLE - September 2009 UNIX / Linux commands Basic level Magali COTTEVIEILLE - September 2009 What is Linux? Linux is a UNIX system Free Open source Developped in 1991 by Linus Torvalds There are several Linux distributions:

More information

Advanced Bash Scripting. Joshua Malone (jmalone@ubergeeks.com)

Advanced Bash Scripting. Joshua Malone (jmalone@ubergeeks.com) Advanced Bash Scripting Joshua Malone (jmalone@ubergeeks.com) Why script in bash? You re probably already using it Great at managing external programs Powerful scripting language Portable and version-stable

More information

Bash Shell. Lecturer: Prof. Andrzej (AJ) Bieszczad Phone:

Bash Shell. Lecturer: Prof. Andrzej (AJ) Bieszczad   Phone: Lecturer: Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954 The shell of Linux Linux has a variety of different shells: Bourne shell (sh), C shell (csh), Korn shell (ksh), TC shell

More information

The following is intended as a guide for new Mac users to configure their computers, specifically, the terminal application and X11.

The following is intended as a guide for new Mac users to configure their computers, specifically, the terminal application and X11. The following is intended as a guide for new Mac users to configure their computers, specifically, the terminal application and X11. Step 0: Click once on the blank desktop to ensure the Finder is active.

More information

why Z shell (zsh) is cooler than your shell Brendon Rapp - Cave Lunch #1

why Z shell (zsh) is cooler than your shell Brendon Rapp - Cave Lunch #1 why Z shell (zsh) is cooler than your shell Brendon Rapp - Cave Lunch #1 why Z shell (zsh) is cooler than your shell (unless your shell is zsh) Brendon Rapp - Cave Lunch #1 (alternate title) she sells

More information

Setting up PostgreSQL

Setting up PostgreSQL Setting up PostgreSQL 1 Introduction to PostgreSQL PostgreSQL is an object-relational database management system based on POSTGRES, which was developed at the University of California at Berkeley. PostgreSQL

More information

Steve Crouch, Mike Jackson, The Software Sustainability Institute. Steve McGough, Newcastle University.

Steve Crouch, Mike Jackson, The Software Sustainability Institute. Steve McGough, Newcastle University. Bash Shell Key Points ===================== Steve Crouch, Mike Jackson, The Software Sustainability Institute. Steve McGough, Newcastle University. This work is licensed under the Creative Commons Attribution

More information

Introduction to Linux for HPC. Basic Linux for Beginner HPC Users

Introduction to Linux for HPC. Basic Linux for Beginner HPC Users Introduction to Linux for HPC Basic Linux for Beginner HPC Users Purpose of This Lecture Fundamentals of using Linux and Linux-like systems on HPC systems History of Linux Shell and basic commands File,

More information

Chapter 3 Introduction to Shells and Scripting

Chapter 3 Introduction to Shells and Scripting Chapter 3 Introduction to Shells and Scripting 3.1 What is a Shell? For our purposes, a shell will be considered as a command line interface that allows the user to input commands. These commands can range

More information

Using Commands in Linux

Using Commands in Linux Hervey Allen Network Startup Resource Center PacNOG 6: Nadi, Fiji Using Commands in Linux The format of a command command [options] parameters Traditionally, UNIX command-line options consist of a dash,

More information

Command Line Crash Course For Unix

Command Line Crash Course For Unix Command Line Crash Course For Unix Controlling Your Computer From The Terminal Zed A. Shaw December 2011 Introduction How To Use This Course You cannot learn to do this from videos alone. You can learn

More information

Getting Started with Mplus Version 7.31 Demo for Mac OS X and Linux

Getting Started with Mplus Version 7.31 Demo for Mac OS X and Linux Getting Started with Mplus Version 7.31 Demo for Mac OS X and Linux This document shows how to install Mplus Demo, how to use Mplus Demo, and where to find additional documentation. Overview Mplus Version

More information

The Linux Operating System and Linux-Related Issues

The Linux Operating System and Linux-Related Issues Review Questions: The Linux Operating System and Linux-Related Issues 1. Explain what is meant by the term copyleft. 2. In what ways is the Linux operating system superior to the UNIX operating system

More information

Introduction to UNIX and SFTP

Introduction to UNIX and SFTP Introduction to UNIX and SFTP Introduction to UNIX 1. What is it? 2. Philosophy and issues 3. Using UNIX 4. Files & folder structure 1. What is UNIX? UNIX is an Operating System (OS) All computers require

More information

Brief UNIX Introduction (adapted from C. Swanson, "Unix Tutorial") CSci 1113, Spring 2016 Lab 00. Introduction to UNIX and C++

Brief UNIX Introduction (adapted from C. Swanson, Unix Tutorial) CSci 1113, Spring 2016 Lab 00. Introduction to UNIX and C++ CSci 1113, Spring 2016 Lab 00 Introduction to UNIX and C++ Welcome to the first lab in CSci 1113. In this lab you will explore some computational resources needed during this course, and write a few short

More information

Fundamentals of UNIX Lab 16.2.6 Networking Commands (Estimated time: 45 min.)

Fundamentals of UNIX Lab 16.2.6 Networking Commands (Estimated time: 45 min.) Fundamentals of UNIX Lab 16.2.6 Networking Commands (Estimated time: 45 min.) Objectives: Develop an understanding of UNIX and TCP/IP networking commands Ping another TCP/IP host Use traceroute to check

More information

Shell Scripts. Jacob Morzinski Jan-23 1

Shell Scripts. Jacob Morzinski Jan-23 1 Shell Scripts Jacob Morzinski jmorzins@mit.edu http://sipb.mit.edu/iap/2006/shell/ http://web.mit.edu/sipb-iap/www/2006/shell/ 2006-Jan-23 1 Why use shell scripts? They simplify your life. Store complicated

More information

Introduction to Operating Systems

Introduction to Operating Systems Introduction to Operating Systems It is important that you familiarize yourself with Windows and Linux in preparation for this course. The exercises in this book assume a basic knowledge of both of these

More information

1. The UNIX Architecture

1. The UNIX Architecture Chapter 2. The UNIX Architecture and Command Usage Introduction In order to understand the subsequent chapters, we first need to understand the architecture of UNIX and the concept of division of labor

More information

Introduction to Linux Scripting. Albert Lund CHPC User Services

Introduction to Linux Scripting. Albert Lund CHPC User Services Introduction to Linux Scripting Albert Lund CHPC User Services Overview What is scripting? Compiling mini-excercise Basic bash/tcsh scripting exercises Slides: home.chpc.utah.edu/~u0403692/introscripting.pdf

More information

An Introduction to the Linux Command Shell For Beginners

An Introduction to the Linux Command Shell For Beginners An Introduction to the Linux Command Shell For Beginners Presented by: Victor Gedris In Co-Operation With: The Ottawa Canada Linux Users Group and ExitCertified Copyright and Redistribution This manual

More information

Lecture 4: Writing shell scripts

Lecture 4: Writing shell scripts Handout 5 06/03/03 1 Your rst shell script Lecture 4: Writing shell scripts Shell scripts are nothing other than les that contain shell commands that are run when you type the le at the command line. That

More information

UNIX, Shell Scripting and Perl Introduction

UNIX, Shell Scripting and Perl Introduction UNIX, Shell Scripting and Perl Introduction Bart Zeydel 2003 Some useful commands grep searches files for a string. Useful for looking for errors in CAD tool output files. Usage: grep error * (looks for

More information

BASH Scripting. A bash script may consist of nothing but a series of command lines, e.g. The following helloworld.sh script simply does an echo.

BASH Scripting. A bash script may consist of nothing but a series of command lines, e.g. The following helloworld.sh script simply does an echo. BASH Scripting bash is great for simple scripts that automate things you would otherwise by typing on the command line. Your command line skills will carry over to bash scripting and vice versa. bash comments

More information

Intermediate Unix practical guide

Intermediate Unix practical guide UNIVERSITY OF BRISTOL COMPUTING SERVICE Document unix-t2 Intermediate Unix practical guide Document unix-t2 Intermediate Unix practical guide Introduction 1 The operating system 1 This document 1 Before

More information

Bash Reference Manual

Bash Reference Manual Bash Reference Manual Reference Documentation for Bash Edition 4.4, for Bash Version 4.4. September 2016 Chet Ramey, Case Western Reserve University Brian Fox, Free Software Foundation This text is a brief

More information

No Frills Command Line Magento

No Frills Command Line Magento No Frills Command Line Magento Alan Storm 2013 Pulse Storm LLC Contents Introduction............................................ 1 What This Book Is........................................ 1 About the

More information

Automating tasks through scripting. HPC Certificate Program

Automating tasks through scripting. HPC Certificate Program Automating tasks through scripting HPC Certificate Program Summary of preparation lectures From "The Shell" at Software Carpentry: Lecture 4: Pipes and Filters The redirect operator saves command output

More information

CHAPTER 5 THE KORN SHELL

CHAPTER 5 THE KORN SHELL CHAPTER 5 THE KORN SHELL ALIASES The Korn shell allows you to create and customize your ow ommands by using the alias command. alias [word [=string]] alias dir= ls F # option-f appends / for files, * for

More information