UNIX Operating System - PowerPoint PPT Presentation

1 / 42
About This Presentation
Title:

UNIX Operating System

Description:

Unix is a complete multi-tasking and multi-user operating system. ... X,x deletes characters. 3x deletes 3 char. dw deletes words. dd deletes lines. Applications ... – PowerPoint PPT presentation

Number of Views:261
Avg rating:3.0/5.0
Slides: 43
Provided by: atili
Category:

less

Transcript and Presenter's Notes

Title: UNIX Operating System


1
UNIX Operating System
  • Compe 111 Lab

2
Software Classification
3
Unix
  • Unix is a complete multi-tasking and multi-user
    operating system. Many users may login to the
    unix system and each user may run multiple
    programs simultaneously.

4
Unix
(Kernel)
5
Kernel
  • Kernel directs the hardware.
  • File manager (reading writing files)
  • Device drivers
  • Memory manager
  • Scheduler and dispatcher (Running processes with
    respect to priorities, time intervals and such)

6
Shell
  • Shell reads and executes commands types by the
    users. It acts as an interpreter between the user
    and the Unix kernel.
  • It can be text based or with GUI (window manager)
  • sh, bash, ksh, csh... are sample text shells

7
Starting to Unix
  • Through
  • Start?Run... Type
  • telnet 172.16.220.252
  • This is the IP address of unix server in our
    operating systems laboratory.
  • Username std01 (std02...std39)
  • Password 111std01
    (111std02...111std39)
  • Do not use std12

8
Starting to Unix
9
User accounts
  • Your default shell might be different.
  • Switch between sh, ksh, csh shells
  • We will use bash
  • Type bash in command line to switch to bash

10
User accounts
  • passwd for changing your passwords. It must be
    at least 6 character.
  • Try to change your passwords as aaa111
  • It will be asked twice.
  • Now, turn back to your old passwords
  • std01 ?111std01
  • std02 ?111std02
  • std39 ?111std39
  • exit or logout is used to close the session

11
User accounts
  • pwd gives current working path
  • date returns date and time of day
  • cal returns the calendar for month
  • cal, cal 2 (for feb.), cal 2006, cal 3 2008
  • df returns the free disk space in kb

12
User accounts
  • who lists who is logged on the system
  • whoami displays your user name
  • w returns who is doing what on the system
  • stty returns terminal status
  • echo text displays the text as output

13
Commands in Unix
  • Syntax
  • command
  • command options argument
  • command options argument1 argument 2
  • ls (like dir in dos)
  • ls al (lists all entities (files folders
    hiddens) with all attributes and specifications
    in long format)
  • ls l temp (listing folder temp in long format)
  • ls .txt (list the files ending with .txt)

14
Commands in Unix
  • Example
  • drwxr-xr-x 3 std01 staff 512 Oct 17
    1613 temp
  • d directory
  • - file
  • rwxr-xr-x owner-group-others
  • r read
  • w write
  • x execute
  • - not allowed
  • rwxr-xr-x 755 rwxrwxrwx 777
  • You may set permissions by chmod
  • chmod 777 temp
  • chmod 744 temp

15
Commands in Unix
  • Example
  • drwxr-xr-x 3 std01 staff 512 Oct 17
    1613 temp
  • 3 i-node number pointing the file. It is related
    to file allocation structure of unix. Keeps
    position, owner, structure, links, types etc.
  • staff user type. (standard user, root...)
  • 512 size in bytes
  • Oct 17 1613 creation date and time
  • temp name

16
Getting help
  • man is used to getting help
  • man command
  • man man
  • man ls

17
User accounts
  • During login each shells executes a shell program
    (Bourne and Korn shells execute .profile). This
    is your startup file and keeps your programs to
    be run, variables.

18
Variables
  • Each shell variable has a name and value
    associated with it.
  • To define a variable and set its value
  • var_namevalue (for Bourne and Korn) or
  • set var_namevalue (C and TC shells)

19
Variables
  • Example
  • namebelinda
  • surnameblack
  • age18
  • To see the values
  • echo name
  • echo age
  • echo name surname age

20
Environment Variables
  • Some variables have special meaning to the shell
    and they are automatically set whenever you
    login. Might be kept in your .profile
  • HOME path of your home directory
  • PATH defines the directories searched when shell
    is looking for the file to execute when a process
    is to run.
  • MAILMSG The message is given when you have an
    e-mail. e.g. You have a mail.
  • TERM contains the code that indicates the make
    and model of the terminal you are using. Like,
    vt100, ansi...

21
Environment Variables
  • echo HOME
  • echo PATH
  • echo MAILMSG
  • echo TERM

22
Command History
  • Type history to see your past actions.
  • You can move between your actions using arrows.

23
Processes and Scheduling
  • ps lists running processes
  • PID TTY TIME CMD
  • 20883 pts/6 000000 bash
  • PID process id. Unique to the process
  • TTY terminal
  • Time execution
  • CMD process name
  • ps e Show all processes

24
Processes and Scheduling
  • sleep 10 wait for 10 seconds.
  • CtrlC (or CtrlZ) to interrup the current
    process
  • sleep 150 runs the process at back ground.
    Allows you to execute other commands.
  • You can see your background tasks by jobs
  • You can also see them by ps

25
Processes and Scheduling
  • If you put a process at background and you want
    it to run after you logout, use
  • nohup command arguments
  • nohup sleep 1000 will prepare a file to be run
    after you leave the session.
  • kill PID kills the processes with the specified
    ID.

26
Processes and Scheduling
  • ps to get PID of sleep process
  • and kill it
  • kill also resolves deadlock condition (when
    system in undecisive mode)

27
Processes and Scheduling
  • bg command is used to put a background task
  • If you suspend a process by CtrlC (or CtrlZ),
    you can resume it by using bg.
  • Now, run man ls
  • Break it using CtrlC (or CtrlZ)
  • 4 Stopped man ls
  • 4 is jobs number.
  • bg 4 is used to put the process back in ps

28
Processes and Scheduling
  • You may also set a list of jobs to be executed at
    a specifiec time using at command (scheduling).
  • at 10am Jul 31
  • or
  • at 1pm tomorrow

29
Processes and Scheduling
  • First you will see a warning about which shell to
    be used for execution.
  • Then you will type your commands
  • atgt ls al
  • atgt echo hello
  • ctrl c or ctrlz to break scheduling
  • It will be recorded to run later.
  • atq lists all at jobs belonging to user
  • atrm username removes all at jobs of user

30
File system
  • Unix keeps a hierarchical tree for file and
    directory sturcture
  • root
  • bin usr home lib
  • user1 user2 user3

31
File system
  • /bin Unix system utilities, ls, date...
  • /usr Additional user utilities
  • /home User directories
  • /lib Libraries such as C language
    and mathematics
  • Files and folders have names upto 256 characters.
  • Unix is case sensitive.
  • Myfile ! myFile ! MYFILE

32
File system
  • Creating a file
  • cat gt firstfile
  • This is just a test
  • CtrlD
  • Appending a file
  • cat gtgtfirstfile
  • It is the second line of test file
  • Here is the third line
  • CtrlD
  • Displaying content
  • cat firstfile
  • cat firstfile more page by page

33
File system
  • Creating a second file
  • cat gt secondfile
  • First line of second file
  • ctrld
  • Combining files
  • cat firstfile secondfile gt thirdfile
  • cat thirdfile

34
File system
  • Copying a file
  • cp firstfile copyfirstfile
  • Renaming (or moving) a file
  • mv firstfile FirstFILE
  • Sorting the contents of a file
  • sort firstfile (firstfile is not updated)
  • sort firstfile o output
  • cat output

35
File system
  • Searching expression
  • grep -i test firstfile
  • Searches test in lines of firstfile
  • grep -l test
  • Searches all files including test
  • Counting
  • wc l firstfile counts lines
  • wc w firstfile counts words
  • wc c firstfile counts characters

36
File system
  • Removing files cannot be got back
  • rm secondfile
  • rm i thirdfile asks for sure?
  • rm .doc removes all .doc documents

37
File system
  • Creating a directory
  • mkdir project
  • Moving a file to a folder
  • mv firstfile project
  • (cp firstfile project if you want to copy)
  • ls l to see that firstfile is moved
  • cd project to change current directory
  • pwd to see where you are
  • ls l to see firstfile is here
  • cd .. (not cd..) to move one level above

38
File system
  • Renaming a directory
  • mv project newproject
  • Now project is changed as newproject
  • Removing directories
  • rmdir newproject it must be empty
  • rmdir r newproject removing everything
    recursively

39
Applications
  • vi text editor
  • vi deneme
  • It has 2 modes command mode and insert mode
  • Esc and then i is to switch to insert mode
  • Esc to switch to command mode

40
Applications
  • In insert mode, you can type.
  • In command mode, h(left), j(down), k (up) and l
    (right) are used.
  • In command mode,
  • X,x deletes characters. 3x deletes 3 char.
  • dw deletes words
  • dd deletes lines

41
Applications
  • In insert mode,
  • w to save
  • wq to save and exit
  • q to exit
  • q! to exit discarding changes after last save
  • Use man vi for more information

42
Applications
  • Pico editor is an easy editor.
  • pico deneme .txt
  • After typing, all actions are done via
  • Ctrl X, O, R, U ....
Write a Comment
User Comments (0)
About PowerShow.com