Shell Programming. Erwin Earley Sr. @Zend

Size: px
Start display at page:

Download "Shell Programming. Erwin Earley Sr. @Zend"

Transcription

1 Shell Programming Erwin Earley Sr. @Zend 2016 Rogue Wave Software, Inc. All Rights Reserved. 1

2 2016 Rogue Wave Software, Inc. All Rights Reserved. 2

3 2016 Rogue Wave Software, Inc. All Rights Reserved. 3

4 About Me 39 Years in the Industry Worked with multiple of *NIX variants including AT&T System V Release 3, DGUX, SUN/OS, Linux Worked with many different hardware platforms including PDP 11/70, AT&T 3B2/400, MainFrame, AS/400, PC/XT, PC/AT, Started out in development including Model 204, PL/1, Pascal, C Open Source Software (OSS) Background Test team lead for original enablement of Linux on AS/400 in 2001 Linux instructor as Adjunct Professor for University of MN in early 2000s RHCE certified LPIC level 1 & 2 certified Mirantis Openstack Professional certification Headed up OSS center of competency for the iseries Technology Center (precursor to IBM Lab Services) Lead consultant on OSS team in IBM Lab Services Also worked with Database, Quality Assurance, Technical Sales Support, Customer Enablement IBM technical advocate for initial roll-out of PHP enablement on IBM i Still working on wife 1.0 Have 3 Children 2 Married Sons 1 Daughter never getting married! Newest Edition to the team!! 2016 Rogue Wave Software, Inc. All Rights Reserved. 4

5 Agenda What is a Shell? Working within the shell Programming Constructs 2016 Rogue Wave Software, Inc. All Rights Reserved. 5

6 But before we begin Some Useless Trivia The Story of the Linux Penguin Linus Torvalds has claimed in various posts to have been attacked by a "ferocious penguin that bit me and infected me with a little known disease called penguinitis. "Penguinitis makes you stay awake at nights just thinking about penguins and feeling great love towards them" Torvalds later said that while he did indeed have a close and personal encounter with a penguin, the bird wasn't ferocious, and just timidly nibbled on Torvald's finger. Many thought a strong, smart and fierce beast would be the best representation for Linux. Sharks, foxes, eagles, and hawks were discussed on the Linux forums. Torvalds spoke up and said he thought that a penguin would be the perfect Linu logo but not just any penguin, Torvalds specifically wanted to steer away from the "macho penguin" image, and instead urged the developers to focus on creating an image of a cute, cuddly and contended penguin. Contented meaning, in Torvald's words that "the penguin had just stuffed itself on herring" So when you think penguin, Torvalds told the developers, "you should be imagining a slightly overweight penguin, sitting down after having gorged itself, and having just burped. It's sitting there with a beatific smile the world is a good place to be when you have just eaten a few gallons of raw fish and you can feel another burp coming." Rogue Wave Software, Inc. All Rights Reserved. 6

7 What is a Shell? The command line used on Unix systems Like CL it can be used interactively, or run as a program Like CL most commands are actually programs that get called There are some built in commands Unlike CL there are a number of varieties of shell sh bourne shell csh c shell ksh korn shell bash bourne again shell qsh Q shell There are some similarities and some differences Most of the discussion here is not operating system specific Will work on AIX, Linux, QSH in OS/400, other nasty Unix variants, etc 2016 Rogue Wave Software, Inc. All Rights Reserved. 7

8 Why do we care about the shell? All system configuration operations can be done through the shell often more quickly then through a GUI It may be the only environment available in the case of a system crash Shell scripts can automate most routine tasks such as backups, scheduled s, etc. GUI can be used for a great amount of admin activities However, the shell tends to be a comfort zone providing ability to fix things in case something goes wrong 2016 Rogue Wave Software, Inc. All Rights Reserved. 8

9 Different Types of Shells A number of shells are available each providing function/usability customized to a particular type of user: Popular shells include: BASH (Borune Again Shell) PDKsh (Public Domain Korn Shell) csh (C shell) mc (Midnight Commander) QSHELL (PASE shell) Difference tends to be in scripting capabilities and user interface Items such as command recall and file name completion are typically different 2016 Rogue Wave Software, Inc. All Rights Reserved. 9

10 Login Shell vs. Non-Login Shell Login Shell: Shell executed when user logs in to the system. Typically performs general setup initializes the terminal, sets some variables, etc. Non-login shell: Either subshells (started from the login shell), shells started by the GUI desktop, or disconnected shells started by a command Remember that shell is simply another command on the system Login shells unlike Non-login shells read a series of configuration files: Login Shell: On login if /etc/profile, source it if ~/.bash_profile exists, source it else if ~/.bash_login exists, source it if ~/.profile exists, source it Non Login Shell: On startup if ~/.bashrc exists, source it On exit if ~/.bash_logout exists, source it 2016 Rogue Wave Software, Inc. All Rights Reserved. 10

11 11 Starting with bash bash stands for Bourne Again Shell Developed by Brian Fox in 1987 One of the most popular shells available in Linux Bash incorporates features of the Korn and C shell (ksh and csh) Bash configuration files: /bin/bash Bash executable /etc/profile System wide initialization file for login shells ~/.bash_profile Personal initialization file for login shells ~/.bashrc Personal per-interactive-shell startup file ~/.bash_logout Login shell clean file that executes when shell exits 2016 Rogue Wave Software, Inc. All Rights Reserved. 11

12 A little more on BASH Default Linux shell This can be changed in a variety of ways /etc/profile login shell Magic string within the script (more on this in a moment) Very powerful as a command line shell Recall previous commands Command and file completion with the <TAB> key May programming features Loops and conditionals 2016 Rogue Wave Software, Inc. All Rights Reserved. 12

13 13 Shell Environment The shell is an environment where commands can be entered and the Operations system can respond to them A key concept to the environment is environment variables There are a large number of environment variables HISTFILE: points to file containing the shell history, defaults to ~/.bash_history HISTFILESIZE: how man last commands you wish to have in history HOME: points to your home directory PATH: set of directories to search when trying to execute a command PS1: Prompt variable USER: username 2016 Rogue Wave Software, Inc. All Rights Reserved. 13

14 Shell metacharacters Symbol Meaning > Output redirection >> Output redirection (append) < Input redirection * File substitution wildcard; zero or more characters? File substitution wildcard; one character [ ] File substitution wildcard; any character between brackets `cmd` Command substitution $(cmd) Command substitution The pipe : Command Sequence OR conditional execution && AND conditional execution Symbol Meaning ( ) Group commands & Run command in the background # Comment $ Expand the value of a variable \ Prevent or exape interpretation of the next character << Input redirection " $val " Literal with variable substitution ' $val ' Literal without variable substituion 2016 Rogue Wave Software, Inc. All Rights Reserved. 14

15 15 Useful Shell Constructs Arrow Up & Down: Scroll through recent commands used &&: command is only executed if preceding command was successful: command1 && command2 alias: sets a command alias or prints defined aliases alias wrklnk=ls bg[jobid]: Resumes the suspended job in the background cd: changes current directory to directory indicated cd /home 2016 Rogue Wave Software, Inc. All Rights Reserved. 15

16 16 Useful Shell Constructs (continued) echo: Outputs the arguments echo hello world find [path][expression]: searches the directory indicating looking for files that match expression: find / -name passwd print pwd Prints the absolute pathname of the current working directory unalias Removes an alias history displays command history with line numbers umask User file creation mask logout: exits the shell environment exit [n]: exits shell environment with exit status n 2016 Rogue Wave Software, Inc. All Rights Reserved. 16

17 17 More information on bash Just enter the command $ man bash Manual page for bash is about 5,000 lines!! 2016 Rogue Wave Software, Inc. All Rights Reserved. 17

18 18 qsh A version of a shell for System i Has many of the same features as bash RTFM This is an excellent and comprehensive book! 2016 Rogue Wave Software, Inc. All Rights Reserved. 18

19 19 The First Shell Program #!/bin/bash echo Hello World This is called a shell script The first line #!/bin/bash is a magic string When a file is loaded if the first two characters are #! then the remainder of the line is used as the program to run the file #!/home/erwin/my_nice_program is a valid shell script echo is a built-in command that just displays the rest of the line 2016 Rogue Wave Software, Inc. All Rights Reserved. 19

20 20 Creating a shell program Use a text editor Traditional Unix editors include vi and emacs More user friendly editors include nano On System i use edtf 2016 Rogue Wave Software, Inc. All Rights Reserved. 20

21 21 Writing Your Shell Script Using nano 2016 Rogue Wave Software, Inc. All Rights Reserved. 21

22 22 Running Your Shell Script ls l test.sh -rw-r r 1 earley earley :54 test.sh earley@testbed:~$ test.sh -bash: test.sh: command not found earley@testbed:~$ We have a test.sh program in our directory Lets try and run it Doesn t work! Why not!?!? 2016 Rogue Wave Software, Inc. All Rights Reserved. 22

23 23 Running Your Shell Script echo $PATH /home/earley/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/ usr/bin:/sbin:/bin:/usr/bin/x11 test.sh Hello World The program is not in the path The current directory is not in the path Can run a shell script by typing. Means load the file into the current shell 2016 Rogue Wave Software, Inc. All Rights Reserved. 23

24 24 Running Your Shell Script mv test.sh ~/bin/ echo $PATH /home/earley/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/ usr/bin:/sbin:/bin:/usr/bin/x11 test.sh -bash: /home/earley/bin/test.sh: Permission denied Move the shell script into a directory in the path Try and execute it again Now we get Permission denied! Why!?!? 2016 Rogue Wave Software, Inc. All Rights Reserved. 24

25 25 Running Your Shell Script ls l ~/bin/test.sh -rw-r--r-- 1 earley earley :54 /home/earley/bin/test.sh earley@testbed:~$ chmod u+x ~/bin/test.sh earley@testbed:~$ ls l ~/bin/test.sh -rwx--r-- 1 earley earley :54 /home/earley/bin/test.sh earley@testbed:~$ test.sh Hello World earley@testbed:~$ The file is not marked with executable permissions chmod u+x says make it executable by the user who owns it NOW it works 2016 Rogue Wave Software, Inc. All Rights Reserved. 25

26 26 Running a shell script in QSH 2016 Rogue Wave Software, Inc. All Rights Reserved. 26

27 27 Running a shell script in QSH 2016 Rogue Wave Software, Inc. All Rights Reserved. 27

28 28 Running a shell script in QSH Can also get into qsh via 'STRQSH' Keep in mind that you could also simply ssh into your IBM I system (assuming the ssh daemon is running) and run your scripts 2016 Rogue Wave Software, Inc. All Rights Reserved. 28

29 29 Running a shell script in QSH 2016 Rogue Wave Software, Inc. All Rights Reserved. 29

30 30 When good scripts go bad If you get Command not found the path to the shell is probably wrong Another error occurs if you move a file from a Windows machine to Linux and the line endings get messed up If this happens, you can use the following command: tr d \r < erwin.sh > erwin2.sh we will understand that line more later 2016 Rogue Wave Software, Inc. All Rights Reserved. 30

31 31 Input and Output Unix programs start with three open files Input (called stdin) (#0) Output (called stdout) (#1) Error output (called stderr) (#2) Our shell program uses the echo command to write to stdout We can redirect the output to go to a file by using > ls l > output.txt This will take the output of the ls l command and write it into a file called output.txt 2016 Rogue Wave Software, Inc. All Rights Reserved. 31

32 32 Input and Output You can also specify which output goes to a file ls l 1> output.txt this is the same as before. Redirecting only error output grep fred * 2> grep.err this will redirect only the error output to the file grep.err 2016 Rogue Wave Software, Inc. All Rights Reserved. 32

33 33 Input and Output Use the < operator to redirect input Equivalent to typing at the keyboard For example sed s/erwin/erwin/g < my.txt This runs the command sed (an editor) changing erwin to Erwin and taking its input from a file called my.txt Input and output sed s/erwin/erwin/g < my.txt > my2.txt 2016 Rogue Wave Software, Inc. All Rights Reserved. 33

34 34 Common *nix commands Unix is built around the idea of lots of little programs that all do one thing well ls lists files sed an editor grep a searcher cat a file outputer find a file locator sort sorts files tr translates characters ps list processes seq print a sequence of numbers a thousand others Help for all these is in the man (for manual ) command E.g. man sed Shell programs generally involve stringing lots of these together Which leads us to pipes All of these except 'seq' are available in the IFS and can be run from a IBM I shell (i.e., qsh, ssh session) 2016 Rogue Wave Software, Inc. All Rights Reserved. 34

35 35 Pipes Connect the output of one program to the input of another ps x grep java List processes, search for any involving java 2016 Rogue Wave Software, Inc. All Rights Reserved. 35

36 36 Variables Bash (both interactively and in programs) has variables Variables do not need to be declared, and don t have types #!/bin/bash STR="Hello World!" echo $STR 2016 Rogue Wave Software, Inc. All Rights Reserved. 36

37 37 Special Variables $1 is the first argument, $2 is the second argument, etc $* is all the arguments $# is the number of arguments $? Is the status of the last command 2016 Rogue Wave Software, Inc. All Rights Reserved. 37

38 38 Command variables $( command) can be used like a variable, but executes the command FILES=$(ls) Sets the variable $FILES to the output of the ls command Use the let command to evaluate expressions COUNTER=0 COUNTER=$COUNTER+1 echo $COUNTER # This prints 0+1 COUNTER=0 let COUNTER=COUNTER+1 echo $COUNTER # This prints Rogue Wave Software, Inc. All Rights Reserved. 38

39 Interacting with a User Enter Your Name Shell script gets a name from user input and echoes it to the screen #!/bin/bash echo "Enter Your Name: " read NAME echo "Your name is $NAME" exit Rogue Wave Software, Inc. All Rights Reserved. 39

40 40 Doing Math Another choice for doing math is $(( expression )) counter=1 counter=$((counter+1)) echo $counter 2016 Rogue Wave Software, Inc. All Rights Reserved. 40

41 41 If statements Standard if/then/else Note the weird syntax involving [ ] and ; #!/bin/bash if [ "foo" = "foo" ] ; then echo expression evaluated as true else echo expression evaluated as false fi 2016 Rogue Wave Software, Inc. All Rights Reserved. 41

42 42 Conditions [ ] [ ] is a synonym for the test command man test gives the options [ -z $x ] the length of the string is zero [ STRING1 = STRING2 ] the strings are equal [ STRING1!= STRING2 ] the strings are not equal [ INTEGER1 -eq INTEGER2 ] INTEGER1 is equal to INTEGER2 [ INTEGER1 -ge INTEGER2 ] INTEGER1 is greater than or equal to INTEGER2 [ INTEGER1 -gt INTEGER2 ] INTEGER1 is greater than INTEGER2 [ INTEGER1 -le INTEGER2 ] INTEGER1 is less than or equal to INTEGER2 [ INTEGER1 -lt INTEGER2 ] INTEGER1 is less than INTEGER2 [ INTEGER1 -ne INTEGER2 ] INTEGER1 is not equal to INTEGER2 [ -d FILE ] FILE exists and is a directory [ -e FILE ] FILE exists [ -f FILE ] FILE exists and is a regular file 2016 Rogue Wave Software, Inc. All Rights Reserved. 42

43 43 If statements and variables The example makes more sense with a variable #!/bin/bash if [ "$myvar" = "foo" ]; then echo expression evaluated as true else echo expression evaluated as false fi 2016 Rogue Wave Software, Inc. All Rights Reserved. 43

44 Example Script Simple file copy script with a if/then/else loop #!/bin/bash #Name: Copy File echo "Enter a Filename to copy:" read SRC echo "Enter the filename to copy to:" read DEST if cp $SRC $DEST 2>/dev/null then echo "Task Complete" else echo "Copy Failed!" > &2 exit 1 fi exit Rogue Wave Software, Inc. All Rights Reserved. 44

45 45 Loops for: very different from other programming languages. Loops over a series of 'words' within a string. while: loops while a condition is true until: almost identical to the while loop, except that the code is executed while the control expression evaluates to false. #!/bin/bash for i in $( ls ); do echo item: $i done 2016 Rogue Wave Software, Inc. All Rights Reserved. 45

46 46 Loop Examples #!/bin/bash for i in `seq 1 10`; do echo $i done #!/bin/bash COUNTER=0 while [ $COUNTER -lt 10 ]; do echo The counter is $COUNTER let COUNTER=$COUNTER+1 done 2016 Rogue Wave Software, Inc. All Rights Reserved. 46

47 Case Statement The case statement can be used to replace nested if/then/else statements case EXRESSIOON in pattern1) statements ;; pattern2) statements ;;... esac NOTES: EXPRESSION is expanded and checks are made against each pattern (in order) When a match is found all associated statements are executed (execution terminates with ;;) After first match, case terminates exit status is status of last command executed If no match, exit status of case is zero 2016 Rogue Wave Software, Inc. All Rights Reserved. 47

48 case statement simple example #!/bin/bash echo -n "Do you agree with this? [yes or no]: " read yno case $yno in [yy] [yy][ee][ss] ) echo "Agreed" ;; [nn] [n N][O o] ) echo "Not agreed, you can't proceed the installation"; exit 1 ;; *) echo "Invalid input" ;; esac 2016 Rogue Wave Software, Inc. All Rights Reserved. 48

49 49 Functions You can use functions #!/bin/bash function quit { exit } function hello { echo Hello! } hello quit echo foo 2016 Rogue Wave Software, Inc. All Rights Reserved. 49

50 50 Functions with arguments Arguments use the same $1, $2 syntax as the main program #!/bin/bash function quit { exit } function mysay { echo $1 } mysay Hello mysay World quit echo foo 2016 Rogue Wave Software, Inc. All Rights Reserved. 50

51 51 Putting Text Inline; or Here documents Can redirect input from inside a shell script using the << operator Treats any text until the TAG as if it is input #!/bin/bash mail s "Test Mail" $1 << END_OF_MAIL Hello $1, This is some spam. Thanks for reading END_OF_MAIL 2016 Rogue Wave Software, Inc. All Rights Reserved. 51

52 52 Setting Exit Status Shell scripts return a status value exit 0 exit -1 You can also test the status of a command you call using the special $? Variable or by using the command in an if statement directly #!/bin/bash cp $1 /tmp/backup/ if [ $? == 0 ] then echo "Copy of $1 succeeded" else echo "Copy of $1 failed" fi 2016 Rogue Wave Software, Inc. All Rights Reserved. 52

53 53 Using Exit Status #!/bin/bash if cp $1 /tmp/backup/ then echo "Copy of $1 succeeded" else echo "Copy of $1 failed" fi 2016 Rogue Wave Software, Inc. All Rights Reserved. 53

54 54 A Sample (and useful) backup script #!/bin/bash if [ -z "$1" ]; then echo usage: $0 directory exit fi SRCD=$1 TGTD="/var/backups/" OF=home-$(date +%Y%m%d).tgz tar -czf $TGTD$OF $SRCD 2016 Rogue Wave Software, Inc. All Rights Reserved. 54

55 55 File Level Backup to the IFS An Example Scripts can be implemented to perform file-level backup to the IFS This facilitates the backup/restore of files form Linux without having to take the Linux server down (which would be required for a full SAV of the storage space). One method would be to have the script find all files that have been modified over a defined period, build a backup set and then write the backup set out to the IFS Additional scripts could then be developed to list the contents of the backup set and retrieve (restore) files from the backup set The following slides present some simple script examples 2016 Rogue Wave Software, Inc. All Rights Reserved. 55

56 56 File Level Backup to the IFS an Example Backup Script #!/bin/sh ################################### # Script Name: backup.sh ################################### # Environment Variables ################################### PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/s bin:/usr/bin:/usr/x11r6/bin:/root/bin SOURCE= /home TARGET= linux.backup.`date +%d^b^y` DAYS=1 HOST= USER= qsecofr PASSWD= packers FTPDST= /home/linux.backup/$target # Following find statement builds the cpio set of modifies files find $SOURCE mtime -$DAYS print cpio ocbv F /tmp/$target 2> /dev/null 2016 Rogue Wave Software, Inc. All Rights Reserved. 56

57 57 File Level Backup to the IFS an Example Backup Script # Following statements use ftp to copy the cpio set to the i5/os partition ftp n $HOST << END_SCRIPT quote USER $USER quote PASS $PASSWD bin put /tmp/$target $FTPDST quit END_SCRIPT exit Rogue Wave Software, Inc. All Rights Reserved. 57

58 58 File Level Backup to the IFS an Example List Script #!/bin/sh ###################################### # Script Name: list.sh ###################################### # Environment Variables ###################################### HOST= USER= qsecofr PASSWD= packers ################################################ # First lets get a list of the save sets that # # are available. # ################################################ list.files.sh 2> /dev/null grep linux.backup tr s cut f6 d > /tmp/linux.backup.save.sets 2016 Rogue Wave Software, Inc. All Rights Reserved. 58

59 59 File Level Backup to the IFS an Example List Script ###################################################################################### # The following statements check the usage form of the command. If the command did # # not include the file name then a usage statement is output along with a list of # # backup sets available on the server. # ###################################################################################### if [ $# -eq 0 ] then echo Usage: $0 backup-file-name echo echo Backup files are located in the /home/linux.backup echo directory of the IFS of the OS/400 parttion echo echo Files follow the name convention of linux.backup.ddmmmyy echo Current files available echo cat /tmp/linux.backup.save.sets exit 0 fi 2016 Rogue Wave Software, Inc. All Rights Reserved. 59

60 60 File Level Backup to the IFS an Example List Script if test `grep c $1 /tmp/linux.backup.save.sets` -eq 0 then echo Save set $1 does not exist echo echo Current files available echo cat /tmp/linux.backup.save.sets exit 0 fi ###################################################### # The following statements get the requested backup # # set from the server. # ###################################################### TARGET=$1 FTPDST= /home/linux.backup/$target ftp n $HOST << END_SCRIPT quote USER $USER quote PASS $PASSWD bin get $FTPDST /tmp/$target quit END_SCRIPT 2016 Rogue Wave Software, Inc. All Rights Reserved. 60

61 61 File Level Backup to the IFS an Example List Script ##################################################3############ # The following command lists the contents of the backup set. # ############################################################### cpio itcvb F /tmp/$target 2>/dev/null cut -bytes= rm /tmp/$target rm /tmp/linux.backup.save.sets exit Rogue Wave Software, Inc. All Rights Reserved. 61

62 62 File Level Backup to the IFS an Example List.Files Script #!/bin/sh #################################################3 # Script Name: list.files.sh ################################################## # Environment Variables ################################################## HOST= USER= qsecofr PASSWD= packers ############################################################### # The following commands use ftp to build a list of save sets # # available in the IFS # ############################################################### ftp n $HOST << END_SCRIPT quote USER $USER quote PASS $PASSWD cd /home/linux.backup ls quit END_SCRIPT exit Rogue Wave Software, Inc. All Rights Reserved. 62

63 63 File Level Backup to the IFS an Example Restore Script #!/bin/sh ################################################ # Script Name: restore.sh ################################################ # Environment Variables ################################################ HOST= USER= qsecofr PASSWD= packers ####################################################################################### # The following statements test the usage of the command. If the command was called # # with the incorrect number of arguments, a usage statement is output along with a # # list of save sets available in the IFS. # ####################################################################################### If test $# -lt 2 then echo Usage $0 backup-file-name name-of-file-to-restore echo echo Backup files are located in the /home/linux.backup echo directory of the IFS of the OS/400 partition echo echo Files follow the naming convention of linux.backup.ddmmmyy echo Current files available echo list.files.sh 2>/dev/null grep linux.backup tr s cut f6 d exit 0 fi 2016 Rogue Wave Software, Inc. All Rights Reserved. 63

64 64 File Level Backup to the IFS an Example Restore Script ########################################################################## # The following statements retrieve the request backup set from the IFS # ########################################################################## TARGET=$1 FILE=$2 FTPDST=/home/linux.backup/$TARGET echo $TARGET ftp n $HOST << END_SCRIPT quote USER $USER quote PASS $PASSWD bin bet $FTPDST /tmp/$target quit END_SCRIPT ###################################################################################### # The following statement retrieves the specified file from the retrieved backup set # ###################################################################################### cpio ivcbum $FILE < /tmp/$target rm /tmp/$target exit Rogue Wave Software, Inc. All Rights Reserved. 64

65 65 WebMin Can Be Customized to Launch Your Scripts Launchers can be developed in WebMin that execute Linux scripts Creative solutions can be implemented for a number of functions 2016 Rogue Wave Software, Inc. All Rights Reserved. 65

66 How did I get bash on my i Currently in beta, but. Check out: gy%20updates/page/rpms%20-%20getting%20started 2016 Rogue Wave Software, Inc. All Rights Reserved. 66

67 67 More information qsh Read the book bash man bash Other useful links Rogue Wave Software, Inc. All Rights Reserved. 67

68 A Moment of Fun Linux and Open Source Quotes the Linux philosophy is "laugh in the face of danger". Oops. Wrong one. "Do it yourself". That's it (Linus Torvalds) Linux: the choice of a GNU generation ('93 Tshirt) Linux hackers are funny people: They count the time in patch levels (seen in a.sig) What happens when you read some doc and either it doesn't answer your question or is demonstrably wrong? In Linux, you say "Linux sucks" and go read the code. In Windows/Oracle/etc you say "Windows sucks" and start banging your head against the wall" (Denis Vlaskenko in ikml) Those who don't understand Linux are doomed to reinvent it, poorly. (Unidentified source) It's a bird, it's a plane...no, it's KernelMan, faster than a speeding bullet to your rescue. Doing new kernel versions in under 5 seconds flat (Linus, in the announcement for ) Rogue Wave Software, Inc. All Rights Reserved. 68

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

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

Useful Unix Commands Cheat Sheet

Useful Unix Commands Cheat Sheet Useful Unix Commands Cheat Sheet The Chinese University of Hong Kong SIGSC Training (Fall 2016) FILE AND DIRECTORY pwd Return path to current directory. ls List directories and files here. ls dir List

More information

BASH Programming Introduction

BASH Programming Introduction BASH Programming Introduction 1. Very simple Scripts Traditional hello world script: echo Hello World A very simple backup script: tar -czf /var/my-backup.tgz /home/me/ 2. Redirection stdout 2 file: ls

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. 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

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

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

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

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

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

EECS 470 Lab 5. Linux Shell Scripting. Friday, 1 st February, 2018

EECS 470 Lab 5. Linux Shell Scripting. Friday, 1 st February, 2018 EECS 470 Lab 5 Linux Shell Scripting Department of Electrical Engineering and Computer Science College of Engineering University of Michigan Friday, 1 st February, 2018 (University of Michigan) Lab 5:

More information

CISC 220 fall 2011, set 1: Linux basics

CISC 220 fall 2011, set 1: Linux basics CISC 220: System-Level Programming instructor: Margaret Lamb e-mail: malamb@cs.queensu.ca office: Goodwin 554 office phone: 533-6059 (internal extension 36059) office hours: Tues/Wed/Thurs 2-3 (this week

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

Essentials for Scientific Computing: Bash Shell Scripting Day 3

Essentials for Scientific Computing: Bash Shell Scripting Day 3 Essentials for Scientific Computing: Bash Shell Scripting Day 3 Ershaad Ahamed TUE-CMS, JNCASR May 2012 1 Introduction In the previous sessions, you have been using basic commands in the shell. The bash

More information

9.2 Linux Essentials Exam Objectives

9.2 Linux Essentials Exam Objectives 9.2 Linux Essentials Exam Objectives This chapter will cover the topics for the following Linux Essentials exam objectives: Topic 3: The Power of the Command Line (weight: 10) 3.3: Turning Commands into

More information

COMP 4/6262: Programming UNIX

COMP 4/6262: Programming UNIX COMP 4/6262: Programming UNIX Lecture 12 shells, shell programming: passing arguments, if, debug March 13, 2006 Outline shells shell programming passing arguments (KW Ch.7) exit status if (KW Ch.8) test

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

Using bash. Administrative Shell Scripting COMP2101 Fall 2017

Using bash. Administrative Shell Scripting COMP2101 Fall 2017 Using bash Administrative Shell Scripting COMP2101 Fall 2017 Bash Background Bash was written to replace the Bourne shell The Bourne shell (sh) was not a good candidate for rewrite, so bash was a completely

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

Bourne Shell Reference

Bourne Shell Reference > Linux Reviews > Beginners: Learn Linux > Bourne Shell Reference Bourne Shell Reference found at Br. David Carlson, O.S.B. pages, cis.stvincent.edu/carlsond/cs330/unix/bshellref - Converted to txt2tags

More information

A shell can be used in one of two ways:

A shell can be used in one of two ways: Shell Scripting 1 A shell can be used in one of two ways: A command interpreter, used interactively A programming language, to write shell scripts (your own custom commands) 2 If we have a set of commands

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

More Scripting Techniques Scripting Process Example Script

More Scripting Techniques Scripting Process Example Script More Scripting Techniques Scripting Process Example Script 1 arguments to scripts positional parameters input using read exit status test program, also known as [ if statements error messages 2 case statement

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

Topic 2: More Shell Skills

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

More information

LING 408/508: Computational Techniques for Linguists. Lecture 5

LING 408/508: Computational Techniques for Linguists. Lecture 5 LING 408/508: Computational Techniques for Linguists Lecture 5 Last Time Installing Ubuntu 18.04 LTS on top of VirtualBox Your Homework 2: did everyone succeed? Ubuntu VirtualBox Host OS: MacOS or Windows

More information

Shell Scripting. Todd Kelley CST8207 Todd Kelley 1

Shell Scripting. Todd Kelley CST8207 Todd Kelley 1 Shell Scripting Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 If we have a set of commands that we want to run on a regular basis, we could write a script A script acts as a Linux command,

More information

Shell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

Shell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong Shell Prof. Jinkyu Jeong (Jinkyu@skku.edu) TA -- Minwoo Ahn (minwoo.ahn@csl.skku.edu) TA -- Donghyun Kim (donghyun.kim@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu

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

UNIX System Programming Lecture 3: BASH Programming

UNIX System Programming Lecture 3: BASH Programming UNIX System Programming Outline Filesystems Redirection Shell Programming Reference BLP: Chapter 2 BFAQ: Bash FAQ BMAN: Bash man page BPRI: Bash Programming Introduction BABS: Advanced Bash Scripting Guide

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

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

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

Basic Linux (Bash) Commands

Basic Linux (Bash) Commands Basic Linux (Bash) Commands Hint: Run commands in the emacs shell (emacs -nw, then M-x shell) instead of the terminal. It eases searching for and revising commands and navigating and copying-and-pasting

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

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. 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

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

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

Sub-Topic 1: Quoting. Topic 2: More Shell Skills. Sub-Topic 2: Shell Variables. Referring to Shell Variables: More

Sub-Topic 1: Quoting. Topic 2: More Shell Skills. Sub-Topic 2: Shell Variables. Referring to Shell Variables: More Topic 2: More Shell Skills Plan: about 3 lectures on this topic 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

More information

More Raspian. An editor Configuration files Shell scripts Shell variables System admin

More Raspian. An editor Configuration files Shell scripts Shell variables System admin More Raspian An editor Configuration files Shell scripts Shell variables System admin Nano, a simple editor Nano does not require the mouse. You must use your keyboard to move around the file and make

More information

CSE 15L Winter Midterm :) Review

CSE 15L Winter Midterm :) Review CSE 15L Winter 2015 Midterm :) Review Makefiles Makefiles - The Overview Questions you should be able to answer What is the point of a Makefile Why don t we just compile it again? Why don t we just use

More information

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University Lecture 4 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation 27-Sep-2017 Location: Goldberg CS Building Time: Wednesday, 16:05

More information

Shell Start-up and Configuration Files

Shell Start-up and Configuration Files ULI101 Week 10 Lesson Overview Shell Start-up and Configuration Files Shell History Alias Statement Shell Variables Introduction to Shell Scripting Positional Parameters echo and read Commands if and test

More information

Lecture 4. Log into Linux Reminder: Homework 1 due today, 4:30pm Homework 2 out, due next Tuesday Project 1 out, due next Thursday Questions?

Lecture 4. Log into Linux Reminder: Homework 1 due today, 4:30pm Homework 2 out, due next Tuesday Project 1 out, due next Thursday Questions? Lecture 4 Log into Linux Reminder: Homework 1 due today, 4:30pm Homework 2 out, due next Tuesday Project 1 out, due next Thursday Questions? Tuesday, September 7 CS 375 UNIX System Programming - Lecture

More information

Essential Unix (and Linux) for the Oracle DBA. Revision no.: PPT/2K403/02

Essential Unix (and Linux) for the Oracle DBA. Revision no.: PPT/2K403/02 Essential Unix (and Linux) for the Oracle DBA Revision no.: PPT/2K403/02 Architecture of UNIX Systems 2 UNIX System Structure 3 Operating system interacts directly with Hardware Provides common services

More information

CSCI 211 UNIX Lab. Shell Programming. Dr. Jiang Li. Jiang Li, Ph.D. Department of Computer Science

CSCI 211 UNIX Lab. Shell Programming. Dr. Jiang Li. Jiang Li, Ph.D. Department of Computer Science CSCI 211 UNIX Lab Shell Programming Dr. Jiang Li Why Shell Scripting Saves a lot of typing A shell script can run many commands at once A shell script can repeatedly run commands Help avoid mistakes Once

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

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

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

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

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT Unix as a Platform Exercises + Solutions Course Code: OS 01 UNXPLAT Working with Unix Most if not all of these will require some investigation in the man pages. That's the idea, to get them used to looking

More information

Introduction to Linux

Introduction to Linux Introduction to Linux Mukesh Pund Principal Scientist, NISCAIR, New Delhi, India History In 1969, a team of developers developed a new operating system called Unix which was written using C Linus Torvalds,

More information

COMS 6100 Class Notes 3

COMS 6100 Class Notes 3 COMS 6100 Class Notes 3 Daniel Solus September 1, 2016 1 General Remarks The class was split into two main sections. We finished our introduction to Linux commands by reviewing Linux commands I and II

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

INTRODUCTION TO UNIX

INTRODUCTION TO UNIX WEEK 1.3 INTRODUCTION TO UNIX Unix is a key operating system in the history of communications. Here, you will gain experience in using Unix both in command line and with a graphical interface. Most importantly,

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

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 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

Unix Introduction to UNIX

Unix Introduction to UNIX Unix Introduction to UNIX Get Started Introduction The UNIX operating system Set of programs that act as a link between the computer and the user. Developed in 1969 by a group of AT&T employees Various

More information

CS 25200: Systems Programming. Lecture 10: Shell Scripting in Bash

CS 25200: Systems Programming. Lecture 10: Shell Scripting in Bash CS 25200: Systems Programming Lecture 10: Shell Scripting in Bash Dr. Jef Turkstra 2018 Dr. Jeffrey A. Turkstra 1 Lecture 10 Getting started with Bash Data types Reading and writing Control loops Decision

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

A Big Step. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

A Big Step. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers A Big Step Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers Copyright 2006 2009 Stewart Weiss What a shell really does Here is the scoop on shells. A shell is a program

More information

Topic 2: More Shell Skills. Sub-Topic 1: Quoting. Sub-Topic 2: Shell Variables. Difference Between Single & Double Quotes

Topic 2: More Shell Skills. Sub-Topic 1: Quoting. Sub-Topic 2: Shell Variables. Difference Between Single & Double Quotes Topic 2: More Shell Skills Sub-Topic 1: Quoting 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

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

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

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

Command Interpreters. command-line (e.g. Unix shell) On Unix/Linux, bash has become defacto standard shell.

Command Interpreters. command-line (e.g. Unix shell) On Unix/Linux, bash has become defacto standard shell. Command Interpreters A command interpreter is a program that executes other programs. Aim: allow users to execute the commands provided on a computer system. Command interpreters come in two flavours:

More information

CS246 Spring14 Programming Paradigm Notes on Linux

CS246 Spring14 Programming Paradigm Notes on Linux 1 Unix History 1965: Researchers from Bell Labs and other organizations begin work on Multics, a state-of-the-art interactive, multi-user operating system. 1969: Bell Labs researchers, losing hope for

More information

Practical Computing-II. Programming in the Linux Environment. 0. An Introduction. B.W.Gore. March 20, 2015

Practical Computing-II. Programming in the Linux Environment. 0. An Introduction. B.W.Gore. March 20, 2015 Practical Computing-II March 20, 2015 0. An Introduction About The Course CMS M.2.2 Practical Computing-II About The Course CMS M.2.2 Practical Computing-II 25 credits (33.33% weighting) About The Course

More information

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description: BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description: This course provides Bioinformatics students with the

More information

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala Linux Training for New Users of Cluster Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala pakala@uga.edu 1 Overview GACRC Linux Operating System Shell, Filesystem, and Common

More information

Linux Shell Scripting. Linux System Administration COMP2018 Summer 2017

Linux Shell Scripting. Linux System Administration COMP2018 Summer 2017 Linux Shell Scripting Linux System Administration COMP2018 Summer 2017 What is Scripting? Commands can be given to a computer by entering them into a command interpreter program, commonly called a shell

More information

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used: Linux Tutorial How to read the examples When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used: $ application file.txt

More information

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version... Contents Note: pay attention to where you are........................................... 1 Note: Plaintext version................................................... 1 Hello World of the Bash shell 2 Accessing

More information

Scripting. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

Scripting. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers Scripting Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers Adapted from Practical Unix and Programming Hunter College Copyright 2006 2009 Stewart Weiss What a shell

More information

Linux at the Command Line Don Johnson of BU IS&T

Linux at the Command Line Don Johnson of BU IS&T Linux at the Command Line Don Johnson of BU IS&T We ll start with a sign in sheet. We ll end with a class evaluation. We ll cover as much as we can in the time allowed; if we don t cover everything, you

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

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions Lanka Education and Research Network Linux Architecture, Linux File System, Linux Basic Commands 28 th November 2016 Dilum Samarasinhe () Overview History of Linux Linux Architecture Linux File System

More information

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2 Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades 2017-2018 Q2 Facultat d Informàtica de Barcelona This first lab session is focused on getting experience in working

More information

The Unix Shell & Shell Scripts

The Unix Shell & Shell Scripts The Unix Shell & Shell Scripts You should do steps 1 to 7 before going to the lab. Use the Linux system you installed in the previous lab. In the lab do step 8, the TA may give you additional exercises

More information

Lecture 3. Unix. Question? b. The world s best restaurant. c. Being in the top three happiest countries in the world.

Lecture 3. Unix. Question? b. The world s best restaurant. c. Being in the top three happiest countries in the world. Lecture 3 Unix Question? Denmark is famous for? a. LEGO. b. The world s best restaurant. c. Being in the top three happiest countries in the world. d. Having the highest taxes in Europe (57%). e. All of

More information

Linux Shell Script. J. K. Mandal

Linux Shell Script. J. K. Mandal Linux Shell Script J. K. Mandal Professor, Department of Computer Science & Engineering, Faculty of Engineering, Technology & Management University of Kalyani Kalyani, Nadia, West Bengal E-mail: jkmandal@klyuniv.ac.in,

More information

Introduction to UNIX Command Line

Introduction to UNIX Command Line Introduction to UNIX Command Line Files and directories Some useful commands (echo, cat, grep, find, diff, tar) Redirection Pipes Variables Background processes Remote connections (e.g. ssh, curl) Scripts

More information

Shell scripting and system variables. HORT Lecture 5 Instructor: Kranthi Varala

Shell scripting and system variables. HORT Lecture 5 Instructor: Kranthi Varala Shell scripting and system variables HORT 59000 Lecture 5 Instructor: Kranthi Varala Text editors Programs built to assist creation and manipulation of text files, typically scripts. nano : easy-to-learn,

More information

Linux Bash Shell Scripting

Linux Bash Shell Scripting University of Chicago Initiative in Biomedical Informatics Computation Institute Linux Bash Shell Scripting Present by: Mohammad Reza Gerami gerami@ipm.ir Day 2 Outline Support Review of Day 1 exercise

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

Shell script. Shell Scripts. A shell script contains a sequence of commands in a text file. Shell is an command language interpreter.

Shell script. Shell Scripts. A shell script contains a sequence of commands in a text file. Shell is an command language interpreter. Shell Scripts A shell script contains a sequence of commands in a text file. Shell is an command language interpreter. Shell executes commands read from a file. Shell is a powerful programming available

More information

Last Time. on the website

Last Time. on the website Last Time on the website Lecture 6 Shell Scripting What is a shell? The user interface to the operating system Functionality: Execute other programs Manage files Manage processes Full programming language

More information

Introduction to Linux Basics Part II. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

Introduction to Linux Basics Part II. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala Introduction to Linux Basics Part II 1 Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala pakala@uga.edu 2 Variables in Shell HOW DOES LINUX WORK? Shell Arithmetic I/O and

More information

My Favorite bash Tips and Tricks

My Favorite bash Tips and Tricks 1 of 6 6/18/2006 7:44 PM My Favorite bash Tips and Tricks Prentice Bisbal Abstract Save a lot of typing with these handy bash features you won't find in an old-fashioned UNIX shell. bash, or the Bourne

More information

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Introduction to remote command line Linux. Research Computing Team University of Birmingham Introduction to remote command line Linux Research Computing Team University of Birmingham Linux/UNIX/BSD/OSX/what? v All different v UNIX is the oldest, mostly now commercial only in large environments

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

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

Exploring UNIX: Session 5 (optional)

Exploring UNIX: Session 5 (optional) Exploring UNIX: Session 5 (optional) Job Control UNIX is a multi- tasking operating system, meaning you can be running many programs simultaneously. In this session we will discuss the UNIX commands for

More information

Unix basics exercise MBV-INFX410

Unix basics exercise MBV-INFX410 Unix basics exercise MBV-INFX410 In order to start this exercise, you need to be logged in on a UNIX computer with a terminal window open on your computer. It is best if you are logged in on freebee.abel.uio.no.

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

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

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