CS21Lecture18

Download Report

Transcript CS21Lecture18

Introduction to Unix – CS 21
Lecture 18
Lecture Overview



Running programs at certain times
Linux Distributions
Installing packages

Standard ways of distribution packages





Configure scripts
apt-get
Rpm
Connecting to other machines and X-windows
Quiz #3
Running Processes At Certain
Times

What are your options if you want to
run a program once every day?

Manually run it once every day


Write a script that you run that performs a
task once a day


Sometimes it’s a hassle and you forget
Script could be killed or the system could be
rebooted
Utilize cron to run your program
Why Would You Want To Do
This?

Run backups


Checking for updates


Write your own version of automatic update
Keep statistics


At least once a night if not more often
Calculate the average number of people logged on
per hour
Reminders

If you are working too hard and forget about
some important event
The cron Daemon

crond



Always running in the background
Starts up every time a Unix machine boots
up
Once a minute, checks certain files to see if
anything needs to be run
How crond Works
Do I run anything now?
User’s cron Table
crond
1 Minute!
Wake up!
Back to sleep
A Daemon Program




Not some supernatural creature that lives in
your computer
A program that is run in the background from
the very beginning
Typically has no input or output except to log
files
Constantly checks and handles some events
in the background

Examples: printer daemons, network connection
daemons
The crontab Program

Usage: crontab file


Replace your current cron table with the one
located in “file”
Alternate usage: crontab [OPTION]

-l


-r


Show your current cron table
Remove your current cron table
-e

Edit your current cron table
Steps For Using crontab



Edit a file with a list of times and
commands
Run “crontab file”
Wait…

Any errors when running commands will be
automatically mailed to you
Fields Of A crontab File






Minute: 0-59
Hour: 0-23 (military time)
Day of the month: 1-31
Month: 1-12 (or names)
Day of the week: 0-7 (0 and 7 are
Sunday)
Each item can be an individual item, a
hyphenated list, or a *
Example
Getting Your Own Unix System


By now, you have been introduced to a
lot of the workings of Unix
How do you go about getting a working
version?

Several free options available for download


Linux
BSD
Different Distributions Of
Linux

Redhat



Mandrake



Ease of use
Debian


Selling support
Sponsors Fedora
The do-it-yourself version
Gentoo
Slackware
Distribution Differences


The kernel (actual operating system) is
the same with each distribution
Differences are again in the bells and
whistles


All of the user and graphical interfaces look
different
Different sets of programs available from
the start with different distributions
Installing Packages

When using Linux, you will undoubtedly
run into programs that are updated
frequently or may not be available on
your installation



www.gnu.org
freshmeat.net
A couple of standard package
distribution forms exist
Installing Packages From
tarballs


The most common way programs are
distributed: package.tar.gz
Usually include the source code


May include only the executables
Unfortunately, no standard exists for
tarball distributions

Pseudo-standard exists, but you should
always read the documentation
“Standard” Installation
Procedure




Step
Step
Step
Step
1: tar -xzvf
2: configure
3: make
4 (optional): make install
Configure Scripts


Each package comes with its own script
called “configure”
Designers write these as checks to see
what tools are available on each and
create a particular Makefile according to
what was detected
Example
Once configure Has Run


Running “make” should create
executables
Running “make install” places those
executables in common locations


/bin or /usr/local/bin
Must have permission (should be root)
Problems

Sometimes, configure scripts don’t always run
correctly




Some necessary tool is missing on your system
Worse, you know you have the tool but configure
can’t find it!
Getting something installed can turn into a
long, ugly process
Keep in mind, there is no magic here

Configure scripts are simply shell programs just
like the kind you have written, although longer
Other Package Distributions

rpm



Redhat package manager
(Also used by Mandrake)
apt-get


Used in Debian systems
(Fedora Core 2 has support as well)
RPM

Both a file format and a program



packages.rpm
rpm –i package.rpm
Usage: rpm [OPTION] packageFile

-i, -u, -f


-e


Install, update, or freshen
Erase
-q

Query
apt-get

Debian systems


Fedora Core uses them too
Package Manager

Automatically retrieves (over an internet
connection) and installs packages that you
specify
Using Unix In A Networked
Environment

Unix has powerful networking features
built in


Sockets and ports are easily accessible
For all the gory details about setting up
your Unix machine, take cs183


In the meantime, check out netconfig and
ifconfig
Must be root to run these
rlogin, telnet, ftp

rlogin and telnet



ftp



Remote login
Used to open up terminals on other systems
File transfer protocol
Used to transfer files efficiently
All unsafe as everything is sent in plain text

Anyone watching can see what your password is
and break in
ssh – The Secure Alternative
To telnet And rlogin

Secure shell



Opens a terminal on another system just like
telnet and rlogin
Sends all information (not just password)
encrypted
Slight Problem:


ssh1 and ssh2 are incompatible
Not as much a problem nowadays as it used to be
Scp – The Secure Alternative
To ftp

Secure copy



Works just like cp, only the source or
destination can be a different machine
Usage: scp source destination
Example:

scp myFile [email protected]:myFile

Copies myFile to eon
If ftp Isn’t Safe, Why Does
Everyone Use It?



Many, many web pages have ftp links
Most of the package distributions are
done over ftp
Most ftp sites allow anonymous logins



Login name: anonymous
Password: email address (or anything)
Anonymous logins and open source
software isn’t worth stealing
The GUI Of Unix: X-Windows



Some systems you will encounter (or set up
like Debian) default to the command line
interface
Everything we’ve done so far in this class has
primarily been command line driven
In an effort to be more appealing and user
friendly, a standard for graphical user
interfaces was created - X
Working With X-Windows


startx or x in order to run X windows
The version everyone uses is Version 11,
Revision 6


X11R6
Initialization files



.xinitrc
.xsession
Used to start xterms

Terminals on top of the X-windows environment
GUI Components
User
Window Manager
Window System
Kernel
What Does Each Part Do?

Windows System


Controls basic functionality like resizing
windows and creating windows
Windows Manager

Controls how these functionalities appear

Example: a slider or button will resize a window
Windows Managers

Just like different distributions, different
window managers exist





KDE
Gnome
FVWM2
All try to create their own look and feel
Some have more features than others, but I
can’t say one is better than any other
KDE Example
Controlling Access

xhost




Allows or disallows other machines to open up
windows on your display
Usage: xhost +machineName
Other Usage: xhost –machineName
The DISPLAY variable


Tells the system where to send windows (where X
connections go)
export DISPLAY=283-13.cs.ucr.edu:0.0
Why Would You Ever Do That?


If you open up a window on someone
else’s machine, you don’t have control
over it!
If you want two people to work on
modifying a file at the same time, you
can open up an emacs window on
another machine
A Unix Environment In
Windows

X-Win32



Simply allows X connections from another
machine to be displayed on your Windows
machine
Not free, however
Cygwin


A sort of emulation of Linux running as a
Windows process
Freely available
Next Time

Review of class


Bring any questions you would like
discussed
Study guide


Should be posted later today
A list of many, many questions like those
that will appear on the final
Quiz #3

Good Luck