0% found this document useful (0 votes)
101 views48 pages

Introduction To UNIX: Motivate The Use of UNIX Introduce Basic UNIX Features (E.g. Using Directories, Files) Introduce

This document provides an introduction to the UNIX operating system. It discusses the objectives of learning UNIX, including basic features like directories and files. It also introduces popular text editors like vi and emacs. The document then covers various UNIX topics like the file system, directories, files, email, and vi/emacs. It aims to provide background on UNIX, explain why it is useful, and discuss its history. It also offers guidance on finding UNIX help resources and getting started with basic commands.

Uploaded by

Sangram Anand
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views48 pages

Introduction To UNIX: Motivate The Use of UNIX Introduce Basic UNIX Features (E.g. Using Directories, Files) Introduce

This document provides an introduction to the UNIX operating system. It discusses the objectives of learning UNIX, including basic features like directories and files. It also introduces popular text editors like vi and emacs. The document then covers various UNIX topics like the file system, directories, files, email, and vi/emacs. It aims to provide background on UNIX, explain why it is useful, and discuss its history. It also offers guidance on finding UNIX help resources and getting started with basic commands.

Uploaded by

Sangram Anand
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 48

Introduction to UNIX

CET 421


Objectives
Motivate the use of UNIX
Introduce basic UNIX features (e.g. using
directories, files)
Introduce vi and emacs
Contents
1. Background on UNIX
2. Starting / Finishing
3. Typing UNIX Commands
4. Commands to Use Right Away
5. UNIX help

continued
6. The UNIX File System
7. Working with Directories
8. Working with Files
9. Communicating with People
10. E-mail
11. vi/emacs
1. Background on UNIX
1.1. What is UNIX?

1.2. History

1.3. Why use UNIX?


What is Unix?

A fully featured modern operating system

It is available in a variety of “flavors.”

It’s comprised of simple tools that perform a single
function well.

These tools can be used together to perform
complex tasks.
1.1. What is UNIX?

The UNIX Operating System (OS) is a large
program (mostly coded in C) that turns the
computer into a useable machine.


It provides a number of facilities:
 management of hardware resources
 directory and file system
 loading / execution / suspension of programs
History

Beginnings in 1969

AT & T Bell Laboratories

Ken Thompson and Dennis Richie

Working version (in 1970) on a DEC PDP 11/70

UNIX and C Relationship

June 81: Berkeley UNIX 4.1 BSD (enhanced with vi, csh, and
virtual memory management)

1983: Berkeley UNIX 4.2 BSD (added TCP/IP networking,
sockets and a new file system)

Later  UNIX/32V, SYSTEM III, SYSTEM V

and then    Linux
1.2. (Brief) History

1969 First UNIX at Bell Labs

1975 Bell Labs makes UNIX freeware

1970’s Berkeley UNIX (BSD)

1980’s TCP/IP
MIT X-Windows

1990’s The Web,
LINUX
1.3. Why Use UNIX?

multi-tasking / multi-user

lots of software

networking capability

graphical (with command line)

easy to program

portable (PCs, mainframes,
super-computers)

continued

free! (LINUX, FreeBSD, GNU)

popular

profitable
1996 Sales: US$34.5 Billion, up 12%

not tied to one company

active community
UNIX

Hardware is surrounded by the operating system
software

Operating system is called the system kernel
 The kernel is the core of an operating system and
manages the machine’s hardware resources (including
the processor and the memory), and provides and
controls the way any other software component can
access these resources.
 The kernel runs with a higher privilege than other programs
(so-called user-mode programs).

Comes with a number of user services and interfaces
 Shell
 Components of the C compiler
 GUI or Command Line Interface
UNIX
Modern UNIX Systems

System V Release 4 (SVR4)

Solaris 9

4.4BSD

Linux
Unix is Made Up of
Processes
• Running Programs
User owned
System owned
Files
• Regular Files:
– Data
– Executables <-- usually start a process
• Directory Files
– Contain other files and directories
• Special Files
UNIX Kernel
Modern UNIX Kernel
Unix Help

There is online help available on any Unix
system.

The help system is call the "Unix man pages"
 set of help files and a command to view them.
 the book has some of the same information, but
you might need to check the man pages for your
specific system for details.
RTFM
The acronym RTFM (commonly found in
newgroups and other sources of information for
Unix users and System Administrators) stands
for:
Read The … Man page
(or Read The … Manual).

It's common for beginners to struggle instead of


reading the man pages … it takes a while to get
the hang of how to decipher the man pages.
Learning Unix

In class we will have:
 lectures
 demonstrations
 thought exercises


You need to spend time playing on a Unix
system to learn!
Operating Systems

An Operating System controls (manages)
hardware and software.
 provides support for peripherals such as
keyboard, mouse, screen, disk drives, …
 software applications use the OS to communicate
with peripherals.
 The OS typically manages (starts, stops, pauses,
etc) applications.
Single vs. Multitasking

Some old operating systems could only do one
thing at a time (DOS).

Most modern systems can support multiple
applications (tasks) and some can support
multiple users (at the same time).

Supporting multiple tasks/users means the OS
must manage memory, CPU time, network
interfaces, ...
User Interfaces

The User Interface is the software that
supports interactions with a human.

Some operating systems directly provide a
user interface and some don't.

Windows is an example of an Operating
System that includes a user interface.

Unix (the OS) does not directly provide a
user interface.
Unix and Users

Most flavors of Unix (there are many) provide the
same set of applications to support humans
(commands and shells).

Although these user interface programs are not
part of the OS directly, they are standardized
enough that learning your way around one flavor
of Unix is enough.
Flavors of Unix

There are many versions of Unix that are
used by lots of people:
 SysV (from AT&T)
 BSD (from Berkeley)
 Solaris (Sun)
 IRIX (SGI)
 AIX (IBM)
 LINUX (free software)
POSIX

POSIX is a standard that describes a single
interface to a Unix like operating system.

POSIX is not an implementation - it is a
description!

Most vendors are supporting POSIX (by making
sure their version of Unix adheres to the
standard).
Unix History and Motivation

The first version of Unix came from AT&T in the
early 1970s (Unix is old!).

Unix was developed by programmers and for
programmers.

Unix is designed so that users can extend the
functionality - to build new tools easily and
efficiently (this is important for programmers).
Some Basic Concepts

Unix provides a simple interface to peripherals
(it's pretty easy to add support for a new
peripheral).

Unix includes a basic set of commands that
allow the user to view/change the system
resources (filesystem, processes, peripherals,
etc.).
What we will look at

In this course we will learn about:
 Unix user accounts
 the core set of Unix commands
 the Unix filesystem
 A couple of special programs called "shells".
 A number of commonly used applications:
 Window system, text editors, programming tools.
The power of Unix is that you can
extend the basic commands

We will also look at how to extend the basic
functionality of Unix:
 customize the shell and user interface.
 string together a series of Unix commands to create
new functionality.
 create custom commands that do exactly what we
want.
Our View of the World as Users

Your Shell
A shell is a process
that acts as an
interface to the OS. It
Unix Shell allows the user to run
programs individually
and together to
accomplish a task.
Use the command line
While graphical user interfaces are available and
often used on Unix systems you must have a working
knowledge of the standard command line utilities,
pipes, and I/O redirection to benefit from the
considerable strengths of Unix.
Simple Unix
Directory Structure
/

usr etc home bin var ...

local bin ... class home ugrad ...

u1 u2 ...
Your First Command
Man(manual) -- Documentation is your friend


Syntax: man topic

man provides online documentation on nearly every
standard command and configuration file.

Optional Syntax: man -k keyword

man man for more details
Special Directories
Home Directory

/home/u1

~u1

~

A user generally has permission to freely manipulate
files within this directory and its children.

Users start with their home directory as their pwd
when they login.
Changing Directories

The cd(Change Directory) command is used to change
directories

cd path

Paths can be relative or absolute

pwd reports present working directory

cd when entered by itself sets the pwd to the user’s home
directory.
Your Prompt Helps you Navigate

The default prompt on your user account tells you what


directory is your pwd(where you are at the moment).

Some Examples:
 csy12:~/bin>

 csy12:/home
 csy12:/usr/man
Other File System Utilities


ls Lists all files in a directory

cp Copies files

mv Moves files

rm Deletes files

mkdir Makes directories

rmdir Removes directories
Basic Syntax

ls ls

cp cp source dest OR
cp source … dir

mv mv source dest OR
mv source … dir

rm rm file

mkdir mkdir new directory name

rmdir rmdir directory to be removed
Other Comands
Every Unix distribution comes with hundreds of other standard
commands that can be used for everything from viewing and
searching files to developing software.

Look through /bin, /usr/bin, and /usr/local/bin on most systems


system and look at the man pages for the programs in those
directories for more information.
Using Other Commands
Syntax: command file


cat Echoes file contents to the screen

grep Searches a file for a string

more Echos a file a line at a time

less Same as more but more features

wc Counts the words in a file and more

sort Sorts the contents of a file
Pipes and Redirection
The Unix “philosophy” involves a set of generic tools
which each do one thing well. Using these tools together
allows you to appreciate the power of the Unix command.

In Unix everything (including hardware devices) is treated


as a File that can be read from and written to.
Pipes

Pipes connect stdout of one command to stdin of
another comand.
i.e.

ls | less

cat student_list | grep senior | sort
I/O Redirection

I/O redirection allows the user to change where input to
a command or output from a command goes to/comes
from.

cat student_list > outfile

program < infile

program < infile > outfile
Standard File Handles
Every Unix process automatically comes with three file
handles or descriptors.
These are:
 Standard Input (stdin)
 Keyboard
 Standard Output (stdout)
 Display
 Standard Error (stderr)
 Display (unbuff)
Three Default Open Files

Program stdout Buffer

stdin stderr
Standard File Handles
All standard shells provide a facility to re-map
these three file handles to other devices and files
in addition to other commands.

This allows one to use several simple Unix


commands to perform a complex task.
Pipes

Program 1
stdout
Pipe Program 2
stdin
stdout
Pipe Program 3
stdin
Shell/Environment Variables
Shell Variables Environment Variables

Parent Process Parent Process


VAR=1 VAR=1

Child Process Child Process


VAR=???? VAR=1

You might also like