introduction to unix – cs 21 lecture 18. lecture overview running programs at certain times linux...
TRANSCRIPT
![Page 1: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/1.jpg)
Introduction to Unix – CS 21
Lecture 18
![Page 2: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/2.jpg)
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
![Page 3: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/3.jpg)
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
Sometimes it’s a hassle and you forget Write a script that you run that
performs a task once a day Script could be killed or the system could
be rebooted Utilize cron to run your program
![Page 4: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/4.jpg)
Why Would You Want To Do This? Run backups
At least once a night if not more often Checking for updates
Write your own version of automatic update Keep statistics
Calculate the average number of people logged on per hour
Reminders If you are working too hard and forget about
some important event
![Page 5: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/5.jpg)
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
![Page 6: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/6.jpg)
How crond Works
User’s cron Table
crondDo I run anything now?
1 Minute!Wake up!
Back to sleep
![Page 7: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/7.jpg)
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
![Page 8: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/8.jpg)
The crontab Program Usage: crontab file
Replace your current cron table with the one located in “file”
Alternate usage: crontab [OPTION] -l
Show your current cron table -r
Remove your current cron table -e
Edit your current cron table
![Page 9: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/9.jpg)
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
![Page 10: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/10.jpg)
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 *
![Page 11: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/11.jpg)
Example
![Page 12: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/12.jpg)
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
![Page 13: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/13.jpg)
Different Distributions Of Linux Redhat
Selling support Sponsors Fedora
Mandrake Ease of use
Debian The do-it-yourself version
Gentoo Slackware
![Page 14: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/14.jpg)
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
![Page 15: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/15.jpg)
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
![Page 16: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/16.jpg)
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
![Page 17: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/17.jpg)
“Standard” Installation Procedure Step 1: tar -xzvf Step 2: configure Step 3: make Step 4 (optional): make install
![Page 18: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/18.jpg)
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
![Page 19: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/19.jpg)
Example
![Page 20: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/20.jpg)
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)
![Page 21: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/21.jpg)
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
![Page 22: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/22.jpg)
Other Package Distributions rpm
Redhat package manager (Also used by Mandrake)
apt-get Used in Debian systems (Fedora Core 2 has support as well)
![Page 23: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/23.jpg)
RPM Both a file format and a program
packages.rpm rpm –i package.rpm
Usage: rpm [OPTION] packageFile -i, -u, -f
Install, update, or freshen -e
Erase -q
Query
![Page 24: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/24.jpg)
apt-get Debian systems
Fedora Core uses them too Package Manager
Automatically retrieves (over an internet connection) and installs packages that you specify
![Page 25: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/25.jpg)
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
![Page 26: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/26.jpg)
rlogin, telnet, ftp rlogin and telnet
Remote login Used to open up terminals on other systems
ftp 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
![Page 27: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/27.jpg)
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
![Page 28: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/28.jpg)
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
![Page 29: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/29.jpg)
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
![Page 30: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/30.jpg)
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
![Page 31: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/31.jpg)
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
![Page 32: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/32.jpg)
GUI Components
Window Manager
Window System
Kernel
User
![Page 33: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/33.jpg)
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
![Page 34: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/34.jpg)
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
![Page 35: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/35.jpg)
KDE Example
![Page 36: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/36.jpg)
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
![Page 37: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/37.jpg)
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
![Page 38: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/38.jpg)
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
![Page 39: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/39.jpg)
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
![Page 40: Introduction to Unix – CS 21 Lecture 18. Lecture Overview Running programs at certain times Linux Distributions Installing packages Standard ways of distribution](https://reader035.vdocuments.mx/reader035/viewer/2022062407/56649ea95503460f94bad0e6/html5/thumbnails/40.jpg)
Quiz #3 Good Luck