ITR3 lecture 6: intoduction to UNIX - PowerPoint PPT Presentation

About This Presentation
Title:

ITR3 lecture 6: intoduction to UNIX

Description:

Files are continuous chunks data on disks ... Bourne shell sh -- Korn shell ksh. C shell csh -- extended C shell tcsh. Bourne again shell bash z shell zsh ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 28
Provided by: kric2
Learn more at: https://openlib.org
Category:

less

Transcript and Presenter's Notes

Title: ITR3 lecture 6: intoduction to UNIX


1
ITR3 lecture 6 intoduction to UNIX
  • Thomas Krichel
  • 2002-10-21

2
Today we have fun with
  • Disks
  • Unix basics
  • Important unix utilities

3
Files, directories and links
  • Files are continuous chunks data on disks that
    are required for software applications.
  • Directories are files that contain other files.
    Microsoft calls them folders.
  • A link is a file that contain the address of
    another file. Microsoft call it a shortcut.

4
Structure of a disk
  • Disks are round devices divided into tracks and
    sectors.
  • A hard disk may have several physical disks.
  • Sector is 571 bytes long
  • 512 bytes are used by the user
  • The rest is reserved for disk operation
  • The disk spins, a head reads and writes data.

5
Data integrity
  • The special data in each sector is kept there to
    try ensure that the user data is safe.
  • It contains a summary of the user data.
  • When the summary and the user data no longer
    match, the summary can be used to correct the
    user data.
  • SMART disks are those that can monitor if they
    are a in good shape.

6
Formatting a floppy
  • Physical formatting
  • writing tracks
  • writing sectors
  • Logical formatting
  • labeling each sector
  • create boot record
  • create file allocation table (FAT)

7
Formatting a hard disk
  • That is the same as formatting a floppy but
  • Between physical and logical formatting, the hard
    disk may be partitioned.
  • This allows for several logical disks on the same
    physical disk
  • Therefore the boot record is more complicated
    than on the floppy and called a master boot
    record MBR.
  • Example dual boot Linux/Windows machine

8
Unix file conventions
  • In UNIX the root directory is /.
  • / is the directory separator.
  • A number of special files in /dev represent
    devices.
  • Each device is mounted as a subdirectory of the
    root directory. Example
  • mount /dev/fd0 /floppy
  • You need to be root to do this.

9
Device names
  • /dev/fd0 first floppy drive
  • /dev/fd1 second floppy
  • /dev/sda first SCSI disk
  • /dev/sdb second SCSI disk
  • /dev/scd0 first SCSI CD-ROM
  • /dev/hda master disk on IDE primary controller
  • /dev/hdb slave disk on IDE primary controller
  • /dev/hdc master disk on IDE secondary controller
  • /dev/hdd slave disk on IDE secondary controller

10
Root user
  • root is the user name of the superuser.
  • The superuser has all priviledges.
  • Most of the time, you should not work as the
    superuser, but use your own private account.

11
Permission model
  • Permission of files are give to the owner, the
    group, and the rest of the world.
  • A group is a grouping of users. Unix allows to
    define any number of groups and make users a
    member of it.
  • The rest of the world are all other users who
    have access to the system.

12
Listing files
  • ls lists files
  • ls l make a long listing. It contains
  • Date
  • Owner
  • Group
  • Size
  • permission

13
First element in ls -l
  • Type indicator
  • d means directory
  • l means link
  • - means ordinary file
  • 3 letters for permission of owner
  • 3 letters for permission of group
  • 3 letters for permission of rest of the world
  • r means read, w means write, x means execute

14
Change permission chmod
  • A permission is a number
  • 4 is read
  • 2 is write
  • 1 is excute
  • Permissons are three numbers, for owner, group
    and rest of the world.
  • Example chmod 764 file
  • Directories need to be executable to get in them

15
Change owner and group
  • chown user file
  • chgrp group file
  • Usually you need to be root to do this.
  • Add users with adduser, follow instructions.
  • userdel rids you of an annoying user.

16
shell
  • The shell is a command line interpreter.
  • When you login, a shell is started for you.
  • Shells include
  • Bourne shell sh -- Korn shell ksh
  • C shell csh -- extended C shell tcsh
  • Bourne again shell bash z shell zsh
  • The default shell will be bash, which is linked
    to the default place where the shell is found,
    /bin/sh

17
General structure of commands
  • commandname flag --option
  • Where commandname is a name of a command
  • Flag can be a letter
  • Several letters set several flags or form an
    option
  • An option can also be expressed with - - and a
    word.

18
Bash features
  • cd is a command to change directory
  • File names and command names can be completed
    with TAB
  • The command history can be activated with the
    arrow keys of the keyboard
  • Environment variables can be completed
  • So login now

19
Environment variables
  • Are variable that the shell knows about.
  • Env lists all of them
  • PATH, where the executable files are searched
  • EDITOR, the default editor
  • PS1, the primary prompt
  • HOME, the home directory

20
Setting and showing them
  • LWORDlibrary
  • Set lword to be library
  • export LWORD
  • Make it visible to the shell
  • echo LWORD
  • Show the value.
  • Other example
  • PATHPATHHOME/bin

21
Copying and removing
  • cp file copyfile
  • scp user_at_machinefile user_at_machinefile
  • User is a user
  • Machine is a machine
  • File is the path to a file
  • Of course you will need permissions here!
  • rm file there is no recycling bin!!
  • -r flag copies and deletes recursively

22
Directories and files
  • mkdir file makes a directory
  • rmdir file removes it
  • touch file
  • makes a new empty file
  • sets the time on an existing file
  • more file
  • Pages contents of file, no way back
  • less file
  • Pages contents of file, u to go back, q to
    quit

23
Important programs
  • echo, shows argument on the screen
  • cat file, shows file on the screen
  • who, shows who is logged in
  • top, shows processes
  • ln s file1 file2 create a link form file2 to
    file1. pretty confusing
  • man command shows manual for command
  • man k term looks for commands with the keyword
    term

24
grep
  • Looks up an expression in a file
  • Syntax is one of simple regular expressions
  • READ the man page for this command. This is an
    important reading and will be part of the quiz
    after the installation

25
kill
  • Sends signal to a process.
  • You need to know the number of the process, you
    can do that with ps
  • Signal 9 will kill the process
  • Signal HUP will hang up the process, it will read
    its configuration file again .

26
find
  • Finds files
  • Has a exec flag that allows you to execute
    programs on the files found.
  • READ the man page for this command. This is an
    important reading and will be part of the quiz
    after the installation

27
http//openlib.org/home/krichel
  • Thank you for your attention!
Write a Comment
User Comments (0)
About PowerShow.com