Subject: Linux Tips 002
=======================

===============================================================
Switches/options of commonly used commands.
===============================================================

(see man cmd, or cmd --help for more options/details)
===============================================================
Command       Description
================================================================
  ls                 Directory list
  ls -ltr            sorted by date, reverse order (comparable to dos "dir").
  ls --color=auto    turn on color for file types in directory list
  ls -1              one column list in directory
  ls -d .*           show only "." directories
ex: ls -ltr --color=auto

  du                Disk space used
  du -X             disclude files in "list".
  du -h .           Disk space used in this directory, in human readable
                    numbers.
  du -m .           Disk space used in this directory, in Megabytes
  du -c             Disk space used with total.
  du -hc            Disk space used with total, in human readable numbers.

ex: du -hc -X out.txt /home/ftp/pub* > /usr/local/bbbs/menus/bull5
  (out.txt: index.html
            dir2html.sh
            ziplist
            descript.ion
            descript.ion~
            dir2html.sh~
            index.html~
            files.bbs
            lost+found
  )
The above example will generate a decent File "overview" bulletin. It excludes
backup files (filename~) and other you may not want included.

  df                Disk space free
  df -h             Disk space free in human readable format, all drives.
  df -h .           Disk space free, current drive only.

===============================================================
How to Copy/Paste from the command line on a tty:
===============================================================

Hold down left mouse button, drag across text.  Place cursor in the location
where you'd like to copy the text.  Press right mouse button.


In X, you can do the same by highlighting text you want to copy with the
left mouse button, and you copy the text to the new location by pressing BOTH
mouse buttons simultaneously.  You can highlight the text on one window and
copy it to the command-line on another.


===============================================================
Notes about Archivers, etc.:
==============================================================
Archivers which you may have used under DOS are available:

name:                 date of last update for Linux:
zip                   10/13/98
unzip                 11/30/98
lha                    6/28/99
unarj                  6/22/99
pkzip251               4/15/99
arc                    5/29/99
rar                    5/28/99


===============================================================
Viewing multiple Archives:
===============================================================

As you probably know, unzip -v filename.zip will list the contents of one
archive.  To list the contents of multiple archives, enclose the argument in
quotes:

unzip -v "*.zip"

ex.: [bbs@jkracht bbbs]$ unzip -v "*.zip"

   Archive:  nodelist.zip
    Length   Method    Size  Ratio   Date   Time   CRC-32    Name
   --------  ------  ------- -----   ----   ----   ------    ----
    1706292  Defl:N   560625  67%  09-14-99 15:57  a18214bc  NODELIST.253
   --------          -------  ---                            -------
    1706292           560625  67%                            1 file

   Archive:  ppphowto.zip
    Length   Method    Size  Ratio   Date   Time   CRC-32    Name
   --------  ------  ------- -----   ----   ----   ------    ----
     158718  Defl:N    48642  69%  10-16-99 20:32  b4ad98a9  PPP-HOWTO
   --------          -------  ---                            -------
     158718            48642  69%                            1 file

   2 archives were successfully processed.



===============================================================
tar/gzip:
===============================================================
Tar and gzip are used commonly on Linux.  Often you'll see archives with
.tgz extensions, or no extension at all.  You can use the File command to
see how the file is archived/stored if there is no externsion or if you are
just curious:

[bbs@jkracht bbbs]$ file ZPMF025D.TGZ
ZPMF025D.TGZ: gzip compressed data, deflated, last modified: Thu Jun  8
04:55:16 1995, max compression, os: Unix

So you'd need to un-gzip this file first, then un-tar it.

gzip -d ZPMF025D.TGZ

 This results in the file ZPMF025.tar

To list the contents of the tar file, type tar -tf filename.tar
To extract the tar, type tar -xf filename.tar

There are options to "keep old files" with both gzip and tar which you may
also want to include on the command line.  The default action is to remove
the original tar. See tar --help, and gzip --h for more info.

Here's a shortcut to extract both the tar and gzip files in one command:

tar xvzf filename.tar.gz

   the "z" flag says "un-gzip before un-tarring".  The same flag works in
      reverse when tarring.


questions/comments:  Linux-User FidoNet Echo

by Janis Kracht (janis@filegate.net)

Back to the Links page