[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Newbie comments & queries



On Wed, Nov 07, 2001 at 12:35:19PM -0800, Karsten M. Self wrote:
> on Tue, Nov 06, 2001 at 05:42:51AM +0200, Ian Balchin (fables@imaginet.co.za) wrote:
> > Hi, all,
> > 
> > My last post seemed to have evaporated into thin air.  Tere have been no 
> > answers so imagine that you didn't see it either.
> > 
> > Dman, to answer you, I can print via lpr but nothing out of cat [file] > 
> > /dev/lp0 _unless_ I print from root when it works.
> 
> If you'll look at /dev/lp0, you'll probably find it looks like:
> 
>     crw-rw----  1 root   lp      6,   0 Jul 20  1998 /dev/lp0
> 
> ...which means it can only be written to by user root, or group lp.
> Generally, you want to print using the lpr command.

I will add my voice to this advice:  don't print by catting to
a /dev device.  Use lpr.  Generally, don't cat anything to a
/dev device.

BTW, items in /dev are the low-level device drivers (I think),
what would be .sys on a dos or windows machine.

> > The lpr switch -i appears to do nothing for the margin. Thus,

The bad news is, according to the lpr man page, "this option
is not supported on all printers".

> > # pr myfile -o6 | lpr

Well I didn't know about the pr command before... it
seems to be a filter for text files, and will re-arrange
the text file similarly to mpage, psnup, a2ps, enscript,
or any of the other postscript output re-arrangers.

That means it is the right tool to do your indenting,
and the above command is the right way to to it.
The pr command rearranges your text file, and the
lpr command prints the result.  The | symbol is
called the pipe symbol, and it takes the output
from the first command and feeds it to the input
of the second command.

> > THE FIRST BOOK OF UNIX by Douglas Topham (1990) is the only book on
> > the subject in the whole library service of the Eastern Cape Province
> > here, so have that out at the moment.  They found one title on Linux
> > also recorded, but cannot find it.  Lots of commands to try out.
> 
> Again, there are *tons* of useful docs available free of charge online,
> including packaged into Debian as HOWTOs, man pages, and info documents.
> A fully loaded Debian system has literally hundreds of volumes worth of
> documentation on it.  If you can't store it all locally, it's also
> available on the Web.

Hmm, 1990, that's a bit old.  Then again so is unix, so somethings
will remain the same, but many others will be different.  Get
in the habit of checking the man pages, HOWTOS, and other online
docs for anything you read in the book.

As for the "online" aspect of the man pages/docs/info pages,
I've found you have to install the package of interest in order
to view its info pages.  Not a problem for stuff like lpr or
ps, but... <gripe> I wanted to learn about fvwm before installing
it, and had to install it to read the pages. </gripe>

>     UNIX Power Tools

I can recommend this book.

>     Learning the Korn Shell

Korn Shell will have a lot of similarities with bash, so
it's useful to have this book.  I've got this one too.

> disk.  It's been known to float around the Web.  And you'll want to buy
> all the O'Reilly books you can get your paws on afterwards (I have...).

Me too.  Well, I haven't bought every one I've seen, but I'm
working on it :-)

For Debian, I also just got the Debian Unleashed book, it seems
useful.

> > When I run top the processes dissapear off the bottom of the page.  I
> > can find no key in the help to do this.  I nuked tty5 where I was
> > running it when I tried to pipe top through more or less.

The reason why top doesn't work through less/more is that
top gives repeating snapshots of the processes running on
the machine, and so is not suitable for piping through more
or less.  (I think top is a program wrapped around ps:  it
runs ps repeatedly and formats the output.)

What you can do with top is to narrow the number of processes
by choosing to show only processes belonging to a certain
user (type u into the term where top is running, then the
user name whose processes you want to see).  Also you can
change the order the processes are sorted, see the man
page and search for INTERACTIVE.  Surprisingly, the u
command isn't there, but it does work.

But narrowing the number of processes doesn't help you with
your task which is to see if the numbers add up.

The following suggestions from Karsten are commands that run
only once (take only 1 snapshot) and so are useful with less/more.

> There are several alternative commands you can use.
> 
> 'top' under Solaris, IIRC, would allow paging through the process list,
> which was helpful.  GNU top doesn't offer this.
> 
> You can toggle display of processes -- the 'h' key will give you a list
> of options you can run while doing 'top', notably display of idle
> processes.

Great stuff, learned something else.

> You can run a different command.
> 
>     $ ps aux | less 
> 
> ...will list all processes, and you can scroll up and down through the
> list.  Another neat command is pstree, which lists processes in a tree
> form.

pstree is another program wrapped around ps, it runs ps, and
then reformats the output to show which process is the "parent"
of which other processes - giving the tree form.

> > With 16Mb ram, I have about 1 left when running logged in as root on
> > tty5 and as user on tty1.  Is that not an excessive consumption for a
> > shell that is not actually doing anything (top, of course).  What does
> > that actually mean?  Without being able to see the bottom of top (!) I
> > cannot add the figures up to see if they add up.
> 
> Post output of:
> 
>     $ free
> 
> GNU/Linux uses memory effectively.  That is, it uses it, for various
> tasks, which it will then give up if needed.  Your system is supporting
> processes in memory, shared memory, and cached access to your
> filesystem, as well as processes swapped to disk.  Don't worry about
> what top reports.  If your system bogs down and there's a lot of disk
> access,                             you're in a memory starved situation.
          then that's how you'll know

Ie, the system gobbled up all that memory, so that when you run
your process it can give your process some of the memory it has.
Sort of.  You can't assess linux system performance this way like
you can in DOS.  Apples and oranges.  However it is a useful exercise
to familiarise yourself with what a healthy running system looks like,
so you can recognise an unhealthy one (excessive disk activity
being an unhealthy symptom, meaning you're running out of memory
and the system is swapping to disk a lot - "thrashing").

-- 
bjb@achilles.net



Reply to: