[SWLUG] Defrag and dir /p equivilents

Steve Hill steve at nexusuk.org
Wed Feb 22 22:20:03 UTC 2006


On Wed, 22 Feb 2006, Stephen wrote:

> had so many files and folders in it that an "ls" command returned too may for 
> one screen.  The screen was not scrollable.  Is there an equivalent to dos' 
> "dir /p" or "dir /w" commands.  I tried the help/man but it said nothing 
> about it.  This site was very informative as well but implies that what I 
> want to do cannot be done.

The unix methodology is to write many programs, each doing one thing well. 
You can then string them together using pipes to get the functionality you 
want (some commands are blurring this methodology a bit these days - e.g. 
tar accepts a 'j' option to tell it to compress it's output rather than 
expecting you to pipe it through bzip2, etc, but generally if a command 
doesn't have a function you're looking for you're probably expected to 
glue another command into the pipe line).

i.e. "ls" will output a lot of data.  "less" will accept a lot of data as 
input and present it in a nice scrollable display, so you can do:
   ls | less
which stuffs the output of ls into the input of less.

Similarly you can join lots of commands together, connecting each 
command's input to the next command's output.  i.e.:
   ls | sort | less

Pipes are possibly the single most useful invention from the Unix world - 
learning to use them makes everything so much more powerful and easier to 
use.

> Is there any defrag tool in Linux and if so what is it.  I am using Mandriva 
> 2006.  Is there any need to defrag.  Much controversy on the web.  Any direct 
> experiences you care to share.

I believe there is (somewhere) a defragmenter for the ext2 and ext3 
filesystems, but almost noone uses it - these filesystems are designed to 
reduce the need for fragmentation by spreading the files out a bit over 
the disk rather than allocating space linearly like FAT does.

The only times people need to worry too much about fragmentation on ext2/3 
filesystems is when the disk is almost full and you're doing a lot of 
deletion and addition of data to it in the remaining space, or if you're 
dealing with sparse files (some database people do this and have to keep 
an eye out for fragmentation - normal users will probably never see a 
sparse file)

-- 

  - Steve
    xmpp:steve at nexusuk.org   sip:steve at nexusuk.org   http://www.nexusuk.org/

      Servatis a periculum, servatis a maleficum - Whisper, Evanescence




More information about the Swlug mailing list