[newbie] UNIX INTRO: lessons declared open source

1999-07-30 Thread Richard Myers


Because:

  o Open source works better than closed source; and

  o The lessons were developed partly using ksh rather than BASH; and

  o It is entirely possible that there could be undetected errors; and

  o Additional contributors will make the lessons better, I hereby
declare:

...that everyone is invited and welcome to test the lessons on their Linux
installations, particularly using the BASH shell, and to send me any
corrections, suggestions for improvements, suggestions for new lessons, or
even developed lessons in similar format.

Maybe we can make something worthwhile out of these sessions for all new
Linux users. (No, I'm not going to go to all the trouble of issuing a GPL
at this time... grin...)

Note: I'm not experienced enough (by a few lightyears!) to offer similar
material on system admin issues. Well, there is the Linux Documentation
Project. But that is more task-oriented than training-oriented.

There may already be worthwhile efforts of this sort somewhere in
cyberspace, which could provide cross-fertilization. Anyone know of any?


best wishes,

richard myers



RE: [newbie]Change the command line prompt

1999-07-30 Thread Richard Myers
f bash
  \w   current working directory
  \W   abbreviated current working directory
  \#   command number of the current prompt
  \!   command history number of the current prompt
  \$   # for root, $ for everyone else  

By the way, I had a chance to quickly explore the PS1 variable and the
startup files in Linux. I found a very curious entry in /etc/bashrc. This
is the entire file:

-- 
# /etc/bashrc 
# System wide functions and aliases 
# Environment stuff goes in /etc/profile

# For some unknown reason bash refuses to inherit
# PS1 in some circumstances that I can't figure out.
# Putting PS1 here ensures that it gets loaded every time.

PS1="[\u@\h \W]\\$ "

alias which="type -path"
--

Sooo, this is apparently where the prompt is defined on some Linux
systems. I also found this entry in the Config HOWTO at
http://www.metalab.unc.edu/linux/ so it may actually have come from there
(not sure).

Note that the same PS1 line appears in /etc/profile so this variable is
defined twice. No harm in that, the last definition is used by the system.

I don't really like the results of the line

  PS1="[\u@\h \W]\\$ "

...because I (so far) haven't needed the hostname in my
prompt. Therefore I changed my prompt to:

  PS1="[ \W ] \u \\$ "

I think it is a bit less busy.


QUESTION: What is the significance of the leading . in .bash_profile and
.bashrc ???

ANSWER: It prevents the file from being displayed by the ls statement. To
see these files (if they exist), you have to use ls -a

This is to reduce clutter, and to protect these important system files
from careless tampering.


best wishes,

richard myers




Re: [newbie] low port privs

1999-07-30 Thread Richard Myers

On Fri, 30 Jul 1999, David Kammer wrote:

 Hi All,
 Odd question.  It seems as if only root is allowed to start proccesses
 with low port numbers like 80 (httpd is not running on my machine).  when
 non-su's try to do this, the port allocation simply fails.  My question is
 is there a way to allow a user to start low port proccesses without giving
 them full su status?  
 thanks,
 -dave

There are various solutions, but this is one I have been given privileges
with. Others can provide more complete info...

Sudo - a utility to allow restricted root access
Sudo (superuser do) allows a system administrator to give certain users
(or groups of users) the ability to run some (or all) commands as root
while logging all commands and arguments. Sudo operates on a per-command
basis, it is not a replacement for the shell.

 http://www.courtesan.com/sudo/


best wishes,

richard myers



[newbie] UNIX INTRO: Shells, redirection

1999-07-29 Thread Richard Myers
d command.

But now we are faced with a disturbing recognition:

...we COULD have executed pwd just by calling the
pwd command directly! 

$ pwd
/u02/home5/rtmyers/testdir
$ 

Why on earth did we go to all of the trouble to call
it indirectly by putting the pwd command in another file
and then calling that file?

And the answer is profound: with this simple procedure,
we have created our first simple executable script! We
don't have to content ourself with one command, we can
put in multiple commands. Also, data structures, and 
program logic, and other nifty stuff.

With these simple techniques, we can build scripts that 
can do amazing things! Even UNIX!

  ___________ end ___ 


best wishes,

richard myers



[newbie] UNIX INTRO: Pipes and Redirection

1999-07-29 Thread Richard Myers


--
 Pipes and
   Redirection
--

Someone wrote:
: OK...I thought I had it all straight in my mind but 
: I now find the difference between redirection and
: pipes really foggy.  Is there something absolute I 
: can put in my mind to clarify the two?

EXCELLENT question!!!

--
Digest
--

Redirection is a mechanism in the shell that causes the standard input for
a program to come from a file rather than from the terminal. It also
causes the standard output and standard error to go to a file rather than
to the terminal. (Standard output, standard error? Later lesson!)

Input redirection is symbolized by the  character. Output is the 
character, and output with append uses the  characters.

A pipe is a mechanism used by one command to pass information to a second
command for processing; a pipe connects the standard output of one command
to the standard input of the next, without creating an intermediate file.

A pipe is symbolized by the vertical bar | character.

--
  In-depth
--

I don't know of any easy way to learn the difference, other than to
practice and see what works:

  $ echo this  thisfile
  $ cat thisfile
  this
  $

We have redirected the output of echo to a file. We can then cat the file
and display what is in it. Now try piping from echo to a file:

  $ echo this | thisfile
  -ksh: thisfile: cannot execute [Permission denied]
  $

As you can see, this does not work. However, we can pipe from one command
to another:

  $ echo this | cat
  this
  $ 

This is a redundant operation. It would win the "useless use of cat" award
(more about that later). However, it works without generating an error
(important for our purposes), and this next step proves that *echo* isn't
displaying "this" to the screen, *cat* is.

Now lets try to redirect to cat and see what happens:

  $ echo this  cat
  $

Well, what happened to our output? It didn't appear on the screen! We can
find it if we look for redirection to a file using cat:

  $ cat cat
  this
  $

Aha! In the previous command we redirected the string "this" to a
newly-created file called cat, and we can display that file with cat.

As a general guideline, then, redirection seems to work with files, and
piping works with commands. It does get a bit more complicated later on,
but for now that is a good way to tell the difference. 

Lets try one more example. The wc command does word counting, and this
particular behavior is turned on with the -w switch. Thus:

  $ echo this | wc -w
 1
  $

We have echoed one word to wc -w.

  $ echo this that | wc -w
 2
  $

  $ echo this that other | wc -w
 3
  $

...and a two, and a three...

Now lets try redirecting three words to wc -w (instead of piping).
 
  $ echo this that other  wc -w
  $  

No output. No error. That means our command was successful, but maybe
didn't do what we wanted (since we were expecting output to the screen).

We can find the file created with redirection by using ls:

  $ ls
  wc
  $ 

And now for the mysterious part:

  $ cat wc 
  this that other -w
  $ 

Our words were not counted, they were redirected into a file which has
the filename wc.

But how did that -w get in there? Ahhh, but that is the subject of a later
lesson!

  ___ end ___ 

Errata: it IS possible to pipe to a file. How? Because (as we saw in the
last lesson) a file can become a command.

But piping to a user-created command is an advanced technique, and we
aren't going to explore that right away.


best wishes,

richard myers



Re: [newbie] UNIX INTRO: Shells, redirection

1999-07-29 Thread Richard Myers


  $ thisfile
  -ksh: thisfile: cannot execute [Permission denied]
 
On Thu, 29 Jul 1999, Andy Goth wrote:
 So I was right.  I was expecting pdksh, though (the Public Domain Korn
 SHell).

It appears that the maillist switched the order of my two posts. Yes, Korn
Shell. In my experience pdksh is not a good substitute for ksh (although
my experience was years ago; not sure of the current status).

 And what of the C Shell?  

I have used the C Shell, and it provides a nice interface. However, csh is
worse than worthless for creating scripts:

quote
Unix Support frequently advises people not to use /bin/csh. Here is the
classic document by Tom Christiansen on why you shouldn't use it for
scripts.

Csh Programming Considered Harmful

Resolved: The csh is a tool utterly inadequate for programming, and its
use for such purposes should be strictly banned.

I am continually shocked and dismayed to see people write test cases,
install scripts, and other random hackery using the csh. 
/quote

See the complete article at:

  http://vega.ing.iac.es/~cfg/notes/pub_notes/csh.html

   ...I read about one version called "tcsh" in a
 Linux book.  

I've heard it is improved. I'd do some research before I started using it,
however. The above URL is a good place to start, it mentions tcsh.

 Isn't there a convention that the first line of all shell scripts should
 be a comment identifying which shell it is to be run with?  I believe I
 have seen things like:
 
 #!/bin/sh

In the UNIX world, there are basically two types of shell scripts-- those
based upon the Bourne Shell (including Korn Shell and BASH), and those
based upon the C Shell. The common shell language for writing portable
scripts is the Bourne Shell. Advanced features of other shells are to be
avoided unless the script is never expected to leave the target system.

There may be other considerations for Linux. It seems that BASH has become
pretty much a standard.

The #! convention is an interesting story. Too long for posting here; I
refer you to:

unix/faq Digest part 3 of 7 by Ted Timar - [EMAIL PROTECTED]

It is a regular posting in comp.unix.shell, or check out:

  http://www.faqs.org/faqs/by-newsgroup/comp/comp.unix.shell.html 
 
Here is just an excerpt:

quote
3.16) Why do some scripts start with #! ... ?

 [...] 
  The Berkeley folks had a neat idea to extend how the kernel starts
  up programs.  They hacked the kernel to recognize the magic number
  `#!'.  (Magic numbers are 16-bits and two 8-bit characters makes
  16 bits, right?)  When the `#!' magic number was recognized, the
  kernel would read in the rest of the line and treat it as a
  command to run upon the contents of the file.  With this hack you
  could now do things like:
 
#! /bin/sh
 
#! /bin/csh
 
#! /bin/awk -F:
 
  This hack has existed solely in the Berkeley world, and has
  migrated to USG kernels as part of System V Release 4. 
[...]

 /quote
 

best wishes,

richard myers



[newbie] General configuration, tool comparison questions

1999-07-27 Thread Richard Myers


What is the best way to learn system configuration and administration
skills for a home-based Linux system, without feeling like I am on a
treasure hunt through the Linux Documentation Project files?

I'm somewhat experienced with Unix, but not experienced with system
administration and not experienced with Linux.

I'm in the process of configuring Mandrake 6.0. I have used the
Configuration HOWTO, and found that it had a lot of excellent information.

However, I am impatient with brief, introductory information. I want more
technical material. Why do I configure it this way? What other options are
available?

Does anyone have recommendations (books, online documents, URL's,
other maillists, etc.)???

ALSO-- we have a number of choices available when selecting basic tools in
Linux. Is there a good source for comparing such tools for feature-set,
ease of configuration and use, etc. ???

I'd be happy to spend some money for the right books-- I already have
Linux for Dummies, and Linux in a Nutshell. Unfortunately they are more
introductory than in-depth. Other recommendations welcome. I've checked
out book reviews at fatbrain.com, but most of the titles that are recent
publication-date and sound good aren't available yet.


best wishes,

richard myers



Re: [newbie] Oh, yeah

1999-07-27 Thread Richard Myers
 
-rw-rw-r--   2 rtm465  0 Jul 27 02:22 hardlink_1
-rw-rw-r--   2 rtm465  0 Jul 27 02:22 hardlink_2
lrwxrwxrwx   1 rtm465 10 Jul 27 02:35 softlink_1 - hardlink_1  

Whoa! Notice that our soft link is created with WORLD WRITE permissions
(the 3rd "w" in the group of "rwx's" in the line above). Doesn't matter,
the symlink REALLY inherits the permissions of whatever it points to.

Also notice that the symlink has 10 bytes. Why is that?

Now we will put something into the file that the symlink points to:

$ echo another string  softlink_1  
$

So, what happens if we cat the contents of all the files in the directory?
   
$ cat * 
another string  
another string  
another string  
$ 

$ ls -l 
total 6 
-rw-rw-r--   2 rtm   465   15 Jul 27 02:35 hardlink_1
-rw-rw-r--   2 rtm   465   15 Jul 27 02:35 hardlink_2
lrwxrwxrwx   1 rtm   465   10 Jul 27 02:35 softlink_1 - hardlink_1  
$

All of our files now contain 15 bytes-- 14 for the string, plus one. Well,
EXCEPT for the symlink. It still contains 10 bytes. That is because it is
just a pointer to another filename (whether that filename exists or not).

If we remove the first hard link, see what happens:

$   
$ rm hardlink_1 
$   
$ ls -l 
total 4 
-rw-rw-r--   1 rtm   465   15 Jul 27 02:35 hardlink_2
lrwxrwxrwx   1 rtm   465   10 Jul 27 02:35 softlink_1 - hardlink_1  
$   
$ cat * 
another string  
cat: cannot open softlink_1: No such file or directory  
$

Since our symlink points to a non-existant filename, we cannot display
contents. BUT, the contents still exist under a different filename.

BUT-- the symlink still points to that filename. If we create that file
anew:

$ echo some other NEW stuff in our file  hardlink_1
$   
$ cat * 
some other NEW stuff in our file
another string  
some other NEW stuff in our file
$  

Neat stuff, huh? This is Unix.


best wishes,

richard myers



Re: [newbie] Oh, yeah

1999-07-27 Thread Richard Myers


 On Tue, 27 Jul 1999, Richard Myers wrote:
  Neat stuff, huh? This is Unix.
  best wishes,
  richard myers
 
On Tue, 27 Jul 1999, darkknight wrote:
 : )  Ever thought about teaching?

We, I taught an online college-level Intro to Unix course for several
years. Gave it up because (1) the college didn't support it well enough,
and (2) I make ten times as much money working for Lucent Technologies.

 I always had trouble grasping the diferrence between hard links and soft
 (symbolic) links, untill now. And I was'nt even the poster of the message.
 cool ,  thanks alot, you really have patients and should consider teaching as a
 career. Great stuff indeed, Unix has always facinated me but I thought it too
 hard for me to grasp. More lessons like that and there might be hope for me yet.
 I shure am glad I make it a habbit to at least skim through each and every post.
 Thanks alot,
 John Love
 [EMAIL PROTECTED]

Hmmm. Glad it helped. Maybe we should do some quickie Unix-command-line
intro lessons online. QUESTION: should it be on this list, or would it be
better to start a new, separate maillist? Or should we just try a few easy
lessons, and see how it goes, with the option to move elsewhere later?

What say, everyone?


best wishes,

richard myers



Re: [newbie] Oh, yeah

1999-07-26 Thread Richard Myers


On Sun, 25 Jul 1999, Andy Goth wrote:
 Then what are hard links good for?

There are two applications which do something similar. Call them xyzzy and
plugh. xyzzy gives you a help menu, but plugh is for expert users who
don't need (and don't want) a menu.

I write a better application-- better than both of them, but it
incorporates the features of both.  Everyone starts using my application
instead of the two old ones.

And I include a flag that you can set-- either menu, or no menu. But my
users get tired of always having to turn that darn menu on or off.

Soo, I come up with this great idea. I create two names (make that two
*file* names) for the new application, xyzzy, and plugh. These are hard
links to the same file. They both do the same thing-- launch my program.

Well, they do one thing different. They place different values into one
special variable made available to my program, which keeps track of what
filename was used to launch my program. And those two different values
are: xyzzy, and plugh.

In my application I test whether it was called with the command xyzzy. If
so, I make it act like xyzzy, menu and all.

If my application was called by the name plugh, I know this must be an
expert user-- she's calling it by the name of the old program she used to
use-- and so for her my application automatically provides no menu to take
up screen space and get in the way.

Hard links make both my user groups happy.


(Honesty in posting-- I didn't come up with any of these ideas, but I
think they are nifty. ;-)

Trivia-- xyzzy and plugh are actually magic words from the 70's computer
game "advent".


best wishes,

richard myers



[newbie] mount partition problem solved!

1999-07-24 Thread Richard Myers


I posted this in a newsgroup, but since it solved a problem
I had earlier asked about here, I thought the solution
might be of interest to someone on the list:


- From [EMAIL PROTECTED] Sat Jul 24 21:44:48 1999
- Date: Sat, 24 Jul 1999 21:25:05 -0600
- From: Richard Myers [EMAIL PROTECTED]
- Newsgroups: comp.os.linux.setup
- Subject: Re: mount problem-- still not working


On 22 Jul 1999, Colin Watson wrote:

 In article 7n6qum$[EMAIL PROTECTED], [EMAIL PROTECTED] wrote:
 Colin Watson ([EMAIL PROTECTED]) wrote:
 : Have you tried using the full syntax for mount, that is:
 : mount -t ext2 /dev/hda9 /mnt/win2

  [...]
 
 Does creating a completely new partition and mounting it work?

No. But I solved the problem-- it was a lot more stubborn than I had
expected. 

I went looking for a partition table problem when I saw in a 
help file or man page that logical partitions should start 
numbering at 5-- mine started at 6. (I had wondered about this,
but decided earlier that I didn't know enough to consider it
a problem.)

Somehow I had a "hidden" partition, /dev/hda5, which was only a 
fraction of a megabyte. It was so tiny that fdisk, partition magic,
and even Linux itself did not see it. I didn't discover it until 
I ran cfdisk, which showed it plain as day. Such a small sliver
of free space, guess I might have noticed if I had really 
studied those numbers carefully.

But it was enough to mess up the swap file, and some other stuff,
because Linux couldn't tell if it should be assigned as /dev/hda9 
or /dev/hda8.

I removed the tiny partition and re-installed Linux, and things
are working much better now. Thanks for the help!

Lesson: look at a stubborn problem in a number of different ways, 
using a number of different tools. The solution may jump out
at you just when you're about to pull your hair out!!  ;-)

And with experience, I will know that my vague unease about the
numbering starting at /dev/hda6 instead of /dev/hda5 is 
something to prompt quick investigation next time.



best wishes,

richard myers



Re: [newbie] hardware

1999-07-23 Thread Richard Myers


On Thu, 22 Jul 1999, [EMAIL PROTECTED] wrote:
 Ok, I'm gonna be upgrading a large amount of my hardware and need to make
 sure I buy linux compatible hardware. Most notable I'm gonna be getting a
 new modem, vid card, NIC, and something else I seem to be missing. Is there
 a website I can go to and check if all the hardware I'm looking into getting
 is supported?

Wise move.

You'll want to memorize this URL, or build a link to it on your web page:

  http://www.metalab.unc.edu/linux/

The specific document you want is,

  Plain text:

 http://metalab.unc.edu/pub/Linux/docs/HOWTO/Hardware-HOWTO

...or,

  HTML:

 http://www.metalab.unc.edu/linux/HOWTO/Hardware-HOWTO.html

There are also a few special-purpose hardware compat web sites, I'm away
from my list right now but maybe someone else can help out here.



best wishes,

richard myers



Re: [newbie] Oh, yeah

1999-07-23 Thread Richard Myers


On Fri, 23 Jul 1999, Andy Goth wrote:

 I've spent long sleepless nights before fixing the system.ini file after
 moving programs from C:\Program Files to D:\Prog.  Luckily, I had a
 utility to rename most references that went to my CD-ROM drive after it
 changed letters.  In Linux, such a thing isn't necessary since drives
 are referred to by their real names, not by arbitrary letters. 

I think that the problem is not the "arbitrary letters", but the fact that
these letter designations get "bumped" when new hardware is added.

rant
There is a user interface analysis website (ask me for the link, if
interested) that strongly suggests Microsoft has used graphic designers to
create their interfaces so that they look pretty, even when this renders
them semi- or non-functional. Shouldn't be any surprise.

If your CDROM could just stay as your D: drive, and your next hard drive
could become E:, the upgrade problems would be fewer. Of course then
installation software would have to query each storage device, "are you a
hard drive or CDROM?" I think this identification process is common sense
now, but when the drive scheme was set up, Microsoft's simplification of
the Windows installation procedure was probably more important to them
than any provision for upgrading. "What, have a CDROM in between
non-consecutive hard drive letters? That's not pretty enough for our
customers!"   /rant


best wishes,

richard myers



Re: [newbie] CRASH!

1999-07-20 Thread Richard Myers


On Mon, 19 Jul 1999, Ramon Gandia wrote:

 [...nfs discussion deleted...]

 All of this is best done in console and not in X or you may
 incur the wrath of Athena, the goddesd of hard rocks.
 ^^^

I know, this is the *daemon* of goddesses, right?  grin



best wishes,

richard myers



Re: [newbie] OSS

1999-07-20 Thread Richard Myers


On Tue, 20 Jul 1999, Bert Bullough wrote:

 Greetings all.
 I have just successfully installed the OSS Drivers for the Turtle Beach
 Montego cheers I tried it out with an AVI movie and some Mp3z. These
 both work great but when I play a wave file the audio is choppy,
 high-pitched, and distorted.
 Ideas?

Isn't it still beta software? Last time I checked it out (few weeks ago),
it was beta and they charged a small fee for it to keep it working past
the (20 minute?) cutoff code.

I'll be trying it in a few more weeks, hope it is finalized by then.


best wishes,

richard myers



Re: [newbie] Filesystem gets badly corrupted !

1999-07-18 Thread Richard Myers


On Sun, 18 Jul 1999, Khalid wrote:

 Hi To all
 
 I have just installed Mandrake 6.0 on an IBM Thinkpad 1400.
 
 KDE freeze too often, I always need to reboot, but at boot time Linux
 tells me that the file system is corrupted and that I need to run a
 fsck. 

2.2.9? Not sure if this is related, but check out:

  http://lwn.net/1999/0624/a/ac-corruption1.html

(excerpt)

---

From:   Alan Cox [EMAIL PROTECTED]

Ok this is the distilled info so far

2.2.7 - 2.2.9 broke a small number of systems. 

---

I didn't follow this, you may find more info on Alan Cox's site.


Good luck,

richard myers



Re: [newbie] lost info in bash prompt

1999-07-18 Thread Richard Myers


   On Sat, 17 Jul 1999, pauljw wrote:
I did some fiddling and had to put my home (user, not root) directory
back in place from a backup. Happily, everything worked save for the
bash prompt. It looks like: bash-2.03$. It used to show the user name
and the current directory. How can I get that back?
TIA,
-Paul-

On Sun, 18 Jul 1999, Richard Myers wrote:

I had a chance to explore the PS1 variable and the startup files in 
Linux. I found a very curious entry in a file called bashrc in the
/etc directory. This is the entire file:

-- 
# /etc/bashrc 
# System wide functions and aliases 
# Environment stuff goes in /etc/profile

# For some unknown reason bash refuses to inherit
# PS1 in some circumstances that I can't figure out.
# Putting PS1 here ensures that it gets loaded every time.

PS1="[\u@\h \W]\\$ "

alias which="type -path"
--

Sooo, this is apparently where the prompt is defined. It 
sure would be interesting to know who wrote the notation
there-- anyone know if this is in a /etc/bashrc file
in RedHat Linux?

Note that the same PS1 line appears in /etc/profile
so this variable is defined twice. No harm in that, the
last definition is used by the system.

Note that \$ gives a # if you are root, otherwise it
will print a $

I don't really like the results of the line

  PS1="[\u@\h \W]\\$ "

...because I (so far) haven't needed the hostname in my
prompt. Therefore I changed my prompt to:

  PS1="[ \W ] \u \\$ "

I think it is a bit less busy.

The normal order of startup that I am familiar with 
(that is, the order in which the files are read and
executed) would be:

  /etc/profile
  ~/.bash_profile

(where ~/ represents your home directory).

  ~/.bashrc

But with a /etc/bashrc file, the order is going
to be:

  /etc/profile
  /etc/bashrc
  ~/.bash_profile
  ~/.bashrc

(again, where ~/ represents your home directory).

Therefore, you can set global system variables (that is,
variables that are defined for all users) in the two
files in /etc, and these variables can (normally) be
redefined in the users' files.

QUESTION: What is the significance of the leading . in
.bash_profile and .bashrc ???

ANSWER: It prevents the file from being displayed by
the ls statement. To see these files (if they exist),
you have to use ls -a

This is to reduce clutter, and to protect these 
important system files from careless tampering.


best wishes,

richard myers



Re: [newbie] Problem...FreeBSD?

1999-07-18 Thread Richard Myers


On Sun, 18 Jul 1999, Mark E Hood wrote:

 I've kinda been fooling with FreeBSD, too. In what ways is it different than
 linux? Is it better? worse? 

Check out:

  http://slashdot.org/article.pl?sid=99/07/02/0537230mode=thread

(Slashdot synopsis)
  "In what
  has got to be one of the better pieces on the Linux vs. BSD
  debate Wes Peters talks about both OS's, the strengths
  and weakness of each, and how they live together to form a
  symbiotic circle. " 



best wishes,

richard myers