Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Computer Organization & Systems Topics: Intro to UNIX COMP 21000 John Barr.

Similar presentations


Presentation on theme: "Introduction to Computer Organization & Systems Topics: Intro to UNIX COMP 21000 John Barr."— Presentation transcript:

1 Introduction to Computer Organization & Systems Topics: Intro to UNIX COMP 21000 John Barr

2 Operating System How do we interact with our computer? 2-2

3 Operating System What about multiple programs? multiple users? 2-3

4 Operating System The reality? The OS intervenes The OS controls the hardware – software must talk to the OS via System calls 2-4 Kernel

5 Operating System What about logging in? How does software talk to multiple things? 2-5 Shell

6 Operating System What about multiple input streams? What about networks? 2-6

7 Operating System What is systems programming? – writing programs to talk to the OS – using system calls, functions that talk to the OS – often more tricky and dangerous than library calls like printf 2-7 System Calls System Call examples: open() write() read() fork() System Call examples: open() write() read() fork()

8 Unix Accounts – Changing passwords, finding out about people passwd whoami or who finger accountName Help – about a command man cmdName apropos cmdName or man –k cmdName which cmdName ;gives path to the application 2-8

9 Unix Processes – What’s running? ps ;only your processes ps –a ;all processes PID TTY TIME CMD 33129 ttys000 0:00.02 -bash 33178 ttys000 0:00.00 man builtin 33186 ttys000 0:00.00 /usr/bin/less -is 33131 ttys001 0:00.01 -bash 33130 ttys002 0:00.02 –bash kill -9 pid ;kill process pid ^c ;hold down control key and press the c key ;kills currently running process 2-9

10 Unix Directories – Seeing, manuvering, creating cd /path/to/new/directory pwd ls [-a –l] Mkdir dirName rmdir dirName rm –r dirName pushd. popd 2-10

11 Unix Files – Moving, deleting cp src dest rm fileName – Viewing more fileName cat fileName1 fileName2 2-11

12 Unix Files – Permissions ls –l A228536:~ barr$ ls -l total 36736 drwxrwxrwx@ 55 barr CAMPUS\Domain Users 1870 Mar 13 2012 Admin at IC drwxr-xr-x 3 barr CAMPUS\Domain Users 102 Jun 22 2012 Applications d rwx rwx rwx Directory user group other r = read w = write x = execute chmod o+r fileName chmod g-w fileName chmod u+x *.c ; can use wild card charcter 2-12

13 More Unix Configuration files –.exrc and.vimrc files put in your home directory Can put set commands in this file These commands will be executed every time you start vi (.exrc) or vim (.vimrc) 2-13

14 More Unix Shells – Environmental variables (capitalization counts!) $ENV $PATH #the search path used by UNIX when you #use a command to see all environmental variables enter: > env 2-14

15 More Unix –.bashrc and.bash_profile files alias # creates aliases for commands – alias la='ls -A’ –# now when you type la the command ls –A is executed changing $PATH –export PATH=$PATH:$HOME:. –#this adds your home directory #and the current directory (e.g., ‘.’) to the search #path –Do NOT put spaces before or after the = When you change.bashrc, use source to act on the changes –source.bashrc 2-15

16 More Unix.bashrc vs.bash_profile files It's explained in man bash: Login shells are the ones that are read once you login (so, they are not executed when merely starting up xterm, for example). There are other ways to login. For example using an X display manager. Those have other ways to read and export environment variables at login time. 2-16 /bin/bash The bash executable /etc/profile The systemwide initialization file, executed for login shells ~/.bash_profile The personal initialization file, executed for login shells ~/.bashrc The individual per-interactive-shell startup file ~/.bash_logout The individual login shell cleanup file, executed when a login shell exits ~/.inputrc Individual readline initialization file

17 More Unix Pipes – using the | operator to connect programs –gcc myfile.c | more Redirection – using > and >> to redirect stdout to a file > to overwrite >> to append – using &> to redirect stderr to a file gcc –g -o ex1 ex1.c &> err.txt – using < to redirect stdin from file 2-17

18 More Unix History –history ;shows past commands 1170 la 1171 vi.exrc 1172 popd 1173 ls 1174 vi helloworld.c 1175 vim helloworld.c 1176 history – the ! Operator !1170 ; this will run the comand “la” 2-18

19 grep grep is a command that searches through files for a pattern and prints lines that contain that pattern for example, the following command will search for the string “int” in all files that end in “.c” and print out the lines with that string: grep int *.c could give the result: prob2.c:int main(int arc, char *argv[]) prob2.c: int x; prob3.c:int main(int arc, char *argv[]) prob3.c: int y, z; 2-19


Download ppt "Introduction to Computer Organization & Systems Topics: Intro to UNIX COMP 21000 John Barr."

Similar presentations


Ads by Google