Chapter 2. UNIX File System Introduction- File System Layout, file and ls Commands

CONTENTS

Chapter 2. UNIX File System Introduction- File System Layout, file and ls Commands

  •  The Basics of UNIX
  •  File Types
  •  The file Command
  •  The ls Command
  •  File System Layout
  •  Linux File System Layout
  •  Manual Pages for Some Commands Used in Chapter 2

The Basics of UNIX

Nearly everything in UNIX comes down to files and directories. If you understand the hierarchical UNIX file system layout and how to manipulate files and directories, then you're a long way toward understanding UNIX.

A lot goes into working with UNIX files and directories. This chapter covers the basics and background of files and directories in UNIX, including:

  • The file command

  • The ls command

  • The file system layout

There are references to a number of UNIX operating systems in this chapter including Linux, because the commands covered apply to nearly all UNIX variants.

graphics/02icon01.gif

The next chapter covers commands related to files and directories. The only commands covered in this chapter are the file and ls commands. file is used to determine the type of file and ls is used to list files and directories.

File Types

A file is a means by which information is stored on a UNIX system. The commands you issue, the applications you use, the data you store, and the devices you access such as printers and keyboard are all contained in files. This is one aspect of UNIX that makes it both simple and complex; simple because you know everything out there is a file, complex because the contents of a file could be anything ranging from ASCII text files to executable programs.

Every file on the system has a file name. The operating system takes care of all file-system-related tasks; you just need to know the name of the file and how to use it. Many types of files are on UNIX systems. Some file types are peculiar to the UNIX variant you are using. Device files, for instance, contain information about the specific hardware platform on which you are running your UNIX variant. In general, however, most file types are similar going from system to system. The file types we will look at are:

  • Text Files

  • Data Files

  • Source Code Files

  • Executable Files

  • Shell Programs

  • Links

  • Device Files

Many times when you are dealing with various types of files, there are extensions associated with those files. Many applications, for instance, associate a specific extension with that application. Text files sometimes have a.txt extension. Most C source code programs have a.c extension, and most C++ programs have a.cc extension. Although the extension can be useful for determining the type of a file, no written requirements state that a particular type of file must contain an assigned extension or that you must have any extension at all.

The following table shows some commonly used extensions for various types of files:

Extension

File Type

.1 to .n

Online manual source.

.a

An archive or library.

.c

C program source.

.cc

C++ program source.

.csh

C shell script.

.f

FORTRAN program source.

.ksh

Korn shell script.

.o

Object file of compiled source.

.ps

Postscript source.

.1 to .n

Online manual source.

.shar

Shell archive.

.sh

Bourne shell script.

.tar

tar archive.

.txt

ASCII text file.

.Z

Compressed file.

graphics/02icon01.gif

A useful technique for determining the file type is to use the file command. Most UNIX variants support the file command, although the outputs differ somewhat, so I suggest that you use the file command to determine file type. The best way to learn about file types and the file command is through example, which we'll do later in this chapter after discussing some common file types in more detail.

Text Files

What could be simpler than a file that contains characters, just like the ones you're now reading in this chapter? These ASCII characters are letters and numerals that represent the work you perform. If, for instance, you use a UNIX editor to create an electronic mail message or a letter, you are creating a text file in most cases. Here is an example of part of an ASCII text file from a Linux system:

Thu Nov  5 07:29:53 1999 debug: FTS: appending  /dev/hda1   Thu Nov  5 07:29:53 1999 debug: FTS: appending  /tmp/LST/swap.sel   Thu Nov  5 07:29:53 1999 debug: Building partition-list with argument <Linux>  Thu Nov  5 07:29:53 1999 debug: Respecting exclude file /tmp/LST/targets.sel:  /dev/hdd  /dev/hda1  /dev/hda2  Thu Nov  5 07:29:53 1999 debug: No ADDITIONAL partitions available  Thu Nov  5 07:29:59 1999 debug: added  8390  to  /root/tmp/modules.handled   Thu Nov  5 07:29:59 1999 debug: added  8390  to  '/root/etc/modules/2.0.29/#1 Tue  Feb 11 20:36:48 MET 1997.default   Thu Nov  5 07:29:59 1999 debug: added  scsi_mod  to  /root/tmp/modules.handled   Thu Nov  5 07:29:59 1999 debug: added  scsi_mod  to  /root/etc/modules/2.0.29/#1  Tue Feb 11 20:36:48 MET 1997.default   Thu Nov  5 07:29:59 1999 debug: added  sd_mod  to  /root/tmp/modules.handled   Thu Nov  5 07:29:59 1999 debug: added  sd_mod  to  /root/etc/modules/2.0.29/#1 Tue  Feb 11 20:36:48 MET 1997.default   Thu Nov  5 07:29:59 1999 debug: added  sr_mod  to  /root/tmp/modules.handled   Thu Nov  5 07:29:59 1999 debug: added  sr_mod  to  /root/etc/modules/2.0.29/#1 Tue  Feb 11 20:36:48 MET 1997.default   Thu Nov  5 07:29:59 1999 debug: added  st  to  /root/tmp/modules.handled   Thu Nov  5 07:29:59 1999 debug: added  st  to  /root/etc/modules/2.0.29/#1 Tue Feb  11 20:36:48 MET 1997.default   Thu Nov  5 07:29:59 1999 debug: added  sg  to  /root/tmp/modules.handled   Thu Nov  5 07:29:59 1999 debug: added  sg  to  /root/etc/modules/2.0.29/#1 Tue Feb  11 20:36:48 MET 1997.default   Thu Nov  5 07:29:59 1999 debug: added  nfs  to  /root/tmp/modules.handled   Thu Nov  5 07:29:59 1999 debug: added  nfs  to  /root/etc/modules/2.0.29/#1 Tue  Feb 11 20:36:48 MET 1997.default   Thu Nov  5 07:29:59 1999 debug: added  isofs  to  /root/tmp/modules.handled   Thu Nov  5 07:29:59 1999 debug: added  isofs  to  /root/etc/modules/2.0.29/#1 Tue  Feb 11 20:36:48 MET 1997.default   Thu Nov  5 07:29:59 1999 debug:  isofs  is already handled  Thu Nov  5 07:29:59 1999 debug:  nfs  is already handled  Thu Nov  5 07:29:59 1999 debug:  sg  is already handled  Thu Nov  5 07:29:59 1999 debug:  st  is already handled 

Data Files

A file that contains data used by one of your applications is a data file. If you use a sophisticated desktop publishing tool such as FrameMaker to write a book, you create data files that FrameMaker uses. These data files contain data, which you can usually read, and formatting information, which you can sometimes read but is usually hidden from you. If your UNIX installation uses a database program, then you may have data files that you can partially read.

Source Code File

A source code file is a text file that contains information related to a programming language such as C, C++, Pascal, FORTRAN, and so on. These files are readable - at least to the programmer who wrote it. When a programmer develops a source code file, they create a file that conforms to the naming convention of the program language being used, such as adding a ".c" to the end of the file if creating a C program.

The following is an example of a C source code file:

/* this is K &R sortprogram */  # include <stdio.h>  # include <stdlib.h>         int N;         int v[1000000];        /* v is array to be sorted */         int left = 0;          /* left pointer */         int right;         int swapcount, comparecount = 0;                                /* count swaps and compares*/         int i, j, t;         char print;         char pr_incr_sorts;  main()  {    printf("Enter number of numbers to sort : ");     scanf("%10d", &N);                    /* 10d used for a BIG input */     printf ("\n");                            /* select type of input to sort */     printf("Enter rand(1), in-order(2), or reverse order (3)    sort : ");     scanf("%2d", &type);     printf ("\n");                        /* select type of input to sort */     if (type == 3)                 for (i=0; i<N; ++i)       /* random        */                      v[i]=(N -i);     else if (type == 2)                 for (i=0; i<N; ++i)                      v[i]= (i + 1);        /* in order       */     else if (type == 1)                 for (i=0; i<N; ++i)                       v[i]=rand();          /* reverse order */     fflush(stdin);     printf("Do you want to see the numbers before sorting (y or n)? : ");     scanf("%c", &print);     printf ("\n");                        /* View unsorted numbers?  */     if (print == 'y')        {             printf ("\n");           for (i=0; i<N; ++i)              printf("a[%2d]= %2d\n", i, v[i]);              printf ("\n");        }     fflush(stdin);    printf("Do you want to see the array at each step as it sorts? (y or n)? : ");     scanf("%c", &pr_incr_sorts);     printf ("\n");                     /* View incremental sorts?  */        right = N-1;                    /* right pointer           */                   qsort(v, left, right);     {       fflush(stdin);        printf ("Here is the sorted list of %2d items\n", N);            printf ("\n");        for (i=0; i<N; ++i)            printf ("%2d\n ", v[i]);            printf ("\n");            printf ("\n");                /* print sorted list */                   }                      printf ("number of swaps = %2d\n ", swapcount);                      printf ("number of compares = %2d\n ", comparecount);      }  /* qsort function */            void qsort( v, left, right)                          int v[], left, right;      {                  int i, last;                   if (left > right)                    return;                   swap(v, left, (left + right)/2);                   last = left;                   for (i=left+1; i <= right; i++)                   {                     comparecount = ++comparecount;                        if (v[i] < v[left])                   swap(v, ++last, i);                   }                   swap(v, left, last);                   qsort(v, left, last-1);                   qsort(v, last+1, right);                  }                  /* swap function */                   swap(v, i, j)                      int v[], i, j;                     {int temp;                        swapcount = swapcount++;                        temp = v[i];                        v[i] = v[j];                        v[j] = temp;   if (pr_incr_sorts == 'y')      {                  printf("Incremental sort of array = ");         printf ("\n");         for (i=0; i<N; ++i)            printf("a[%2d]= %2d\n", i, v[i]);            printf ("\n");      }  } 

Executable Files

Executable files are compiled or interpreted programs that can be run. You can't read executable files and you'll typically get a bunch of errors, unreadable characters, and beeps from your UNIX system when you try to look at one of these. You may also lose your screen settings and cause other problems.

You don't have to go far in UNIX to find executable files; they are everywhere. Many of the UNIX commands you issue are executable files that you can't read. In addition, if you are developing programs on your system, you are creating your own executables.

Here is an example of what you see if you attempt to send an executable to the screen:

unknown/etc/ttytyperunknown<@=>|<@=>|:unknown<@=>  callocLINESCOLUMNSunknownPackaged for  argbad aftger%3  parmnumber missing <@=>|<@=>|:  @ @ 3### @@@A:2TTO|>@#<|2X00R  EraseKillOOPS<@=>|<@=>|:  <@=>|<@=>|:  <@=>|<@=>|:<@=>|ATOO<@=>|:<@=>|<@=>|:<@=>|<@=>|:<@=>|<@=  >|: 

Shell Programs

A shell program is both a file you can run to perform a task and a file that you can read. So yes, even though you can run this file because it is executable, you can also read it. I'm going to describe shell programming in more detail in an upcoming chapter.

I consider shell programming to be an important skill for every user to have. I'll spend some time going over the basics of shell programming. Some of the background I'm about to cover relating to file types and permissions is important when it comes to shell programming, so this is important information for you to understand.

Here is an example of part of a shell program that performs an audit of a system:

#!/bin/sh  { echo "PROG>>>>> determining if Ignite-UX loaded on sys tem."  igtest=`swlist  | grep Ignite`  echo $igtest  if [ -n "$igtest" ]; then  echo "Ignite-UX installed"  else  echo "Ignite-UX is not installed"  fi  echo "PROG>>>>> determining if make_recovery has been run  by               checking for /var/opt/ignite/arch.include."  if [ -f /var/opt/ignite/recovery/arch.include ]; then  echo "make_recovery has been run."  else  echo "make_recovery has not been run."  fi  echo "PROG>>>>> determining if make_recovery was run with  the               -C (for check_recovery) option."  if [ -f /var/opt/ignite/recovery/makrec.last ]; then  echo "make_recovery with -C has been run. We'll now               run check_recovery."  /opt/ignite/bin/check_recovery 2>&1  else  echo "make_recovery with -C has not been run. We can't               run check_recovery."  fi  }  | tee -a /tmp/IMPORTANT/igtest.out 

The shell program is text you can read and modify if indeed you have permission to do so. In addition to programming information, shell programs contain comments indicated by lines beginning with a #.

Links

A link is a pointer to a file stored elsewhere on the system. Instead of having two or more copies of a file on your system, you can link to a file that already exists on your system.

One particularly useful way links have been used in UNIX is related to new releases of the operating system. The locations of files sometimes change going from one release to another, and rather than learn all the new locations, you can use links which are produced from the old location to the new one. When you run a command using the old location, the link points to the new location.

Links are also useful for centralizing files. If a set of identical files has to be updated often, it is easier to link to a central file and update it, rather than having to update several copies of the file in several different locations.

Device Files

Device files, sometimes called device special files, contain information about the hardware connected to your system. Because device special files are associated with system administration functions, they are usually not covered much in user, as opposed to system administration, material. I think the situation should be otherwise. It is very frustrating for a user to want to write a file to a floppy disk or a tape and not have any idea how to access a device file. I'll cover some use of device files so you are not completely in the dark in this area.

Devices on your system can often be accessed with different device files. A disk, for instance, can be accessed with either a block device file or a character device file. Most of this access is the responsibility of your system administrator; however, when you attempt to determine the file type, you may encounter special files of different types such as character and block.

Other types of files are on your system as well, but for the purposes of getting started with UNIX, the file types which I will describe supply sufficient background to get you started.

The file Command

graphics/02icon01.gif

The file command is used to determine the file type. This command is useful because the name of a file does not always indicate its file type. The following examples perform a long listing of a file to provide some background information on the file, and then the file command is run to show the file type. I don't cover the command used to list files until the next chapter, but I include it in these examples. The ls command provides a listing of files. ls is covered in detail in the next chapter. We need to use it in this chapter in only its basic form. I have included the man page for ls at the end of this chapter if you need to view it. Combined with the "-l" option, you can produce a long listing that provides a lot of information about files. Using ls -l in the following examples, you will see the name of each file, file type, permissions, number of hard links, owner name, group name, size in bytes, and time stamp. You may not know what much of this information is for now; however, some of this information may be useful when viewing the output of the file command. Examples in this chapter for the file command show that different UNIX variants may produce somewhat different outputs of the file command . The following examples show an HP-UX output for the "UNIX example" and then a Linux output where available.

Text File (UNIX example)

(Described by the file command as ascii text.)

graphics/02icon01.gif

 

graphics/02icon02.gif

# ls -l .mosaic-global-history  -rw-r--r--   1 201      users         587 Dec 22  1999 .mosaic- global-history  # file .mosaic-global-history  .mosaic-global-history: ascii text  # 

Text File (Linux example)

(Described by the file command as ASCII text.)

# ls -l *  -rw-r--r--   1 root      root       251367 Nov 5 07:11 debug  -rw-r--r--   1 root      root         2020 Nov 5 07:11 history  # file *  debug:     ASCII text  history:    ASCII text 

Data File (UNIX example)

(Described by the file command as data.)

# ls -l Static.dat  -rw-r--r--   1 201     users     235874 Aug 26  1999 Static.dat  # file Static.dat  Static.dat:     data  # 

Source Code File (UNIX example)

(Described by the file command as c program text.)

# ls -l krsort.c  -rwxrwxrwx   1 201      users       3234 Nov 16  1999 krsort.c  # file krsort.c  krsort.c:       c program text  # 

Source Code File (Linux example)

(Described by the file command as C program text.)

graphics/02icon01.gif

 

graphics/02icon02.gif

# ls -l *.c  -rw-r--r--   1 root    root          4521 Jul 12  1999 intl-bindtextdom.c  -rw-r--r--   1 root    root          6234 Jul 12  1999 intl-cat-compat.c  -rw-r--r--   1 root    root         14128 Jul 12  1999 intl-dcgettext.c  -rw-r--r--   1 root    root          1750 Jul 12  1999 intl-dgettext.c  -rw-r--r--   1 root    root         12759 Jul 12  1999 intl-finddomain.c  -rw-r--r--   1 root    root          1907 Jul 12  1999 intl-gettext.c  -rw-r--r--   1 root    root          1646 Jul 12  1999 intl-intl-compat.c  -rw-r--r--   1 root    root          5361 Jul 12  1999 intl-loadmsgcat.c  -rw-r--r--   1 root    root          7271 Jul 12  1999 intl-localealias.c  -rw-r--r--   1 root    root          2914 Jul 12  1999 intl-textdomain.c  # file *.c  intl-bindtextdom.c: C program text  intl-cat-compat.c:  C program text  intl-dcgettext.c:   C program text  intl-dgettext.c:    C program text  intl-finddomain.c:  C program text  intl-gettext.c:     C program text  intl-intl-compat.c: C program text  intl-loadmsgcat.c:  C program text  intl-localealias.c: C program text  intl-textdomain.c:  C program text  # 

Executable File (UNIX example)

(Described by the file command as shared executable.)

# ls -l krsort  -rwxr-xr-x   1 201      users      34592 Nov 16  1999 krsort  # file krsort  krsort:         PA-RISC1.1 shared executable dynamically linked  -not stripped  # 

Executable File (Linux example)

(Described by the file command as executable.)

# ls -l a*  -rwxr-xr-x   1 root     root         3888 Jul 24  1999 activate  -rwxr-xr-x   1 root     root         4452 Feb 25  1999 adjtimex  # file a*  activate: ELF 32-bit LSB executable, Intel 80386, version 1,  stripped  adjtimex: ELF 32-bit LSB executable, Intel 80386, version 1,  stripped  # 

Shell Program (UNIX example)

graphics/02icon02.gif

(Described by the file command as commands text.)

graphics/02icon01.gif

# ls -l llsum  -rwxrwxrwx   1 root     sys         1267 Feb 23 1999 llsum  # file llsum  llsum:          commands text  # 

graphics/02icon03.gif

Shell Program (Linux example)

(Described by the file command as Bourne shell script text.)

# ls -l request-route  -rwx------  1 root    root        1046 Sep 19  1999 request-route  # file request-route  request-route: Bourne shell script text  # 

Link (UNIX example)

(The link is not referenced by the file command; this is shown as a shared executable dynamically linked. The reference to dynamically linked does not mean that this is a link.)

# ls -l /usr/bin/ar  lr-xr-xr-t   1 root       sys            15 Mar 23 1999 ar -> /  usr/ccs/bin/ar  # file /usr/bin/ar  /usr/bin/ar:            s800 shared executable dynamically linked  # 

Link (Linux example)

(The link shown is a symbolic link.)

graphics/02icon02.gif

 

graphics/02icon01.gif

# ls -l reboot  lrwxrwxrwx  1 root   root          4 Nov 5 01:31 reboot -> halt  # file * | grep link  depmod:            symbolic link to modprobe  ksyms:             symbolic link to insmod  pidof:             symbolic link to killall5  reboot:            symbolic link to halt  rmmod:             symbolic link to insmod  swapoff:           symbolic link to swapon  telinit:           symbolic link to init  udosctl:           symbolic link to /sbin/umssync  umssetup:          symbolic link to /sbin/umssync  # 

Block Device File (UNIX example)

(Described by the file command as block special.)

# ls -l /dev/dsk/c0t1d0  brw-r--r--   1 bin     sys       31 0x001000 Apr 17 1999 /dev/  dsk/c0t1d0  # file /dev/dsk/c0t1d0  /dev/dsk/c0t1d0:        block special (31/4096)  # 

Block Device File (Linux example)

(Described by the file command as block special.)

# ls -l loop*  brw-rw----   1 root    disk      7,  0 Sep 23  1999 loop0  brw-rw----   1 root    disk      7,  1 Sep 23  1999 loop1  brw-rw----   1 root    disk      7,  2 Sep 23  1999 loop2  brw-rw----   1 root    disk      7,  3 Sep 23  1999 loop3  brw-rw----   1 root    disk      7,  4 Sep 23  1999 loop4  brw-rw----   1 root    disk      7,   5 Sep 23  1999 loop5  brw-rw----   1 root    disk      7,   6 Sep 23  1999 loop6  brw-rw----   1 root    disk      7,   7 Sep 23  1999 loop7  # file loop*  loop0: block special (7/0)  loop1: block special (7/1)  loop2: block special (7/2)  loop3: block special (7/3)  loop4: block special (7/4)  loop5: block special (7/5)  loop6: block special (7/6)  loop7: block special (7/7)  # 

graphics/02icon01.gif

Character Device File (UNIX example)

(Described by the file command as character special.)

graphics/02icon02.gif

# ls -l /dev/rdsk/c0t1d0  crw-r-----   1 root    sys      188 0x001000 Mar 23  1999 /dev/  rdsk/c0t1d0  # file /dev/rdsk/c0t1d0  /dev/rdsk/c0t1d0:       character special (188/4096)  # 

Character Device File (Linux example)

(Described by the file command as character special.)

# ls -l mi*  crw-rw-rw-   1 root     sys       14,   2 Sep 23  1999 midi00  crw-rw-rw-   1 root     sys       14,  18 Sep 23  1999 midi01  crw-rw-rw-   1 root     sys       14,  34 Sep 23  1999 midi02  crw-rw-rw-   1 root     sys       14,  50 Sep 23  1999 midi03  crw-rw-rw-   1 root     sys       14,   0 Sep 23  1999 mixer  crw-rw-rw-   1 root     sys       14,  16 Sep 23  1999 mixer1  # file mi*  midi00: character special (14/2)  midi01: character special (14/18)  midi02: character special (14/34)  midi03: character special (14/50)  mixer:  character special (14/0)  mixer1: character special (14/16)  # 

The ls Command

graphics/02icon02.gif

The ls command brings with it a lot to discuss. I haven't yet described the options to ls, yet we have already used this command and the -l option as part of the file command discussion. You can't do much on a UNIX system without ls, so I'll cover it now. The best way to cover the most important options to ls is to show examples. I do just that in the upcoming description of the ls command.

ls

The following is an example of ls without any options other than the directory to list:

# ls /home/denise  27247b.exe  410pt1.exe  410pt2.exe  41ndir.exe  41nds1.exe  41nds4.exe  41nwad.exe  41rtr2.exe  HPDA1.EXE  Mail  N3212B6.EXE  SCSI4S.EXE  clean  clean2  clean3  content.exe  dsenh.exe  eg1  eg2  en0316bz.exe  en0316tb.exe  explore.exe  flexi_cd.exe  fred.h  hal.c  hpdl0117.exe  hpdlinst.txt  hpux.patches  j2577a.exe  ja95up.exe  msie10.exe  n32e12n.exe  nfs197.exe  pass.sb  plusdemo.exe  ps4x03.exe  psg  quik_res.exe  rclock.exe  rkhelp.exe  roni.mak  sb.txt  smsup2.exe  softinit.remotesoftcm  srvpr.exe  steve.h  target.exe  tcp41a.exe  tnds2.exe  upgrade.exe  whoon  win95app.exe  total 46718 

graphics/02icon02.gif

Which of these are files? Which are directories? Have all of the entries been listed? There are many options to ls that will answer these questions.

There is not a lot of information reported as a result of having issued this command. ls lists the contents of the directory specified, or the current working directory if no directory is specified.

ls -a

graphics/02icon02.gif

To list all the entries of a directory, you would use the -a option. Files that begin with a "." are called hidden files and are not usually listed with ls. The following example shows the output of ls -a:

$ ls -a /home/denise  .Xauthority  .cshrc  .dt  .dtprofile  .elm  .exrc  .fmrc.orig  .glancerc  .gpmhp  .history  .login  .lrom  .mailrc  .netscape-bookmarks.html  .netscape-cache  .netscape-cookies  .netscape-history  .netscape-newsgroups-news.spry.com  .netscape-newsgroups-newsserv.hp.com  .netscape-preferences  .newsrc-news.spry.com  .newsrc-newsserv.hp.com  .profile  .rhosts  .sh_history  .softbuildrc  .softinit.orig  .sw  .xinitrc  .xsession  27247b.exe  410pt1.exe  410pt2.exe  41ndir.exe  41nds1.exe  41nds4.exe  41nwad.exe  41rtr2.exe  HPDA1.EXE  Mail  N3212B6.EXE  SCSI4S.EXE  clean  clean2  clean3  content.exe  dsenh.exe  eg1  eg2  en0316bz.exe  en0316tb.exe  explore.exe  flexi_cd.exe  fred.h  hal.c  hpdl0117.exe  hpdlinst.txt  hpux.patches  j2577a.exe  ja95up.exe  msie10.exe  n32e12n.exe  nfs197.exe  pass.sb  plusdemo.exe  ps4x03.exe  psg  quik_res.exe  rclock.exe  rkhelp.exe  roni.mak  sb.txt  smsup2.exe  softinit.remotesoftcm  srvpr.exe  steve.h  target.exe  tcp41a.exe  tnds2.exe  upgrade.exe  whoon  win95app.exe  total 46718 

graphics/02icon02.gif

Notice that this output includes hidden files, those that begin with a ".", as well as all other files listed with just ls. These did not appear when ls was issued without the -a option. All subsequent examples include the -a option.

ls -l

To list all information about the contents of directory, you use the -l option to ls, as shown in the following example (some of these file names were shortened to fit on the page):

$ ls -al /home/denise  -rw-------  1 denise  users       98 Oct 6 09:19 .Xauthority  -r--r--r--  1 denise  users      814 May 19 10:10 .cshrc  drwxr-xr-x  7 denise  users     1024 Sep 26 11:14 .dt  -rwxr-xr-x  1 denise  users     8705 Jul 7 12:04 .dtprofile  drwx------  2 denise  users     1024 Jul 31 18:48 .elm  -r--r--r--  1 denise  users      347 May 19 10:10 .exrc  -rwxrwxrwx  1 denise  users      170 Jun 6 14:20 .fmrc.orig  -rw-------  1 denise  users       97 Jun 12 18:59 .glancerc  -rw-------  1 denise  users    17620 Sep 21 16:11 .gpmhp  -rwxr-xr-x  1 denise  users      391 Sep 19 09:55 .history  -r--r--r--  1 denise  users      341 May 19 10:10 .login  drwx--x--x  2 denise  users     1024 Jul 31 18:48 .lrom  -rw-r--r--  1 denise  users      768 Jul 28 12:54 .mailrc  -rw-------  1 denise  users     1450 Oct 6 13:58 .netscape-bookmarks.html  drwx------  2 denise  users    10240 Oct 10 15:24 .netscape-cache  -rw-------  1 denise  users       91 Sep 18 14:16 .netscape-cookies  -rw-------  1 denise  users    43906 Oct 10 15:32 .netscape-history  -rw-r--r--  1 denise  users       566 Aug 25 14:36 .netscape--news.spry.com  -rw-------    denise  users     46514 Jun 28 12:35 .netscape-.hp.com  -rw-------  1 denise  users      1556 Sep 28 15:02 .netscape-preferences  -rw-------  1 denise  users       104 Jul 11 11:01 .newsrc-news.spry.com  -rw-r--r--  1 denise  users       223 Sep 26 13:26 .newsrc-newv.hp.com  -r--r--r--  1 denise  users       446 May 19 10:10 .profile  -rw-------  1 denise  users        21 Jul 6 13:21 .rhosts  -rw-------  1 denise  users      2328 Oct 10 15:22 .sh_history  -rw-r--r--  1 denise  users      1052 Sep 22 15:00 .softbuildrc  -rwxrwxrwx  1 denise  users       161 Jul 11 12:19 .softinit.orig  drwxr-xr-x  3 denise  users      1024 Aug 31 15:44 .sw  -rw-------  1 denise  users        23 Jun 2 15:01 .xinitrc  -rwxr-xr-x  1 denise  users     11251 May 19 10:41 .xsession  -rw-r--r--  1 denise  users    611488 Oct 3 12:00 27247b.exe  -rw-r--r--  1 denise  users    114119 Sep 29 12:49 410pt1.exe  -rw-r--r--  1 denise  users    136979 Sep 29 12:53 410pt2.exe  -rw-r--r--  1 denise  users    173978 Sep 29 12:40 41ndir.exe  -rw-r--r--  1 denise  users    363315 Sep 29 12:52 41nds1.exe  -rw-r--r--  1 denise  users    527524 Sep 29 12:57 41nds4.exe  -rw-r--r--  1 denise  users   1552513 Sep 29 12:50 41nwad.exe  -rw-r--r--  1 denise  users    853424 Sep 29 12:24 41rtr2.exe  -rw-r--r--  1 denise  users   1363011 Sep 20 12:20 HPDA1.EXE  drwx------  2 denise  users        24 Jul 31 18:48 Mail  -rw-r--r--  1 denise  users   1787840 Aug 31 09:35 N3212B6.EXE  -rw-r--r--  1 denise  users     13543 Sep 23 09:46 SCSI4S.EXE  -rw-r--r--  1 denise  users     28395 Aug 30 15:07 cabview.exe  -rwx--x--x  1 denise  users        66 Jun 8 17:40 clean  -rwx--x--x  1 denise  users        99 Jun 20 17:44 clean2  -rwx--x--x  1 denise  users        66 Jun 20 17:51 clean3  -rw-r--r--  1 denise  users     15365 Aug 30 15:07 content.exe  -rw-r--r--  1 denise  users    713313 Sep 29 12:56 dsenh.exe  -rwx------  1 denise  users       144 Aug 14 17:10 eg1  -rwx------  1 denise  users       192 Aug 15 12:13 eg2  -rw-r--r--  1 denise  users    667890 Sep 20 12:41 en0316bz.exe  -rw-r--r--  1 denise  users    641923 Sep 20 12:42 en0316tb.exe  -rw-r--r--  1 denise  users      6251 Aug 30 15:07 explore.exe  -rw-r--r--  1 denise  users     23542 Aug 30 15:08 flexi_cd.exe  -rw-r--r--  1 denise  users        30 Aug 14 17:02 fred.h  -rw-r--r--  1 denise  users         0 Aug 14 17:24 hal.c  -rw-r--r--  1 denise  users    895399 Sep 20 12:32 hpdl0117.exe  -rw-r--r--  1 denise  users     14135 Sep 20 12:39 hpdlinst.txt  -rw-------  1 denise  users      2943 Jun 19 14:42 hpux.patches  -rw-r--r--  1 denise  users    680279 Sep 20 12:26 j2577a.exe  -rw-r--r--  1 denise  users    930728 Sep 20 15:16 ja95up.exe  -rw-r--r--  1 denise  users     53575 Oct 10 10:37 mbox  -rw-r--r--  1 denise  users   1097728 Aug 30 15:03 msie10.exe  -rw-r--r--  1 denise  users   1790376 Sep 18 14:32 n32e12n.exe  -rw-r--r--  1 denise  users   1393835 Sep 29 12:59 nfs197.exe  -rw-------  1 denise  users       977 Jul 3 14:25 pass.sb  -rw-r--r--  1 denise  users   1004544 Aug 30 15:00 plusdemo.exe  -rw-r--r--  1 denise  users    229547 Sep 29 12:27 ps4x03.exe  -rwxr--r--  1 denise  users       171 Aug 9 13:43 psg  -rw-r--r--  1 denise  users     16645 Aug 30 15:08 quik_res.exe  -rw-r--r--  1 denise  users     14544 Aug 30 15:08 rclock.exe  -rw-r--r--  1 denise  users   2287498 Aug 30 15:12 rkhelp.exe  -rw-r--r--  1 denise  users         0 Aug 15 12:10 roni.mak  -rw-r--r--  1 denise  users      1139 Sep 28 10:35 sb.txt  -rw-r--r--  1 denise   sers    569855 Sep 29 12:55 smsup2.exe  -rw-------  1 root    sys         161 Jul 11 12:18 softinit.remotesoftcm  -rw-r--r--  1 denise  users        39 Sep 29 12:48 srvpr.exe  -rw-r--r--  1 denise  users        38 Aug 15 12:14 steve.h  -rw-r--r--  1 denise  users     14675 Aug 30 15:08 target.exe  -rw-r--r--  1 denise  users    229630 Sep 29 12:54 tcp41a.exe  -rw-r--r--  1 denise  users   1954453 Sep 29 12:26 tnds2.exe  -rw-r--r--  1 denise  users    364270 Sep 23 09:50 upgrade.exe  -rwx-----x  1 denise  users        88 Aug 9 13:43 whoon  -rw-r--r--  1 denise  users    191495 Aug 30 15:00 win95app.exe  total 46718 

graphics/02icon02.gif

Because I find this to be the most commonly used option with the ls command, I describe each of the fields produced by ls -l. I'll use the earlier example of the ls -l command, which showed only one file when describing the fields:

$ ls -l sort  -rwxr-x--x   1 marty     users     120 Jul 26 10:20 sort 

The first field defines the access rights of the file, which I covered in "Permissions" in an earlier chapter. The owner has read, write, and execute permissions on the file. The group has read and execute permissions on the file. The other has execute permissions.

The second field is the link count. This lists how many files are symbolically linked to the file. We will get into the details of the ln command used to link files later. In this case, the link count is 1, which means that this file is linked only to itself. For directories such as.dt shown below, the number of subdirectories is shown rather than the link count. This number includes one for the directory itself as well as one for the parent directory. This means that a total of five directories are below.dt.

drwxr-x--x   7 denise      users    1024 Jul 26 10:20 .dt 

The subdirectories below /home/denise/.dt are:

/home/denise/.dt/Desktop  /home/denise/.dt/appmanager  /home/denise/.dt/palettes  /home/denise/.dt/sessions  /home/denise/.dt/types 

These five subdirectories plus the directory itself and the parent directory make a total of seven.

The third field lists the owner of the file. Your login name, such as denise, is listed here. When you create a file, your login name is listed by default as the owner of the file.

The fourth field lists the group to which the file belongs. Groups were covered earlier in " Permissions."

The fifth field shows the size of the file. The file sort is 120 bytes in size.

The sixth field (which includes a date and time such as Jul 26 10:20) lists the date and time the file was created or last changed.

The seventh field lists the files and directories in alphabetical order. You first see the files that begin with a ".", then the files that begin with numbers, then the files that begin with uppercase letters, and finally the files that begin with lowercase letters. There are a lot of characters a file can begin with in UNIX, so if you perform an ls -l and don't see the file you are looking for, it may appear at a different spot in the listing from what you expected.

graphics/02icon02.gif

ls -i

To get information about the inode of a file, you use the -i option to ls. The following example includes both the -i and -l options to ls:

$ls -ail /home/denise  137717 -rw-------  1 denise  users       98 Oct 6 09:19 .Xauthority  137623 -r--r--r--  1 denise  users      814 May 19 10:10 .cshrc  140820 drwxr-xr-x  7 denise  users     1024 Sep 26 11:14 .dt  137629 -rwxr-xr-x  1 denise  users     8705 Jul 7 12:04 .dtprofile  180815 drwx------  2 denise  users     1024 Jul 31 18:48 .elm  137624 -r--r--r--  1 denise  users      347 May 19 10:10 .exrc  137652 -rwxrwxrwx  1 denise  users      170 Jun 6 14:20 .fmrc.orig  137650 -rw-------  1 denise  users       97 Jun 12 18:59 .glancerc  137699 -rw-------  1 denise  users    17620 Sep 21 16:11 .gpmhp  137640 -rwxr-xr-x  1 denise  users      391 Sep 19 09:55 .history  137625 -r--r--r--  1 denise  users      341 May 19 10:10 .login  185607 drwx--x--x  2 denise  users      1024 Jul 31 18:48 .lrom  137642 -rw-r--r--  1 denise  users       768 Jul 28 12:54 .mailrc  137641 -rw-------  1 denise  users      1450 Oct 6 13:58 .netscaperks.html  179207 drwx------  2 denise  users     10240 Oct 10 15:24 .netscape-cache  137656 -rw-------  1 denise  users        91 Sep 18 14:16 .netscape-cookies  137635 -rw-------  1 denise  users     43906 Oct 10 15:32 .netscape-history  137645 -rw-r--r--  1 denise  users       566 Aug 25 14:36 .netscapes.spry.com  137646 -rw-------  1 denise  users     46514 Jun 28 12:35 .netsca  137634 -rw-------  1 denise  users      1556 Sep 28 15:02 .netscaperences  137637 -rw-------  1 denise  users       104 Jul 11 11:01 .newsrcws.spry.com  137633 -rw-r--r--  1 denise  users       223 Sep 26 13:26 .newsrc-hp.com  137626 -r--r--r--  1 denise  users       446 May 19 10:10 .profile  137649 -rw-------  1 denise  users        21 Jul 6 13:21 .rhosts  137694 -rw-------  1 denise  users      2328 Oct 10 15:22 .sh_history  137698 -rw-r--r--  1 denise  users      1052 Sep 22 15:00 .softbuildrc  137636 -rwxrwxrwx  1 denise  users       161 Jul 11 12:19 .softinit.orig   33600 drwxr-xr-x  3 denise  users      1024 Aug 31 15:44 .sw  137648 -rw-------  1 denise  users        23 Jun 2 15:01 .xinitrc  137628 -rwxr-xr-x  1 denise  users     11251 May 19 10:41 .xsession  137715 -rw-r--r--  1 denise  users    611488 Oct 3 12:00 27247b.exe  137707 -rw-r--r--  1 denise  users    114119 Sep 29 12:49 410pt1.exe  137710 -rw-r--r--  1 denise  users    136979 Sep 29 12:53 410pt2.exe  137705 -rw-r--r--  1 denise  users    1 3978 Sep 29 12:40 41ndir.exe  137709 -rw-r--r--  1 denise  users    363315 Sep 29 12:52 41nds1.exe  137714 -rw-r--r--  1 denise  users    527524 Sep 29 12:57 41nds4.exe  137708 -rw-r--r--  1 denise  users   1552513 Sep 29 12:50 41nwad.exe  137696 -rw-r--r--  1 denise  users    853424 Sep 29 12:24 41rtr2.exe  137654 -rw-r--r--  1 denise  users   1363011 Sep 20 12:20 HPDA1.EXE  182429 drwx------  2 denise  users        24 Jul 31 18:48 Mail  137683 -rw-r--r--  1 denise  users   1787840 Aug 31 09:35 N3212B6.EXE  137702 -rw-r--r--  1 denise  users     13543 Sep 23 09:46 SCSI4S.EXE  137638 -rwx--x--x  1 denise  users        66 Jun 8 17:40 clean  137651 -rwx--x--x  1 denise  users        99 Jun 20 17:44 clean2  137632 -rwx--x--x  1 denise  users        66 Jun 20 17:51 clean3  137688 -rw-r--r--  1 denise  users     15365 Aug 30 15:07 content.exe  137713 -rw-r--r--  1 denise  users    713313 Sep 29 12:56 dsenh.exe  137667 -rwx------  1 denise  users       144 Aug 14 17:10 eg1  137671 -rwx------  1 denise  users       192 Aug 15 12:13 eg2  137662 -rw-r--r--  1 denise  users    667890 Sep 20 12:41 en0316bz.exe  137665 -rw-r--r--  1 denise  users    641923 Sep 20 12:42 en0316tb.exe  137689 -rw-r--r--  1 denise  users      6251 Aug 30 15:07 explore.exe  137690 -rw-r--r--  1 denise  users     23542 Aug 30 15:08 flexi_cd.exe  137670 -rw-r--r--  1 denise  users        30 Aug 14 17:02 fred.h  137673 -rw-r--r--  1 denise  users         0 Aug 14 17:24 hal.c  137660 -rw-r--r--  1 denise  users    895399 Sep 20 12:32 hpdl0117.exe  137661 -rw-r--r--  1 denise  users     14135 Sep 20 12:39 hpdlinst.txt  137647 -rw-------  1 denise  users      2943 Jun 19 14:42 hpux.patches  137659 -rw-r--r--  1 denise  users    680279 Sep 20 12:26 j2577a.exe  137697 -rw-r--r--  1 denise  users    930728 Sep 20 15:16 ja95up.exe  137684 -rw-r--r--  1 denise  users   1097728 Aug 30 15:03 msie10.exe  137658 -rw-r--r--  1 denise  users   1790376 Sep 18 14:32 n32e12n.exe  137643 -rw-r--r--  1 denise  users   1393835 Sep 29 12:59 nfs197.exe  137639 -rw-------  1 denise  users       977 Jul 3 14:25 pass.sb  137664 -rw-r--r--  1 denise  users   1004544 Aug 30 15:00 plusdemo.exe  137704 -rw-r--r--  1 denise  users    229547 Sep 29 12:27 ps4x03.exe  137666 -rwxr--r--  1 denise  users       171 Aug 9 13:43 psg  137691 -rw-r--r--  1 denise  users     16645 Aug 30 15:08 quik_res.exe  137692 -rw-r--r--  1 denise  users     14544 Aug 30 15:08 rclock.exe  137693 -rw-r--r--  1 denise  users   2287498 Aug 30 15:12 rkhelp.exe  137669 -rw-r--r--  1 denise  users         0 Aug 15 12:10 roni.mak  137657 -rw-r--r--  1 denise  users      1139 Sep 28 10:35 sb.txt  137712 -rw-r--r--  1 denise  users    569855 Sep 29 12:55 smsup2.exe  137644 -rw-------  1 root    sys         161 Jul 11 12:18 softinittesoftcm  137706 -rw-r--r--  1 denise  users        39 Sep 29 12:48 srvpr.exe  137682 -rw-r--r--  1 denise  users        38 Aug 15 12:14 steve.h  137685 -rw-r--r--  1 denise  users     14675 Aug 30 15:08 target.exe  137711 -rw-r--r--  1 denise  users    229630 Sep 29 12:54 tcp41a.exe  137700 -rw-r--r--  1 denise  users   1954453 Sep 29 12:26 tnds2.exe  137703 -rw-r--r--  1 denise  users    364270 Sep 23 09:50 upgrade.exe  137663 -rwx-----x  1 denise  users        88 Aug 9 13:43 whoon  137678 -rw-r--r--  1 denise  users    191495 Aug 30 15:00 win95app.exe 

The inode number contains the following: the location of files and directories on the disk; access permissions; owner and group IDs; file link count; time of last modification; time of last access; device identification number for special files; and a variety of other information. inode numbers are used extensively by the system as you change directories and perform various tasks.

ls -p

graphics/02icon02.gif

Because you may have subdirectories within the directory you are listing, you may want to use the -p option to ls, which puts a "/" (slash) in after directory names, as shown in the following example:

$ ls -ap /home/denise  .Xauthority  .cshrc  .dt/  .dtprofile  .elm/  .exrc  .fmrc.orig  .glancerc  .gpmhp  .history  .login  .lrom/  .mailrc  .netscape-bookmarks.html  .netscape-cache/  .netscape-cookies  .netscape-history  .netscape-newsgroups-news.spry.com  .netscape-newsgroups-newsserv.hp.com  .netscape-preferences  .newsrc-news.spry.com  .newsrc-newsserv.hp.com  .profile  .rhosts  .sh_history  .softbuildrc  .softinit.orig  .sw/  .xinitrc  .xsession  27247b.exe  410pt1.exe  410pt2.exe  41ndir.exe  41nds1.exe  41nds4.exe  41nwad.exe  41rtr2.exe  HPDA1.EXE  Mail/  N3212B6.EXE  SCSI4S.EXE  clean  clean2  clean3  content.exe  dsenh.exe  eg1  eg2  en0316bz.exe  en0316tb.exe  explore.exe  flexi_cd.exe  fred.h  hal.c  hpdl0117.exe  hpdlinst.txt  hpux.patches  j2577a.exe  ja95up.exe  msie10.exe  n32e12n.exe  nfs197.exe  pass.sb  plusdemo.exe  ps4x03.exe  psg  quik_res.exe  rclock.exe  rkhelp.exe  roni.mak  sb.txt  smsup2.exe  softinit.remotesoftcm  srvpr.exe  steve.h  target.exe  tcp41a.exe  tnds2.exe  upgrade.exe  whoon  win95app.exe 

ls -R

graphics/02icon02.gif

Because the subdirectories you are listing probably have files and subdirectories beneath them, you may want to recursively list these. The -R option to ls shown in the following example performs this recursive listing. This listing is truncated because it would be too long if it included all the subdirectories under /home/denise:

$ ls -aR /home/denise  .Xauthority  .cshrc  .dt  .dtprofile  .elm  .exrc  .fmrc.orig  .glancerc  .gpmhp  .history  .login  .lrom  .mailrc  .netscape-bookmarks.html  .netscape-cache  .netscape-cookies  .netscape-history  .netscape-newsgroups-news.spry.com  .netscape-newsgroups-newsserv.hp.com  .netscape-preferences  .newsrc-news.spry.com  .newsrc-newsserv.hp.com  .profile  .rhosts  .sh_history  .softbuildrc  .softinit.orig  .sw  .xinitrc  .xsession  27247b.exe  410pt1.exe  410pt2.exe  41ndir.exe  41nds1.exe  41nds4.exe  41nwad.exe  41rtr2.exe  HPDA1.EXE  Mail  N3212B6.EXE  SCSI4S.EXE  clean  clean2  clean3  content.exe  dsenh.exe  eg1  eg2  en0316bz.exe  en0316tb.exe  explore.exe  flexi_cd.exe  fred.h                    .                    .                          (skip some of the listing)                    .  /home/denise/.lrom:  LRAAAa27637.CC  LRBAAa27637.CC  LROM.AB  LROM.AB.OLD  LROM.AB.lk1  LROM.SET  /home/denise/.netscape-cache:  cache306C05510015292.gif  cache306C05560025292.gif  cache306C05560035292.gif  /home/denise/.sw:  sessions                    .                    .                    (skip remainder of the listing)                    . 

ls Summary

graphics/02icon02.gif

I have shown you what I believe to be the most important, and most often used, ls options. Because you may have future needs to list files and directories based on other criteria, I provide you with a list of most ls options. There is no substitute, however, for issuing the man ls command. Whatever I provide is only a summary. Viewing the man pages for ls gives you much more information. The following is a summary of the more commonly used ls options:

ls - List the contents of a directory

 

Options

   
 

-a

List all entries.

 

-b

Print non-graphic characters.

 

-c

Use the time the file was last modified for producing order in which files are listed.

 

-d

List only the directory name, not its contents.

 

-f

Assume that each argument is a directory.

 

-g

Only the group is printed and not the owner.

 

-i

Print the inode number in the first column of the report.

 

-m

List the contents across the screen, separated by commas.

 

-n

Numbers for UID and GID are printed instead of names.

 

-o

List the information in long form (-l), except that group is omitted.

 

-p

Put a slash (/) at the end of directory names.

 

-q

Non-printing characters are represented by a "?".

 

-r

Reverse the order in which files are printed.

 

-s

Show the size in blocks instead of bytes.

 

-t

List in order of time saved, with most recent first.

 

-u

Use the time of last access instead of last modification for determining order in which files are printed.

 

-x

List files in multi-column format as shown in examples.

 

-A

Same as -a, except that current and parent directories aren't listed (only used on some UNIX variants).

 

-C

Multicolumn output produced.

 

-F

Directory followed by a "/", executable by an "*", symbolic link by an "@", and FIFO by a "I".

 

-L

List file or directory to which link points.

 

-R

Recursively list subdirectories.

 

-1

Output will be listed in single-column format.

 

graphics/02icon02.gif

Also, some shorthand command names are available for issuing ls with options. For instance, ll is equivalent to ls -l, andlsr is equivalent to ls -R in some UNIX variants. We will also cover creating an "alias," whereby you can define your own shorthand for any command in an upcoming chapter.

You can selectively list and perform other file-related commands with wild cards. The following section covers filename expansion and wild cards.

File System Layout

graphics/02icon04.gif

Before I begin describing the file system layout, you need to know that you do not necessarily have a single file system. Your system administrator may have set up a variety of file system types on your system. As a beginning user, you don't care too much about the different types of file systems; however, before proceeding to the file system layout, let me briefly cover some of the different file system types. Your system administrator cares a lot about the different file system types because the commands he or she issues allow them to specify an option such as "-F" followed by the file system type. One good place to start when looking for the different file system types supported by your UNIX variant is the manual page for the mount command. The "-F" option, or another option such as "-t" for type in Linux, is usually followed by a list of file system types supported. The different file system types and command options to file system types depend on the UNIX variant that you are using. Some commands that commonly support a file system type option are dcopy, fsck, mksf, mount, newfs, and others, some of which you may need to know as an advanced user if you are going to perform system administration in the future. The following is a description of some of the commonly supported file systems on UNIX variants:

  • Personal Computer File System (PCFS) is a file system type that allows direct access to PC formatted disks.

  • UNIX File System (UFS) is the standard or basic default UNIX file system on some UNIX variants.

  • CD-ROM File System (CDFS) is used when you mount a CD-ROM. Most CD-ROMs are read-only, so you can't write to them. This is called High Sierra File System (HSFS) on some UNIX variants.

  • Network File System (NFS) is a way of accessing files on other systems on the network from your local system. An NFS mounted file system looks as though it is local to your system even though it is located on another system.

  • Loopback File System (LOFS) allows you to have the same file system in multiple places using alternate path names.

  • VxFS is an extent-based Journal File System that supports fast file system recovery and online features such as backup on HP-UX.

  • High Performance File System (HFS) is HP's version of the UNIX File System. This is used in most of the examples.

  • TMPFS is a memory-based file system.

  • CacheFS is a file system present in cache.

File system types is an area of high customization on UNIX variants. You will find some of the file systems listed on some UNIX variants and others on other UNIX variants. Although UNIX and its associated commands are very similar, going from one UNIX variant to another, file system types are generally peculiar to a specific UNIX variant. A good place to start when determining what file system types are included with your UNIX variant is to view the file system types listed in the manual page for mount.

graphics/02icon04.gif

The manual page for mount on the Caldera Linux system, we are using lists many file system types. With the Linux mount command, you would use the -t vfstype option to specify one of the file system types to mount:

  • minix

  • ext

  • ext2

  • xiafs

  • hpfs

  • fat

  • msdos

  • umsdos

  • vfat

  • proc

  • nfs

  • iso9660

  • smb

  • ncp

  • affs

  • ufs

  • sysv

  • xenix

  • coherent

One common file system I often mount on Linux systems is a DOS floppy disk. For example, we would go through the following sequence of events to mount a DOS floppy, copy a file to it, and unmount it:

# mount -t msdos /dev/fd0 /mnt/floppy  # cp * /mnt/floppy  # ls /mnt/floppy  file1     file2     file3      file4  # umount /dev/fd0 

graphics/02icon04.gif

 

graphics/02icon05.gif

 

graphics/02icon02.gif

This sequence of commands first mounts /dev/fd0, which is the floppy disk device file, under the mount point /mnt/floppy. /dev/fd0 is mounted as type msdos, as specified by the -t msdos. I next copy all files in the current directory to the floppy. All the files on the floppy are then listed with ls, producing the list of four files shown. I then unmount the floppy disk with the umount command so that I can take the floppy to a DOS system and read the files. Because the floppy was mounted as type msdos, the files were written to the floppy in DOS format.

Similarly, to mount a CD-ROM on a Linux system, you would issue the following mount command, unless it's mounted at boot:

# mount /dev/hdd /cdrom  mount: block device /dev/hdd is write-protected, mounting read only  # 

You would substitute your CD-ROM device file for /dev/hdd. This CD-ROM is, of course, a read-only device, as the message from mount indicates.

The file system layout of most UNIX variants is based on the AT&T SVR4 layout. This means that going from one UNIX variant to the next, you see pretty much the same names used in the file system layouts.

Figure 2-1 is a high-level depiction of the file system.

Figure 2-1. General UNIX File System Layout (differs somewhat among UNIX variants)

graphics/02fig01.gif

Here are some of the more important features of the UNIX file system layout:

  • Files and directories are organized by category. The two most obvious categories that appear in Figure 2-1 are static vs. dynamic files. Also, other categories are executable, configuration, data files, and so on. The static files are also labeled "shared," because other hosts on the network may share these. The directories /usr, /sbin, and/opt are shared directories.

  • The operating system (OS) and applications are kept separate from one another. Application vendors don't care where their applications are loaded; that is up to you. But to a system administrator, it is highly desirable to keep applications separate from the operating system so you don't inadvertently have application files overwriting operating system files. In addition, if applications are loaded in a separate area, they are "modular," meaning that a system administrator can add, remove, and modify them without affecting the operating system or other applications. Applications are kept in the /opt directory.

  • Intra-system files are kept in a separate area from inter-system, or network-accessible files. /usr and /sbin are shared operating system directories. No host-specific information is in these two directories. /etc is used to hold the host-specific configuration files.

  • Executable files are kept separate from system configuration files so that the executables may be shared among hosts. Having the configuration files separate from the programs that use them also means that updates to the operating system won't affect the configuration files.

I provide descriptions of some of the most important directories of the file system layout and their contents:

/

This is the root directory, which is the base of the file system's hierarchical tree structure. A directory is logically viewed as being part of /. Regardless of the disk on which a directory or logical volume is stored, it is logically viewed as a part of the root hierarchy.

/dev

Contains host-specific device files.

/etc

Contains host-specific system and application configuration files. The information in this directory is important to the operation of the system and is of a permanent nature. There are also additional configuration directories below /etc. Therearetwo/etc subdirectories of particular interest:

/export

Servers export root directories for networked clients. For instance, a server might export user directories such as /export/home/username.

/home

Users' home directories are located here. Because the data stored in users' home directories will be modified often, you can expect thisdirectory to grow in size.

/kernel

Contains kernel configuration and binary files that are required to bring up a system such as genunix.

/lost+found

This is the lost files directory. Here you find files that are in use but are not associated with a directory. These files typically become "lost" as a result of a system crash that caused the link between the physical information on the disk and the logical directory to be severed. The program fsck, which is run at the time of boot, finds these files and places them in the lost+found directory.

/mnt

This directory is reserved as a mount point for local file systems. You can either mount directly to /mnt or have /mnt subdirectories as mount points such as /mnt1, /mnt2, /mnt3, etc.

/net

Name reserved as mount points for remote file systems.

/opt

The directory under which applications are installed. As a rule, application vendors never specify a particular location for their applications to be installed. Now, with /opt, there is a standard directory under which applications should be installed. This is an organizational improvement for system administrators because they can now expect applications to be loaded under /opt and the application name.

/sbin

Contains commands and scripts used to boot, shut down, and fix file system mounting problems. /sbin is available when a system boots, because it contains commands required to bring up a system.

/stand

Contains kernel configuration and binary files that are required to bring up a system. Two significant files contained in this directory are the system and vmunix (kernel) files.

/tmp

This is a free-for-all directory, where any user can temporarily store files. Because of the loose nature of this directory, it should not be used to store anything important, and users should know that whatever they have stored in /tmp can be deleted without notice. Application working files should go in /var/ tmp or /var/opt/appname, not in /tmp.

/usr

Most of the UNIX operating system is contained in /usr. Included in this directory are commands, libraries, and documentation. A limited number of subdirectories can appear in /usr.

/var

Holds files that are primarily temporary. Files such as log files, which are frequently deleted and modified, are stored here. Think of this as a directory of "variable" size. Files that an application or command create at runtime should be placed in this directory, including logfile and spool files. However, some applications may store state information in /var.

Linux File System Layout

The Linux file system layout is very similar to the other UNIX variants described earlier, both in concept and in implementation. Files are contained in directories, and directories can have any number of subdirectories. Most operating systems are arranged this way, including UNIX.

The following is a long listing at the root level of a Caldera Linux system:

graphics/02icon02.gif

# ls -l /  total 439  -rw-rw-rw-   1 root     root        23 Nov  5 07:10 .lgdb  dr-xr-xr-x   3 root     root       1024 Nov  5 07:10 amd  dr-xr-xr-x   2 root     root        512 Nov  5 07:10 auto  drwxr-xr-x   2 root     root       2048 Nov  5 07:12 bin  drwxr-xr-x   2 root     root       1024 Nov  5 01:44 boot  drwxr-xr-x   2 root     root      10240 Nov  6 22:27 dev  drwxr-xr-x  15 root     root       2048 Nov  7 00:15 etc  drwxr-xr-x   5 root     root       1024 Nov  5 01:43 home  drwxr-xr-x   2 root     root       1024 Nov  5 01:29 initrd  lrwxrwxrwx   1 root     root        11 Nov  5 01:29 install ->                                                    /var/lib/LST  drwxr-xr-x   4 root     root       1024 Nov  5 01:44 lib  drwxr-xr-x   2 root     root      12288 Nov  5 01:29 lost+found  drwxr-xr-x   4 root     root       1024 Nov  5 01:44 mnt  drwxr-xr-x   4 root     root       1024 Sep 10 1996 opt  dr-xr-xr-x   5 root     root          0 Nov  5 01:59 proc  drwxr-xr-x   5 root     root       1024 Nov  6 20:56 root  drwxr-xr-x   2 root     root       2048 Nov  7 00:03 sbin  drwxrwxrwt   6 root     root       1024 Nov  7 00:10 tmp  drwxr-xr-x  21 root     root       1024 Nov  5 01:40 usr  drwxr-xr-x   4 root     root       1024 Nov  5 01:32 var  -rw-r--r--   1 root     root     404158 Nov  5 01:29 vmlinuz 

Most of the directories are the same as those described earlier. A couple of directory names did not appear earlier that are significant, however. The Linux kernel, vmlinuz, appears at the root level. The directory /root is the home directory of the user root.

The /proc directory contains information about the Linux system. The /proc directory is really a set of data structure information that looks like a directory. The following is a long listing of the /proc directory:

graphics/02icon02.gif

# ls -l /proc  total 0  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 1  dr-xr-xr-x   3 root     root             0 Nov 7 00:16 1011  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 104  dr-xr-xr-x   3 bin      root             0 Nov 7 00:13 106  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 116  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 118  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 146  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 155  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 156  dr-xr-xr-x   3 daemon   root             0 Nov 7 00:13 162  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 167  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 170  dr-xr-xr-x   3 root     65535            0 Nov 7 00:13 178  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 18  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 19  dr-xr-xr-x   3 nobody   65535            0 Nov 7 00:13 193  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 199  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 2  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 20  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 200  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 201  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 202  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 203  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 204  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 205  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 21  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 273  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 274  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 276  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 3  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 307  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 327  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 358  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 375  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 443  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 444  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 445  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 45  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 482  dr-xr-xr-x   3 root     root             0 Nov 7 00:13 483  dr-xr-xr-x   3 root     root             0 Nov 7 00:16 996  dr-xr-xr-x   3 root     root             0 Nov 7 00:16 997  dr-xr-xr-x   3 root     root             0 Nov 7 00:16 998  -r--r--r--   1 root     root             0 Nov 7 00:13 cmdline  -r--r--r--   1 root     root             0 Nov 7 00:13 cpuinfo  -r--r--r--   1 root     root             0 Nov 7 00:13 devices  -r--r--r--   1 root     root             0 Nov 7 00:13 dma  -r--r--r--   1 root     root             0 Nov 7 00:13 filesys  -r--r--r--   1 root     root            0 Nov 7 00:13 interrupt  -r--r--r--   1 root     root             0 Nov 7 00:13 ioports  -r--------   1 root     root      33558528 Nov 7 00:13 kcore  -r--------   1 root     root             0 Nov  5 07:00 kmsg  -r--r--r--   1 root     root             0 Nov  7 00:13 ksyms  -r--r--r--   1 root     root             0 Nov  7 00:05 loadavg  -r--r--r--   1 root     root             0 Nov  7 00:13 locks  -r--r--r--   1 root     root             0 Nov  7 00:13 mdstat  -r--r--r--   1 root     root             0 Nov  7 00:13 meminfo  -r--r--r--   1 root     root             0 Nov  7 00:13 modules  -r--r--r--   1 root     root             0 Nov  7 00:13 mounts  dr-xr-xr-x   2 root     root             0 Nov  7 00:13 net  -r--r--r--   1 root     root             0 Nov  7 00:13 pci  dr-xr-xr-x   2 root     root             0 Nov  7 00:13 scsi  lrwxrwxrwx   1 root     root           64 Nov  7 00:13 self->110  -r--r--r--   1 root     root             0 Nov  7 00:13 stat  dr-xr-xr-x   5 root     root             0 Nov  7 00:13 sys  -r--r--r--   1 root     root             0 Nov  7 00:13 uptime  -r--r--r--   1 root     root             0 Nov  7 00:13 version 

The directories in the long listing, which have a "d" at the beginning of the line, are processes. The file /proc/kcore represents the physical memory of your Linux system. Files in /proc contain some interesting information about your system. One file you'll want to take a look at is the /proc/cpuinfo file. An example of this file is shown in the following listing:

graphics/02icon06.gif

# more /proc/cpuinfo  processor      : 0  cpu            : 686  model          : 3  vendor_id      : GenuineIntel  stepping       : 4  fdiv_bug       : no  hlt_bug        : no  fpu            : yes  fpu_exception  : yes  cpuid          : yes  wp             : yes  flags          : fpu vme de pse tsc msr pae mce cx8 11 mtrr pge  mca cmov mmx  bogomips       : 266.24 

more is covered in the next chapter. For now, you just need to know that more is used for viewing files.

The /boot directory contains the Linux kernel and other files used by the LILO boot manager. The following is a listing of /boot:

graphics/02icon02.gif

# ls -l /boot  total 452  -rw-r--r--   1 root    root      15954 Feb 11  1997 WHATSIN  -rw-r--r--   1 root    root      15954 Feb 11  1997                                         WHATSIN-2.0.29-modular  -rw-r--r--   1 root    root         204 Jul 24  1996 any_b.b  -rw-r--r--   1 root    root         204 Jul 24  1996 any_d.b  -rw-r--r--   1 root    root         512 Nov  5 01:44 boot.0300  -rw-r--r--   1 root    root        4416 Jul 24  1996 boot.b  -rw-r--r--   1 root    root          88 Jul 24  1996 chain.b  -rw-------   1 root    root        7680 Nov  5 01:44 map  -r--r--r--   1 root    root        1565 Mar  7  1997 message  -rw-r--r--   1 root    root         192 Jul 24  1996 os2_d.b  -rw-r--r--  1 root     root      404158 Feb 11  1997 vmlinuz-                                                 2.0.29-modular 

As a user, you are probably most concerned with your home directory, assigned to you by your system administrator, which is most likely in the /home directory. I think, however, that as a UNIX user you need to understand the overall UNIX file system layout. Keep in mind that you may find minor differences in the file system layout going from one UNIX variant to another, but, in general, the layout is similar.

If you're running a graphical user interface on your Linux system, you can view the file system graphically. Figure 2-2 shows the Red Hat Linux File Manager that is part of the Gnome user interface.

Figure 2-2. File Manager in Gnome Showing the Red Hat Linux File System

graphics/02fig02.gif

You can see that many of the directories shown on the left-hand side of Figure 2-2 are the same as those described earlier for UNIX systems in general. Although you may be working with any number of different UNIX variants, you'll find most of the system structures to be similar.

Manual Pages for Some Commands Used in Chapter 2

The following are the HP-UX manual pages for many of the commands used in this chapter. Commands often differ among UNIX variants, so you may find differences in the options or other areas for some commands; however, the following manual pages serve as an excellent reference.

file

file - Run test to classify file.

graphics/02icon01.gif

file(1)                                                  file(1  NAME       file - determine file type  SYNOPSIS       file [-m mfile] [-c] [-f ffile] file ...  DESCRIPTION       file performs a series of tests on each file in an attempt to classify       it. If file appears to be an ASCII file, file examines the first 512       bytes and tries to guess its language. If file is an executable a.out       file, file prints the version stamp, provided it is greater than 0       (see the description of the -V option in ld(1)).       file uses the file /etc/magic to identify files that have some sort of       magic number, that is, any file containing a numeric or string       constant that indicates its type. Commentary at the beginning of       /etc/magic explains the format.     Options       file recognizes the following command-line options:            -m mfile       use alternate magic file mfile.            -c             Check the magic file for format errors. This                           validation is not normally carried out for reasons                           of efficiency. No file classification is done                           when this option is specified.            -f ffile       Obtain the list of files to be examined from file                           ffile. file classifies each file whose name                           appears in ffile.  EXTERNAL INFLUENCES     Environment Variables       LC_MESSAGES determines the language in which messages are displayed.       If LC_MESSAGES is not specified in the environment or is set to the       empty string, the value of LANG is used as a default for each       unspecified or empty variable. If LANG is not specified or is set to       the empty string, a default of "C" (see lang(5)) is used instead of       LANG.       If any internationalization variable contains an invalid setting, file       behaves as if all internationalization variables are set to "C". See       environ(5).    International Code Set Support       Single- and multi-byte character code sets are supported. However,       all non-ASCII text files are identified as "data".  SEE ALSO       ld(1).  STANDARDS CONFORMANCE       file: SVID2, SVID3, XPG2, XPG4 

ls

ls - List the contents of a directory.

graphics/02icon02.gif

ls(1)                                                                ls(1)  NAME       ls, l, ll, lsf, lsr, lsx - list contents of directories  SYNOPSIS       ls [-abcdefgilmnopqrstuxACFLR1] [names]       l [ls_options] [names]       ll [ls_options] [names]       lsf [ls_options] [names]       lsr [ls_options] [names]       lsx [ls_options] [names]  DESCRIPTION    For each directory argument, the ls command lists the contents of the    directory. For each file argument, ls repeats its name and any other    information requested. The output is sorted in ascending collation    order by default (see Environment Variables below). When no argument    is given, the current directory is listed. When several arguments are    given, the arguments are first sorted appropriately, but file    arguments appear before directories and their contents.    If you are a user with appropriate privileges, all files except . and    .. are listed by default.    There are three major listing formats. The format chosen depends on    whether the output is going to a login device (determined by whether    output device file is a tty device), and can also be controlled by    option flags. The default format for a login device is to list the    contents of directories in multicolumn format, with entries sorted    vertically by column. (When individual file names (as opposed to    directory names) appear in the argument list, those file names are    always sorted across the page rather than down the page in columns    because individual file names can be arbitrarily long.) If the    standard output is not a login device, the default format is to list    one entry per line. The -C and -x options enable multicolumn formats,    and the -m option enables stream output format in which files are    listed across the page, separated by commas. In order to determine    output formats for the -C, -x, and -m options, ls uses an environment    variable, COLUMNS, to determine the number of character positions    available on each output line. If this variable is not set, the    terminfo database is used to determine the number of columns, based on    the environment variable TERM. If this information cannot be    obtained, 80 columns is assumed.  Options    ls recognizes the following options:         -a    List all entries; usually entries whose names begin with a               period (.) are not listed.               -b    Force printing of nongraphic characters to be in the octal                     \ddd notation.               -c    Use time of last modification of the inode (file created,                     mode changed, etc.) for sorting (-t) or printing (-l                     (ell)).               -d    If an argument is a directory, list only its name (not its                     contents); often used with -l (ell) to get the status of a                     directory.               -e    Print the extent attributes of the file. If any of the                     files has a extent attribute, this option prints the extent                     size, space reserved and allocation flags. This option                     must be used with the -l (ell) option.               -f    Force each argument to be interpreted as a directory and                     list the name found in each slot. This option disables -l                     (ell), -t, -s, and -r, and enables -a; the order is the                     order in which entries appear in the directory.               -g    Same as -l, (ell) except that only the group is printed                     (owner is omitted). If both -l (ell) and -g are specified,                     the owner is not printed.               -i    For each file, print the inode number in the first column                     of the report. When used in multicolumn output, the number                     precedes the file name in each column.               -l    (ell) List in long format, giving mode, number of links,                     owner, group, size in bytes, and time of last modification                     for each file (see further DESCRIPTION and Access Control                     Lists below). If the time of last modification is greater                     than six months ago, or any time in the future, the year is                     substituted for the hour and minute of the modification                     time. If the file is a special file, the size field                     contains the major and minor device numbers rather than a                     size.               -m    Stream output format.               -n    The same as -l, (ell) except that the owner's UID and                     group's GID numbers are printed, rather than the associated                     character strings.               -o    The same as -l, (ell) except that only the owner is printed                     (group is omitted). (If both -l (ell) and -o are                     specified, the group is not printed).               -p    Put a slash (/) after each file name if that file is a                     directory.               -q    Force printing of nongraphic characters in file names as                     the character (?).               -r    Reverse the order of sort to get reverse (descending)                     collation or oldest first, as appropriate.               -s    Give size in blocks, including indirect blocks, for each                     entry. The first entry printed is the total number of                     blocks in the directory. When used in multicolumn output,                     the number of blocks precedes the file name in each column.               -t    Sort by time modified (latest first) before sorting                     alphabetically.        -u    Use time of last access instead of last modification for              sorting (-t option) or printing (-l (ell) option).        -x    Multicolumn output with entries sorted across rather than              down the page.        -A    The same as -a, except that the current directory "." and              parent directory ".." are not listed. For a user with              appropriate privileges, this flag defaults to ON, and is              turned off by -A.        -C    Multicolumn output with entries sorted down the columns.        -F    Put a slash (/) after each file name if that file is a              directory or a symbolic link to a directory; put an              asterisk (*) after each file name if that file is              executable; put an at sign (@) after each file name if that              file is a symbolic link to a file; put a vertical bar (|)              after each file name if that file is a FIFO.        -L    If the argument is a symbolic link, list the file or              directory to which the link refers rather than the link              itself.        -R    Recursively list subdirectories encountered.        -1    (one) The file names will be listed in single column format              regardless of the output device. This forces single column              format to the user's terminal.  Specifying more than one of the options in the following mutually  exclusive pairs is not considered an error: -C and -l (ell), -m and -l  (ell), -x and -l (ell), -C and -1 (one), -c and -u.  ls is normally known by several shorthand-version names for the  various formats:       l     equivalent to ls -m.       ll    equivalent to ls -l (ell).       lsf   equivalent to ls -F.       lsr   equivalent to ls -R.       lsx   equivalent to ls -x.  The shorthand notations are implemented as links to ls. Option  arguments to the shorthand versions behave exactly as if the long form  above had been used with the additional arguments.  Mode Bits Interpretation (-l option)  The mode printed in listings produced by the -l (ell) option consists  of 10 characters. The first character indicates the entry type:       d     Directory       b     Block special file       c     Character special file       l     Symbolic link       p     Fifo (also called a "named pipe") special file       n     Network special file       s     socket       -     Ordinary file.  The next 9 characters are interpreted as three sets of three bits each  which identify access permissions for owner, group, and others as  follows:       +------------------ 0400 read by owner (r or -)              | +---------------- 0200 write by owner (w or -)              | | +-------------- 0100 execute (search directory) by owner              | | |                    (x, s, S, or -)              | | | +------------ 0040 read by group (r or -)              | | | | +---------- 0020 write by group (w or -)              | | | | | +-------- 0010 execute/search by group              | | | | | |              (x, s, S, or-)              | | | | | | +------ 0004 read by others (r or -)              | | | | | | | +---- 0002 write by others (w or -)              | | | | | | | | +-- 0001 execute/search by others              | | | | | | | | | (x, t, T, or-)              | | | | | | | | |              r w x r w x r w x         Mode letters are interpreted as follows:              -      Permission not granted in corresponding position.              r      Read permission granted to corresponding user class.              w      Write permission granted to corresponding user class.              x      Execute (or search in directory) permission granted to                     corresponding user class.              s      Execute (search) permission granted to corresponding user                     class. In addition, SUID (Set User ID) permission granted                     for owner, or SGID (Set Group ID) permission granted for                     group, as indicated by position.              S      Same as s except that execute (search) permission is                     denied to corresponding user class.              t      (last position only) Execute (search) permission granted                     to others and "sticky bit" is set (see chmod(2) S_ISVTX                     description).              T      Same as t except execute (search directory) permission                     denied to others.        When an option is specified that results in a listing of directory        and/or file sizes in bytes or blocks (such as the -s or -l (ell)        option), a total count of blocks, including indirect blocks, is also        printed at the beginning of the listing.      Access Control Lists (ACLs)        If a file has optional ACL entries, the -l (ell) option displays a        plus sign (+) after the file's permissions. The permissions shown are        a summary representation of the file's access control list, as        returned by stat() in the st_mode field (see stat(2)). To list the        contents of an access control list, use the lsacl command (see        lsacl(1) and acl(5)).   EXTERNAL INFLUENCES      Environment Variables        If the COLUMNS variable is set, ls uses the width provided in        determining positioning of columnar output.        LANG determines the locale to use for the locale categories when both        LC_ALL and the corresponding environment variable (beginning with LC_)        do not specify a locale. If LANG is not set or is set to the empty        string, a default of "C" (see lang(5)) is used.        LC_COLLATE determines the order in which the output is sorted.        LC_CTYPE determines which characters are classified as nongraphic for        the -b and -q options, and the interpretation of single- and/or        multibyte characters within file names.        LC_TIME determines the date and time strings output by the -g, -l        (ell), -n, and -o options.        LC_MESSAGES determines the language in which messages (other than the        date and time strings) are displayed.        If any internationalization variable contains an invalid setting, ls        behaves as if all internationalization variables are set to "C" (see        environ(5)).      International Code Set Support        Single- and multibyte character code sets are supported.   RETURN VALUE        ls exits with one of the following values:              0   All input files were listed successfully.             >0   ls was aborted because errors occurred when accessing files.                  The following conditions cause an error:                     - Specified file not found.                     - User has no permission to read the directory.                     - Process could not get enough memory.                     - Invalid option specified.   EXAMPLES        Print a long listing of all the files in the current working directory        (including the file sizes). List the most recently modified        (youngest) file first, followed by the next older file, and so forth,        to the oldest. Files whose names begin with a . are also printed.             ls -alst   WARNINGS        Setting options based on whether the output is a login (tty) device is        undesirable because ls -s is very different from ls -s | lp. On the        other hand, not using this setting makes old shell scripts that used        ls almost inevitably fail.        Unprintable characters in file names may confuse the columnar output        options.   DEPENDENCIES        NFS  The -l (ell) option does not display a plus sign (+) after the             access permission bits of networked files to represent existence             of optional access control list entries.        AUTHOR             ls was developed by AT&T, the University of California, Berkeley and             HP.        FILES             /etc/passwd              to get user IDs for ls -l (ell) and ls -o.             /etc/group               to get group IDs for ls -l (ell) and ls -g.             /usr/share/lib/terminfo/?/*                                      to get terminal information.        SEE ALSO             chmod(1), find(1), lsacl(1), stat(2), acl(5).        STANDARDS CONFORMANCE             ls: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2 
CONTENTS


UNIX User's Handbook
UNIX Users Handbook (2nd Edition)
ISBN: 0130654191
EAN: 2147483647
Year: 2001
Pages: 34

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net