The Shell and some useful administrative Unix Commands - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

The Shell and some useful administrative Unix Commands

Description:

UNIX Consistency. The version of the UNIX kernel that is used on a machine is determined by the ... Many of the same shells are found across all the versions of UNIX. ... – PowerPoint PPT presentation

Number of Views:95
Avg rating:3.0/5.0
Slides: 16
Provided by: jimdab
Category:

less

Transcript and Presenter's Notes

Title: The Shell and some useful administrative Unix Commands


1
The Shell and some useful administrative Unix
Commands
  • How Unix works along with some additional, useful
    administrative Unix commands you might need to
    know.

2
UNIX Consistency
  • The version of the UNIX kernel that is used on a
    machine is determined by the architecture of the
    hardware.
  • Many of the same shells are found across all the
    versions of UNIX.
  • All the versions of UNIX seem to be the same
    due to the identical interface.

3
Shells
  • Bourne shell (sh)
  • Only shell guaranteed to be on every version of
    UNIX
  • Probably the fastest shell due to its lack of
    features
  • C - shell (csh)
  • Uses C programming like syntax, but lacks a
    strong I/O component which makes scripting hard.
  • Korn shell (ksh)
  • Combines functionality of C-shell with the
    scripting strength of Bourne shell.
  • T Shell (tcsh)
  • Much better interface than C shell, but not
    uniformly available across all UNIX. Is on
    miller / grid
  • bash is also a popular shell

4
Shell Commands
  • Command line UNIX is the most powerful interface,
    but the most difficult to master.
  • Commands follow a general format
  • command -options arguments
  • command this is the actual command that you
    are sending to the shell to be executed.
  • -options Options are also referred to as
    flags. They are usually preceded with a minus
    sign (-) Options modify the functionality of a
    command.
  • arguments Used to tell the command what to
    work with or what to work upon.
  • The spaces allow for the shell to parse the
    command.

5
How the shell works
  • Shell displays a prompt.
  • Example for miller miller.cs
  • Example for alpha ( alpha ) n
  • where n is the number of commands so far.
  • You type in a command.
  • You press the return key.
  • The shell interprets the commands you typed and
    tries to find the correct programs to run.
  • The kernel runs the requested programs and
    returns the results to the shell.
  • The shell displays the command prompt again.

6
Changing The Shell
  • You can switch between which shell your using
    relatively easy.
  • On miller / grid Simply type the shell that you
    want to use. Example miller.cs tcsh
  • On alpha use the chsh command
  • Example (alpha) 1 chsh
  • Changing shell for SampleUser.
  • Old shell /usr/local/bin/tcsh
  • New shell csh

7
Standard Input, Output and Error
  • Standard input
  • stdin
  • The place the program normally looks for input.
  • The keyboard.
  • Standard output
  • stdout
  • The place where the program normally sends its
    output.
  • The screen.
  • Standard error
  • stderr
  • Used by programs to display error messages.
  • Also the screen.

8
Grouping commands
  • Executing one command at at time can be tedious.
  • Unix allows for grouping of commands by
    separating commands with a semi-colon ().
  • Example miller.cs pwd cal 10 2003 date

9
(pipe)
  • Used to link commands.
  • command command etc.
  • The output of the first command is sent as the
    input to the second command, and so on, and so on
  • Example miller.cs who more

10
Wildcards
  • Typing in Unix can be tedious.
  • Unix supports three wild-card characters
  • Asterisk () matches any string of characters
    including blanks.
  • Question mark (?) matches single characters.
  • Square brackets () Tells the shell to match
    any characters that appear inside the brackets.

11
Job control
  • Unix works via jobs or processes.
  • Every command or program is a separate process
    executed by a user.
  • Processes are usually run in the foreground, but
    can be made to run in the background.
  • Processes can be killed by the user who created
    them.

12
Job control
  • ctrl-c cancels a command/job
  • Good for breaking out of infinite loops!
  • ctrl-z suspends a command/job
  • ps displays the status of current processes
  • Example miller.cs ps
  • PID TT S TIME COMMAND
  • 3979 pts/131 S 000 -csh
  • 5629 pts/131 S 000 tcsh

13
bg
  • Forces a process to the background.
  • First, type a ctrl-z to suspend the process.
  • Then type bg and the process is forced to the
    background.
  • Use the ps command to see it.
  • You can force a process to the background
    immediately with the .

14
fg
  • Brings a process to the foreground.
  • Use the ps command to see the processes you have
    running.
  • Type fg number and that process will be
    brought to the foreground.

15
kill
  • Kills a process that you have running.
  • Use the ps command to see what you have running.
  • Type kill number.
  • Not the most graceful way out, but it works.
Write a Comment
User Comments (0)
About PowerShow.com