SlideShare une entreprise Scribd logo
1  sur  13
UNIX (UNICS)
                [UNiformed Information and Computational language]

Operating system:

       Interface between hardware and user through applications.
       Only OS can interact with hardware directly.

Applications:

       Start menu - .dll
       Calculator - .exe

user       Applications / GUI        OS        Hardware

Programming languages: (Language used to write programs)

       Low (Machine language):
          o Binary coded
          o E.g.: ADD A,B ; MOV A,B
       Medium (Assembly language):
          o OS(system) can easily convert it to machine language directly
          o Short commands
          o E.g. :A+B
       High:
          o OS(system) cannot interpret high language
          o Requires interpreter to be converted to machine language
          o E.g.: C, C++, JAVA, etc.

UNIX features:

       Portable, multitasking, multiuser OS
       Developed in 1969 by group of AT&T employees at BELL labs, including Ken Thompson,
       Dennis Ritchie, Brian Kernighan, Douglas Mcllroy and Joe Ossanna.
       Initially developed in assembly language but later on recorded entirely in C language.

UNIX System V:

       Abbreviated: SysV
       1st commercial version of UNIX OS
       Release SVR4 in 1991
       Incorporated elements od BSD and SunOS into System V
UNIX Standards: [All standards belong to POSIX]

      1980s: Motivation
      1998: POSIX
      1990s: Spec 1170
      1997 : Single UNIX Specification version 2
      2001 : POSIX:2001, Single UNIX Specification version 3
      2004 : POSIX:2004
      2008 : POSIX:2008

UNIX Components:

      Computer hardware
      UNIX Kernel:
          o System booted – Kernel loaded
          o 1OS           1UNIX kernel    Multiple users
          o Connection between hardware and shells
      The shell:
          o 1Shell         1User
          o Connection between Kernel and applications / utilities
      Utilities and application programs

                                                Utilities &
                                          Application programs

                                              The Shell


                                             UNIX Kernel


                                              Computer
                                              Hardwar
                                                 e




                              UNIX components / computer hardware for UNIX
LOG Process/ Shell creation:

Daemon:
     Background processes which becomes active when system boots up till the time when
     system shuts down
     Take large memory, power and CPU usage

Fork:
        Duplicating/ parallel processing
        If forked element dies, the one creating it still lives

Spawn / exec:
      Creating from within self
      Child creation
      If parent dies, the child also dies.




         init


                  fork



           init                  getty                 login            shell
                         exec/            exec/                 exec/
                         spawn            spawn                 spawn
                                                                            fork



                                                                        shell




                                 Log process / Shell creation


Process:

        inits are the daemons of UNIX system.
        For the log in process, init forks another init (one for every terminal/ login /user)
        This forked init further spawns/exec onegetty
        This getty further spawns/exec one login
This login is nothing but GUI displaying the page for Login ID and password. It compares
      the entered details of login ID and password with the authenticated ID and passwords
      saved in files.
      If ID and password matches, then login spawns/exec one shell, else getty and login
      processes terminates and goes back to init process.
      This shell interacts with application to do further process. It can also fork other shells for
      doing parallel processing of more than one applications/utilities.
      Once the user logs out, forked init dies causing the entire getty,login,shell,forked shells to
      die (as they are childs).

Shell prompts:

      Successful login is indicated by appearance of shell prompts or system prompts on the
      terminal.
      List of default prompts are:

      Sr. No.      Prompts             Shells
      1            $ (dollar)          Bourne &Korn shells (sh, bash &ksh)
      2            % (percent)         C shells (csh&tcsh)
      3            # (hash)            Any shell as root [admin login]


Commands in UNIX:

      Commands are instructions/programs written to perform specific action
      Lower cased and cryptic
      Have arguments (-), format specifiers (+) & options
      Can use 2dary prompt (>) [command more than one line]
      Killed using <delete> or <ctrl-u>
      Types:
          o External (commands in files which shell doesn’t recognize) &
          o Internal (Shell commands)

Basic UNIX commands:

      echo
      uname
      who
      who am i
      date
      cal
      cat
      spell
      man
Note:
              > : insertion / overwriting
              >> : appending
              ctrl+z : exiting the file
              q : coming out of editor
              exit : logout as well as closing putty window

      H.W.:
              Types of kernel
              Generation of computers
              File system of UNIX OS
              Commands description

      File system:

      File: store information
      Directory: Special kind of file which stores other files and directories
      File system: System made up of files and directories
                                                              /




      bin           dev            home              lib    temp        sbin          etc   usr    var




dsk           fdd          lpo                                           bin         sbin   lib   local




                                  romeo     juliet




                          progs     Login.sql    .profile
              File                                                               System
      Static inbuilt folders:
/(root):

bin: Binary executables (shell software and UNIX commands)

dev: device files necessary for hardware configuration i.e to operate peripherals like printers and
terminal

home:user folders

lib:

temp: temporary files and folder becomes empty when rebooted

sbin: Self binary executables which start and stop by themselves

etc:

usr:

var: files and folders with variable information e.g. help file, root path to printer, file links

Note: Rest folders are variable

Path names:

       Route taken to reach a file in the file system is known as path to that file
       Depending on beginning point from where path is defined, there are two types of path
       names:
          o Absolute path name: Beginning from root
          o Relative path name: Beginning from present working directory (PWD)

Wild-cards:

Characters such as ?, *, [], ! have special meaning attached to them in regard to pattern matching.
They are called wild-cards or Meta-characters.

        *- zero or one or many
        ? - exactly one character
        []- character class (forward order only)
        ! - Bang character (not, negating)

Note: echo* --- list files and directories (similar to ls [not hidden ones])

File and directory commands:
Sr. No.        Command                                              Explanation
  1.    ls :                         Lists file and directories
                   ls -a             All files and directories including the hidden ones
                   ls -A             All files and directories excluding .& ..
  2.     wc                          Lines, words, characters count
                   wc –l             Lines count
                   wc –m             Character count
                   wc –c             Bytes count (similar to character count :wc -m)
                   wc –w             Words count
                   wc –L             Maximum line length
  3.     mkdir                       Make a directory
  4.     cd directory                Change to named directory (if exists)
  5.     cd                          Change to home directory
  6.     cd~                         Change to home directory
  7.     cd..                        Change o parent directory
  8.     cp file1 file2              Copy file1 and call it file2 (duplicate)
         cp –r dir1 dir2             Copy recursively all files and directories from dir1 to dir2
                                     (duplicate)
  9.     mv file1 file2              Move(different) or rename(same directory) file1 to file2
         mv dir1 dir2                Move(different parent) or rename(same parent directory) file1
                                     to file2
 10.     rm                          Remove file
         rm *                        Remove all files
 11.     rmdir                       Remove directory (only when empty)
 12.     cat file                    Display a file
 13.     less file                   Display a file, one page at time
 14.     head file                   Display first few lines of file
 15.     tail file                   Display last few lines of file
 16.     ln :                        Link creation
                   ln file1 file2    Hard link file2 of file1 (file2 linked to content of file1) [file1
                   ln –s file1 file2 deleted : link exists]
                                     Soft link file2 of file1 (file2 linked to file1)[file1 deleted : link
                                     broken]
 17.     grep ‘keyword’ file         Search a file for keyword [displays sentence in which word
                                     appears]




File attributes and permission:
Owner (u-user)

                                                   Group (g) (a)
                                                          All

                                                   All others (o-others)



File attributes:

        Name
        Creation
        Size
        Owner
        Group to which owner belongs to
        Link information
        Permissions
        inode number (where meta data is stored)

Note: Every file has inode block (meta data-data of data) and data block

File type:

        d (directory)
        l (symbolic link)
        b (block special file)
        c (character special file)
        p (named pipe special file)
        s (local socket special file)

Note:
        socket: Port
        Piping: Deals with inter-process communication i.e. input and output of one program are
        related to input and output of other program




File Permissions:                                                  permission

                                                owner (u)           group (g)     other (o)

                                                    rwx               rwx           rwx
Reading (r)
      Writing (w)
      Execution (x)

File access commands:

         Sr. No.        Command               Explanation
         1.             ls:                   Long listing format
                              ls – a          All files and directories
                              ls -al          Al visible as well as hidden files and directories
         2.             chmod                 Change file permission
         3.             chgrp                 Change file ownership
         4.             chown                 Change group of file
         5.             file                  Identify type of file based on their content

Examples:

      ls:
      ls –l
      total 4 [block of data]
      [permission user group size      date       time       file/dir name]
      drwxrwxrw- user6 user61023 2 may 2012 1:30 pm        keviniti1
      -rw-r--r--      user6 user6 3232 1 may 2012 10:44 pm   niti.txt

      file:
      file niti.txt
      niti.txt : ASCII text

      chmod:
         o chmod 655 niti.txt [octal representation / assignment]
         o chmod u=rw, go=rx [full assignment – previous rites dropped]
         o chmoda+r, u+w, go+x [partial assignment – added to previous rites ]
             ls –l
             -rw-r-xr-x    user6 user6 3232 1 may 2012 10:44 pm             niti.txt
      [only present owner can do so i.e. user6]

      chown:
      chown user1 niti.txt
      [only present owner can do so i.e. user6]

      chgrp:
      chgrp user1 niti.txt
      [only present owner can do so i.e. user6]
      Pipe and piping
Pipe: Data

Piping: Process on intercommunication between commands. In this output of one
command is taken as input to other command. (original source and destinations are
altered)


                     command1                               command2




                    output of command1          input to command2

                                           Piping


Redirection (Input, Output, Error):

Redirection: Altering the source and destination

Input redirection: Keyboard is the standard input. Instead of keyboard, if input is taken
from a file, then it is called input redirection. All commands cannot be made to do input
redirection. Only those commands, which accept input from keyboard, can be redirected.
e.g. < or 0<, etc.

Output redirection: Display screen is the standard output. Generally when program is made
to execute, its output goes to standard shell prompt output i.e. display screen. Instead of
display screen, if output is made to go somewhere else like file, printer, disappear or other
command, then it is known as output redirection.
e.g. 1> or >, 1>> or >>, | (piping), etc.

Error redirection: Display screen is the standard error output. Generally when program is
executed and errors are not required to be displayed or required to be stored somewhere
temporarily, then it can be redirected to file. This is known as error redirection. %
e.g. 2>, 2>>, etc.




                                        Redirection:
Sr. Redirection                 Description                               Examples
       No.  symbols
        1.      <      Input redirection                                 wc niti.txt
                                                                         wc<niti.txt
           2.     >        Output redirection                            wc< niti.txt > output.txt
                                                                         who> filename
           3.    >>        Output redirection with appending             cat>> niti.txt

           4.     |        Output of one command as input to other       who | wc –l
                           command                                       who | grep ‘user6’

Filters:

       Program that gets most of its data from its standard input (main input stream) and write its
       main result / output into its standard output (main output stream).
       Inputs should be greater than or equal to outputs
       UNIX filters are used as elements of pipelines
       E.g.s: grep, wc, cat, tee, head, tail, cut, sort, uniq, awk, sed, etc

Process:

       Program (set of instructions) in action / execution is known as process.
       Kernel is the main process (in process hierarchy). It generates or spawns other processes.
       Each process has unique id called process identity (PID).
       Maximum number of PID is 32767.
       Process is responsible for creating other processes, which becomes its child.

Types of processes:

       Interactive of foreground processes:
          o Act upon user directories
          o Normally attached to terminal

       Non-interactive or background processes:
          o Runs independent of terminal

       Daemons:
          o Comes into existence as soon as system boots up and will be alive till system is shut
            down
          o Cannot kill these processes prematurely
          o Its combination of foreground and background processes
          o Only admin can interact (direct / redirect) with daemons but they cannot stop them

Running command in background:
Command is made to run in background by terminating it with an amperes and (&)
      symbol.e.g. who | sort –r >user.lst
      The shell immediately returns the PID as well as shell prompt ($)
      The user can find the process status using the PID.
      As soon as background process is completed, output pops out and mixes with the
      foreground processes. Hence it is recommended to redirect the output to a file.

Process attributes:

                Sr. no.        Process attributes                   Description
                  1.                  PID                  Process identification number
                  2.                 TTY                          Terminal type
                  3.                 TIME                        Cumulative time
                  4.                 CMD                             Command
                  5.                  UID                             User ID
                  6.                 PPID                            Parent PID
                  7.                STIME                          Starting time
                  8.                   C                       CPU time consumed


‘ps’ command:

      Displays attributes of processes that are currently running
         o –f : full list
         o –a : all users
         o –u : user
         o –t : terminal
         o –e : every thing (default)



‘nice’ command: [only by admin]

      All processes in UNIX have equal priority.
      Process priority:
          o UNIX: 0(highest) to 39(lowest-default)
          o LINUX: -19(highest) to +20(lowest-default)
      Users can decrease the priority but cannot increase them (only admins can increase
      priority)
      E.g. nice -19
      LINUX: 20+(19)=39
      E.g. nice - -19
      LINUX: 20+(-19)=1

Signals:
Messages(signals) are sent to process in one of the following occasions:
      Under error condition or user interrupt, the kernel generates the signal
      During inter process communication, the participating process generates these signals

                                          Types of signals

                 Sr. No.     Signal no.            Name                 Function
                   1.             1               SIGHUP                 Hangup
                   2.             2               SIGINT               Interruupt
                   3.             3              SIGQUIT                   Quit
                   4.             9               SIGKILL                Sure kill
                   5.            15              SIGTERM             s/w termination
                   6.            24              SIGSTOP                   Stop


‘trap command’:

      Traps are one or more signals to decide further course if action.
      Syntax: trap [commands] signal_numbers
      E.g.: trap “exit” 2 3 15
      To reset: trap 2 3 15

‘kill’ command: [only by admin]

      Terminating a process prematurely is called killing. This can be done with DEL or BREAK
      key.
      To kill background process, kill command is used.
      Syntax: kill PID

                   Sr. No.    Shortcut       Description           Signal
                       1.     ctrl + c       User interrupt        Signal 2
                       2.     ctrl +        Sure kill             Signal 9
                       3.     ctrl + z       Stop                  Signal 24

Contenu connexe

Tendances

Unix(introduction)
Unix(introduction)Unix(introduction)
Unix(introduction)
meashi
 
Lpi 101 study_guide
Lpi 101 study_guideLpi 101 study_guide
Lpi 101 study_guide
ousman1
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
Reka
 
Assignment unix & shell programming
Assignment  unix  & shell programmingAssignment  unix  & shell programming
Assignment unix & shell programming
Mohit Aggarwal
 

Tendances (20)

Piping into-php
Piping into-phpPiping into-php
Piping into-php
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013
 
Unix(introduction)
Unix(introduction)Unix(introduction)
Unix(introduction)
 
Unix Command Line Productivity Tips
Unix Command Line Productivity TipsUnix Command Line Productivity Tips
Unix Command Line Productivity Tips
 
Lesson 3 Working with Files in Linux
Lesson 3 Working with Files in LinuxLesson 3 Working with Files in Linux
Lesson 3 Working with Files in Linux
 
QSpiders - Unix Operating Systems and Commands
QSpiders - Unix Operating Systems  and CommandsQSpiders - Unix Operating Systems  and Commands
QSpiders - Unix Operating Systems and Commands
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Linux final exam
Linux final examLinux final exam
Linux final exam
 
Red hat linux essentials
Red hat linux essentialsRed hat linux essentials
Red hat linux essentials
 
Lpi 101 study_guide
Lpi 101 study_guideLpi 101 study_guide
Lpi 101 study_guide
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Linux
LinuxLinux
Linux
 
Linux command for beginners
Linux command for beginnersLinux command for beginners
Linux command for beginners
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
50 most frequently used unix linux commands (with examples)
50 most frequently used unix   linux commands (with examples)50 most frequently used unix   linux commands (with examples)
50 most frequently used unix linux commands (with examples)
 
Operating system lab manual
Operating system lab manualOperating system lab manual
Operating system lab manual
 
Assignment unix & shell programming
Assignment  unix  & shell programmingAssignment  unix  & shell programming
Assignment unix & shell programming
 
Unix system programming
Unix system programmingUnix system programming
Unix system programming
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Spsl by sasidhar 3 unit
Spsl by sasidhar  3 unitSpsl by sasidhar  3 unit
Spsl by sasidhar 3 unit
 

Similaire à Unix_commands_theory

Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338
Cam YP Co., Ltd
 
Unix Basics
Unix BasicsUnix Basics
Unix Basics
Dr.Ravi
 

Similaire à Unix_commands_theory (20)

Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338
 
Ch1 linux basics
Ch1 linux basicsCh1 linux basics
Ch1 linux basics
 
Nguyễn Vũ Hưng: Basic Linux Power Tools
Nguyễn Vũ Hưng: Basic Linux Power Tools Nguyễn Vũ Hưng: Basic Linux Power Tools
Nguyễn Vũ Hưng: Basic Linux Power Tools
 
Unix Basics
Unix BasicsUnix Basics
Unix Basics
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
 
Unix
UnixUnix
Unix
 
Karkha unix shell scritping
Karkha unix shell scritpingKarkha unix shell scritping
Karkha unix shell scritping
 
84640411 study-of-unix-os
84640411 study-of-unix-os84640411 study-of-unix-os
84640411 study-of-unix-os
 
Linux Notes-1.pdf
Linux Notes-1.pdfLinux Notes-1.pdf
Linux Notes-1.pdf
 
Linux introduction (eng)
Linux introduction (eng)Linux introduction (eng)
Linux introduction (eng)
 
Linux 4 you
Linux 4 youLinux 4 you
Linux 4 you
 
60761 linux
60761 linux60761 linux
60761 linux
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Operating System Laboratory presentation .ppt
Operating System Laboratory presentation .pptOperating System Laboratory presentation .ppt
Operating System Laboratory presentation .ppt
 
Shell_Scripting.ppt
Shell_Scripting.pptShell_Scripting.ppt
Shell_Scripting.ppt
 
Linux Getting Started
Linux Getting StartedLinux Getting Started
Linux Getting Started
 
Linuxs1
Linuxs1Linuxs1
Linuxs1
 
Spsl unit1
Spsl   unit1Spsl   unit1
Spsl unit1
 
Linux basic
Linux basicLinux basic
Linux basic
 

Dernier

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 

Dernier (20)

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 

Unix_commands_theory

  • 1. UNIX (UNICS) [UNiformed Information and Computational language] Operating system: Interface between hardware and user through applications. Only OS can interact with hardware directly. Applications: Start menu - .dll Calculator - .exe user Applications / GUI OS Hardware Programming languages: (Language used to write programs) Low (Machine language): o Binary coded o E.g.: ADD A,B ; MOV A,B Medium (Assembly language): o OS(system) can easily convert it to machine language directly o Short commands o E.g. :A+B High: o OS(system) cannot interpret high language o Requires interpreter to be converted to machine language o E.g.: C, C++, JAVA, etc. UNIX features: Portable, multitasking, multiuser OS Developed in 1969 by group of AT&T employees at BELL labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas Mcllroy and Joe Ossanna. Initially developed in assembly language but later on recorded entirely in C language. UNIX System V: Abbreviated: SysV 1st commercial version of UNIX OS Release SVR4 in 1991 Incorporated elements od BSD and SunOS into System V
  • 2. UNIX Standards: [All standards belong to POSIX] 1980s: Motivation 1998: POSIX 1990s: Spec 1170 1997 : Single UNIX Specification version 2 2001 : POSIX:2001, Single UNIX Specification version 3 2004 : POSIX:2004 2008 : POSIX:2008 UNIX Components: Computer hardware UNIX Kernel: o System booted – Kernel loaded o 1OS 1UNIX kernel Multiple users o Connection between hardware and shells The shell: o 1Shell 1User o Connection between Kernel and applications / utilities Utilities and application programs Utilities & Application programs The Shell UNIX Kernel Computer Hardwar e UNIX components / computer hardware for UNIX
  • 3. LOG Process/ Shell creation: Daemon: Background processes which becomes active when system boots up till the time when system shuts down Take large memory, power and CPU usage Fork: Duplicating/ parallel processing If forked element dies, the one creating it still lives Spawn / exec: Creating from within self Child creation If parent dies, the child also dies. init fork init getty login shell exec/ exec/ exec/ spawn spawn spawn fork shell Log process / Shell creation Process: inits are the daemons of UNIX system. For the log in process, init forks another init (one for every terminal/ login /user) This forked init further spawns/exec onegetty This getty further spawns/exec one login
  • 4. This login is nothing but GUI displaying the page for Login ID and password. It compares the entered details of login ID and password with the authenticated ID and passwords saved in files. If ID and password matches, then login spawns/exec one shell, else getty and login processes terminates and goes back to init process. This shell interacts with application to do further process. It can also fork other shells for doing parallel processing of more than one applications/utilities. Once the user logs out, forked init dies causing the entire getty,login,shell,forked shells to die (as they are childs). Shell prompts: Successful login is indicated by appearance of shell prompts or system prompts on the terminal. List of default prompts are: Sr. No. Prompts Shells 1 $ (dollar) Bourne &Korn shells (sh, bash &ksh) 2 % (percent) C shells (csh&tcsh) 3 # (hash) Any shell as root [admin login] Commands in UNIX: Commands are instructions/programs written to perform specific action Lower cased and cryptic Have arguments (-), format specifiers (+) & options Can use 2dary prompt (>) [command more than one line] Killed using <delete> or <ctrl-u> Types: o External (commands in files which shell doesn’t recognize) & o Internal (Shell commands) Basic UNIX commands: echo uname who who am i date cal cat spell man
  • 5. Note: > : insertion / overwriting >> : appending ctrl+z : exiting the file q : coming out of editor exit : logout as well as closing putty window H.W.: Types of kernel Generation of computers File system of UNIX OS Commands description File system: File: store information Directory: Special kind of file which stores other files and directories File system: System made up of files and directories / bin dev home lib temp sbin etc usr var dsk fdd lpo bin sbin lib local romeo juliet progs Login.sql .profile File System Static inbuilt folders:
  • 6. /(root): bin: Binary executables (shell software and UNIX commands) dev: device files necessary for hardware configuration i.e to operate peripherals like printers and terminal home:user folders lib: temp: temporary files and folder becomes empty when rebooted sbin: Self binary executables which start and stop by themselves etc: usr: var: files and folders with variable information e.g. help file, root path to printer, file links Note: Rest folders are variable Path names: Route taken to reach a file in the file system is known as path to that file Depending on beginning point from where path is defined, there are two types of path names: o Absolute path name: Beginning from root o Relative path name: Beginning from present working directory (PWD) Wild-cards: Characters such as ?, *, [], ! have special meaning attached to them in regard to pattern matching. They are called wild-cards or Meta-characters. *- zero or one or many ? - exactly one character []- character class (forward order only) ! - Bang character (not, negating) Note: echo* --- list files and directories (similar to ls [not hidden ones]) File and directory commands:
  • 7. Sr. No. Command Explanation 1. ls : Lists file and directories ls -a All files and directories including the hidden ones ls -A All files and directories excluding .& .. 2. wc Lines, words, characters count wc –l Lines count wc –m Character count wc –c Bytes count (similar to character count :wc -m) wc –w Words count wc –L Maximum line length 3. mkdir Make a directory 4. cd directory Change to named directory (if exists) 5. cd Change to home directory 6. cd~ Change to home directory 7. cd.. Change o parent directory 8. cp file1 file2 Copy file1 and call it file2 (duplicate) cp –r dir1 dir2 Copy recursively all files and directories from dir1 to dir2 (duplicate) 9. mv file1 file2 Move(different) or rename(same directory) file1 to file2 mv dir1 dir2 Move(different parent) or rename(same parent directory) file1 to file2 10. rm Remove file rm * Remove all files 11. rmdir Remove directory (only when empty) 12. cat file Display a file 13. less file Display a file, one page at time 14. head file Display first few lines of file 15. tail file Display last few lines of file 16. ln : Link creation ln file1 file2 Hard link file2 of file1 (file2 linked to content of file1) [file1 ln –s file1 file2 deleted : link exists] Soft link file2 of file1 (file2 linked to file1)[file1 deleted : link broken] 17. grep ‘keyword’ file Search a file for keyword [displays sentence in which word appears] File attributes and permission:
  • 8. Owner (u-user) Group (g) (a) All All others (o-others) File attributes: Name Creation Size Owner Group to which owner belongs to Link information Permissions inode number (where meta data is stored) Note: Every file has inode block (meta data-data of data) and data block File type: d (directory) l (symbolic link) b (block special file) c (character special file) p (named pipe special file) s (local socket special file) Note: socket: Port Piping: Deals with inter-process communication i.e. input and output of one program are related to input and output of other program File Permissions: permission owner (u) group (g) other (o) rwx rwx rwx
  • 9. Reading (r) Writing (w) Execution (x) File access commands: Sr. No. Command Explanation 1. ls: Long listing format ls – a All files and directories ls -al Al visible as well as hidden files and directories 2. chmod Change file permission 3. chgrp Change file ownership 4. chown Change group of file 5. file Identify type of file based on their content Examples: ls: ls –l total 4 [block of data] [permission user group size date time file/dir name] drwxrwxrw- user6 user61023 2 may 2012 1:30 pm keviniti1 -rw-r--r-- user6 user6 3232 1 may 2012 10:44 pm niti.txt file: file niti.txt niti.txt : ASCII text chmod: o chmod 655 niti.txt [octal representation / assignment] o chmod u=rw, go=rx [full assignment – previous rites dropped] o chmoda+r, u+w, go+x [partial assignment – added to previous rites ] ls –l -rw-r-xr-x user6 user6 3232 1 may 2012 10:44 pm niti.txt [only present owner can do so i.e. user6] chown: chown user1 niti.txt [only present owner can do so i.e. user6] chgrp: chgrp user1 niti.txt [only present owner can do so i.e. user6] Pipe and piping
  • 10. Pipe: Data Piping: Process on intercommunication between commands. In this output of one command is taken as input to other command. (original source and destinations are altered) command1 command2 output of command1 input to command2 Piping Redirection (Input, Output, Error): Redirection: Altering the source and destination Input redirection: Keyboard is the standard input. Instead of keyboard, if input is taken from a file, then it is called input redirection. All commands cannot be made to do input redirection. Only those commands, which accept input from keyboard, can be redirected. e.g. < or 0<, etc. Output redirection: Display screen is the standard output. Generally when program is made to execute, its output goes to standard shell prompt output i.e. display screen. Instead of display screen, if output is made to go somewhere else like file, printer, disappear or other command, then it is known as output redirection. e.g. 1> or >, 1>> or >>, | (piping), etc. Error redirection: Display screen is the standard error output. Generally when program is executed and errors are not required to be displayed or required to be stored somewhere temporarily, then it can be redirected to file. This is known as error redirection. % e.g. 2>, 2>>, etc. Redirection:
  • 11. Sr. Redirection Description Examples No. symbols 1. < Input redirection wc niti.txt wc<niti.txt 2. > Output redirection wc< niti.txt > output.txt who> filename 3. >> Output redirection with appending cat>> niti.txt 4. | Output of one command as input to other who | wc –l command who | grep ‘user6’ Filters: Program that gets most of its data from its standard input (main input stream) and write its main result / output into its standard output (main output stream). Inputs should be greater than or equal to outputs UNIX filters are used as elements of pipelines E.g.s: grep, wc, cat, tee, head, tail, cut, sort, uniq, awk, sed, etc Process: Program (set of instructions) in action / execution is known as process. Kernel is the main process (in process hierarchy). It generates or spawns other processes. Each process has unique id called process identity (PID). Maximum number of PID is 32767. Process is responsible for creating other processes, which becomes its child. Types of processes: Interactive of foreground processes: o Act upon user directories o Normally attached to terminal Non-interactive or background processes: o Runs independent of terminal Daemons: o Comes into existence as soon as system boots up and will be alive till system is shut down o Cannot kill these processes prematurely o Its combination of foreground and background processes o Only admin can interact (direct / redirect) with daemons but they cannot stop them Running command in background:
  • 12. Command is made to run in background by terminating it with an amperes and (&) symbol.e.g. who | sort –r >user.lst The shell immediately returns the PID as well as shell prompt ($) The user can find the process status using the PID. As soon as background process is completed, output pops out and mixes with the foreground processes. Hence it is recommended to redirect the output to a file. Process attributes: Sr. no. Process attributes Description 1. PID Process identification number 2. TTY Terminal type 3. TIME Cumulative time 4. CMD Command 5. UID User ID 6. PPID Parent PID 7. STIME Starting time 8. C CPU time consumed ‘ps’ command: Displays attributes of processes that are currently running o –f : full list o –a : all users o –u : user o –t : terminal o –e : every thing (default) ‘nice’ command: [only by admin] All processes in UNIX have equal priority. Process priority: o UNIX: 0(highest) to 39(lowest-default) o LINUX: -19(highest) to +20(lowest-default) Users can decrease the priority but cannot increase them (only admins can increase priority) E.g. nice -19 LINUX: 20+(19)=39 E.g. nice - -19 LINUX: 20+(-19)=1 Signals:
  • 13. Messages(signals) are sent to process in one of the following occasions: Under error condition or user interrupt, the kernel generates the signal During inter process communication, the participating process generates these signals Types of signals Sr. No. Signal no. Name Function 1. 1 SIGHUP Hangup 2. 2 SIGINT Interruupt 3. 3 SIGQUIT Quit 4. 9 SIGKILL Sure kill 5. 15 SIGTERM s/w termination 6. 24 SIGSTOP Stop ‘trap command’: Traps are one or more signals to decide further course if action. Syntax: trap [commands] signal_numbers E.g.: trap “exit” 2 3 15 To reset: trap 2 3 15 ‘kill’ command: [only by admin] Terminating a process prematurely is called killing. This can be done with DEL or BREAK key. To kill background process, kill command is used. Syntax: kill PID Sr. No. Shortcut Description Signal 1. ctrl + c User interrupt Signal 2 2. ctrl + Sure kill Signal 9 3. ctrl + z Stop Signal 24