Operating Systems. Lab Manual. Compiled by: Mr. Mohammed Al-Qadhi Computer Science Department

Size: px
Start display at page:

Download "Operating Systems. Lab Manual. Compiled by: Mr. Mohammed Al-Qadhi Computer Science Department"

Transcription

1 J A Z A N U N I V E R S I T Y C O M P U T E R S C I E N C E D E P A R T M E N T Operating Systems Lab Manual Compiled by: Mr. Mohammed Al-Qadhi Computer Science Department

2 Table of Contents First Lab Session... 1 What is Linux? UNIX & Linux Operating Systems Linux s File System Terminal Emulators Linux Shell First Keystrokes of Shell Commands... 6 Part One... 8 Interactive Linux Shell Commands Commands for Navigating File System Commands for Manipulating Files and Directories Permissions chmod Change File Mode umask Set Default Permissions Other Commands Part Two Bash Shell Scripting Writing Your First Shell Script What are Shell Scripts? How to Write a Shell Script? Script File Format User Input/Output User Variables Quote Character Control Structures if-then Statement Control Structures if-then-else Statement... 34

3 2.7 Control Structures if-elif-else Statement Command-Controlled Repetition: While Loop List-Controlled Repetition: For Loop Compound Condition Testing Practicing Exercises References Appendix Installing & Operating Cygwin Simulator (Arabic Illustration)... 41

4 Tentative Breakdown of Lab Sessions Topics to be Covered No of Weeks Contact Hours First Lab Session: What is Linux? 1 2 Linux Interactive Shell Commands 5 10 Bash Shell Scripting 6 12

5 P a g e 1 First Lab Session: What is Linux? Lab Objectives: This Lab is for new users of the Linux operating System. The students assumed to have some prior experience with computers, but not necessarily with Linux. The followings are the primary objectives of this lab session: What is Linux? Understanding Linux File System. Knowing different shells in Linux. Knowing Linux terminal. Starting doing some initial shell interactive commands. 1. UNIX & Linux Operating Systems UNIX is a powerful operating system originally developed at AT&T Bell Labs. It is very popular among the scientific, engineering, and academic communities due to its multi-user and multi-tasking environment, flexibility and portability, electronic mail and networking capabilities, and the numerous programming, text processing and scientific utilities available. The UNIX system is mainly composed of three different parts: the kernel, the file system, and the shell. (1) The kernel is that part of the system which manages the resources of whatever computer system it lives on, to keep track of the disks, tapes, printers, terminals, communication lines and any other devices. (2) The file system is the organizing structure for data. The file system is perhaps the most important part of the Linux operating system. The file

6 P a g e 2 system goes beyond being a simple repository for data, and provides the means of organizing the layout of the data storage in complex ways. (3) The shell is the command interpreter. Although the shell is just a utility program, and is not properly a part of the system, it is the part that the user sees. The shell listens to your terminal and translates your requests into actions on the part of the kernel and the many utility programs Linux is a freely available, open source, UNIX-like operating System. Written originally for the PC by Linus Torvalds (A young student in the University of Helsinki), with the help of many other developers across the internet, Linux now runs on multiple hardware platforms, from the smallest to the largest, and serves a wide variety of needs from servers to movie-making to running businesses to user desktops. 2. Linux s File System A file system is a logical organization of storage space designed to contain files in directories. The Linux file system is quite similar to that of MS-DOS or Windows. It is organized hierarchically (inverted tree) into directories for efficient organization. However, in Windows, there are many logical trees represented by drive letters such as C:, D:, H:, etc. In Linux, all file systems (Hard Disks, CD-ROMs, Floppy Disks, ZIP drives, network mounts, etc ) are mounted onto one logical tree. The top of the hierarchy is traditionally called root which is represented by a / (slash).

7 P a g e 3 Figure 1: File System Hierarchy in Linux 3. Terminal Emulators When using a graphical user interface, we need another program called a terminal emulator to interact with the shell. If we look through our desktop menus, we will probably find one. KDE uses konsole and GNOME uses gnome-terminal, though it's likely called simply terminal on our menu. There are a number of other terminal emulators available for Linux, but they all basically do the same thing; give us access to the shell. You will probably develop a preference for one or another based on the number of bells and whistles it has.

8 P a g e 4 Figure 2: Terminal Window in Linux 3.1 Linux Shell When we speak of the command line, we are really referring to the shell. The shell is a program that takes keyboard commands and passes them to the operating system to carry out. Almost all Linux distributions supply a shell program from the GNU Project called bash. The name bash is an acronym for Bourne Again SHell, a reference to the fact bash is an enhanced replacement for sh, the original UNIX shell program written by Steve Bourne. The Shell is somewhat unique, in that it is both a powerful command line interface to the system and a scripting language interpreter. As we will see, most of the things that can be done on the command line can be done in scripts, and most of the things that can be done in scripts can be done on the command line.

9 P a g e 5 The Shell is simply another program on top of the kernel which provides a basic human-os interface. It is a command interpreter that is built on top of the kernel which enables users to run services provided by the UNIX OS. In its simplest form, a series of commands in a file is a shell program that saves having to retype commands to perform common tasks. Figure 3: Linux OS Structure The following UNIX/Linux Shells are more likely to be used: [1] sh: Bourne Shell (Original Shell) (Steven Bourne of AT&T) [2] bash: Bourne Again Shell (GNU Improved Bourne Shell) [3] csh: C-Shell (C-like Syntax)(Bill Joy of Univ. of California) [4] ksh: Korn-Shell (Bourne+some C-shell)(David Korn of AT&T) [5] tcsh: Turbo C-Shell (More User Friendly C-Shell).

10 P a g e 6 4. First Keystrokes of Shell Commands Command date cal df free exit clear history echo $SHELL Function Displays the current time and date. Displays a calendar of the current month. To see the current amount of free space on your disk drives To display the amount of free memory Ending a terminal session Clearing the screen Displays the history of commands that have been entered so far. To check which shell is used recently Note: you can go back to the list of entered commands one-by-one by means of the upward and downward arrows buttons on the keyboard. This is useful and timesaving if one wants to reuse or modify a command that has been entered before instead of rewriting the whole command again.

11 Part One Interactive Linux Shell Commands

12 P a g e 8 Lab Objectives: To make students: Able to use Linux terminal to administrate Linux. Familiar with Linux s Bash Shell interactive commands related to: File system navigation. Manipulating files and directories. Permissions. 1.1 Commands for Navigating File System Command Function Example(s) pwd ls <directory> ls -l ls -lt Displaying The Current Working Directory To list the files and directories in the current working directory To list the files and directories in a specified directory To list the files and directories in a specified directory with revealing more details To list the files and directories in a specified directory with revealing more details [student@localhost ~]$ pwd [student@localhost ~]$ ls [student@localhost ~]$ ls /home/student/mohd [student@localhost ~]$ ls -l [student@localhost ~]$ ls -lt

13 P a g e 9 [student@localhost ~]$ pwd [student@localhost ~]$ ls cd <dir> Changing current directory the working To open mohd directory: [student@localhost ~]$ cd mohd If the directory you want to change to is not within the current working directory then, you should specify the directory path: cd.. cd - tree <options> [directory] Changing the current working directory by going one directory backward Changes the working directory to the previous working directory. Display the contents of a directory in a tree hierarchy format [student@localhost ~]$ cd /<dir path>/mohd [student@localhost ~]$ pwd To go back to student : [student@localhost ~]$ cd.. [student@localhost ~]$ pwd [student@localhost ~]$ cd - [student@localhost ~]$ cd / In the following example, executing the command will display 2 directory levels (relative to the current location) in tree form: [student@localhost ~]$ tree -d -L 2 More options: tree -a: Include hidden files in the tree listing tree -d: List directories only tree -L [NUM]: List the specified number of levels deep

14 P a g e Commands for Manipulating Files and Directories Command Function Examples gedit mkdir <directory name> Creating textual files using gedit program Creating directories [student@localhost ~]$ gedit ahmed.txt [student@localhost ~]$ gedit OS.txt To create a single directory [student@localhost ~]$ mkdir dir1 To create multiple directories at once [student@localhost ~]$ mkdir dir2 dir3 dir4 [student@localhost ~]$ cp ahmed.txt dir1 Copy files and directories from source to dest Note: we here just mentioned the text file and the directory without their full path because; both of them are located in the current working directory. However, if any of them located outside the current working directory then; the full file path should be mentioned as follows: [student@localhost ~]$ cp /<file path>/ahmed.txt /<dir path>/dir1 cp <source> <dest> We can use update option when copying files from one directory to another, only copy files that either don't exist, or are newer than the existing corresponding files, in the destination directory: Using * wildcard to copy a set of files having the same file extension at once [student@localhost ~]$ cp -u *.txt dir2 We can use interactive option before overwriting an existing file, prompt the user for confirmation. If this option is not specified, cp will silently overwrite files: [student@localhost ~]$ cp -i *.txt dir2 We can use verbose option to display informative messages as the copy is performed: [student@localhost ~]$ cp -v *.txt dir2

15 P a g e 11 [student@localhost ~]$ mv ahmed.txt dir1 To move files and folders Note: we here just mentioned the text file and the directory without their full path because; both of them are located in the current working directory. However, if any of them located outside the current working directory then; the full file path should be mentioned as follows: [student@localhost ~]$ mv /<file path>/ahmed.txt mv <source> <dest> We can use update option when moving files from one directory to another, only move files that either don't exist, or are newer than the existing corresponding files, in the destination directory: Using * wildcard to move a set of files having the same file extension at once [student@localhost ~]$ mv -u *.txt dir2 We can use interactive option before overwriting an existing file, prompt the user for confirmation. If this option is not specified, mv will silently overwrite files: [student@localhost ~]$ mv -i *.txt dir2 We can use verbose option to display informative messages as the move is performed: [student@localhost ~]$ mv -v *.txt dir2 student@localhost ~]$ rm ahmed.txt dir1 rm <file> To remove (delete) files and directories: Note: we here just mentioned the text file and the directory without their full path because; both of them are located in the current working directory. However, if any of them located outside the current working directory then; the full file path should be mentioned as follows: [student@localhost ~]$ rm <file path> ahmed.txt

16 P a g e 12 rmdir <directory> To delete directories. We can use interactive option before overwriting an existing file, prompt the user for confirmation. If this option is not specified, rm will silently overwrite files: [student@localhost ~]$ rm -i ahmed.txt We can use verbose option to display informative messages as the removal is performed: [student@localhost ~]$ rm -v ahmed.txt [student@localhost ~]$ rmdir dir1 Note: rmdir will only remove empty directories. If dir1 is a non-empty directory, use: [student@localhost ~]$ rm -r dir1 More Practicing Examples

17 P a g e 13

18 P a g e Permissions Command Function Examples id To find out information about the current user s identity [student@localhost ~]$ id [student@localhost ~]$ ls l moh.txt ls -l Access rights to files and directories are defined in terms of read access, write access, and execution access. If we look at the output of the ls command, we can get some clue as to how this is implemented: Result of command: -rw-rw-r-- 1 me me :52 moh.txt The first ten characters of the listing are the file attributes. The first of these characters is the file type. Table 1 is listing the file types you are most likely to see. chmod Change file mode See Subsection umask Set Default Permissions See Subsection Table 1: File Types

19 P a g e 15 The remaining nine characters of the file attributes, called the file mode, represent the read, write, and execute permissions for the file's owner, the file's group owner, and everybody else: When set, the r, w, and x mode attributes have the following effect on files and directories: Table 2: Permission Attributes

20 P a g e 16 Table 3: Permission Attribute Examples chmod Change File Mode To change the mode (permissions) of a file or directory, the chmod command is used. Be aware that only the file s owner or the super user can change the mode of a file or directory. chmod supports two distinct ways of specifying mode changes: octal number representation, or symbolic representation. We will cover octal number representation first. With octal notation we use octal numbers to set the pattern of desired permissions. Since each digit in an octal number represents three

21 P a g e 17 binary digits, this maps nicely to the scheme used to store the file mode. This table shows what we mean: Table 4: Permission Possibilities List By using three octal digits, we can set the file mode for the owner, group owner, and world: [student@localhost ~]$ ls -l mohd.txt -rw-rw-r-- 1 me me :52 foo.txt [student@localhost ~]$ chmod 600 mohd.txt [student@localhost ~]$ ls -l mohd.txt -rw me me :52 foo.txt By passing the argument 600, we were able to set the permissions of the owner to read and write while removing all permissions from the group owner and world. Though remembering the octal to binary mapping may seem inconvenient, you will usually only have to use a few common ones: 7 (rwx), 6 (rw-), 5 (r-x), 4 (r--), and 0 (---).

22 P a g e 18 chmod also supports a symbolic notation for specifying file modes. Symbolic notation is divided into three parts: who the change will affect, which operation will be performed, and what permission will be set. To specify who is affected, a combination of the characters u, g, o, and a is used as follows: Table 5: chmod Symbolic Notation If no character is specified, all will be assumed. The operation may be a + indicating that a permission is to be added, a - indicating that a permission is to be taken away, or a = indicating that only the specified permissions are to be applied and that all others are to be removed. Permissions are specified with the r, w, and x characters. Here are some examples of symbolic notation:

23 P a g e 19 Table 6: chmod Symbolic Notation Examples umask Set Default Permissions The umask command controls the default permissions given to a file when it is created. It uses octal notation to express a mask of bits to be removed from a file's mode attributes. Let's take a look: [student@localhost ~]$ rm -f foo.txt [student@localhost ~]$ umask 0002 [student@localhost ~]$ > foo.txt [student@localhost ~]$ ls -l foo.txt -rw-rw-r-- 1 me me :53 foo.txt

24 P a g e 20 We first removed any old copy of foo.txt to make sure we were starting fresh. Next, we ran the umask command without an argument to see the current value. It responded with the value 0002 (the value 0022 is another common default value), which is the octal representation of our mask. We next create a new instance of the file foo.txt and observe its permissions. We can see that both the owner and group both get read and write permission, while everyone else only gets read permission. The reason that world does not have write permission is because of the value of the mask. Let's repeat our example, this time setting the mask ourselves: [student@localhost ~]$ rm foo.txt [student@localhost ~]$ umask 0000 [student@localhost ~]$ > foo.txt [student@localhost ~]$ ls -l foo.txt -rw-rw-rw- 1 me me :58 foo.txt When we set the mask to 0000 (effectively turning it off), we see that the file is now world writable. To understand how this works, we have to look at octal numbers again. If we take the mask and expand it into binary, then compare it to the attributes we can see what happens: Ignore for the moment the leading zeros (we'll get to those in a minute) and observe that where the 1 appears in our mask, an attribute was removed in this case, the world write permission. That's what the mask does. Everywhere a 1 appears in the binary value of the mask, an attribute is unset. If we look at a mask value of 0022, we can see what it does:

25 P a g e 21 Again, where a 1 appears in the binary value, the corresponding attribute is unset. Play with some values (try some sevens) to get used to how this works. When you're done, remember to clean up: [student@localhost ~]$ rm foo.txt; umask 0002 Most of the time you won't have to change the mask; the default provided by your distribution will be fine. In some high-security situations, however, you will want to control it.

26 P a g e Other Commands Command Function Examples Online manual [student@localhost ~]$ man ls for shell man <command> commands [student@localhost ~]$ man pwd whatis <command> locate <options> <directory/file> Display a description of the specified command Search the locate database for files and directories. [student@localhost ~]$ whatis ls [student@localhost ~]$ whatis ls who rm [student@localhost ~]$ locate moh > The output of a command can be redirected to other locations such as a text file. Redirection is initiated by using the > character on the keyboard. [student@localhost ~]$ [student@localhost ~]$ date > date.txt ls -l testfile touch <options> <file> Update time stamps on a file. [student@localhost ~]$ [student@localhost ~]$ touch testfile ls -l testfile cat <file> expr <expression> Displays the content of a file on the command line. [student@localhost ~]$ [student@localhost ~]$ date cat mohd.txt The expr command allowed the processing of equations from the command line, [student@localhost ~]$ expr

27 P a g e 23 While the standard operators work fine in the expr command, the problem comes in actually using them from a script or the command line. Many of the expr command operators have other meanings in the shell (such as the asterisk). Using them in the expr command produces odd results: [student@localhost ~]$ expr 5 * 2 expr: syntax error Table 7: Some of the expr Command Operators

28 Part Two Bash Shell Scripting

29 P a g e 25 Lab Objectives: To make students: Able to write simple shell scripts to illustrate programming logic that contains entering/ printing data, control structures. Able to write simple shell scripts that uses repetition concept. Feel how much similarity that shell scripting has in compare to other programming languages. 2.1 Writing Your First Shell Script What are Shell Scripts? In the simplest terms, a shell script is a file containing a series of commands. The shell reads this file and carries out the commands as though they have been entered directly on the command line How to Write a Shell Script? To successfully create and run a shell script, we need to do three things: 1) Write a script. Shell scripts are ordinary text files. So we need a text editor to write them. The best text editors will provide syntax highlighting, allowing us to see a color-coded view of the elements of the script. Syntax highlighting will help us spot certain kinds of common errors. vim, gedit, kate, and many other editors are good candidates for writing scripts.

30 P a g e 26 2) Make the script executable. The system is rather fussy about not letting any old text file be treated as a program, and for good reason! We need to set the script file s permissions to allow execution. 3) Put the script somewhere the shell can find it. The shell automatically searches certain directories for executable files when no explicit pathname is specified. For maximum convenience, we will place our scripts in these directories Script File Format In keeping with programming tradition, we ll create a hello world program to demonstrate an extremely simple script. So let s fire up our text editors and enter the following script: #!/bin/bash # This is our first script. echo 'Hello World!' The last line of our script is pretty familiar, just an echo command with a string argument. The second line is also familiar. It looks like a comment that we have seen used in many of the configuration files we have examined and edited. One thing about comments in shell scripts is that they may also appear at the end of lines, like so: echo 'Hello World!' # This is a comment too

31 P a g e 27 Everything from the # symbol onward on the line is ignored. Like many things, this works on the command line, too: [student@localhost ~]$ echo 'Hello World!' # This is a comment too Hello World! Though comments are of little use on the command line, they will work. The first line of our script is a little mysterious. It looks like it should be a comment, since it starts with #, but it looks too purposeful to be just that. The #! character sequence is, in fact, a special construct called a shebang. The shebang is used to tell the system the name of the interpreter that should be used to execute the script that follows. Every shell script should include this as its first line. Now, let s begin implementing the 3-steps procedure: 1) Write this script using the window-based gedit text editor as following: [student@localhost ~]$ gedit hello_world The following window in figure 3 will be opened:

32 P a g e 28 Figure 3: gedit program window in Linux After saving the file, it means that it has been saved within the current working directory. 2) Make the script executable by means of chmod command: [student@localhost ~]$ chmod u+x hello_world 3) Run the shell script from the command line using the following method: [student@localhost ~]$./hello_world

33 P a g e User Input/Output Construct(s) [1] echo: command is well appreciated when trying to debug scripts. Example 1 Example 2 Example 3 Example 4 Syntax : echo {options} string Options: -n : do not output a new-line at the end. String can be a weakly quoted or a strongly quoted string. In the weakly quoted strings, the references to variables are replaced by the value of those variables before the output. [2] read: shell allows to prompt for user input Syntax: read varname [more vars] or read p "prompt" varname [more vars] words entered by user are assigned to varname and more vars last variable gets rest of input line #!/bin/bash # This is a comment! echo Hello World # This is a comment, too! #!/bin/bash # This is a comment! echo "Hello World" # This is a comment, too! #!/bin/bash echo Who am I talking to? read user_name echo Hello $user_name #!/bin/bash read -p "enter your name: " first echo "First name: $first" echo "Last name: $last" last

34 P a g e User Variables Construct(s) Setting variables allows you to temporarily store data and use it throughout the script, making the shell script more Example 1 Example 2 like a real computer program. Variables Naming Rules User variables can be any text string of up to 20 letters, digits, or an underscore character. User variables are case sensitive, so the variable Var1 is different from the variable var1. Values are assigned to user variables using an equal sign. No spaces can appear between the variable, the equal sign, and the value. For example: var1=10 var2=-57 var3=testing var4="still more testing" The shell script automatically determines the data type used for the variable value. #!/bin/bash # testing variables GPA= 4 student="ahmed" echo "$student has average of = $GPA" GPA= 2 student="ali" echo "$student has average of = $GPA" #!/bin/bash # assigning a variable value to another variable value1=10 value2=$value1 echo The resulting value is $value2

35 P a g e Quote Character Construct(s) There are three different quote characters with different behaviour. These are: [1] : double quote, weak quote. If a string is enclosed in the references to variables (i.e $variable ) are replaced by their values. Also, back-quote and escape \ characters are treated specially. [2] : single quote, strong quote. Everything inside single quotes are taken literally, nothing is treated as special. [3] ` : back quote (aka backtick). A string enclosed as Example 1 Example 2 Example 3 such is treated as a command and the shell attempts to execute it. If the execution is successful the primary output from the command replaces the string. #!/bin/bash # printing variable value using double and single quotes GPA= 4 student="ahmed" echo "$student has average of = $GPA" # true echo $student has average of = $GPA # false #!/bin/bash # using the backtick character testing=`date` echo "The date and time are: " $testing #!/bin/bash # An example of using the expr command var1=10 var2=20 var3=`expr $var2 / $var1` echo The result is $var3

36 P a g e 32 Meaning Numeric String Greater than Greater than or equal Less than Less than or equal -gt -ge -lt -le Equal -eq = or == Not equal -ne!= str1 is less than str2 str1 is greater str2 String length is greater than zero String length is zero str1 < str2 str1 > str2 -n str -z str Table 8: Relational Operators for comparing both numeric and strings

37 P a g e Control Structures if-then Statement Construct(s) Syntax : if [ condition ] then statements fi statements are executed only if the condition succeeds, i.e. has return status 0 Example 1 Example 2 #!/bin/bash # testing the if statement if date then echo "it worked" fi #!/bin/bash read p enter any number num if [ num -ge 0 ] then echo >=0 fi

38 P a g e Control Structures if-then-else Statement Construct(s) Syntax : if [ condition ] then statements-1 else statements-2 fi executes statements-1 if condition is true executes statements-2 if condition is false Example 1 Exercise #!/bin/bash # using numeric test comparisons val1=10 val2=11 if [ $val1 -eq $val2 ] then echo "The values are equal" else echo "The values are different" fi Write a bash shell script that will enter the age of a person and whether he has a pension or not to check whether he deserves a social insurance or not based on the following formula: If person s age is greater than or equal 60 years and does not have pension then, he can get social insurance. Otherwise, he cannot get social insurance.

39 P a g e Control Structures if-elif-else Statement Construct(s) Syntax : if [ condition ] then statements-1 elif [ condition ] then statement-2 else statements-3 fi The word elif stands for else if It is part of the if statement and cannot be used by itself Example 1 Exercise #!/bin/bash # comparison between three entered numbers read -p enter any number: n if [ n -gt 0 ]; then echo the number is +ve elif [ n -lt 0 ]; then echo the number is -ve else echo the number is zero fi Write a bash shell script that will enter the year number of a student and decide whether he is: freshman : for year=1, sophomore for year=2, junior for year=3 or senior for year=3.

40 P a g e Command-Controlled Repetition: While Loop Construct(s) Purpose: to execute commands in command-list as long as expression evaluates to true Syntax : while [ expression ] do command-list done Example 1 Example 2 Exercise #!/bin/bash stat=hello while [ "$stat"!= "bye" ] do echo "Please type something in (bye to quit)" read stat echo "You typed: $stat" done #!/bin/bash # calculating the sum of numbers from 1 to 20 num=1 sum=0 while [ $num le 20 ] do let sum=$sum+$num let num=$num+1 done Write a bash shell script that will enter the marks of 5 students and calculate their average using While-loop.

41 P a g e List-Controlled Repetition: For Loop Construct(s) Purpose: Example 1 Example 2 To execute commands as many times as the number of words in the argument-list Syntax : for variable in {argument-list} do done #!/bin/bash commands for i in do echo $i done #!/bin/bash # compute the average weekly temperature sum=0 for day in Sat Sun Mon Tue Wed Thu Fri do read p enter the temperature of $day temp let sum = $sum+$temp if [ $temp ge 25 ]; then echo $day is hot else echo $day is cold fi done let avg = $sum/7 echo average= $avg

42 2.10 Compound Condition Testing P a g e 38 Construct(s) Example 1 Example 2 Exercise There are two Boolean operators for compound conditions: AND: Both conditions must be met for the then section to execute. Syntax: [ condition1 ] && [ condition2 ] OR: If either condition evaluates to a true condition, the then section is executed. Syntax: [ condition1 ] [ condition2 ] #!/bin/bash # finding the maximum among three entered numbers read -p enter three numbers num1 num2 num3 if [ $num1 gt $num2 ] && [ $num1 gt $num3 ] ; then echo num1=$num1 is the maximum elif [ $num2 gt $num1 ] && [ $num2 gt $num3 ] ; then echo num2=$num2 is the maximum else echo num3=$num3 is the maximum fi #!/bin/bash # calculating the sum of odd numbers from 1 to 20 num=1 sum=0 rem=`expr $num % 2` while [ $num le 20 ] && [ $rem ne 1 ] do let sum=$sum+$num let num=$num+1 rem=`expr $num % 2` done Write a bash shell script that will enter the age of a person and whether he has a pension or not to check whether he deserves a social insurance or not based on the following formula: If person s age is greater than or equal 60 years and does not have pension then, he can get social insurance. Otherwise, he cannot get social insurance.

43 P a g e Practicing Exercises [1] Write a bash shell script that will enter a number from the keyboard and find whether it is a perfect number or not. Hint: a perfect number is one whose sum of its proper divisors except the number itself, is equal to the number itself. For instance, the divisors of 6 are 1, 2, 3 and the 1+2+3=6, therefore 6 is a perfect number. [2] Write a bash shell script that will classify the even and odd numbers between 1 and 20 by printing each number with specifying whether it is even or odd on the terminal. [3] Write a bash shell script that will find and print only the prime numbers between 1 and 30. [4] Use the concept of looping to write a bash shell script that will enter the final marks of a set of 10 students in operating systems lab class. Also, it should perform the following: Print the grade of each student which will be one of the set: {A+,A,B+,B,C+,C,D+,D,F} based on Jazan University grading system. Calculates the average mark of the class. Counts how many student got F grade.

44 P a g e 40 References [1] Nicholas Marsh Introduction to the Command Line: The Fat Free Guide to Unix and Linux Commands (2nd ed.). CreateSpace, Paramount, CA. [2] William E. Shotts, Jr Linux Command Line: A Complete Introduction No Starch Press, CA. [3] Richard Blum and Christine Bresnahan Linux Command Line and Shell Scripting Bible, Second Edition (2nd ed.). Wiley Publishing.

45 P a g e 41 Appendix Cygwin Bash Shell Scripting Cygwin Shell Commands Finish 4

46 P a g e 42

47 P a g e 43

48 P a g e 44

49 P a g e 45

50 P a g e 46 nano (nano prog) gedit prog

51 P a g e 47 nano nano y x Ctrl enter

24 Writing Your First Script

24 Writing Your First Script In the preceding chapters, we have assembled an arsenal of command line tools. While these tools can solve many kinds of computing problems, we are still limited to manually using them one by one on the

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

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

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

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

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

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12) Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12) Objective: Learn some basic aspects of the UNIX operating system and how to use it. What is UNIX? UNIX is the operating system used by most computers

More information

CSE 391 Lecture 1. introduction to Linux/Unix environment

CSE 391 Lecture 1. introduction to Linux/Unix environment CSE 391 Lecture 1 introduction to Linux/Unix environment slides created by Marty Stepp, modified by Jessica Miller & Ruth Anderson http://www.cs.washington.edu/391/ 1 2 Lecture summary Course introduction

More information

Operating Systems. Copyleft 2005, Binnur Kurt

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

More information

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

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

More information

CSE 391 Lecture 1. introduction to Linux/Unix environment

CSE 391 Lecture 1. introduction to Linux/Unix environment CSE 391 Lecture 1 introduction to Linux/Unix environment slides created by Marty Stepp, modified by Jessica Miller & Ruth Anderson http://www.cs.washington.edu/391/ 1 2 Lecture summary Course introduction

More information

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University Introduction to Linux Woo-Yeong Jeong (wooyeong@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu What is Linux? A Unix-like operating system of a computer What is an

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

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

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

EE516: Embedded Software Project 1. Setting Up Environment for Projects

EE516: Embedded Software Project 1. Setting Up Environment for Projects EE516: Embedded Software Project 1. Setting Up Environment for Projects By Dong Jae Shin 2015. 09. 01. Contents Introduction to Projects of EE516 Tasks Setting Up Environment Virtual Machine Environment

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

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

: the User (owner) for this file (your cruzid, when you do it) Position: directory flag. read Group.

: the User (owner) for this file (your cruzid, when you do it) Position: directory flag. read Group. CMPS 12L Introduction to Programming Lab Assignment 2 We have three goals in this assignment: to learn about file permissions in Unix, to get a basic introduction to the Andrew File System and it s directory

More information

CSE 390a Lecture 1. introduction to Linux/Unix environment

CSE 390a Lecture 1. introduction to Linux/Unix environment 1 CSE 390a Lecture 1 introduction to Linux/Unix environment slides created by Marty Stepp, modified by Jessica Miller & Ruth Anderson http://www.cs.washington.edu/390a/ 2 Lecture summary Course introduction

More information

Introduction to Linux

Introduction to Linux Introduction to Linux Prof. Jin-Soo Kim( jinsookim@skku.edu) TA - Dong-Yun Lee (dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu What is Linux? A Unix-like operating

More information

Conditional Control Structures. Dr.T.Logeswari

Conditional Control Structures. Dr.T.Logeswari Conditional Control Structures Dr.T.Logeswari TEST COMMAND test expression Or [ expression ] Syntax Ex: a=5; b=10 test $a eq $b ; echo $? [ $a eq $b] ; echo $? 2 Unix Shell Programming - Forouzan 2 TEST

More information

Lec 1 add-on: Linux Intro

Lec 1 add-on: Linux Intro Lec 1 add-on: Linux Intro Readings: - Unix Power Tools, Powers et al., O Reilly - Linux in a Nutshell, Siever et al., O Reilly Summary: - Linux File System - Users and Groups - Shell - Text Editors - Misc

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

Introduction to Linux

Introduction to Linux Introduction to Linux Prof. Jin-Soo Kim( jinsookim@skku.edu) TA - Kisik Jeong (kisik@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu What is Linux? A Unix-like operating

More information

Chapter-3. Introduction to Unix: Fundamental Commands

Chapter-3. Introduction to Unix: Fundamental Commands Chapter-3 Introduction to Unix: Fundamental Commands What You Will Learn The fundamental commands of the Unix operating system. Everything told for Unix here is applicable to the Linux operating system

More information

CENG 334 Computer Networks. Laboratory I Linux Tutorial

CENG 334 Computer Networks. Laboratory I Linux Tutorial CENG 334 Computer Networks Laboratory I Linux Tutorial Contents 1. Logging In and Starting Session 2. Using Commands 1. Basic Commands 2. Working With Files and Directories 3. Permission Bits 3. Introduction

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

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

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

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME Introduction to the Unix command line History Many contemporary computer operating systems, like Microsoft Windows and Mac OS X, offer primarily (but not exclusively) graphical user interfaces. The user

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

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

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

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

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

Introduction to Unix: Fundamental Commands

Introduction to Unix: Fundamental Commands Introduction to Unix: Fundamental Commands Ricky Patterson UVA Library Based on slides from Turgut Yilmaz Istanbul Teknik University 1 What We Will Learn The fundamental commands of the Unix operating

More information

Prof. Navrati Saxena TA: R. Sachan

Prof. Navrati Saxena TA: R. Sachan Prof. Navrati Saxena navrati@ece.skku.ac.kr TA: R. Sachan rochak@skku.edu What is UNIX Command What is UNIX Shell Linux file structure UNIX/LINUX Commands 2 A command is a program which interacts with

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

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

CS/CIS 249 SP18 - Intro to Information Security

CS/CIS 249 SP18 - Intro to Information Security Lab assignment CS/CIS 249 SP18 - Intro to Information Security Lab #2 - UNIX/Linux Access Controls, version 1.2 A typed document is required for this assignment. You must type the questions and your responses

More information

Introduction to Linux

Introduction to Linux Introduction to Linux Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Sanghoon Han(sanghoon.han@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Announcement (1) Please come

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

Linux File System and Basic Commands

Linux File System and Basic Commands Linux File System and Basic Commands 0.1 Files, directories, and pwd The GNU/Linux operating system is much different from your typical Microsoft Windows PC, and probably looks different from Apple OS

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

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

INTRODUCTION TO LINUX

INTRODUCTION TO LINUX INTRODUCTION TO LINUX REALLY SHORT HISTORY Before GNU/Linux there were DOS, MAC and UNIX. All systems were proprietary. The GNU project started in the early 80s by Richard Stallman Goal to make a free

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

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

Essential Linux Shell Commands

Essential Linux Shell Commands Essential Linux Shell Commands Special Characters Quoting and Escaping Change Directory Show Current Directory List Directory Contents Working with Files Working with Directories Special Characters There

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

Command Line Interface The basics

Command Line Interface The basics Command Line Interface The basics Marco Berghoff, SCC, KIT Steinbuch Centre for Computing (SCC) Funding: www.bwhpc-c5.de Motivation In the Beginning was the Command Line by Neal Stephenson In contrast

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

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

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

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

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories Chapter Two Exploring the UNIX File System and File Security Lesson A Understanding Files and Directories 2 Objectives Discuss and explain the UNIX file system Define a UNIX file system partition Use the

More information

Mills HPC Tutorial Series. Linux Basics I

Mills HPC Tutorial Series. Linux Basics I Mills HPC Tutorial Series Linux Basics I Objectives Command Line Window Anatomy Command Structure Command Examples Help Files and Directories Permissions Wildcards and Home (~) Redirection and Pipe Create

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

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

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

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

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

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

Introduction to Unix and Linux. Workshop 1: Directories and Files

Introduction to Unix and Linux. Workshop 1: Directories and Files Introduction to Unix and Linux Workshop 1: Directories and Files Genomics Core Lab TEXAS A&M UNIVERSITY CORPUS CHRISTI Anvesh Paidipala, Evan Krell, Kelly Pennoyer, Chris Bird Genomics Core Lab Informatics

More information

Exercise sheet 1 To be corrected in tutorials in the week from 23/10/2017 to 27/10/2017

Exercise sheet 1 To be corrected in tutorials in the week from 23/10/2017 to 27/10/2017 Einführung in die Programmierung für Physiker WS 207/208 Marc Wagner Francesca Cuteri: cuteri@th.physik.uni-frankfurt.de Alessandro Sciarra: sciarra@th.physik.uni-frankfurt.de Exercise sheet To be corrected

More information

Operating System Interaction via bash

Operating System Interaction via bash Operating System Interaction via bash bash, or the Bourne-Again Shell, is a popular operating system shell that is used by many platforms bash uses the command line interaction style generally accepted

More information

Introduction to Cygwin Operating Environment

Introduction to Cygwin Operating Environment Introduction to Cygwin Operating Environment ICT 106 Fundamentals of Computer Systems Eric Li ICT106_Pract_week 1 1 What s Cygwin? Emulates Unix/Linux environment on a Windows Operating System; A collection

More information

Exercise 1: Basic Tools

Exercise 1: Basic Tools Exercise 1: Basic Tools This exercise is created so everybody can learn the basic tools we will use during this course. It is really more like a tutorial than an exercise and, you are not required to submit

More information

Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers

Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers Review of the Linux File System and Linux Commands 1. Introduction Becoming adept at using the Linux OS requires gaining familiarity

More information

CSCI 2132: Software Development. Norbert Zeh. Faculty of Computer Science Dalhousie University. Shell Scripting. Winter 2019

CSCI 2132: Software Development. Norbert Zeh. Faculty of Computer Science Dalhousie University. Shell Scripting. Winter 2019 CSCI 2132: Software Development Shell Scripting Norbert Zeh Faculty of Computer Science Dalhousie University Winter 2019 Reading Glass and Ables, Chapter 8: bash Your Shell vs Your File Manager File manager

More information

CENG393 Computer Networks Labwork 1

CENG393 Computer Networks Labwork 1 CENG393 Computer Networks Labwork 1 Linux is the common name given to a large family of operating systems. All Linux-based operating systems are essentially a large set of computer software that are bound

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

Linux & Shell Programming 2014

Linux & Shell Programming 2014 Unit -1: Introduction to UNIX/LINUX Operating System Practical Practice Questions: Find errors (if any) otherwise write output or interpretation of following commands. (Consider default shell is bash shell.)

More information

Unix Shell scripting. Dr Alun Moon 7th October Introduction. Notation. Spaces

Unix Shell scripting. Dr Alun Moon 7th October Introduction. Notation. Spaces Unix Shell scripting Dr Alun Moon 7th October 2017 Introduction Shell scripts in Unix are a very powerfull tool, they form much of the standard system as installed. What are these good for? So many file

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

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

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

Computer Architecture Lab 1 (Starting with Linux)

Computer Architecture Lab 1 (Starting with Linux) Computer Architecture Lab 1 (Starting with Linux) Linux is a computer operating system. An operating system consists of the software that manages your computer and lets you run applications on it. The

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

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

15-122: Principles of Imperative Computation

15-122: Principles of Imperative Computation 15-122: Principles of Imperative Computation Lab 0 Navigating your account in Linux Tom Cortina, Rob Simmons Unlike typical graphical interfaces for operating systems, here you are entering commands directly

More information

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80 CSE 303 Lecture 2 Introduction to bash shell read Linux Pocket Guide pp. 37-46, 58-59, 60, 65-70, 71-72, 77-80 slides created by Marty Stepp http://www.cs.washington.edu/303/ 1 Unix file system structure

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

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

CSC209. Software Tools and Systems Programming. https://mcs.utm.utoronto.ca/~209

CSC209. Software Tools and Systems Programming. https://mcs.utm.utoronto.ca/~209 CSC209 Software Tools and Systems Programming https://mcs.utm.utoronto.ca/~209 What is this Course About? Software Tools Using them Building them Systems Programming Quirks of C The file system System

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

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

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

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

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

More information

Introduction to Linux Basics

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

More information

bash Execution Control COMP2101 Winter 2019

bash Execution Control COMP2101 Winter 2019 bash Execution Control COMP2101 Winter 2019 Bash Execution Control Scripts commonly can evaluate situations and make simple decisions about actions to take Simple evaluations and actions can be accomplished

More information

Intro to Linux. this will open up a new terminal window for you is super convenient on the computers in the lab

Intro to Linux. this will open up a new terminal window for you is super convenient on the computers in the lab Basic Terminal Intro to Linux ssh short for s ecure sh ell usage: ssh [host]@[computer].[otheripstuff] for lab computers: ssh [CSID]@[comp].cs.utexas.edu can get a list of active computers from the UTCS

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

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

Introduction to Linux. Fundamentals of Computer Science

Introduction to Linux. Fundamentals of Computer Science Introduction to Linux Fundamentals of Computer Science Outline Operating Systems Linux History Linux Architecture Logging in to Linux Command Format Linux Filesystem Directory and File Commands Wildcard

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

Hitchhiker s Guide to VLSI Design with Cadence & Synopsys

Hitchhiker s Guide to VLSI Design with Cadence & Synopsys Hitchhiker s Guide to VLSI Design with Cadence & Synopsys David Money Harris 17 January 2009 The VLSI design tools at Harvey Mudd College are hosted on a Linux server named chips. This document introduces

More information

CSC 2500: Unix Lab Fall 2016

CSC 2500: Unix Lab Fall 2016 CSC 2500: Unix Lab Fall 2016 Control Statements in Shell Scripts: Decision Mohammad Ashiqur Rahman Department of Computer Science College of Engineering Tennessee Tech University Agenda User Input Special

More information