Introduction to UNIX Operating System - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Introduction to UNIX Operating System

Description:

Introduction to UNIX Operating System Unix Unix (officially trademarked as UNIX, sometimes also written as Unix with small caps) is a computer operating system ... – PowerPoint PPT presentation

Number of Views:373
Avg rating:3.0/5.0
Slides: 27
Provided by: Crodr8
Category:

less

Transcript and Presenter's Notes

Title: Introduction to UNIX Operating System


1
Introduction to UNIX Operating System
2
  • Unix
  • Unix (officially trademarked as UNIX, sometimes
    also written as Unix with small caps) is a
    computer operating system originally developed in
    1969 by a group of ATT employees at Bell Labs,
    including Ken Thompson, Dennis Ritchie, Douglas
    McIlroy, and Joe Ossanna. Today's Unix systems
    are split into various branches, developed over
    time by ATT as well as various commercial
    vendors and non-profit organizations.
  • As of 2007, the owner of the trademark is The
    Open Group, an industry standards consortium.
    Only systems fully compliant with and certified
    to the Single UNIX Specification are qualified to
    use the trademark others are called "Unix
    system-like" or "Unix-like".
  • During the late 1970s and early 1980s, the
    influence of Unix in academic circles led to
    large-scale adoption of Unix (particularly of the
    BSD (Berkeley Software Distribution ) variant,
    originating from the University of California,
    Berkeley) by commercial startups, the most
    notable of which are Solaris, HP-UX, and AIX.
    Today, in addition to certified Unix systems,
    Unix-like operating systems such as Linux and BSD
    are commonly encountered. Sometimes, "traditional
    Unix" may be used to describe a Unix or an
    operating system that has the characteristics of
    either Version 7 Unix or UNIX System V.

3
UNIX commands
  • Misc commands
  • man,banner,cal, calendar,clear,nohup, tty .
  • Man ual command.
  • man man This is help command, and will explains
    you about online manual pages you can also use
    man
  • in conjunction with any command to learn more
    about that command for example.
  • man ls will explain about the ls command and how
    you can use it.
  • man -k pattern command will search for the
    pattern in given command.
  • --------------------------------------------------
    ------------------------------
  • Banner command.
  • banner prints characters in a sort of ascii art
    poster, for example to print wait in big letters.
    I will type
  • banner wait at unix command line or in my script.
    This is how it will look.

4
UNIX commands
  • Cal command
  • cal command will print the calander on current
    month by default. If you want to print calander
    of august of 1965. That's eightht month of 1965.
  • cal 8 1965 will print following results.
  • August 1965
  • S M Tu W Th F S
  • 1 2 3 4 5 6 7
  • 8 9 10 11 12 13 14
  • 15 16 17 18 19 20 21
  • 22 23 24 25 26 27 28
  • 29 30 31
  • --------------------------------------------------
    ------------------------------
  • Clear command
  • clear command clears the screen and puts cursor
    at beginning of first line.

5
UNIX commands
  • Tty command
  • Tty command will display your terminal. Syntax is
  • tty options
  • Options
  • -l will print the synchronous line number.
  • -s will return only the codes 0 (a terminal), 1
    (not a terminal), 2 (invalid options) (good for
    scripts)

6
  • File Management commands.
  • cat,cd, cp, file,head,tail, ln,ls,mkdir ,more,mv,
    pwd, rcp,rm, rmdir, wc.
  • --------------------------------------------------
    ------------------------------
  • Pwd command.
  • pwd command will print your home directory on
    screen, pwd means print working directory.
  • /u0/ssb/sandeep
  • is output for the command when I use pwd in
    /u0/ssb/sandeep directory.
  • --------------------------------------------------
    ------------------------------
  • Ls command
  • ls command is most widely used command and it
    displays the contents of directory.
  • options
  • ls will list all the files in your home
    directory, this command has many options.

7
  • Cp command.
  • cp command copies a file. If I want to copy a
    file named oldfile in a current directory to a
    file named newfile in a current directory.
  • cp oldfile newfile
  • If I want to copy oldfile to other directory for
    example /tmp then
  • cp oldfile /tmp/newfile. Useful options available
    with cp are -p and -r . -p options preserves the
    modification time and permissions, -r recursively
    copy a directory and its files, duplicating the
    tree structure.
  • --------------------------------------------------
    ------------------------------
  • Rcp command.
  • rcp command will copy files between two unix
    systems and works just like cp command (-p and -i
    options too).
  • For example you are on a unix system that is
    called Cheetah and want to copy a file which is
    in current directory to a system that is called
    lion in /usr/john/ directory then you can use rcp
    command
  • rcp filename lion/usr/john
  • You will also need permissions between the two
    machines. For more infor type man rcp at command
    line.
  • --------------------------------------------------
    ------------------------------
  • Mv command.

8
  • Head command.
  • head filename by default will display the first
    10 lines of a file.
  • If you want first 50 lines you can use head -50
    filename or for 37 lines head -37 filename and so
    forth.
  • --------------------------------------------------
    ------------------------------
  • Tail command.
  • tail filename by default will display the last 10
    lines of a file.
  • If you want last 50 lines then you can use tail
    -50 filename.
  • --------------------------------------------------
    ------------------------------
  • More command. more command will display a page at
    a time and then wait for input which is spacebar.
    For example if you have a file which is 500 lines
    and you want to read it all. So you can use
  • more filename

9
  • Rmdir command. rmdir command will remove
    directory or directories if a directory is empty.
  • Options
  • rm -r directory_name will remove all files even
    if directory is not empty.
  • rmdir sandeep is how you use it to remove sandeep
    directory.
  • rmdir -p will remove directories and any parent
    directories that are empty.
  • rmdir -s will suppress standard error messages
    caused by -p.

10
  • Comparison and Searching
  • diff,dircmp, cmp, grep, find.
  • Diff command. diff command will compare the two
    files and print out the differences between.
    Here I have two ascii text files. fileone and
    file two. Contents of fileone are
  • This is first file
  • this is second line
  • this is third line
  • this is different aslkdjf
  • this is not differentfiletwo contains
  • This is first file
  • this is second line
  • this is third line
  • this is different xxxxxxxaslkdjf
  • this is not differentdiff fileone filetwo will
    give following output
  • 4c4 lt this is different aslkdjf --- gt this is
    different xxxxxxxaslkdjf
  • Cmp command. cmp command compares the two files.
    For example I have two different files fileone
    and filetwo. cmp fileone filetwo will give me
  • fileone filetwo differ char 80, line 4 if I run
    cmp command on similar files nothing is
    returned.-s command can be used to return exit
    codes. i.e. return 0 if files are identical, 1 if
    files are different, 2 if files are inaccessible.
    This following command prints a message 'no
    changes' if files are same cmp -s fileone file1
    echo 'no changes' . no changes
  • Dircmp Command. dircmp command compares two
    directories. If i have two directories in my home
    directory nameddirone and dirtwo and each has
    5-10 files in it. Then dircmp dirone dirtwo will
    return this
  • Dec 9 1606 1997 dirone only and dirtwo only Page
    1
  • ./cal.txt

11
  • Grep Command
  • grep command is the most useful search command.
    You can use it to find processes running on
    system, to find a pattern in a file, etc. It can
    be used to search one or more files to match an
    expression.
  • It can also be used in conjunction with other
    commands as in this following example, output of
    ps command is passed to grep command, here it
    means search all processes in system and find the
    pattern sleep.
  • ps -ef grep sleep will display all the sleep
    processes running in the system as follows.
  • ops 12964 25853 0 161224 ttyAE/AAES 000
    sleep 60
  • dxi 12974 15640 0 161225 ttyAH/AAHP 000
    sleep 60
  • ops 12941 25688 0 161221 ttyAE/AAEt 000
    sleep 60
  • ops 12847 25812 0 161159 ttyAH/AAH6 000
    sleep 60
  • ops 12894 25834 0 161212 ttyAE/AAEX 000
    sleep 60
  • dxi 13067 27253 2 161248 ttyAE/ABEY 000
    sleep 1
  • ops 13046 25761 0 161244 ttyAE/AAE0 000
    sleep 60
  • dxi 12956 13078 0 161223 ttyAG/AAG 000
    sleep 60
  • ops 12965 25737 0 161224 ttyAE/AAEp 000
    sleep 60
  • ops 12989 25778 0 161228 ttyAH/AAHv 000
    sleep 60
  • ssb 13069 26758 2 161249 ttyAH/AAHs 000
    grep sleep
  • pjk 27049 3353 0 152023 ? 000
    sleep 3600
  • Options
  • -b option will precede each line with its block
    number.

12
  • Find command.
  • Find command is a extremely useful command. you
    can search for any file anywhere using this
    command provided that file and directory you are
    searching has read write attributes set to you
    ,your, group or all. Find descends directory tree
    beginning at each pathname and finds the files
    that meet the specified conditions. Here are some
    examples.
  • Some Examples
  • find HOME -print will lists all files in your
    home directory.
  • find /work -name chapter1 -print will list all
    files named chapter1 in /work directory.
  • find / -type d -name 'man' -print will list all
    manpage directories.
  • find / -size 0 -ok rm \ will remove all empty
    files on system.
  • conditions of find
  • -atime n -n n will find files that were last
    accessed more than n or less than -n days or n
    days.
  • -ctime n or -n will find that were changed n -n
    or n days ago.
  • -depth descend the directory structure, working
    on actual files first and then directories. You
    can use it with cpio command.
  • -exec commad \ run the Unix command on each
    file matched by find. Very useful condition.
  • -print print or list to standard output (screen).
  • -name pattern find the pattern.
  • -perm nnnfind files whole permission flags match
    octal number nnn.
  • -size n find files that contain n blocks.

13
  • Text processing
  • cut,paste, sort, uniq,awk,sed,vi.
  • --------------------------------------------------
    ------------------------------
  • Cut command.
  • cut command selects a list of columns or fields
    from one or more files.
  • Option -c is for columns and -f for fields. It is
    entered as
  • cut options files
  • for example if a file named testfile contains
  • this is firstline
  • this is secondline
  • this is thirdline
  • Examples
  • cut -c1,4 testfile will print this to standard
    output (screen)
  • ts
  • ts

14
  • Sort command.
  • sort command sort the lines of a file or files,
    in alphabetical order. for example if you have a
    file named testfile with these contents
  • zzz
  • aaa
  • 1234
  • yuer
  • wer
  • qww
  • wwe
  • Then running
  • sort testfile
  • will give us output of
  • 1234
  • aaa
  • qww
  • wer
  • wwe

15
  • Vi editor.
  • vi command launches a vi sual editor. To edit a
    file type
  • vi filename
  • vi editor is a default editor of all Unix
    systems. It has several modes. In order to write
    characters you will need to hit i to be in insert
    mode and then start typing. Make sure that your
    terminal has correct settings, vt100 emulation
    works good if you are logged in using pc.
  • Once you are done typing then to be in command
    mode where you can write/search/ you need to hit
    w filename to write
  • and in case you are done writing and want to exit
  • w! will write and exit.
  • options
  • i for insert mode.
  • I inserts text at the curson
  • A appends text at the end of the line.
  • a appends text after cursor.
  • O open a new line of text above the curson.
  • o open a new line of text below the curson.
  • for command mode.
  • ltescapegt to invoke command mode from insert mode.
  • !sh to run unix commands.

16
  • Shell and programming
  • Shell programming,bourne shell, ksh, csh,
    echo,line,sleep, test,cc compiler.
  • --------------------------------------------------
    ------------------------------
  • Shell programming concepts and commands.
  • Shell programming is integral part of Unix
    operating systems. Shell is command line
    userinterface to Unix operating system, User have
    an option of picking an interface on Unix such as
    ksh, csh, or default sh., these are called
    shells(interface). Shell programming is used to
    automate many tasks. Shell programming is not a
    programming language in the truest sense of word
    since it is not compiled but rather an
    interpreted language. Unix was written in C
    language and thus c language is integral part of
    unix and available on all versions. Shells, like
    ksh and csh are popular shells on unix although
    there are 5 or 6 different shells available but I
    will only be discussing ksh and csh as well as
    sh. Common features among all shells are job
    control, for example if I am running a processes
    which is searching the whole system for .Z files
    and output is directed to a file named
    compressedfiles.
  • example
  • find / -name .Z -print gt compressedfiles
  • then after entering this command hitting
  • ltcontrol zgt
  • key will suspend this job, then entering
  • bg
  • at command line will put this job in background,
    entering
  • fg
  • will put this job in foreground. Entering
  • jobs
  • at command line will show me all my concurrent
    jobs that are running.

17
  • Bourne Shell (sh shell).
  • sh or Bourne shell is default shell of Unix
    operating systems and is the most simplest shell
    in Unix systems.
  • Examples
  • cd ls execute one after another.
  • (datewhopwd)gt logifile will redirect all the
    output from three commands to a filenamed
    logfile.
  • sort file lp will first sort a file and then
    print it.
  • alias options name'command' will let you
    create your own commands. i.e.
  • alias ll"ls -la" will execute ls -la command
    whenever ll is entered.
  • let expressions is syntax of let statement.
  • let ii1 will work as a counter with i
    incrementing each time this statement is
    encountered.
  • for xin list do commands done is syntax for for
    do loop.
  • function name commands is the syntax of a
    function which can be called from anywhere in
    program.
  • if condition1 then commands1 elif condition2 then
    commands2 ... ... ... else commands3 fi
  • --------------------------------------------------
    ------------------------------
  • Ksh shell (Korn).
  • Ksh or Korn shell is widely used shell.

18
  • Cu command.
  • cu command is used for communications over a
    modem or direct line with another Unix system.
  • Syntax is
  • cu options destination
  • Options
  • -bn process lines using n-bit characters (7 or
    8).
  • -cname Search UUCP's device file and select local
    area network that matches name.
  • -d Prints diagnostics.
  • -e sends even parity data to remote system
  • -lline communicate on this device
    (line/dev/tty001, etc)
  • -n prompts for a telephone number.
  • -sn set transmission rate to n(e.g
    1200,2400,9600, BPS)
  • Destination
  • telno is the telephone number of the modem to
    connect to.
  • system is call the system known to uucp.
  • aadr is an address specific to LAN.
  • --------------------------------------------------
    ------------------------------

19
  • Login command.
  • login command invokes a login session to a Unix
    system, which then authenticates the login to a
    system. System prompts you to enter userid and
    password.
  • --------------------------------------------------
    ------------------------------
  • Rlogin command.
  • rlogin command is used to log on to remote Unix
    systems, user must have permissions on both
    systems as well as same userid, or an id defined
    in .rhosts file. Syntax is
  • rlogin options host
  • options
  • -8 will allow 8 bit data to pass, instead of
    7-bit data.
  • -e c will let you use escape character c.
  • -l user will let you to login as user to remote
    host, instead of same as local host.
  • --------------------------------------------------
    ------------------------------
  • Talk command.
  • talk command is used to invoke talk program
    available on all unix system which lets two users
    exchange information back and forth in real time.
    Syntax is

20
  • Storage commands
  • Compress command.
  • Compress command compresses a file and returns
    the original file with .z extension, to
    uncompress this filename.Z file use uncompress
    filename command. syntax for compress command is
  • compress options files
  • Options
  • -bn limit the number of bits in coding to n.
  • -c write to standard output (do not change
    files).
  • -f compress conditionally, do not prompt before
    overwriting files.
  • -v Print the resulting percentage of reduction
    for files.
  • --------------------------------------------------
    ------------------------------
  • Uncompress command.
  • Uncompress file uncompresses a file and return it
    to its original form.
  • syntax is
  • uncompress filename.Z this uncompresses the
    compressed file to its original name.
  • Options

21
  • Dump command is useful to backup the file
    systems.
  • dump command copies all the files in filesystem
    that have been changed after a certain date. It
    is good for incremental backups. This information
    about date is derived from /var/adm/dumpdates and
    /etc/fstab .
  • syntax for HP-UX dump is
  • /usr/sbin/dump option argument ... filesystem
  • Options
  • 0-9 This number is dump level. 0 option causes
    entire filesystem to be dumped.
  • b blocking factor taken into argument.
  • d density of tape default value is 1600.
  • f place the dump on next argument file instead of
    tape.
  • This example causes the entire file system (/mnt)
    to be dumped on /dev/rmt/c0t0d0BEST and specifies
    that the density of the tape is 6250 BPI.
  • /usr/sbin/dump 0df 6250 /dev/rmt/c0t0d0BEST /mnt
  • for more info type man dump at command line.
  • --------------------------------------------------
    ------------------------------
  • Pack command.
  • pack command compacts each file and combine them
    together into a filename.z file. The original
    file is replaced. Pcat and unpack will restore
    packed files to their original form.

22
  • Tar command.
  • tar command creates an archive of files into a
    single file.
  • Tar copies and restore files to a tape or any
    storage media. Synopsis of tar is
  • tar options file
  • Examples
  • tar cvf /dev/rmt/0 /bin /usr/bin creates an
    archive of /bin and /usr/bin, and store on the
    tape in /dev/rmt0.
  • tar tvf /dev/rmt0 will list the tape's content in
    a /dev/rmt0 drive.
  • tar cvf - 'find . -print' gt backup.tar will
    creates an archive of current directory and store
    it in file backup.tar.
  • Functions
  • c creates a new tape.
  • r append files to a tape.
  • t print the names of files if they are stored on
    the tape.
  • x extract files from tape.
  • Options
  • b n use blocking factor of n.
  • l print error messages about links not found.
  • L follow symbolic links.

23
  • System Status
  • Chmod command.
  • chmod command is used to change permissions on a
    file.
  • for example if I have a text file with calender
    in it called cal.txt.
  • initially when this file will be created the
    permissions for this file depends upon umask set
    in your profile files. As you can see this file
    has 666 or -rw-rw-rw attributes.
  • ls -la cal.txt
  • -rw-rw-rw- 1 ssb dxidev 135 Dec 3
    1614 cal.txt
  • In this line above I have -rw-rw-rw- meaning
    respectively that owner can read and write file,
    member of the owner's group can read and write
    this file and anyone else connected to this
    system can read and write this file., next ssb is
    owner of this file dxidev is the group of this
    file, there are 135 bytes in this file, this file
    was created on December 3 at time1614 and at the
    end there is name of this file. Learn to read
    these permissions in binary, like this for
    example Decimal 644 which is 110 100 100 in
    binary meand rw-r--r-- or user can read,write
    this file, group can read only, everyone else can
    read only. Similarly, if permissions are 755 or
    111 101 101 that means rwxr-xr-x or user can
    read, write and execute, group can read and
    execute, everyone else can read and execute. All
    directories have d in front of permissions. So if
    you don't want anyone to see your files or to do
    anything with it use chmod command and make
    permissions so that only you can read and write
    to that file, i.e.
  • chmod 600 filename.

24
  • Chgrp command.
  • chgrp command is used to change the group of a
    file or directory.
  • You must own the file or be a superuser.
  • chgrp options newgroup files is syntax of
    chgrp.
  • Newgroup is either a group Id or a group name
    located in /etc/group .
  • Options
  • -h will change the group on symbolic links.
  • -R recursively descend through directory changing
    group of all files and subdirectories.
  • Crontab command.
  • crontab command is used to schedule jobs. You
    must have permission to run this command by unix
    Administrator. Jobs are scheduled in five
    numbers, as follows.
  • Minutes 0-59
  • Hour 0-23
  • Day of month 1-31
  • month 1-12
  • Day of week 0-6 (0 is sunday)

25
  • Df command.
  • df command displays information about mounted
    filesystems. It reports the number of free disk
    blocks. Typically a Disk block is 512 bytes (or
    1/2 Kilobyte).
  • syntax is
  • df options name
  • Options
  • -b will print only the number of free blocks.
  • -e will print only the number of free files.
  • -f will report free blocks but not free inodes.
  • -F type will report on an umounted file system
    specified by type.
  • -k will print allocation in kilobytes.
  • -l will report only on local file systems.
  • -n will print only the file system name type,
    with no arguments it lists type of all file
    systems

26
  • Who command
  • who command displays information about the
    current status of system.
  • who options file
  • Who as default prints login names of users
    currently logged in.
  • Options
  • -a use all options.
  • -b Report information about last reboot.
  • -d report expired processes.
  • -H print headings.
  • -p report previously spawned processes.
  • -u report terminal usage.
Write a Comment
User Comments (0)
About PowerShow.com