The Unix Operating System
SE 101 Spiros Mancoridis
The Unix Operating System SE 101 Spiros Mancoridis What is an OS? - - PowerPoint PPT Presentation
The Unix Operating System SE 101 Spiros Mancoridis What is an OS? An operating system (OS) is software that manages the resources of a computer Like most managers, the OS aims to manage its resources in a safe and efficient way Examples of
SE 101 Spiros Mancoridis
Microsoft Windows Unix
Without an OS, every application would have to implement some part of this software hierarchy ...
A popular multi-user, multi-tasking OS Attributes: stability, portability, security Created at Bell Labs by Dennis Ritchie and Ken Thompson (won the ACM Turing Award in 1983) Unix is considered one of the greatest achievements in computer science Has been around since the 1960s in various forms,
e.g., AIX, SCO Unix, SunOS, FreeBSD, OpenBSD, NetBSD, Linux, Mac OS X
ACM is the Association for Computing Machinery
World’s largest educational and scientific computer society You can become a student member too www.acm.org
The ACM awards the Turing Award every year. It is the “Nobel Prize” of computing Named after british mathematician Alan M. Turing (1912-1954)
Thompson and Ritchie
Alan M. Turing
Includes device drivers for computer hardware devices, e.g., graphics cards, network cards, disks
A device driver is a program that allows computer programs to interact with hardware devices
CPU and memory management File system management Implements system calls that can be used by application programs and system utilities
The von Neumann Architecture The OS hides this complexity from the programmer
e.g., sh (Bourne shell), bash (Bourne again shell), csh (C shell), ksh(Korn shell)
e.g., Linux KDE, GNOME, Mac OS Leopard
ls, cp, grep, awk, bc, wc, more, rm, mkdir, ...
ssh (remote login) lpd (remote printing) httpd (serves web pages)
A compiler is a computer program that transforms human readable source code of another computer program into machine readable code that a computer can execute. The act of transforming source code into machine code is called compilation.
package com.javadb.examples; import java.util.Arrays; import java.util.List; import java.util.Iterator; public class Main { public static void main(String[] args) { String[] array = {"Programming", "is", "cool"}; List<String> list = Arrays.asList(array); Iterator<String> iterator = list.iterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } } }
Java Source Code Java Compilation Process
A virtual machine (VM) is a software implementation
computer A system VM implements a complete computer that can support the execution of a real OS (e.g., vmware, KVM) A process VM is designed to run a single program (e.g., Java VM) Improves program portability, i.e., the ability to reuse software on a different platform with little or no modification
login: <type your user id> password: <type your password> $ pwd /home/spiros $ exit
passwd date hostname who last finger w clear cal bc -l history ssh Try these Unix commands and see what they do ... The man pages can give you details on how to use these (and
Ordinary Files
Files contain data, program code, etc File names cannot have the ‘/’ character in them
Directories Contain files and other directories Links A link is a pointer reference to another file (like an alias) Devices Allows applications to access hardware devices
/ The "root" directory /bin Essential low-level system utilities /usr/bin Higher-level system utilities and application programs /sbin Superuser system utilities (for performing system administration tasks) /lib Program libraries (collections of system calls that can be included in programs by a compiler)for low-level system utilities /usr/lib Program libraries for higher-level user programs /tmp Temporary file storage space (can be used by any user) /home User home directories containing personal file space for each user. Each directory is named after the login of the user. /etc UNIX system configuration and information files /dev Hardware devices /proc A pseudo-filesystem which is used as an interface to the kernel. Includes a sub- directory for each active program (or process).
$ cd /usr/bin $ pwd /usr/bin $ cd / $ ls
bin/ lib/ media/ proc/ selinux/ sys/ var/ boot/ dev/ homes/ lib32/ mnt/ root/ site/ tmp/ etc/ opt/ sbin/ srv/ usr/
$ man ls
drwxr-xr-x 3 spiros serg 238 May 5 2:05 license.dat
3 access types given to 3 user categories. The three access types are read ('r'), write ('w') and execute ('x'), and the three users categories are the user who owns the file, users in the group that the file belongs to and other users (the general public). An 'r', 'w' or 'x' character means the corresponding permission is present; a '-' means it is absent.
rights specified in the permissions field.
a directory.
file was last accessed (read).
cd path (change directory to path) mkdir directory (make a new directory) rmdir directory (remove a directory) cp source-file destination-file (copy source-file into destination-file) cp source-file(s) destination-directory (copy source files into destination-directory)
mv source destination (move/rename source file or directory to destination file or directory) rm file(s) (remove/delete files) rm -rf directory (remove entire directory) cat target-file(s) (concatenate target files and display them on the screen) cat target-file(s) > output.txt (store concatenation to output file)
ln -s filename linkname (create a pointer to filename and call it linkname) cat ?piros (concatenates all files that start with any character and end with piros) cat * (concatenates all files in the current directory) ls [a-c]*[x-z] (lists files that start with a letter from a-c and end with a letter from x-z)
chmod options files
for options u (user), g (group), o (other), a (all), r (read), w (write), x (execute), + (add permission), - (remove permission), = (assign permission)
What does chmod ug=rw, o-rw, a-x *.txt do? How about chmod -R go+r dir ? How about chmod 600 private.txt ? chgrp group file(s) (changes the group permissions for the files, works with -R option)
To run vi type the following on the command line: $ vi filename vi has three modes: command mode: to navigate through the document insert mode: to add text to the document command line mode: to perform manipulations on the files (e.g., search, save)
Line Command ZZ Text Insertion Mode Command Mode / : return ESC
i l
Note that ^ means hold the control key down e.g., ^F means hold the control key down and press F. The F,B,D,U characters are non case sensitive
G go to the last line in the file n G go to the nth line in the file $ go to the end of the current line ^ go to the beginning of current line (use carat key not control key) 0 same as ^, go to beginning of current line w forward one word, use n w to go forward n words b backward one word, use n b to go backward n words e go to end of the word
dd delete current line n dd delete n lines starting from the current line dw delete word n dw delete n next words D delete from cursor to the end of current line x delete current character n x delete next n characters X delete previous character (backspace)
yy yank current line into a storage buffer (copy) n yy yank next n lines into a storage buffer yw yank current word into a storage buffer n yw yank next n lines into a storage buffer p put yanked buffer text (or deleted text) after cursor P put yanked buffer text (or deleted text) before cursor