Unix Course Notes Part 2

Size: px
Start display at page:

Download "Unix Course Notes Part 2"

Transcription

1 Unix Course Notes Part 2 Chris Bayliss and Alan Reed (Version 5.05)

2 Chris Bayliss and Alan Reed

3 Table of Contents Part 1: Security - File and Directory Access 5 chmod command 5 chmod by numbers 7 Part 2: Strings, Patterns, Regular Expressions and grep 8 strings 8 patterns 9 regular expressions 9 grep 10 Part 3: More about shells 11 Command line recall and editing 11 ksh Programming 11.profile 13 More redirection 14 Part 4: Finding Files 16 find 16 Part 5: Utilities 18 sort 18 uniq 18 Combining files - cat and paste 19 cut 20 wc 20 Part 6: Topics not covered - sed, awk, perl and vi 21 sed 21 awk 21 perl 21 vi 21 Part 7: Processes and how to kill them 22 Processes 22 ps 22 fg 23 kill 23 Chris Bayliss and Alan Reed

4 Appendix I: ASCII characters, strings, patterns, and regular expressions 24 ASCII characters 24 strings 24 patterns 25 regular expressions 25 Expression Meaning 25 Standards used in the document Where you have to do something is shown in text like this: type the following text However, the text shown in non-bold is the prompt text from Unix. The text in bold is the text you have to type. prompt text text you type When using combination keys (ctrl, shift etc) these are shown as follows: control+h this means that you have to hold the Control key down and then press once the letter H (while still holding the control key). Chris Bayliss and Alan Reed

5 Part 1: Security - File and Directory Access chmod command As stated in the first course, there are three main types of access which can be applied to a file, and these can be applied selectively to yourself, your groups or everyone else. These types of access are called file modes. The ls -l command can be used to display the file mode. The chmod command is used to change the file modes. The chmod command is used to change the modes (access permissions) associated with a file. The change is specified in the form: chmod modes filename The mode is three characters which represent who will have their access changed, the operation (whether the access is to be added, subtracted or set) and what access permission is being referred to. who is affected is specified by one of: u user the owner of the file g group the group to which the owner belongs o other everyone else a all u, g and o operation is specified by one of: + add the specified permission - subtract the specified permission = assign the specified permission, ignoring the current setting and access permission is specified by one or more of: r w x Read Write execute (or list if a directory) Note that in order to have access to a file, the user concerned also needs list access (x) to the directory which contains the file, and all directories above it up to and including root. You will need to be aware of this if you set up files which are to be read by others, for example World Wide Web pages. In the examples below the chmod command is given together with the old and new modes for the files concerned. Chris Bayliss and Alan Reed Page 5

6 Ex.1 Given a file file.one with the default modes (read and write for the user), add read mode for the group: Type ls -l file.one the access modes should be as follows:- user group others Before: rw Type chmod o+r file.one Type ls -l file.one again, the access modes have now changed to:- After: rw- --- r-- Ex. 2 Remove read and write access for everyone else from file file.two. Type ls -l file.two the access modes should be as follows:- user group others Before: rwx rw- rw- chmod o-rw file.two After: rwx rw- --- Ex. 3 Give everyone (owner, group and others) read, write and execute permissions on file file.three Before: user Group others irrrelevant chmod a=rwx file.three After: rwx Rwx rwx thing to do! WARNING: Giving write access to other (everyone) is a risky Chris Bayliss and Alan Reed Page 6

7 chmod by numbers File access can be set using numbers rather than letters. The access is specified by three digits, the first being for the User, the second for the Group, and the third for the Others. Each digit is calculated by adding the numbers associated with read, write and execute access. The associated numbers are as follows: 4 Read 2 Write 1 execute (or search in the case of a directory) Chmod will then take the numbers as an argument instead of letters as above. In this way, a particular mode can be set instead of adding or subtracting from specific modes. For example: chmod 777 file4 would set read, write and execute modes for user, group and others. You would not normally wish to give others write access. chmod 755 file4 would set read, write and execute for user, and just read and execute for group and others. chmod 644 file4 would set read and write for user, and just read for group and others. Chris Bayliss and Alan Reed Page 7

8 Part 2: Strings, Patterns, Regular Expressions and grep strings There is a detailed treatment of strings, patterns and regular expressions in the appendix. This section covers a basic description with a few examples. These are sequences of ASCII characters, not just letters. These are taken as arguments to various commands. As special characters and spaces can be included in strings, it is sometimes necessary to quote them, as spaces would normally separate different arguments and you may or may not wish to preserve special characters. There are three types of quotes recognised by Unix. Single quotes pass the literal string without further processing. Double quotes allow the substitution of variables, and back quotes are used when the output of a command is to be used as a string. The differences are shown using the echo command echo $HOME /usr/ittc/demo0 echo " $HOME" /usr/ittc/demo0 echo '$HOME' $HOME echo 'date' date echo `date` Wed Sep 6 14:57:43 BST 1995 Chris Bayliss and Alan Reed Page 8

9 patterns Patterns match one or more strings and may contain wildcards (*?) or ranges of characters ( [a-z], [1-9] ). Note that quotes will inhibit the expansion of wildcards before the string is passed to the command. Examples using ls ls * ls???? list all files list all files with four characters ls [0-9]* list all files starting with a number ls * list files named * regular expressions These are more advanced forms of pattern used by some Unix commands and contain even more special characters. For example, ^ matches start of line and $ matches end of line. Note that the * has a different meaning than in patterns; it means zero or more repetitions of an expression. Examples fred ^fred fred$ fred anywhere on the line fred at the start of a line fred at the end of a line. any character.* any character repeated zero or more times Chris Bayliss and Alan Reed Page 9

10 grep This command finds all occurrences of a regular expression in a file or from the standard input piped to it, and displays all lines containing the regular expression. Regular expressions are explained in Appendix I. These are used by various different programs to represent particular character strings. The grep command can be useful when trying to find a given word or expression in a file or group of files. For example, if you wished to find every line with the word window in it in the file terminal.txt, you would type grep "window" terminal.txt The lines containing window would then be displayed. By default, the search is case sensitive. If you did not wish the match to be case sensitive you would use the -i flag. grep -i "window" terminal.txt The command can be combined with pipes, wildcards and other commands. For example, grep -i "window" *.txt The regular expression can be used to search for a string at the start or end of a line. For example, grep -i "^window" *.txt grep -i "window$" *.txt If you wished to display a list full details of directories in the current directory, you could pipe the output of ls-l into grep. For example, ls -l grep "^d" As ^ in a regular expression matches beginning of line, this displays only lines starting with a d. Chris Bayliss and Alan Reed Page 10

11 Part 3: More about shells Command line recall and editing The Korn shell supports command line recall and edit. This can save a lot of typing, as it gives you the ability to recall previous command lines, alter them and reissue them. Two modes are supported, emacs mode and vi mode, because of the style of the editor that is copied. In order to enable emacs mode, the built-in set command is used. set -o emacs This is normally done in your.profile file (this is discussed later). The basic functions supported are as follows CONTROL+P CONTROL+N CONTROL+B CONTROL+F recall previous line recall next line (only useful after one or more <ctrl>p move back one character move forward one character ksh Programming There are others, and these are documented in the ksh manual pages. Shells can be used to write programs. The simplest programs are files which contain a sequence of commands and allow the passing of parameters from the command line. This is sufficient for many uses. However, the Korn shell has many features which allow complex programs to be written, such as conditional statements and loops. This course does not cover these, but they are mentioned here in case they are of interest. Full details are contained in the manual pages for the Korn shell. A simple example program is given below #!/bin/ksh # Simple demonstration program # echo "What is your name?" read name echo "Hello, $name" The first line sets the shell to be used for this particular program., as it starts with #! followed by the pathname of a shell. The line indicates that the Korn shell should be used. Any other lines starting with a # are treated as comments. Comments are useful for keeping track of what Chris Bayliss and Alan Reed Page 11

12 parts of the file do, who changed the file, why and what changes were made. In addition, they can be used to put in blank lines to improve readability. The fourth line prompts the user for a name. The quotes ensure that the question is followed by a space. The third line reads the user input and puts it in the variable $name. The fourth line types Hello, followed by the value of $name. The program is in a file called prog1. An example of running it is given below. prog1 What is your name? Chris Hello, Chris Note that before a program can be run in this way, you must make sure that you have read and execute access to the file, and that "working directory" is on your PATH (see below). The other basic feature which is very useful is the passing of parameters from the command line. These are available as variables called $1, $2, $3, etc. All parameters together are available in a variable called $*. For example, the program #!/bin/ksh echo "Hello, $1." would print out Hello, followed by the first parameter on the command line. The file in this example is called prog2. An example of running it follows. prog2 Chris Hello, Chris. Chris Bayliss and Alan Reed Page 12

13 .profile This is a special shell program which is run every time you login, and it resides in your home directory. Some parameters are set in the system profile, which is a special profile run when everyone logs in. A typical.profile is given below. # ACS ksh.profile # Last modified: 18-Feb-94 JWH # # This is a file of commands which is read in by your shell when # it first starts up. You may edit it as you wish. # PATH=$PATH:$HOME/bin:. export PATH # umask 077 set -o ignoreeof set -o emacs # The first few lines start with a # and are comments. Normally, the first line selects the shell to be used with information selecting the shell, however this is not done in the.profile as this is run within the login shell, which is set for each user in a system file. PATH=$PATH:$HOME/bin:. export PATH These set your PATH environment variable. The directories $HOME/bin and. (your working directory) are added to your PATH variable. Note that $PATH is expanded to the original value of PATH. This method of modifying PATH avoids the possibility of omitting some of the directories needed to find the commands. The other method is to specify all directories needed in the final PATH and is not recommended, unless you need to remove directories from the PATH set by the system. Chris Bayliss and Alan Reed Page 13

14 umask 077 set -o ignoreeof set -o emacs More redirection This sets the user file creation mask. The effect of this setting is to ensure that nobody else can read or write files which you create. The access modes can be set for individual files or groups of files using the chmod command, should you need to give other people access to them after their creation. Normally, <ctrl>d signifies end of file. This has the same effect as exit to the shell. This command disables this feature, preventing accidental logouts by use of <ctrl>d. This sets emacs mode for command line recall and editing. If you wish to change any settings or add any commands, you may do this by editing your.profile file. For example, if you wished to display the date and time whenever you login, you could add the command echo It is `date` There is one type of redirection which allows the input of several lines to a command. An example is given below. cat <<XXXX Twinkle twinkle little star, How I wonder what you are, Up above the stars so high, Like a diamond in the sky XXXX The above example simply displays the verse on the terminal. However, in programming the pipe could be into a command to send , for example, and if necessary, variables could be included in the text. The XXXX is a sequence of characters which are given to indicate end of input. Any sequence of characters can be used, but it is wise to use a sequence unlikely to appear in the command input. There is a command which can be useful when redirecting standard output. This is tee and allows output from a command to be directed to a file and the terminal at the same time. For example: ls -l tee dirlist would direct the output from the ls command into the file dirlist as well as displaying it on a terminal. Chris Bayliss and Alan Reed Page 14

15 In addition to standard output, commands also produce error output. This is used for error messages and is treated differently by the system and is not redirected in the same way as standard output. However, error output can be directed to a file. For example ls -l xxxx 2> temperrors would put any errors produced by the ls command into the file temperrors instead of displaying the errors on the terminal. This feature is particularly useful if you issue a command which you know will produce a lot of error messages and you do not wish to display them at the terminal. An example of this occurs later in the course. Chris Bayliss and Alan Reed Page 15

16 Part 4: Finding Files find List will only list files in a directory or those immediately below it. Find is a command which will find files within a directory hierarchy, wherever they are within the tree. For example to find the file treasure the following would be used find. -name "treasure" -print The starting directory in this case is the current directory - all directories below it in the tree are searched. Any directory could be specified at this point. If you wished to search the entire hierarchy, you would use find / -name "treasure" -print Note that this will take some time. If you wish to cancel the command before it has finished, you can do so by typing control+c. You can cancel many other commands in this way. The other problem with running a command like the one above is that you can generate a lot of error messages. In this case, the errors are because you do not have sufficient access to some of the directories in the filestore to examine their contents. If you wish to suppress the error messages, you can use redirection. This is demonstrated in the following example. find / -name "treasure" -print 2> /dev/null The file /dev/null is a special device on Unix and is effectively a black hole. Any unwanted output can be directed to it and it will be discarde. If you wanted to search for a pattern rather than a fixed filename, you need to put the pattern in quotation marks. This is to prevent the shell from expanding the pattern before passing the pattern to the command. If you omitted the quotes, find the shell would find matches for the pattern in the current directory, and pass them as arguments to the find command. This would almost certainly not produce the desired results. find. -name "treasure*" -print In all the above examples, the -print option has been used. The -print displays the pathname when it finds the file. If -print is missing the command will find the file and not display it. This may seem a little bizarre to the uninitiated and volatile fuel for the Unix basher, but find has other options and you do not always want to display the pathname if using some of the other options. Chris Bayliss and Alan Reed Page 16

17 Find can perform other tasks instead of simply displaying the pathname. If desired, a command can be given to operate on each file found which matches the criteria. For example, the command. find. -name "*" -exec grep window {} \; would find all files in all directories including and below the current one, and display all lines in all files containing the word "window". The -exec indicates the command to be run, the curly brackets {} indicate where in the command line the found filename is to be placed and the \; characters indicate the end of command to be executed. In this example the print option has not been used. However, if you wished to print only the names of the files for which the command returned output, you would use find. -name "*" -exec grep window {} \; -print Chris Bayliss and Alan Reed Page 17

18 Part 5: Utilities sort uniq The sort command sorts files according to the ASCII sorting sequence by default - this for many purposes is an alphabetical sort. The output is directed to standard output. For example:- sort unsorted.list By default output is sent to the screen, but the results can be piped into a file. For example:- sort unsorted.list > sorted.list You will notice that the command completes very quickly. This causes problems as many users, when sorting a large file for the first time, wrongly assume that the sort has not worked then waste a lot of time checking that it has. The above example sorts the file according to the ASCII ordering of characters. This is fine for most alphabetic sorts, but not very useful for numeric sorts. If you wish to sort a list of numbers, the -n flag is used. sort -n numbers.txt > sorted.txt It is important to make sure that input and output filenames are different. Unix opens the output file for writing first, deleting any previous contents. If the filenames are the same, the contents of the file is therefore deleted. This is true of many different commands in Unix. There are a variety of other options, which allow reverse sorting, ignoring of case or blanks and sorting on different fields. The manual describes these in detail. This command will find and display or remove consecutive duplicate lines in a file. It is particularly useful in sorted files, and can be extremely useful when finding or eliminating repeated lines in data files, for example. uniq datafile.dat would display the sorted file, eliminating duplicates (the -u flag in sort will also do this). sort -u datafile.dat will display only lines which are not repeated. uniq -d datafile.dat displays only repeated lines. Chris Bayliss and Alan Reed Page 18

19 The output is sent to standard output which, by default, is the terminal. As normal this can be redirected to a file if desired. Combining files - cat and paste There are two main commands to join two files together. The first is cat, which is short for concatenate. The files are joined in order, by line, each file on the command line following the previous file. For example, cat verse1.txt verse2.txt verse3.txt > poem.txt would join the three files, one after the other and put the result in a file called poem.txt. The other way to join files is side by side. the paste command can do this. Line by line, the files are joined. For example if we take two files, firstnames.txt surnames.txt containing the following firstnames.txt Jemima Jeremy surnames.txt Puddleduck Fisher and then joined them with the paste command as follows, paste firstnames.txt surnames.txt > fullnames.txt the file fullnames.txt would contain: Jemima Puddleduck Jeremy Fisher Chris Bayliss and Alan Reed Page 19

20 cut The cut command allows extraction of columns of information from files. For example if the file animals.txt contains the following chimpanzee, rat, giraffe, hedgehog, lion baboon, mouse, camel, porcupine, tiger tamarin, coypu, cow, aardvark, leopard wc and you wished to extract the rodents (column 2) the command would be cut -d, -f 2 animals.txt and the output would be rat mouse coypu This can be used in conjunction with paste in order to move columns between files. The wc (word count) command counts the number of lines, words or characters in a file. Used on its own, all three are counted. For example, wc curry.txt curry.txt The -l option restricts the output to the number of lines. This can be very useful when combined with other commands. For example ls wc -l will show the number of files in a directory. Chris Bayliss and Alan Reed Page 20

21 Part 6: Topics not covered - sed, awk, perl and vi sed awk perl vi These three utilities are not covered by the course, but a brief description is given below. The commands sed and awk are documented in the Unix manual. In addition there is a very good Nutshell handbook ( sed & awk by Dale Dougherty ISBN published by O'Reilley and Associates) which covers both of these commands. The Nutshell handbooks cover specific topics in good detail. For most users, a general Unix textbook may well be helpful, preferably one with a positive attitude towards Unix. Our current recommendation is Open Computing Unix Unbound by Harley Hahn ISBN published by McGraw Hill. sed is a stream editor. This allows editing of a file which is piped into it on a line by line basis. Regular expressions can be used and substitutions can be made. Lines can be selectively added or deleted if necessary. awk is a programming language which allows processing of a file on a line by line basis. The file is scanned line by line, patterns are matched and appropriate processing takes place. In addition to this, actions to be taken both before and after the file is processed may be specified. One major use of this is the gathering and processing of statistics from system log files. perl is a shell like programming language. It is not a standard part of Unix, but is very popular. Whilst the Korn shell can be used to write complex programs, perl is commonly used instead. vi is a screen editor. It is the one supplied with Unix. Most people prefer to use emacs, but vi has its supporters. In addition, if you are installing a new system or do not have emacs available, you may need to use vi. It has a man page and a tutorial. An online tutorial is available called vitutor. Chris Bayliss and Alan Reed Page 21

22 Part 7: Processes and how to kill them Processes Most commands and programs run as separate processes. These have their own set of variables, although environment variables are passed to each process you create. Sometimes, processes are run in the background. This may be done intentionally or accidentally. Some programs will have options to run them in the background (for example control Z on emacs), others can be run in the background by placing an ampersand (&) at the end of the command line. If you have background processes running, it may be necessary to either bring them to the foreground and terminate them cleanly, or destroy them. If you try to logout when you have background jobs running, the system will warn you, giving you the opportunity to take any appropriate action. ps The ps (process status) command displays information about active processes. In order to identify a process, which is essential if the process is to be destroyed, the process number is needed. The ps command has many options and will display all running processes. In order to print basic information about your own processes, the -u option is used. For example, ps -u demo0 PID TTY TIME COMD pts/27 0:02 elm pts/27 0:02 ksh pts/27 0:02 ps pts/27 0:02 emacs pts/27 0:02 emacs The PID is the process ID, a number which at any one time uniquely identifies a process on a particular system. Chris Bayliss and Alan Reed Page 22

23 fg The fg command brings the process into the foreground and under your control. If you have only one background process, the command needs no arguments, and can be given on its own. If you have more than one background process, the most recent is brought to the foreground by default. You may specify a process ID to bring a particular background process into the foreground. Using the above example, fg fg the foreground. brings elm into the foreground brings the older suspended emacs session into kill The kill command send a signal to a another process. There are several options. The one most commonly used is the -9 option, as this terminates processes which can ignore some of the other options. It is a useful command for terminating a n unwanted background process. For example in order to terminate the process in the above example, you could use kill Take care when terminating processes such as elm and emacs in this way, as work in progress can be lost. If you need to save work in progress, bring the processes to foreground and terminated them cleanly. Chris Bayliss and Alan Reed Page 23

24 Appendix I: ASCII characters, strings, patterns, and regular expressions ASCII characters strings When using UNIX you will come across the above terms, this document is designed to explain what they are and how they are used in UNIX. These are the letters, digits, punctuation marks, and special symbols that you can type from a keyboard attached to a UNIX computer system. Some characters you can 'see' printed on the keytops but there are others that are hidden from you but the keyboard is able to send to the UNIX computer. Each character has a number associated with it from 0 to 255, thus there are 256 ASCII characters in all. For example the letter A has the number 65, and the digit 0 has 48. In computing we count in 10's (decimal), 8's (octal), and 16's (hexadecimal). Thus the letter A would be 65 in decimal, 101 in octal, or 41 in hexadecimal. The printable ASCII characters are a 'space' and!"#$%&'()*+,-./ :;<=>?@ ABCEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwx yz{ }~ These are a sequence of the above ASCII characters. Thus FRED is a string of the four ASCII characters F R E D. In a UNIX 'shell' such as the Korn shell you can write strings in single quotes ' or in double quotes " or single back quotes `. In single quotes the string is taken literally*, in double quotes it is examined by the shell and all $ names are substituted. When the single back quote is used the shell evaluates the string as a command and returns the result as a string. To understand these behaviours try out these shell commands:- echo '$HOME' produces $HOME echo "$HOME" produces your home directory echo 'date' produces the string d a t e echo `date` produces today s date and time * Not entirely literally because the \ symbol is treated in a special way. To get the non-printing characters you use the \ symbol followed by the three octal digits of the character, thus \007 means the bell, and \014 a newpage. You can also use \n for the linefeed character, and \r for carriage return. Try typing echo 'Hello there\007', and listen for the beep! Chris Bayliss and Alan Reed Page 24

25 patterns A pattern is a string used to match, or stand for, many more strings. In it the character? matches ONE character, * matches ZERO or MORE characters. [a-f] (say)matches the lower case letters a or b or c or d or e or f. The main use you will have for a pattern is for filename generation as follows: Try typing:- ls * ls???? ls x* ls x*f ls [0-9]* ls [abc][xyx] lists all your file names lists all four letter filenames lists all names starting with x ditto starting with x ending in f lists all names starting with a digit lists all 2 letter filenames of all combinations of abc and xyz Note the absence of quote marks, and investigate the difference between typing ls * and ls '*', the former looks for all names while the latter looks for a filename of a single star character. For full details see the man page for the Korn shell (man ksh). regular expressions Expression Meaning A regular expression is an advanced form of a pattern used by some UNIX commands such as grep or the editor sed. The following description is taken from the man page for regular expression (man regexp). A regular expression specifies a set of character strings. A member of this set of strings is said to be matched by the regular expression. Some characters have special meaning when used in a regular expression; other characters stand for themselves. c the character c where c is not a special character. \c the character c where c is any character, except a digit in the range 1-9 ^ the beginning of the line being compared. $ the end of the line being compared.. any character in the input. [s] any character in the set s, where s is a sequence of characters and/or a range of characters, for example, [a-z]. [^s] any character not in the set s, where s is defined as above. Chris Bayliss and Alan Reed Page 25

26 r* zero or more successive occurrences of the regular expression r. The longest leftmost match is chosen. rx the occurrence of regular expression r followed by the occurrence of regular expression x. (Concatenation) r\{m,n\} any number of m through n successive occurrences of the regular expression r. The regular expression r\{m\} matches exactly m occurrences; r\{m,\} matches at least m occurrences. \(r\) the regular expression r. When \n (where n is a number greater than zero) appears in a constructed regular expression, it stands for the regular expression x where x is the nth regular expression enclosed in \( and \) that appeared earlier in the constructed regular expression. For example, \(r\)x\(y\)z\2 is the concatenation of regular expressions rxyzy. Characters that have special meaning except when they appear within square brackets ([ ]) or are preceded by \ are:., *, [, \. Other special characters, such as $ have special meaning in more restricted contexts. The character ^ at the beginning of an expression permits a successful match only immediately after a newline, and the character $ at the end of an expression requires a trailing newline. Two characters have special meaning only when used within square brackets. The character - denotes a range, [c-c], unless it is just after the open bracket or before the closing bracket, [ -c] or [c-] in which case it has no special meaning. When used within brackets, the character ^ has the meaning complement of if it immediately follows the open bracket (example: [^c]); elsewhere between brackets (example: [c^]) it stands for the ordinary character ^. The special meaning of the \ operator can be escaped only by preceding it with another \, for example \\. Chris Bayliss and Alan Reed Page 26

27 After that what can one say! Here are some examples:- regular expression matches fred fred anywhere in a line ^john john at start of a line john$ john at end of a line ^john$ john on a line ONLY ^$ a blank line ONLY =\{14\} exactly fourteen = characters \(.\)\1\1\1 exactly four characters ALL THE SAME. Chris Bayliss and Alan Reed Page 27

5/20/2007. Touring Essential Programs

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

More information

5/8/2012. Exploring Utilities Chapter 5

5/8/2012. Exploring Utilities Chapter 5 Exploring Utilities Chapter 5 Examining the contents of files. Working with the cut and paste feature. Formatting output with the column utility. Searching for lines containing a target string with grep.

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

Linux & Shell Programming 2014

Linux & Shell Programming 2014 Practical No : 1 Enrollment No: Group : A Practical Problem Write a date command to display date in following format: (Consider current date as 4 th January 2014) 1. dd/mm/yy hh:mm:ss 2. Today's date is:

More information

UNIX files searching, and other interrogation techniques

UNIX files searching, and other interrogation techniques UNIX files searching, and other interrogation techniques Ways to examine the contents of files. How to find files when you don't know how their exact location. Ways of searching files for text patterns.

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

A Brief Introduction to the Linux Shell for Data Science

A Brief Introduction to the Linux Shell for Data Science A Brief Introduction to the Linux Shell for Data Science Aris Anagnostopoulos 1 Introduction Here we will see a brief introduction of the Linux command line or shell as it is called. Linux is a Unix-like

More information

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

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

More information

Oxford University Computing Services. Getting Started with Unix

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

More information

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

12.1 UNDERSTANDING UNIX SHELL PROGRAMMING LANGUAGE: AN INTRODUCTION Writing a Simple Script Executing a Script

12.1 UNDERSTANDING UNIX SHELL PROGRAMMING LANGUAGE: AN INTRODUCTION Writing a Simple Script Executing a Script 12 Shell Programming This chapter concentrates on shell programming. It explains the capabilities of the shell as an interpretive high-level language. It describes shell programming constructs and particulars.

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

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 as a Platform Exercises. Course Code: OS-01-UNXPLAT

Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT Unix as a Platform Exercises Course Code: OS-01-UNXPLAT Working with Unix 1. Use the on-line manual page to determine the option for cat, which causes nonprintable characters to be displayed. Run the command

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

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

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2)

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2) BANK ON & SHELL PROGRAMMING-502 (CORE PAPER-2) TOPIC 1: VI-EDITOR MARKS YEAR 1. Explain set command of vi editor 2 2011oct 2. Explain the modes of vi editor. 7 2013mar/ 2013 oct 3. Explain vi editor 5

More information

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

S E C T I O N O V E R V I E W AN INTRODUCTION TO SHELLS S E C T I O N O V E R V I E W Continuing from last section, we are going to learn about the following concepts: understanding quotes and escapes; considering the importance of

More information

commandname flags arguments

commandname flags arguments Unix Review, additional Unix commands CS101, Mock Introduction This handout/lecture reviews some basic UNIX commands that you should know how to use. A more detailed description of this and other commands

More information

The Online Unix Manual

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

More information

Introduction to Unix CHAPTER 6. File Systems. Permissions

Introduction to Unix CHAPTER 6. File Systems. Permissions CHAPTER 6 Introduction to Unix The Unix operating system is an incredibly powerful and complex system that is ideal for running a distributed system such as ours, particularly since we use computers primarily

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

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

AC109/AT109 UNIX & SHELL PROGRAMMING DEC 2014

AC109/AT109 UNIX & SHELL PROGRAMMING DEC 2014 Q.2 a. Explain the principal components: Kernel and Shell, of the UNIX operating system. Refer Page No. 22 from Textbook b. Explain absolute and relative pathnames with the help of examples. Refer Page

More information

Review of Fundamentals

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

More information

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

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

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

File system Security (Access Rights)

File system Security (Access Rights) File system Security (Access Rights) In your home directory, type % ls -l (l for long listing!) You will see that you now get lots of details about the contents of your directory, similar to the example

More information

INSE Lab 1 Introduction to UNIX Fall 2017

INSE Lab 1 Introduction to UNIX Fall 2017 INSE 6130 - Lab 1 Introduction to UNIX Fall 2017 Updated by: Paria Shirani Overview In this lab session, students will learn the basics of UNIX /Linux commands. They will be able to perform the basic operations:

More information

Operating Systems Lab 1 (Users, Groups, and Security)

Operating Systems Lab 1 (Users, Groups, and Security) Operating Systems Lab 1 (Users, Groups, and Security) Overview This chapter covers the most common commands related to users, groups, and security. It will also discuss topics like account creation/deletion,

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

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

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

bash, part 3 Chris GauthierDickey

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

More information

Introduction to UNIX Shell Exercises

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

More information

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

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University Unix/Linux Basics 1 Some basics to remember Everything is case sensitive Eg., you can have two different files of the same name but different case in the same folder Console-driven (same as terminal )

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

UNIX Tutorial Five

UNIX Tutorial Five UNIX Tutorial Five 5.1 File system security (access rights) In your unixstuff directory, type % ls -l (l for long listing!) You will see that you now get lots of details about the contents of your directory,

More information

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

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

More information

2) clear :- It clears the terminal screen. Syntax :- clear

2) clear :- It clears the terminal screen. Syntax :- clear 1) cal :- Displays a calendar Syntax:- cal [options] [ month ] [year] cal displays a simple calendar. If arguments are not specified, the current month is displayed. In addition to cal, the ncal command

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

IMPORTANT: Logging Off LOGGING IN

IMPORTANT: Logging Off LOGGING IN These are a few basic Unix commands compiled from Unix web sites, and printed materials. The main purpose is to help a beginner to go around with fewer difficulties. Therefore, I will be adding to this

More information

Exploring UNIX: Session 3

Exploring UNIX: Session 3 Exploring UNIX: Session 3 UNIX file system permissions UNIX is a multi user operating system. This means several users can be logged in simultaneously. For obvious reasons UNIX makes sure users cannot

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

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

Introduction to Linux

Introduction to Linux Introduction to Linux The command-line interface A command-line interface (CLI) is a type of interface, that is, a way to interact with a computer. Window systems, punched cards or a bunch of dials, buttons

More information

Introduction to Linux

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

More information

Practical Session 0 Introduction to Linux

Practical Session 0 Introduction to Linux School of Computer Science and Software Engineering Clayton Campus, Monash University CSE2303 and CSE2304 Semester I, 2001 Practical Session 0 Introduction to Linux Novell accounts. Every Monash student

More information

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

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

More information

Linux Tutorial #6. -rw-r csce_user csce_user 20 Jan 4 09:15 list1.txt -rw-r csce_user csce_user 26 Jan 4 09:16 list2.

Linux Tutorial #6. -rw-r csce_user csce_user 20 Jan 4 09:15 list1.txt -rw-r csce_user csce_user 26 Jan 4 09:16 list2. File system access rights Linux Tutorial #6 Linux provides file system security using a three- level system of access rights. These special codes control who can read/write/execute every file and directory

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

CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND

CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND Prof. Michael J. Reale Fall 2014 Finding Files in a Directory Tree Suppose you want to find a file with a certain filename (or with a filename matching

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

Scripting Languages Course 1. Diana Trandabăț

Scripting Languages Course 1. Diana Trandabăț Scripting Languages Course 1 Diana Trandabăț Master in Computational Linguistics - 1 st year 2017-2018 Today s lecture Introduction to scripting languages What is a script? What is a scripting language

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

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

Systems Programming/ C and UNIX

Systems Programming/ C and UNIX Systems Programming/ C and UNIX December 7-10, 2017 1/17 December 7-10, 2017 1 / 17 Outline 1 2 Using find 2/17 December 7-10, 2017 2 / 17 String Pattern Matching Tools Regular Expressions Simple Examples

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

Part 1: Basic Commands/U3li3es

Part 1: Basic Commands/U3li3es Final Exam Part 1: Basic Commands/U3li3es May 17 th 3:00~4:00pm S-3-143 Same types of questions as in mid-term 1 2 ls, cat, echo ls -l e.g., regular file or directory, permissions, file size ls -a cat

More information

Introduction to the Shell

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

More information

Basics. I think that the later is better.

Basics.  I think that the later is better. Basics Before we take up shell scripting, let s review some of the basic features and syntax of the shell, specifically the major shells in the sh lineage. Command Editing If you like vi, put your shell

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

B a s h s c r i p t i n g

B a s h s c r i p t i n g 8 Bash Scripting Any self-respecting hacker must be able to write scripts. For that matter, any selfrespecting Linux administrator must be able to script. Hackers often need to automate commands, sometimes

More information

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

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

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

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

Chapter 4. Unix Tutorial. Unix Shell

Chapter 4. Unix Tutorial. Unix Shell Chapter 4 Unix Tutorial Users and applications interact with hardware through an operating system (OS). Unix is a very basic operating system in that it has just the essentials. Many operating systems,

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

6.033 Computer System Engineering

6.033 Computer System Engineering MIT OpenCourseWare http://ocw.mit.edu 6.033 Computer System Engineering Spring 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. M.I.T. DEPARTMENT

More information

Exercise Sheet 2. (Classifications of Operating Systems)

Exercise Sheet 2. (Classifications of Operating Systems) Exercise Sheet 2 Exercise 1 (Classifications of Operating Systems) 1. At any given moment, only a single program can be executed. What is the technical term for this operation mode? 2. What are half multi-user

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

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

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

More information

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

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

More information

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (( )) (( )) [ x x ] cdc communications, inc. [ x x ] \ / presents... \ / (` ') (` ') (U) (U) Gibe's UNIX COMMAND Bible ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The latest file from the Cow's

More information

File Commands. Objectives

File Commands. Objectives File Commands Chapter 2 SYS-ED/Computer Education Techniques, Inc. 2: 1 Objectives You will learn: Purpose and function of file commands. Interrelated usage of commands. SYS-ED/Computer Education Techniques,

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

CSC UNIX System, Spring 2015

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

More information

Operating Systems, Unix Files and Commands SEEM

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

More information

The input can also be taken from a file and similarly the output can be redirected to another file.

The input can also be taken from a file and similarly the output can be redirected to another file. Filter A filter is defined as a special program, which takes input from standard input device and sends output to standard output device. The input can also be taken from a file and similarly the output

More information

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

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

More information

Lecture 3 Tonight we dine in shell. Hands-On Unix System Administration DeCal

Lecture 3 Tonight we dine in shell. Hands-On Unix System Administration DeCal Lecture 3 Tonight we dine in shell Hands-On Unix System Administration DeCal 2012-09-17 Review $1, $2,...; $@, $*, $#, $0, $? environment variables env, export $HOME, $PATH $PS1=n\[\e[0;31m\]\u\[\e[m\]@\[\e[1;34m\]\w

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

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

CSCI 2132 Software Development. Lecture 5: File Permissions

CSCI 2132 Software Development. Lecture 5: File Permissions CSCI 2132 Software Development Lecture 5: File Permissions Instructor: Vlado Keselj Faculty of Computer Science Dalhousie University 14-Sep-2018 (5) CSCI 2132 1 Files and Directories Pathnames Previous

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

Understanding bash. Prof. Chris GauthierDickey COMP 2400, Fall 2008

Understanding bash. Prof. Chris GauthierDickey COMP 2400, Fall 2008 Understanding bash Prof. Chris GauthierDickey COMP 2400, Fall 2008 How does bash start? It begins by reading your configuration files: If it s an interactive login-shell, first /etc/profile is executed,

More information

BASH SHELL SCRIPT 1- Introduction to Shell

BASH SHELL SCRIPT 1- Introduction to Shell BASH SHELL SCRIPT 1- Introduction to Shell What is shell Installation of shell Shell features Bash Keywords Built-in Commands Linux Commands Specialized Navigation and History Commands Shell Aliases Bash

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

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

CS160A EXERCISES-FILTERS2 Boyd

CS160A EXERCISES-FILTERS2 Boyd Exercises-Filters2 In this exercise we will practice with the Unix filters cut, and tr. We will also practice using paste, even though, strictly speaking, it is not a filter. In addition, we will expand

More information

Computer Systems and Architecture

Computer Systems and Architecture Computer Systems and Architecture Introduction to UNIX Stephen Pauwels University of Antwerp October 2, 2015 Outline What is Unix? Getting started Streams Exercises UNIX Operating system Servers, desktops,

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

User Commands sed ( 1 )

User Commands sed ( 1 ) NAME sed stream editor SYNOPSIS /usr/bin/sed [-n] script [file...] /usr/bin/sed [-n] [-e script]... [-f script_file]... [file...] /usr/xpg4/bin/sed [-n] script [file...] /usr/xpg4/bin/sed [-n] [-e script]...

More information

Linux command line basics III: piping commands for text processing. Yanbin Yin Fall 2015

Linux command line basics III: piping commands for text processing. Yanbin Yin Fall 2015 Linux command line basics III: piping commands for text processing Yanbin Yin Fall 2015 1 h.p://korflab.ucdavis.edu/unix_and_perl/unix_and_perl_v3.1.1.pdf 2 The beauty of Unix for bioinformagcs sort, cut,

More information

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

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

More information

Introduction to UNIX. Introduction. Processes. ps command. The File System. Directory Structure. UNIX is an operating system (OS).

Introduction to UNIX. Introduction. Processes. ps command. The File System. Directory Structure. UNIX is an operating system (OS). Introduction Introduction to UNIX CSE 2031 Fall 2012 UNIX is an operating system (OS). Our goals: Learn how to use UNIX OS. Use UNIX tools for developing programs/ software, specifically shell programming.

More information

Introduction to UNIX. CSE 2031 Fall November 5, 2012

Introduction to UNIX. CSE 2031 Fall November 5, 2012 Introduction to UNIX CSE 2031 Fall 2012 November 5, 2012 Introduction UNIX is an operating system (OS). Our goals: Learn how to use UNIX OS. Use UNIX tools for developing programs/ software, specifically

More information