[conspire] Netzero/Breezy Badger

Rick Moen rick at linuxmafia.com
Thu Jan 12 13:40:51 PST 2006

Quoting John Andrews (jla1200 at netzero.net):

> Daniel  I don't know quite how to do the copying right. Is ~/Desktop the 
> correct path to the desktop?  

To the KDE "desktop" directory, yes.

> What is meant by "cannot stat ./root/Desktop/Netzero Internet"?

Read more closely, and you can probably figure this out.  The shell

  cp: cannot stat `./root/Desktop/Netzero': No such file or directory
  cp: cannot stat `Internet': No such file or directory

..when you had typed:

  $ cp ./root/Desktop/Netzero Internet ~/Desktop

Quick, what's the (normal) delimiter between items on a command line?
It's the space character, right?

(I'll bet a lightbulb is going on, in your mind, about now.)

Filenames with embedded space characters in them are valid but a tiny
bit troublesome, because you need to give them special treatment when 
talking about them to the shell, else the shell will misunderstand what
you're saying.

In this case, the shell though you told it to cp two things:


...to destination directory "~/Desktop".  So, you ask, how do you
disambiguate references to filenames containing spaces, when you're
talking to the shell?  Answer:  Using quotation marks around filenames.

   $ cp  "./root/Desktop/Netzero Internet"  ~/Desktop

However, there's a larger issue, here:  You actually don't need to
_type_ those quotation marks.  In fact, the fact that you encountered
that error reveals something important you REALLY need to know.  This is
something that I need to include in the "I installed Linux.  Now what?"
tutorial I keep meaning to write:

The bash shell, like all good shells, does filename completion.  You
_must, must, must_ train your mind/fingers to USE it.  This is something
I see almost all new Linux or BSD users stumbling over, and it's
frustrating to watch, because I know how much better their lives will
be, once they get it right.

I can tell, from what happened, that you must have typed that entire
command line, from beginning to end, complete file path and all, before
pushing Enter and seeing .  You _must_ learn to stop doing that.

Instead, you type one or two letters of a directory or filename, and hit
Tab.  Keep your eyes on the screen, and see if the directory or filename
automagically completes on your command line.  That is, you type

  $ cp ./ro

...and hit Tab.  The screen immediately updates to

  $ cp ./root/

...because the shell has figured out that the only possible qualifying
subirectory is "root", and therefore supplied the remaining letters.
Now, you continue to type, on the same uncompleted command line:

  $ cp ./root/D

...and hit Tab.  The screen immediately updates to

  $ cp ./root/Desktop/

...because the shell has figured out that the only possible qualifying
subirectory is "root/Desktop/".  Now. start typing again:

  $ cp ./root/Desktop/N

...and hit Tab.  The screen immediately updates to

  $ cp  "./root/Desktop/Netzero Internet"

Notice that the shell has retroactively gone back and prepended an
opening quotation mark?  The shell is talented.  The shell is your
friend (except when you tell it to do dumb things).  Use the shell:  
The shell will save you an _immense_ amount of typing, and also will
prevent you from ever, ever, EVER seeing "file not found", ever again.

If you _had_ trusted to the shell and used it for filename completion, 
you would not have encountered the error you did.  Thus the moral of my

Note:  There are fine points to filename completion.  If there had been 
also a "root/Dave" file, then typing 

  $ cp ./root/D

...and then Tab, would not (immediately) have impelled the shell to
automagically fill out your command line to "cp .root/Desktop", because
of the ambiguity.  Instead, it would fail to act.  _However_, if you
then hit Tab a second time (as in, I _really_ want you to complete that
name for me), it would display the matching choices, like this:

  Desktop/  Dave

You can then disambiguate by typing on additional letter:

  $ cp ./root/De

...and then Tab.  The shell now has only one possible candidate, having
ruled out "Dave", and so updates your partial command line:

  $ cp ./root/Desktop/

People who see me helping a new user who's typing commands at a shell
prompt will often see me saying "Hit Tab!  Hit Tab!" and reflexively
punching down my left hand, out of sheer frustration.  ;->

More information about the conspire mailing list