Introduction to Unix CS 21 Lecture 18 Lecture

  • Slides: 40
Download presentation
Introduction to Unix – CS 21 Lecture 18

Introduction to Unix – CS 21 Lecture 18

Lecture Overview n n n Running programs at certain times Linux Distributions Installing packages

Lecture Overview n n n Running programs at certain times Linux Distributions Installing packages n Standard ways of distribution packages n n n Configure scripts apt-get Rpm Connecting to other machines and X-windows Quiz #3

Running Processes At Certain Times n What are your options if you want to

Running Processes At Certain Times n What are your options if you want to run a program once every day? n Manually run it once every day n n Write a script that you run that performs a task once a day n n 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? n Run backups n n Checking for

Why Would You Want To Do This? n Run backups n n Checking for updates n n Write your own version of automatic update Keep statistics n n At least once a night if not more often Calculate the average number of people logged on per hour Reminders n If you are working too hard and forget about some important event

The cron Daemon n crond n n n Always running in the background Starts

The cron Daemon n crond n n n 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!

How crond Works Do I run anything now? User’s cron Table crond 1 Minute! Wake up! Back to sleep

A Daemon Program n n Not some supernatural creature that lives in your computer

A Daemon Program n n 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 n Examples: printer daemons, network connection daemons

The crontab Program n Usage: crontab file n n Replace your current cron table

The crontab Program n Usage: crontab file n n Replace your current cron table with the one located in “file” Alternate usage: crontab [OPTION] n -l n n -r n n Show your current cron table Remove your current cron table -e n Edit your current cron table

Steps For Using crontab n n n Edit a file with a list of

Steps For Using crontab n n n Edit a file with a list of times and commands Run “crontab file” Wait… n Any errors when running commands will be automatically mailed to you

Fields Of A crontab File n n n Minute: 0 -59 Hour: 0 -23

Fields Of A crontab File n n n 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

Example

Getting Your Own Unix System n n By now, you have been introduced to

Getting Your Own Unix System n n By now, you have been introduced to a lot of the workings of Unix How do you go about getting a working version? n Several free options available for download n n Linux BSD

Different Distributions Of Linux n Redhat n n n Mandrake n n n Ease

Different Distributions Of Linux n Redhat n n n Mandrake n n n Ease of use Debian n n Selling support Sponsors Fedora The do-it-yourself version Gentoo Slackware

Distribution Differences n n The kernel (actual operating system) is the same with each

Distribution Differences n n The kernel (actual operating system) is the same with each distribution Differences are again in the bells and whistles n n All of the user and graphical interfaces look different Different sets of programs available from the start with different distributions

Installing Packages n When using Linux, you will undoubtedly run into programs that are

Installing Packages n When using Linux, you will undoubtedly run into programs that are updated frequently or may not be available on your installation n www. gnu. org freshmeat. net A couple of standard package distribution forms exist

Installing Packages From tarballs n n The most common way programs are distributed: package.

Installing Packages From tarballs n n The most common way programs are distributed: package. tar. gz Usually include the source code n n May include only the executables Unfortunately, no standard exists for tarball distributions n Pseudo-standard exists, but you should always read the documentation

“Standard” Installation Procedure n n Step 1: tar -xzvf 2: configure 3: make 4

“Standard” Installation Procedure n n Step 1: tar -xzvf 2: configure 3: make 4 (optional): make install

Configure Scripts n n Each package comes with its own script called “configure” Designers

Configure Scripts n n 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

Example

Once configure Has Run n n Running “make” should create executables Running “make install”

Once configure Has Run n n Running “make” should create executables Running “make install” places those executables in common locations n n /bin or /usr/local/bin Must have permission (should be root)

Problems n Sometimes, configure scripts don’t always run correctly n n Some necessary tool

Problems n Sometimes, configure scripts don’t always run correctly n n 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 n Configure scripts are simply shell programs just like the kind you have written, although longer

Other Package Distributions n rpm n n n Redhat package manager (Also used by

Other Package Distributions n rpm n n n Redhat package manager (Also used by Mandrake) apt-get n n Used in Debian systems (Fedora Core 2 has support as well)

RPM n Both a file format and a program n n n packages. rpm

RPM n Both a file format and a program n n n packages. rpm –i package. rpm Usage: rpm [OPTION] package. File n -i, -u, -f n n -e n n Install, update, or freshen Erase -q n Query

apt-get n Debian systems n n Fedora Core uses them too Package Manager n

apt-get n Debian systems n n Fedora Core uses them too Package Manager n Automatically retrieves (over an internet connection) and installs packages that you specify

Using Unix In A Networked Environment n Unix has powerful networking features built in

Using Unix In A Networked Environment n Unix has powerful networking features built in n n Sockets and ports are easily accessible For all the gory details about setting up your Unix machine, take cs 183 n n In the meantime, check out netconfig and ifconfig Must be root to run these

rlogin, telnet, ftp n rlogin and telnet n n n ftp n n n

rlogin, telnet, ftp n rlogin and telnet n n n ftp n n n 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 n Anyone watching can see what your password is and break in

ssh – The Secure Alternative To telnet And rlogin n Secure shell n n

ssh – The Secure Alternative To telnet And rlogin n Secure shell n n n Opens a terminal on another system just like telnet and rlogin Sends all information (not just password) encrypted Slight Problem: n n ssh 1 and ssh 2 are incompatible Not as much a problem nowadays as it used to be

Scp – The Secure Alternative To ftp n Secure copy n n n Works

Scp – The Secure Alternative To ftp n Secure copy n n n Works just like cp, only the source or destination can be a different machine Usage: scp source destination Example: n scp my. File villarre@eon. cs. ucr. edu: my. File n Copies my. File to eon

If ftp Isn’t Safe, Why Does Everyone Use It? n n n Many, many

If ftp Isn’t Safe, Why Does Everyone Use It? n n n Many, many web pages have ftp links Most of the package distributions are done over ftp Most ftp sites allow anonymous logins n n n Login name: anonymous Password: email address (or anything) Anonymous logins and open source software isn’t worth stealing

The GUI Of Unix: X-Windows n n n Some systems you will encounter (or

The GUI Of Unix: X-Windows n n n 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 n n startx or x in order to run X windows

Working With X-Windows n n startx or x in order to run X windows The version everyone uses is Version 11, Revision 6 n n X 11 R 6 Initialization files n n n . xinitrc. xsession Used to start xterms n Terminals on top of the X-windows environment

GUI Components User Window Manager Window System Kernel

GUI Components User Window Manager Window System Kernel

What Does Each Part Do? n Windows System n n Controls basic functionality like

What Does Each Part Do? n Windows System n n Controls basic functionality like resizing windows and creating windows Windows Manager n Controls how these functionalities appear n Example: a slider or button will resize a window

Windows Managers n Just like different distributions, different window managers exist n n n

Windows Managers n Just like different distributions, different window managers exist n n n KDE Gnome FVWM 2 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

KDE Example

Controlling Access n xhost n n Allows or disallows other machines to open up

Controlling Access n xhost n n Allows or disallows other machines to open up windows on your display Usage: xhost +machine. Name Other Usage: xhost –machine. Name The DISPLAY variable n n 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? n n If you open up a window

Why Would You Ever Do That? n n 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 n X-Win 32 n n n Simply allows X

A Unix Environment In Windows n X-Win 32 n n n Simply allows X connections from another machine to be displayed on your Windows machine Not free, however Cygwin n n A sort of emulation of Linux running as a Windows process Freely available

Next Time n Review of class n n Bring any questions you would like

Next Time n Review of class n n Bring any questions you would like discussed Study guide n n Should be posted later today A list of many, many questions like those that will appear on the final

Quiz #3 n Good Luck

Quiz #3 n Good Luck