LAST DATE FOR MODIFICATION IN THIS DOCUMENT IS TUSEDAY 23/October/2001

 

 

FILE HAS BEEN CLOSED FOR MODIFICATION

3:30PM 23/October/2001

 

You can download this document in either MS-Word format of Adobe Acrobat format

 

http://www.esp.com.lb/pigier/unix/unix.doc

http://www.eps.com.lb/pigier/unix/unix.pdf

 

 

Material Source & Extra Reading:

 

http://www2.linuxjournal.com/help/man.html

http://www.linux.org

http://www.linuxcentral.org

http://www.linuxgazette.com

http://www.root66.net/linux/docs/Mandrake/rhgsg/gsg/doc040.htm

http://www.debian.org/doc/packaging-manuals/fhs/

 

 

 

Red Hat Linux 6 Unleashed ISBN 0-672-31689-7 By SAMS

Linux Man Pages


Table of Contents:

 

Chapter 1

 

  1. History
  2. File Types
    1. Ordinary Files
    2. Special Files
  3. System Directories
  4. Directories and sub-directories
    1. Creation and Hierarchy
  5. File System
    1. General Concepts and interests
    2. Creating Files and Directories

 

Chapter 2

 

  1. User Accounts in UNIX
    1. Predefined super user
    2. Creating users (useradd, passwd)

                                                              i.      /etc/passwd file

    1. Removing users
    2. ‘HOME’ Directory
    3. .profile file
  1. Groups
    1. Predefined groups
    2. Add groups (groupadd)
    3. Removing groups (groupdel)
  2. File & Directory access rights
    1. Attributes rwx and their derivatives
    2. Adding attributes (chmod)
    3. Modifying owner (chown)
    4. Modifying groups (chgrp)

 

Chapter 3

 

  1. Generalities
  2. Essential Commands
    1. Date
    2. ls (-c, -t, -r, -l , -a)
    3. echo
    4. who
    5. ps
    6. pwd
    7. cd
    8. cp
    9. mv
    10. df
    11. diff
    12. grep
    13. find
    14. sort
    15. clear
    16. lp
    17. kill
    18. rm (-i, -r)
  3. Redirection (Redirecting output, redirecting errors), execution pipes

 

Chapter 4

  1. Introducing grouped commands and batch files
  2. Predefined variables
  3. (read) instruction
  4. (echo) instruction
  5. Conditions
    1. Simple choices (if, elif)
    2. Multiple choices (case)
  6. Test commands (-r, -w, -x, -f, -d, -s, -n, -z, -eq, -lt, -le, -ne, -gt, -ge, -a, -o)
  7. Loops
    1. For
    2. While
    3. Until
  8. Logical And & Or
  9. True and False
  10. Break & Continue
  11. ‘expr’ Instruction

 


Chapter 1

1. History of Unix, Linux, and Open Source / Free Software:

1.1. Unix

In 1969-1970, Kenneth Thompson, Dennis Ritchie, and others at AT&T Bell Labs began developing a small operating system on a little-used PDP-7. The operating system was soon christened Unix, a pun on an earlier operating system project called MULTICS. In 1972-1973 the system was rewritten in the programming language C, an unusual step that was visionary: due to this decision, Unix was the first widely-used operating system that could switch from and outlive its original hardware. Other innovations were added to Unix as well, in part due to synergies between Bell Labs and the academic community. In 1979, the ``seventh edition'' (V7) version of Unix was released, the grandfather of all extant Unix systems.

After this point, the history of Unix becomes somewhat convoluted. The academic community, led by Berkeley, developed a variant called the Berkeley Software Distribution (BSD), while AT&T continued developing Unix under the names ``System III'' and later ``System V''. In the late 1980's through early 1990's the ``wars'' between these two major strains raged. After many years each variant adopted many of the key features of the other. Commercially, System V won the ``standards wars'' (getting most of its interfaces into the formal standards), and most hardware vendors switched to AT&T's System V. However, System V ended up incorporating many BSD innovations, so the resulting system was more a merger of the two branches. The BSD branch did not die, but instead became widely used for research, for PC hardware, and for single-purpose servers (e.g., many web sites use a BSD derivative).

The result was many different versions of Unix, all based on the original seventh edition. Most versions of Unix were proprietary and maintained by their respective hardware vendor, for example, Sun Solaris is a variant of System V. Three versions of the BSD branch of Unix ended up as open source: FreeBSD (concentating on ease-of-installation for PC-type hardware), NetBSD (concentrating on many different CPU architectures), and a variant of NetBSD, OpenBSD (concentrating on security). More general information about Unix history can be found at http://www.datametrics.com/tech/unix/uxhistry/brf-hist.htm and http://perso.wanadoo.fr/levenez/unix. Much more information about the BSD history can be found in [McKusick 1999] and ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/src/share/misc/bsd-family-tree.

Those interested in reading an advocacy piece that presents arguments for using Unix-like systems should see http://www.unix-vs-nt.org.

1.2. Free Software Foundation

In 1984 Richard Stallman's Free Software Foundation (FSF) began the GNU project, a project to create a free version of the Unix operating system. By free, Stallman meant software that could be freely used, read, modified, and redistributed. The FSF successfully built a vast number of useful components, including a C compiler (gcc), an impressive text editor (emacs), and a host of fundamental tools. However, in the 1990's the FSF was having trouble developing the operating system kernel [FSF 1998]; without a kernel the rest of their software would not work.

1.3. Linux

In 1991 Linus Torvalds began developing an operating system kernel, which he named ``Linux'' [Torvalds 1999]. This kernel could be combined with the FSF material and other components (in particular some of the BSD components and MIT's X-windows software) to produce a freely-modifiable and very useful operating system. This book will term the kernel itself the ``Linux kernel'' and an entire combination as ``Linux''. Note that many use the term ``GNU/Linux'' instead for this combination.

In the Linux community, different organizations have combined the available components differently. Each combination is called a ``distribution'', and the organizations that develop distributions are called ``distributors''. Common distributions include Red Hat, Mandrake, SuSE, Caldera, Corel, and Debian. There are differences between the various distributions, but all distributions are based on the same foundation: the Linux kernel and the GNU glibc libraries. Since both are covered by ``copyleft'' style licenses, changes to these foundations generally must be made available to all, a unifying force between the Linux distributions at their foundation that does not exist between the BSD and AT&T-derived Unix systems. This book is not specific to any Linux distribution; when it discusses Linux it presumes Linux kernel version 2.2 or greater and the C library glibc 2.1 or greater, valid assumptions for essentially all current major Linux distributions.

1.4. Open Source / Free Software

Increased interest in software that is freely shared has made it increasingly necessary to define and explain it. A widely used term is ``open source software'', which is further defined in [OSI 1999]. Eric Raymond [1997, 1998] wrote several seminal articles examining its various development processes. Another widely-used term is ``free software'', where the ``free'' is short for ``freedom'': the usual explanation is ``free speech, not free beer.'' Neither phrase is perfect. The term ``free software'' is often confused with programs whose executables are given away at no charge, but whose source code cannot be viewed, modified, or redistributed. Conversely, the term ``open source'' is sometime (ab)used to mean software whose source code is visible, but for which there are limitations on use, modification, or redistribution. This book uses the term ``open source'' for its usual meaning, that is, software which has its source code freely available for use, viewing, modification, and redistribution; a more detailed definition is contained in the Open Source Definition. In some cases, a difference in motive is suggested; those preferring the term ``free software'' wish to strongly emphasize the need for freedom, while those using the term may have other motives (e.g., higher reliability) or simply wish to appear less strident. For information on this definition of free software, and the motivations behind it, can be found at http://www.fsf.org.

Those interested in reading advocacy pieces for open source software and free software should see http://www.opensource.org and http://www.fsf.org. There are other documents which examine such software, for example, Miller [1995] found that the open source software were noticeably more reliable than proprietary software (using their measurement technique, which measured resistance to crashing due to random input).

1.5. Comparing Linux and Unix

This article uses the term ``Unix-like'' to describe systems intentionally like Unix. In particular, the term ``Unix-like'' includes all major Unix variants and Linux distributions. Note that many people simply use the term ``Unix'' to describe these systems instead.

Linux is not derived from Unix source code, but its interfaces are intentionally like Unix. Therefore, Unix lessons learned generally apply to both, including information on security. Most of the information in this book applies to any Unix-like system. Linux-specific information has been intentionally added to enable those using Linux to take advantage of Linux's capabilities.

Unix-like systems share a number of security mechanisms, though there are subtle differences and not all systems have all mechanisms available. All include user and group ids (uids and gids) for each process and a filesystem with read, write, and execute permissions (for user, group, and other). See Thompson [1974] and Bach [1986] for general information on Unix systems, including their basic security mechanisms.

 

2. File Types:

If you're new to Linux, it won't take long before you begin seeing files with extensions that may seem foreign. A file's extension is the last part of a file's name, after the final dot (in the file sneakers.txt, ``txt'' was that file's extension).

Here's a brief listing of extensions and their meanings:

Compressed/Archived Files

  • .Z -- a compressed file
  • .tar -- an archive file (short for tape archive)
  • .gz -- a compressed file (gzipped)
  • .tgz -- a tarred and gzipped file

File Formats

  • .txt -- a plain ASCII text file
  • .html/.htm -- an HTML file
  • .ps -- a PostScript file; formatted for printing
  • .au -- an audio file
  • .wav -- an audio file
  • .xpm -- an image file
  • .jpg -- a graphical or image file, such as a photo or artwork
  • .gif -- a graphical or image file
  • .png -- a graphical or image file

System Files

  • .rpm -- a Red Hat Package Manager file
  • .conf -- a configuration file
  • .a -- an archive file
  • .lock -- a ``lock'' file; determines whether a program is in use

Programming and Scripting Files

  • .h -- a C and C++ program language header file
  • .c -- a C program language source code file
  • .cpp -- a C++ program language source code file
  • .o -- a program object file
  • .pl -- a Perl script
  • .tcl -- a TCL script
  • .so -- a library file

3. System Directories:

The first thing to note is that in a directory path, directory and file names are separated by forward slashes ("/") instead of backslashes. In Linux, directories are arranged in a tree-like structure, starting with what is known as the "root," or top-most directory. The root directory is represented by a single forward slash. Underneath it are the main system directories. To display the contents of the root directory, we can use the "ls" (list) command, specifying the root directory:

tom@murdock:~$ ls /

The output of that command will include the following directories:

bin boot dev etc home lib mnt proc root sbin tmp usr var

Now, let's talk about the significance of these items.

  • "/bin" - contains essential system commands and programs (in machine-readable format, or "binary" format, which is what "bin" stands for), such as "ls," "cp" (used to copy files), "mv" (used to move files to a different location), and so on. It also contains "bash," which is most likely the shell you are currently using. The shell is a program that allows you to issue commands to the operating system and view their output. When you are working in a terminal window, you are using the shell.
  • "/boot" - contains files necessary for booting the system. If you're not familiar with this term, it describes the process of starting the system when it is powered on or restarted. During this process, a number of things happen. These might include checking the integrity of your disks, detecting hardware and getting it ready for use by the system, and starting essential programs that help to keep the system running. Also, the kernel (the "guts" of your system) may be stored in "/boot".
  • "/dev" - contains files which represent system devices, such as your hard disks, serial ports, mouse, etc. For example, "/dev/hda" represents the first IDE device on your system, usually your hard drive. If this sounds confusing, don't worry -- understanding what is in this directory is the most important part.
  • "/etc" - contains essential system-wide configuration files. When administering your system, you'll frequently be editing files in this directory. They control many system services and settings. Some examples of files in this directory are "/etc/resolv.conf" (contains your nameserver information) and "/etc/fstab" (a table of devices or directories that hold data and need to be accessed by the system, such as your hard drive or a CD-ROM drive). Program-specific configuration files may be here as well, and are usually identified by the letters "rc" at the end of the filename, for "run commands." An example of this might be "/etc/vimrc" (a system-wide configuration file for the vim text editor).
  • "/home" - contains the home directories for all regular users. A home directory is where a user generally stores personal files. For example, if your username is "tom," then your home directory is "/home/tom." A convenient shortcut for referring to your home directory is "~/" (a tilde, followed by a forward slash). So, for the user "tom," "~/mp3/moby.mp3" actually refers to the file "/home/tom/mp3/moby.mp3".
  • "/lib" - contains system libraries. Libraries are files that contain program code that is common to several applications. For example, a common thing that a program might need to do is write out to a file somewhere on disk. Rather than have to include that code in every program they write, programmers can simply point to a specific library which contains that functionality. Libraries help to keep programs smaller, more efficient, and easier to maintain. Another thing you'll find in this directory, under "/lib/modules/(kernel-version)" are your kernel modules. Modules usually serve as device drivers -- that is, they provide the necessary interface for "talking" to your system hardware, such as a network card or a SCSI CD-ROM drive.
  • "/mnt" - contains "mount points," which are the locations you would use to access files on various different media such as floppies or CD-ROMs. For example, "/mnt/floppy" would be where you would usually access your floppy. All this is defined by the "/etc/fstab" file mentioned above.
  • "/proc" - contains files with system information. For example, "/proc/cpuinfo" has information about your computer's processor, and "/proc/modules" lists which kernel modules are currently loaded in the system.
  • "/root" - contains the "root" user's home directory.
  • "/sbin" - contains commands used by the superuser ("root") for system administration. These include commands such as "shutdown" (used to shutdown or reboot the system) and fsck (a tool for checking and repairing the data on your hard disk, similar to "scandisk" on Windows).
  • "/tmp" - a place to put temporary files. Applications use this directory often, which can be accessed by all users on the system.
  • "/usr" - contains a number of important subdirectories. "/usr/bin" contains the bulk of the programs on your system. "/usr/sbin" contains important commands for system administration that are not already in "/sbin." So, why the difference between "/bin" and "/usr/bin", or "/sbin" and "/usr/sbin"? Well, "/bin" and "/sbin" should contain all the commands necessary for getting the system up and running, without being connected to the network. This allows "/usr" to actually be located on another computer on the network, and remotely accessed. Now, let's take a look at the rest of the "/usr" subdirectories. "/usr/lib" contains more system libraries, (as discussed above). "/usr/include" contains additional common pieces of code, similar to libraries, but used when compiling software. Compiling software is the process of taking "source code" (the human-readable instructions written by programmers using a programming language, such as C), and using a special program called a "compiler" to create a file that can be understood by the computer, called a binary file. "/usr/src" contains source code stored on the system (such as the Linux kernel source, or source code that you may have downloaded so that you can compile a program by hand). Finally, "/usr/local" contains programs and data files that have been added locally to the system, and are intended to be kept separate from the main system directories.
  • "/var" - contains administrative files (such as system logs), and data that changes frequently (such as incoming mail and news).

4. Directories & Sub-directories

            4.1 Creation and Hierarchy

NAME

mkdir - make directories

SYNOPSIS

       mkdir [OPTION] DIRECTORY...
 
 

DESCRIPTION

       Create the DIRECTORY(ies), if they do not already exist.
 
       -m, --mode=MODE
              set  permission mode (as in chmod), not rwxrwxrwx -
              umask
 
       -p, --parents
              no error if existing, make  parent  directories  as
              needed
 
       --verbose
              print a message for each created directory
 
       --help display this help and exit
 
       --version
              output version information and exit

                                               

5. File Systems

            5.1 General concepts and interests

The UNIX filesystem is characterized by:

  • A hierarchical structure
  • Consistent treatment of file data
  • Protection of file data

This standard assumes that the operating system underlying an FHS-compliant file system supports the same basic security features found in most UNIX filesystems. Note that this standard does not attempt to agree in every possible respect with any particular UNIX system's implementation. However, many aspects of this standard are based on ideas found in UNIX and other UNIX-like systems.

This is after careful consideration of other factors, including:

  • Traditional and well-considered practices in UNIX-like systems.
  • The implementation of other filesystem structures
  • Applicable standards

It is possible to define two independent categories of files: shareable vs. unshareable and variable vs. static.

Shareable data is that which can be shared between several different hosts; unshareable is that which must be specific to a particular host. For example, user home directories are shareable data, but device lock files are not.

Static data includes binaries, libraries, documentation, and anything that does not change without system administrator intervention; variable data is anything else that does change without system administrator intervention.

For ease of backup, administration, and file-sharing on heterogenous networks of systems with different architectures and operating systems, it is desirable that there be a simple and easily understandable mapping from directories (especially directories considered as potential mount points) to the type of data they contain.

Throughout this document, and in any well-planned filesystem, an understanding of this basic principle will help organize the structure and lend it additional consistency.

The distinction between shareable and unshareable data is needed for several reasons:

  • In a networked environment (i.e., more than one host at a site), there is a good deal of data that can be shared between different hosts to save space and ease the task of maintenance.
  • In a networked environment, certain files contain information specific to a single host. Therefore these filesystems cannot be shared (without taking special measures).
  • Historical implementations of UNIX-like filesystems interspersed shareable and unshareable data in the same hierarchy, making it difficult to share large portions of the filesystem.

The "shareable" distinction can be used to support, for example:

  • A /usr partition (or components of /usr) mounted (read-only) through the network (using NFS).
  • A /usr partition (or components of /usr) mounted from read-only media. A CD-ROM is one copy of many identical ones distributed to other users by the postal mail system and other methods. It can thus be regarded as a read-only filesystem shared with other FHS-compliant systems by some kind of "network".

The "static" versus "variable" distinction affects the filesystem in two major ways:

  • Since / contains both variable and static data, it needs to be mounted read-write.
  • Since the traditional /usr contains both variable and static data, and since we may want to mount it read-only (see above), it is necessary to provide a method to have /usr mounted read-only. This is done through the creation of a /var hierarchy that is mounted read-write (or is a part of another read-write partition, such as /), taking over much of the /usr partition's traditional functionality.

Here is a summarizing chart. This chart is only an example for a common FHS-compliant system, other chart layouts are possible within FHS-compliance.

 

Shareable

unshareable

static

/usr
/opt

/etc
/boot

variable

/var/mail
/var/spool/news

/var/run
/var/lock

 

            5.2 Creating files and directories

NAME

 
touch - change file timestamps
 
 

SYNOPSIS

       touch [OPTION]... FILE...
 
 

DESCRIPTION

              or   :  ../src/touch  [-acm]  MMDDhhmm[YY]  FILE...
              (obsolescent)
 
       Update the access and modification times of each  FILE  to
       the current time.
 
       -a     change only the access time
 
       -c, --no-create
              do not create any files
 
       -d, --date=STRING
              parse STRING and use it instead of current time
 
       -f     (ignored)
 
       -m     change only the modification time
 
       -r, --reference=FILE
              use this file's times instead of current time
 
       -t STAMP
              use [[CC]YY]MMDDhhmm[.ss] instead of current time
 
       --time=WORD
              set  time  given by WORD: access atime use (same as
              -a) modify mtime (same as -m)
 
       --help display this help and exit
 
       --version
              output version information and exit
 
       Note that the three time-date formats recognized  for  the
       -d and -t options and for the obsolescent argument are all
       different.

 

 


Chapter 2

 

  1. User Accounts in UNIX
    1. Predefined super user

 

Root is the predefined user on new unix installation. The password is given at installation time, and should be kept secret. Root has complete power to perform any task in this unix environment, even delete operating system files, and render the system un-bootable. It is wise to create a backup of the root account, this can be used on a regular basis, while the root account is not accessed for daily use.

 

    1. Creating users (useradd, passwd)

 

NAME

adduser, addgroup - add a user or group to the system    

SYNOPSIS

adduser [--system [--home directory] [--group]] [--quiet] [--force-badname] [--help] [--version] [--debug] username

adduser [--quiet] [--force-badname] [--help] [--version] [--debug] username group

adduser [--group] [--quiet] [--force-badname] [--help] [--version] [--debug] group

DESCRIPTION

adduser and addgroup add users and groups to the system according to information provided in the configuration file /etc/adduser.conf. adduser and addgroup automatically determine the UID or GID and places the entity in the password or group file, as appropriate.

If necessary, adduser creates a home directory for the new user, copies "skeletal" user files to it from /etc/skel and allows the system administrator to set an initial password and finger information for the user.

Because it needs to be able to write to such files as /etc/passwd adduser can only be run as root.

Generally, there are two types of users and groups on a system: those users that log into the system and those "non-user" accounts and groups which exist for various system tasks and projects. Henceforth, user will refer to the login type and system user or group will refer to the type used for system maintenance and projects.

By default, each user in Debian GNU/Linux is given a corresponding group with the same name and ID, allowing people easily to give access to their home directories to others. This option can be turned off in the configuration file, in which case each user is, by default, added to a group called users.

Under Debian GNU/Linux, IDs less than or equal to 100 are allocated by the base system maintainer for various purposes. IDs from 101 to the value specified in the configuration file (1000, by default) are used for system users and groups. IDs greater than 1000 are reserved for users and their corresponding groups.

When invoked with a single name, adduser creates a user with that name. When given two names, adduser assumes that the first name represents an existing user and that the second name represents an existing group. In this case, the user is added to the group.

OPTIONS

--system

Create a system user. This user will be assigned the shell /bin/false and have an asterisk in the password field. Unless otherwise specified, the user will be placed in the group nogroup. Skeletal configuration files will not be copied into the user's home directory.

--home directory

when used with --system , uses directory as the user's home directory, rather than the default specified in the configuration file. If the directory does not exist, it is created.

--group

When combined with --system, a group with the same name and ID as the system user is created. If not combined with --system, a group with the given name is created. This is the default action if the program is invoked as addgroup.

--quiet

Suppress progress messages.

--force-badname

By default, user and group names are required to consist of a lowercase letter followed by one or more lowercase letters or numbers. This option forces adduser or addgroup to be more lenient.

--help

Display brief instructions.

--version

Display version and copyright information.

--debug

Display a large quantity of debugging information.

adduser.conf(5)

 


NAME

passwd - change password   

SYNOPSIS

passwd [ name ]

DESCRIPTION

passwd will change the specified user's password. Only the superuser is allowed to change other user's passwords. If the user is not root, then the old password is prompted for and verified.

A new password is prompted for twice, to avoid typing mistakes. Unless the user is the superuser, the new password must have more than six characters, and must have either both upper and lower case letters, or non-letters. Some passwords which are similar to the user's name are not allowed.

FILES

/etc/passwd
/etc/shells

SEE ALSO

chsh(1), chfn(1)

                                                              i.      /etc/passwd file

 

This file contains user name, encrypted password, userid and group id, home directory, shell name ….

It is in text format, with 1 entry per line

 

 

    1. Removing users

 

NAME

userdel - Delete a user account and related files
 

SYNOPSIS

       userdel [-r] login
 
 

DESCRIPTION

       The  userdel  command  modifies  the system account files,
       deleting all entries that refer to login.  The named  user
       must exist.
 
       -r     Files  in the user's home directory will be removed
              along  with  the  home  directory  itself.    Files
              located  in  other  file  system  will  have  to be
              searched for and deleted manually.
 
 

FILES

       /etc/passwd - user account information
       /etc/shadow - secure user account information
       /etc/group - group information
 
 

CAVEATS

       userdel will not allow you to remove  an  account  if  the
       user  is  currently  logged in.  You must kill any running
       processes which belong to an account that you  are  delet­
       ing.   You  may  not  remove  any NIS attributes on an NIS
       client.  This must be performed on the NIS server.

 

 

    1. ‘HOME’ Directory

 

This is the default login directory for a user, and is the default storage area for his files. Home directory is write protected for all users except for the owner of the directory.

 

    1. .profile file

 

 

 

  1. Groups
    1. Predefined groups

 

Root is a predefined group of users containing the root user. All user that should have root permission, should be added to this group.


 

    1. Add groups (groupadd)

NAME

 
      groupadd - Create a new group
 
 

SYNOPSIS

       groupadd [-g gid [-o]] [-r] [-f] group
 
 

DESCRIPTION

       The groupadd command creates a new group account using the
       values specified on the command line and the default  val­
       ues  from  the system.  The new group will be entered into
       the system files as needed.  The options  which  apply  to
       the groupadd command are
 
       -g gid The  numerical value of the group's ID.  This value
              must be unique, unless the -o option is used.   The
              value  must be non-negative.  The default is to use
              the smallest ID value greater than 500 and  greater
              than  every  other group.  Values between 0 and 499
              are typically reserved for system accounts.
 
       -r     This  flag  instructs  groupadd  to  add  a  system
              account. First available gid lower than 499 will be
              automatically selected unless -g  option  is  given
              also on the command line.
              This is an option added by Red Hat Software.
 
       -f     This  is  force  flag. This will stop groupadd exit
              with error when the group about to be added already
              exists  on  the  system.  If  that is the case, the
              group won't be altered (or added  again,  for  that
              matter).
              This  option also modifies the way -g option works.
              When you request a gid that it is  not  unique  and
              you  don't  give  -o option too, the group creation
              will fall back to the standard behavior  (adding  a
              group  as neither -g or -o options were specified).
              This is an option added by Red Hat Software.
 
 

FILES

       /etc/group - group account information
       /etc/gshadow - secure group account information
 
 

SEE ALSO

       chfn(1),  chsh(1),  useradd(8),  userdel(8),   usermod(8),
       passwd(1), groupdel(8), groupmod(8)
 
 
 
    1. Removing groups (groupdel)

 

 

NAME

 
groupdel - Delete a group
 
 

SYNOPSIS

       groupdel group
 
 

DESCRIPTION

       The  groupdel  command  modifies the system account files,
       deleting all entries that refer to group.  The named group
       must exist.
 
       You  must manually check all filesystems to insure that no
       files remain with the named group as the file group ID.
 
 

CAVEATS

       You may not remove the primary group of any existing user.
       You must remove the user before you remove the group.
 
 

FILES

       /etc/group - group information
       /etc/gshadow - secure group information
 
 

SEE ALSO

       chfn(1),   chsh(1),  useradd(8),  userdel(8),  usermod(8),
       passwd(1), groupadd(8), groupmod(8)
 

 

 

  1. File & Directory access rights
    1. Attributes rwx and their derivatives

 

Categories of Users

You are asked to enter a login name and password when you first log into Linux.  When we talk of a user, we refer to the account issuing commands to the operating system at the time and not to the actual person operating the computer.  As soon as Linux authenticates your login name and password you "become" that user and operate using that user account.

Users belong to one or more groups.  (The SuperUser allocates Users to particular groups.)  Each user has a default group.

Linux organises users into three broad categories (the values in brackets are Linux's accepted abbreviations):

  1. user (u) The owner of the file.  A user who creates a file automatically owns it.  Only the owner and the SuperUser (alias root) can change the permissions of a file. 
  2. group (g) The group of a file.  One group of users is given special access to a file.  This is determined by the file owner.
  3. others (o) All other users on the system.  In other words, every account except the file's owner, or users in the file's group.

File access attributes

Each file has a set of attributes specifying what the user in each category (user, group, others) can do with the file.  Here are the three types of access available in Linux:

  1. read (r) This category of users can display, but not necessarily alter, the file.
  2. write (w) This category of users can alter the file (but not necessarily read it.)
  3. execute (x) This category of user can execute (i.e. run) the file.

Displaying file permissions

You can display a file's permissions by executing the ls -l command.  Here is a sample output:

lloy0076@localhost bin2dec]$ ls -l
total 23
-rw-r-----  1 lloy0076 root    286 Aug 28 02:17 b2d.lex
-rwxr-xr-x  1 lloy0076 root  20390 Aug 28 02:17 b2d
-rw-r--r--  1 lloy0076 root     49 Aug 27 22:08 Makefile

You can see the file permissions in the left-most column.  The first character is usually a `-' or `d'.  This actually refers to the type of the file, and does not refer to the file permissions; a `-' indicates the file is a "normal" file, and a `d' indicates the it is a directory.  Other letters indicate files with special meanings to Linux.  The next nine characters refer to file permissions.

The first three (of the nine permission characters) shows what access to the file is permitted for the owner; the next three shows the permissions for anyone in the file's group; and the last three are for those classified as other.  A letter (r, w or x) indicates that the permission for that particular user, group or other is set, and a `-' indicates that the permission is not available.

Schematically you could represent it like this:

-

rwx

rwx

rwx

type

user

group

other


[-rwxrwxrwx]

The b2d.lex file is owned by the user lloy0076, who can read and write it; anyone in the root group can read the file; and nobody else is permitted any access at all.  The b2d file is also owned by lloy0076, who has read, write and execute permission on it.  Anyone in the "root" group has read and execute permissions for the file; and so does everyone else.

Changing file permissions

chmod

To change permissions use the command chmod from the command-line.  You must be the owner of the file (or you must be the SuperUser.)  Take care when changing a file's permissions and be especially careful when you are working with any system files.

The basic format for chmod is:

  • chmod [OPTION]... MODE... FILE...

FILE is a file or directory, which will have its permissions set.  MODE is the permissions being set on the [FILE].

You can use a number of OPTIONs with chmod. Two useful ones are:

  • -v chmod produces verbose output; useful to see exactly what chmod is doing
  • -R chmod will descend (recursively) into all subdirectories, changing all file permissions contained within.  This means that it will iterate through all the files in all the specified FILE's subdirectories (if it has any) changing them at it goes.  This option should be used with care.

You use the `+', '-' or '=' action symbols to add, subtract or set file permissions.  Here is how you do it:

  1. Specify the category of users with the abbreviations for the categories (u, g or o).  A special category ,'a', also exists which means all users.  You can add these together like ug, which means the user and the group
  2. Specify an appropriate action symbol ('+', '-' or '=')
  3. Specify a file access attribute (r, w, or x).  As with the specification for users, you can add these together like rw, which means read and write permissions

Here are two examples of how to use chmod on a file called `test'; for our purposes we will assume that `test' has absolutely no access permited at the start:

  1. chmod ug+rx test This gives read and execute permissions to the user and group, the permissions are now -r-xr-x---
  2. chmod a-x test This removes execute permissions from all users, after these two steps, the permissions are -r--r-----
  3. chmod u=x test This sets execute permission, and removes all others, for the owner.  After these three steps the permissions are ---xr-----

An easy way to determine what the mode string, ug+rx for example, means is by actually saying it fully out loud.  This example would be user; group; add; read permissions; execute permission.  Although it is terrible English, it should be plain what this particular mode is trying to achieve.

 

 

 

    1. Adding attributes (chmod)
 

NAME

chmod - change file access permissions
 
 

SYNOPSIS

       chmod [OPTION]... MODE[,MODE]... FILE...
       chmod [OPTION]... OCTAL-MODE FILE...
       chmod [OPTION]... --reference=RFILE FILE...
 
 

DESCRIPTION

       This  manual  page  documents  the  GNU  version of chmod.
       chmod changes the permissions of each given file according
       to  mode, which can be either a symbolic representation of
       changes to make, or an octal number representing  the  bit
       pattern for the new permissions.
 
       The  format  of a symbolic mode is `[ugoa...][[+-=][rwxXs­
       tugo...]...][,...]'.  Multiple symbolic operations can  be
       given, separated by commas.
 
       A  combination of the letters `ugoa' controls which users'
       access to the file will be changed: the user who  owns  it
       (u),  other users in the file's group (g), other users not
       in the file's group (o), or all users  (a).   If  none  of
       these  are  given, the effect is as if `a' were given, but
       bits that are set in the umask are not affected.
 
       The operator `+' causes the  permissions  selected  to  be
       added to the existing permissions of each file; `-' causes
       them to be removed; and `=' causes them  to  be  the  only
       permissions that the file has.
 
       The letters `rwxXstugo' select the new permissions for the
       affected users: read (r), write (w),  execute  (or  access
       for directories) (x), execute only if the file is a direc­
       tory or already has execute permission for some user  (X),
       set  user  or group ID on execution (s), save program text
       on swap device (t), the permissions that the user who owns
       the  file  currently  has for it (u), the permissions that
       other users in the file's group have for it (g),  and  the
       permissions  that other users not in the file's group have
       for it (o).
 
       A numeric mode is from one to  four  octal  digits  (0-7),
       derived  by  adding  up  the bits with values 4, 2, and 1.
       Any omitted digits are assumed to be leading  zeros.   The
       first  digit  selects the set user ID (4) and set group ID
       (2) and save text image (1) attributes.  The second  digit
       selects  permissions  for the user who owns the file: read
       (4), write (2), and execute (1); the third selects permis­
       sions  for  other users in the file's group, with the same
       values; and the fourth for other users not in  the  file's
       group, with the same values.
 
       is  not  a problem since the permissions of symbolic links
       are never used.  However, for each symbolic link listed on
       the  command  line,  chmod  changes the permissions of the
       pointed-to file.   In  contrast,  chmod  ignores  symbolic
       links encountered during recursive directory traversals.
 
 

OPTIONS

       Change the mode of each FILE to MODE.
 
       -c, --changes
              like verbose but report only when a change is made
 
       -f, --silent, --quiet
              suppress most error messages
 
       -v, --verbose
              output a diagnostic for every file processed
 
       --reference=RFILE
              use RFILE's mode instead of MODE values
 
       -R, --recursive
              change files and directories recursively
 
       --help display this help and exit
 
       --version
              output version information and exit
 
       Each  MODE  is one or more of the letters ugoa, one of the
       symbols +-= and one or more of the letters rwxXstugo.

 

 

    1. Modifying owner (chown)
 

NAME

 
chown - change file owner and group
 
 

SYNOPSIS

       chown [OPTION]... OWNER[.[GROUP]] FILE...
       chown [OPTION]... .GROUP FILE...
       chown [OPTION]... --reference=RFILE FILE...
 
 

DESCRIPTION

       This  manual  page  documents  the  GNU  version of chown.
       chown changes the user  and/or  group  ownership  of  each
       given  file,  according  to its first non-option argument,
       which is interpreted as follows.  If only a user name  (or
       numeric  user ID) is given, that user is made the owner of
       each given file, and the files' group is not changed.   If
       the  user  name  is followed by a colon or dot and a group
       name (or numeric group ID), with no spaces  between  them,
       the group ownership of the files is changed as well.  If a
       colon or dot but no group name follows the user name, that
       user  is  made the owner of the files and the group of the
       files is changed to that user's login group.  If the colon
       or  dot and group are given, but the user name is omitted,
       only the group of the files  is  changed;  in  this  case,
       chown performs the same function as chgrp.
 
       Change the owner and/or group of each FILE to OWNER and/or
       GROUP.
 
       -c, --changes
              like verbose but report only when a change is made
 
       --dereference
              affect the referent of each symbolic  link,  rather
              than the symbolic link itself
 
       -h, --no-dereference
              affect  symbolic  links  instead  of any referenced
              file (available only on systems that can change the
              ownership of a symlink)
 
       -f, --silent, --quiet
              suppress most error messages
 
       --reference=RFILE
              use  RFILE's owner and group rather than the speci­
              fied OWNER.GROUP values
 
       -R, --recursive
              operate on files and directories recursively
 
       -v, --verbose
              output a diagnostic for every file processed
 
              output version information and exit
 
       Owner is unchanged if  missing.   Group  is  unchanged  if
       missing,  but  changed  to  login  group  if  implied by a
       period.  A colon may replace the period.

 

 

    1. Modifying groups (chggroup)

 

NAME

 
chgrp - change group ownership
 
 

SYNOPSIS

       chgrp [OPTION]... GROUP FILE...
       chgrp [OPTION]... --reference=RFILE FILE...
 
 

DESCRIPTION

       Change the group membership of each FILE to GROUP.
 
       -c, --changes
              like verbose but report only when a change is made
 
       --dereference
              affect  the  referent of each symbolic link, rather
              than the symbolic link itself
 
       -h, --no-dereference
              affect symbolic links  instead  of  any  referenced
              file (available only on systems that can change the
              ownership of a symlink)
 
       -f, --silent, --quiet
              suppress most error messages
 
       --reference=RFILE
              use RFILE's group rather than the  specified  GROUP
              value
 
       -R, --recursive
              operate on files and directories recursively
 
       -v, --verbose
              output a diagnostic for every file processed
 
       --help display this help and exit
 
       --version
              output version information and exit
 

Chapter 3

3.1 Generalities

3.2 Essential Commands

  1. Date

NAME

date - show and set date and time      

SYNOPSIS

date [ -u ] [ -c ] [ -n ] [ -d dsttype ] [ -t minutes-west ] [ -a [ + | -] sss . fff ] [ +format ] [ [ yyyy ] mmddhhmm [ yy ][ . ss ] ]

DESCRIPTION

Date without arguments writes the date and time to the standard output in the form Wed Mar 8 14:54:40 EST 1989
with EST replaced by the local time zone's abbreviation (or by the abbreviation for the time zone specified in the TZ environment variable if set). The exact output format depends on the locale.

If a command-line argument starts with a plus sign (`+'), the rest of the argument is used as a format that controls what appears in the output. In the format, when a percent sign (`%') appears, it and the character after it are not output, but rather identify part of the date or time to be output in a particular way (or identify a special character to output):

* The exact output depends on the locale.
If a character other than one of those shown above appears after a percent sign in the format, that following character is output. All other characters in the format are copied unchanged to the output; a newline character is always added at the end of the output.

In Sunday-based week numbering, the first Sunday of the year begins week 1; days preceding it are part of ``week 0.'' In Monday-based week numbering, the first Monday of the year begins week 1.

To set the date, use a command line argument with one of the following forms:

If the century, year, month, or month day is not given, the current value is used. Any of the above forms may be followed by a period and two digits that give the seconds part of the new time; if no seconds are given, zero is assumed.

These options are available:

}

-u or -c

Use GMT when setting and showing the date and time.

-n

Do not notify other networked systems of the time change.

-d dsttype

Set the kernel-stored Daylight Saving Time type to the given value. (The kernel-stored DST type is used mostly by ``old'' binaries.)

-t minutes-west

Set the kernel-stored ``minutes west of GMT'' value to the one given on the command line. (The kernel-stored DST type is used mostly by ``old'' binaries.)

-a adjustment

Change the time forward (or backward) by the number of seconds (and fractions thereof) specified in the adjustment argument. Either the seconds part or the fractions part of the argument (but not both) may be omitted. On BSD-based systems, the adjustment is made by changing the rate at which time advances; on System-V-based systems, the adjustment is made by changing the time.

/usr/lib/locale/ L /LC_TIME description of time locale L
/usr/local/etc/zoneinfo time zone information directory
/usr/local/etc/zoneinfo/localtime local time zone file
/usr/local/etc/zoneinfo/posixrules used with POSIX-style TZ's
/usr/local/etc/zoneinfo/GMT for UTC leap seconds

If /usr/local/etc/zoneinfo/GMT is absent, UTC leap seconds are loaded from
/usr/local/etc/zoneinfo/posixrules.


  1. ls (-c, -t, -r, -l , -a)

NAME

ls, dir, vdir - list contents of directories        

SYNOPSIS

ls [-abcdfgiklmnpqrstuxABCFGLNQRSUX1] [-w cols] [-T cols] [-I pattern] [--all] [--escape] [--directory] [--inode] [--kilobytes] [--numeric-uid-gid] [-no-group] [--hide-control-chars] [--reverse] [--size] [--width=cols]
[--tabsize=cols] [--almost-all] [--ignore-backups] [--classify] [--file-type] [--full-time] [--ignore=pattern] [--dereference] [--literal] [--quote-name] [--recursive] [--sort={none, time, size, extension}] [--format={long, verbose, commas, across, vertical, single-column}] [--time={atime, access, use, ctime, status}] [--help] [--version] [name...]

DESCRIPTION

This manual page documents the GNU version of ls. dir and vdir are versions of ls with different default output formats. These programs list each given file or directory name. Directory contents are sorted alphabetically. For ls, files are by default listed in columns, sorted vertically, if the standard output is a terminal; otherwise they are listed one per line. For dir, files are by default listed in columns, sorted vertically. For vdir, files are by default listed in long format.

OPTIONS

-a, --all

List all files in directories, including all files that start with `.'.

-b, --escape

Quote nongraphic characters in file names using alphabetic and octal backslash sequences like those used in C.

-c, --time=ctime, --time=status

Sort directory contents according to the files' status change time instead of the modification time. If the long listing format is being used, print the status change time instead of the modification time.

-d, --directory

List directories like other files, rather than listing their contents.

-f

Do not sort directory contents; list them in whatever order they are stored on the disk. The same as enabling -a and -U and disabling -l, -s, and -t.

--full-time

List times in full, rather than using the standard abbreviation heuristics.

-g

Ignored; for Unix compatibility.

-i, --inode

Print the index number of each file to the left of the file name.

-k, --kilobytes

If file sizes are being listed, print them in kilobytes. This overrides the environment variable POSIXLY_CORRECT.

-l, --format=long, --format=verbose

In addition to the name of each file, print the file type, permissions, number of hard links, owner name, group name, size in bytes, and timestamp (the modification time unless other times are selected). For files with a time that is more than 6 months old or more than 1 hour into the future, the timestamp contains the year instead of the time of day.

-m, --format=commas

List files horizontally, with as many as will fit on each line, separated by commas.

-n, --numeric-uid-gid

List the numeric UID and GID instead of the names.

-p

Append a character to each file name indicating the file type.

-q, --hide-control-chars

Print question marks instead of nongraphic characters in file names.

-r, --reverse

Sort directory contents in reverse order.

-s, --size

Print the size of each file in 1K blocks to the left of the file name. If the environment variable POSIXLY_CORRECT is set, 512-byte blocks are used instead.

-t, --sort=time

Sort directory contents by timestamp instead of alphabetically, with the newest files listed first.

-u, --time=atime, --time=access, --time=use

Sort directory contents according to the files' last access time instead of the modification time. If the long listing format is being used, print the last access time instead of the modification time.

-x, --format=across, --format=horizontal

List the files in columns, sorted horizontally.

-A, --almost-all

List all files in directories, except for `.' and `..'.

-B, --ignore-backups

Do not list files that end with `~', unless they are given on the command line.

-C, --format=vertical

List files in columns, sorted vertically.

-F, --classify

Append a character to each file name indicating the file type. For regular files that are executable, append a `*'. The file type indicators are `/' for directories, `@' for symbolic links, `|' for FIFOs, `=' for sockets, and nothing for regular files.

-G, --no-group

Inhibit display of group information in a long format directory listing.

-L, --dereference

List the files linked to by symbolic links instead of listing the contents of the links.

-N, --literal

Do not quote file names.

-Q, --quote-name

Enclose file names in double quotes and quote nongraphic characters as in C.

-R, --recursive

List the contents of all directories recursively.

-S, --sort=size

Sort directory contents by file size instead of alphabetically, with the largest files listed first.

-U, --sort=none

Do not sort directory contents; list them in whatever order they are stored on the disk. This option is not called -f because the Unix ls -f option also enables -a and disables -l, -s, and -t. It seems useless and ugly to group those unrelated things together in one option. Since this option doesn't do that, it has a different name.

-X, --sort=extension

Sort directory contents alphabetically by file extension (characters after the last `.'); files with no extension are sorted first.

-1, --format=single-column

List one file per line.

-w, --width cols

Assume the screen is cols columns wide. The default is taken from the terminal driver if possible; otherwise the environment variable COLUMNS is used if it is set; otherwise the default is 80.

-T, --tabsize cols

Assume that each tabstop is cols columns wide. The default is 8.

-I, --ignore pattern

Do not list files whose names match the shell pattern pattern unless they are given on the command line. As in the shell, an initial `.' in a filename does not match a wildcard at the start of pattern.

--help

Print a usage message on standard output and exit successfully.

--version

Print version information on standard output then exit successfully.

On BSD systems, the -s option reports sizes that are half the correct values for files that are NFS-mounted from HP-UX systems. On HP-UX systems, it reports sizes that are twice the correct values for files that are NFS-mounted from BSD systems. This is due to a flaw in HP-UX; it also affects the HP-UX ls program

 


  1. echo

 

NAME

echo - display a line of text
 

SYNOPSIS

       echo [OPTION]... [STRING]...
 

DESCRIPTION

       Echo the STRING(s) to standard output.
 
       -n     do not output the trailing newline
 
       -e     enable   interpretation  of  the  backslash-escaped
              characters
 
              listed below
 
       -E     disable  interpretation  of  those   sequences   in
              STRINGs
 
       --help display this help and exit (should be alone)
 
       --version
              output  version  information  and  exit  (should be
              alone)
 
       Without -E, the following  sequences  are  recognized  and
       interpolated:
 
 
       the character whose ASCII code is NNN (octal)
 
       b      backslash
       a
       c....  alert (BEL)
       k
       s.TP   suppress trailing newline
       p
       a
       form feed
       e
 
       new line
              carriage return
 
 
              horizontal tab
 
       vertical tab

 

 

 

 


  1. who

 

 

 

NAME

 
who - show who is logged on
 
 

SYNOPSIS

       who [OPTION]... [ FILE | ARG1 ARG2 ]
 
 

DESCRIPTION

       -H, --heading
              print line of column headings
 
       -i, -u, --idle
              add user idle time as HOURS:MINUTES, . or old
 
       -l, --lookup
              attempt to canonicalize hostnames via DNS
 
       -m     only hostname and user associated with stdin
 
       -q, --count
              all login names and number of users logged on
 
       -s     (ignored)
 
       -T, -w, --mesg
              add user's message status as +, - or ?
 
       --message
              same as -T
 
       --writable
              same as -T
 
       --help display this help and exit
 
       --version
              output version information and exit
 
       If    FILE    is   not   specified,   use   /var/run/utmp.
       /var/log/wtmp as FILE is common.  If ARG1 ARG2  given,  -m
       presumed: `am i' or `mom likes' are usual.

  1. ps

 

NAME

ps - report process status   

SYNOPSIS

ps [ - ][ lujsvmaxScewhrnu ][ t xx ]\ [ O [ + | - ] k1 [[ + | - ] k2 ...]]\ [ pids ]

there are also two long options:

--sort X[+|-] key[,[+|-] key[,...]]

--help

More long options are on the way...

DESCRIPTION

ps gives a snapshot of the current processes. If you want a repetitive update of this status, use top. This man page documents the /proc-based version of ps, or tries to.

COMMAND-LINE OPTIONS

Command line arguments may optionally be preceeded by a '-', but there is no need for it. There are also some "long options" in GNU style; see below for those.

l

long format

u

user format: gives user name and start time

j

jobs format: pgid sid

s

signal format

v

vm format

m

displays memory info (combine with p flag to get number of pages).

f

"forest" family tree format for command line

a

show processes of other users too

x

show processes without controlling terminal

S

add child cpu time and page faults

c

command name from task_struct

e

show environment after command line and ` + '

w

wide output: don't truncate command lines to fit on one line.

h

no header

r

running procs only

n

numeric output for USER and WCHAN.

txx

only procs with controlling tty xx; use for xx the same letters as shown in the TT field. The tty name must be given immediately after the option, with no intervening space, e.g. ps -tv1.

O[+|-] k1[,[+|-] k2[,...]]

Order the process listing according to the multi-level sort specified by the sequence of short keys from SORT KEYS , k1 , k2 , ... Default order specifications exist for each of the various formats of ps . These are over-ridden by a user specified ordering. The `+' is quite optional, merely re-iterating the default direction on a key. `-' reverses direction only on the key it precedes. As with t and pids , the O option must be the last option in a single command argument, but specifications in successive arguments are catenated.

pids

List only the specified processes; they are comma-delimited. The list must be given immediately after the last option in a single command-line argument, with no intervening space, e.g. ps -j1,4,5. Lists specified in subsequent arguments are catenated, e.g. ps -l 1,2 3,4 5 6 will list all of the processes 1-6 in long format.

These options are preceeded by a double-hyphen. X}[+|-] key[,[+|-] key[,...]] }

--sort X[+|-] key[,[+|-] key[,...]]

Choose a multi-letter key from the SORT KEYS section. X may be any convenient separator character. To be GNU-ish use `='. The `+' is really optional since default direction is increasing numerical or lexicographic order. E.g.: ps -jax -sort=uid,-ppid,+pid

--help

Get a help message that summarizes the usage and gives a list of supported sort keys. This list may be more up to date than this man page.

Note that the values used in sorting are the internal values ps uses and not the `cooked' values used in some of the output format fields. If someone wants to volunteer to write special comparison functions for the cooked values, ... ;-)

SHORT LONG DESCRIPTION

c cmd simple name of executable

C cmdline full command line

f flags flags as in long format F field

g pgrp process group ID

G tpgid controlling tty process group ID

j cutime cumulative user time

J cstime cumulative system time

k utime user time

K stime system time

m min_flt number of minor page faults

M maj_flt number of major page faults

n cmin_flt cumulative minor page faults

N cmaj_flt cumulative major page faults

o session session ID

p pid process ID

P ppid parent process ID

r rss resident set size

R resident resident pages

s size memory size in kilobytes

S share amount of shared pages

t tty the minor device number of tty

T start_time time process was started

U uid user ID number

u user user name

v vsize total VM size in bytes

y priority kernel scheduling priority

FIELD DESCRIPTIONS

PRI

This is the counter field in the task struct. It is the time in HZ of the process's possible timeslice.

NI

Standard unix nice value; a positive value means less cpu time.

SIZE

Virtual image size; size of text+data+stack.

RSS

Resident set size; kilobytes of program in memory.

WCHAN

Name of the kernel function where the process is sleeping, with the `sys_' stripped from the function name. If /boot/psdatabase does not exist, it is just a hex number instead.

STAT

Information about the status of the process. The first field is R for runnable, S for sleeping, D for uninterruptible sleep, T for stopped or traced, or Z for a zombie process. The second field contains W if the process has no resident pages. The third field is N if the process has a positive nice value (NI field).

TT

Controlling tty.

PAGEIN

Number of major page faults (page faults that cause pages to be read from disk, including pages read from the buffer cache).

TRS

Text resident size.

SWAP

Kilobytes (or pages if -p is used) on swap device.

SHARE

Shared memory.

This proc-based ps works by reading the files in the proc filesystem, mounted on /proc. This ps does not need to be suid kmem or have any privileges to run. Do not give this ps any special permissions.

You will need to update the /boot/psdatabase file by running /usr/sbin/psupdate to get meaningful information from the WCHAN field. This should be done every time you compile a new kernel.

NOTES

The member used_math of task_struct is not shown, since crt0.s checks to see if math is present. This causes the math flag to be set for all processes, and so it is worthless.

Programs swapped out to disk will be shown without command line arguments, and unless the c option is given, in parentheses.

%CPU shows the cputime/realtime percentage. It will not add up to 100% unless you are lucky. It is time used divided by the time the process has been running.

The SIZE and RSS fields don't count the page tables and the task_struct of a proc; this is at least 12k of memory that is always resident. SIZE is the virtual size of the proc (code+data+stack).


  1. pwd

 

 

 

NAME

 
pwd - print name of current/working directory
 

SYNOPSIS

       pwd [OPTION]
 
 

DESCRIPTION

       Print  the full filename of the current working directory.
 
       --help display this help and exit
 
       --version
              output version information and exit

 


  1. cp

 

NAME

cp - copy files      

SYNOPSIS

cp [options] source dest
cp [options] source... directory
Options:
[-abdfilprsuvxPR] [-S backup-suffix] [-V {numbered,existing,simple}] [--backup] [--no-dereference] [--force] [--interactive] [--one-file-system] [--preserve] [--recursive] [--update] [--verbose] [--suffix=backup-suffix]
[--version-control={numbered,existing,simple}] [--archive] [--parents] [--link] [--symbolic-link] [--help] [--version]

DESCRIPTION

This manual page documents the GNU version of cp. If the last argument names an existing directory, cp copies each other given file into a file with the same name in that directory. Otherwise, if only two files are given, it copies the first onto the second. It is an error if the last argument is not a directory and more than two files are given. By default, it does not copy directories.

OPTIONS

-a, --archive

Preserve as much as possible of the structure and attributes of the original files in the copy. The same as -dpR.

-b, --backup

Make backups of files that are about to be overwritten or removed.

-d, --no-dereference

Copy symbolic links as symbolic links rather than copying the files that they point to, and preserve hard link relationships between source files in the copies.

-f, --force

Remove existing destination files.

-i, --interactive

Prompt whether to overwrite existing regular destination files.

-l, --link

Make hard links instead of copies of non-directories.

-P, --parents

Form the name of each destination file by appending to the target directory a slash and the specified name of the source file. The last argument given to cp must be the name of an existing directory. For example, the command `cp --parents a/b/c existing_dir' copies the file a/b/c to existing_dir/a/b/c, creating any missing intermediate directories.

-p, --preserve

Preserve the original files' owner, group, permissions, and timestamps.

-r

Copy directories recursively, copying all non-directories as if they were regular files.

-s, --symbolic-link

Make symbolic links instead of copies of non-directories. All source filenames must be absolute (starting with `/') unless the destination files are in the current directory. This option produces an error message on systems that do not support symbolic links.

-u, --update

Do not copy a nondirectory that has an existing destination with the same or newer modification time.

-v, --verbose

Print the name of each file before copying it.

-x, --one-file-system

Skip subdirectories that are on different filesystems from the one that the copy started on.

-R, --recursive

Copy directories recursively.

--help

Print a usage message on standard output and exit successfully.

--version

Print version information on standard output then exit successfully.

-S, --suffix backup-suffix

The suffix used for making simple backup files can be set with the SIMPLE_BACKUP_SUFFIX environment variable, which can be overridden by this option. If neither of those is given, the default is `~', as it is in Emacs.

-V, --version-control {numbered,existing,simple}

The type of backups made can be set with the VERSION_CONTROL environment variable, which can be overridden by this option. If VERSION_CONTROL is not set and this option is not given, the default backup type is `existing'. The value of the VERSION_CONTROL environment variable and the argument to this option are like the GNU Emacs `version-control' variable; they also recognize synonyms that are more descriptive. The valid values are (unique abbreviations are accepted):

`t' or `numbered'

Always make numbered backups.

`nil' or `existing'

Make numbered backups of files that already have them, simple backups of the others.

`never' or `simple'

Always make simple backups.

 

 


  1. mv

 

NAME

mv - rename files     

SYNOPSIS

mv [options] source dest
mv [options] source... directory
Options:
[-bfiuv] [-S backup-suffix] [-V {numbered,existing,simple}] [--backup] [--force] [--interactive] [--update] [--verbose] [--suffix=backup-suffix]

[--version-control={numbered,existing,simple}] [--help] [--version]

DESCRIPTION

This manual page documents the GNU version of mv. If the last argument names an existing directory, mv moves each other given file into a file with the same name in that directory. Otherwise, if only two files are given, it moves the first onto the second. It is an error if the last argument is not a directory and more than two files are given. It can move only regular files across filesystems. If a destination file is unwritable, the standard input is a tty, and the -f or --force option is not given, mv prompts the user for whether to overwrite the file. If the response does not begin with `y' or `Y', the file is skipped.

OPTIONS

-b, --backup

Make backups of files that are about to be removed.

-f, --force

Remove existing destination files and never prompt the user.

-i, --interactive

Prompt whether to overwrite each destination file that already exists. If the response does not begin with `y' or `Y', the file is skipped.

-u, --update

Do not move a nondirectory that has an existing destination with the same or newer modification time.

-v, --verbose

Print the name of each file before moving it.

--help

Print a usage message on standard output and exit successfully.

--version

Print version information on standard output then exit successfully.

-S, --suffix backup-suffix

The suffix used for making simple backup files can be set with the SIMPLE_BACKUP_SUFFIX environment variable, which can be overridden by this option. If neither of those is given, the default is `~', as it is in Emacs.

-V, --version-control {numbered,existing,simple}

The type of backups made can be set with the VERSION_CONTROL environment variable, which can be overridden by this option. If VERSION_CONTROL is not set and this option is not given, the default backup type is `existing'. The value of the VERSION_CONTROL environment variable and the argument to this option are like the GNU Emacs `version-control' variable; they also recognize synonyms that are more descriptive. The valid values are (unique abbreviations are accepted):

`t' or `numbered'

Always make numbered backups.

`nil' or `existing'

Make numbered backups of files that already have them, simple backups of the others.

`never' or `simple'

Always make simple backups.

 

 


  1. df

 

NAME

df - summarize free disk space    

SYNOPSIS

df [-aikPv] [-t fstype] [-x fstype] [--all] [--inodes] [--type=fstype]
[--exclude-type=fstype] [--kilobytes] [--portability] [--print-type] [--help] [--version] [filename...]

DESCRIPTION

This manual page documents the GNU version of df. df displays the amount of disk space available on the filesystem containing each file name argument. If no file name is given, the space available on all currently mounted filesystems is shown. Disk space is shown in 1K blocks by default, unless the environment variable
POSIXLY_CORRECT is set, in which case 512-byte blocks are used.

If an argument is the absolute file name of a disk device node containing a mounted filesystem, df shows the space available on that filesystem rather than on the filesystem containing the device node (which is always the root filesystem). This version of df cannot show the space available on unmounted filesystems, because on most kinds of systems doing so requires very nonportable intimate knowledge of filesystem structures.

OPTIONS

-a, --all

Include in the listing filesystems that have 0 blocks, which are omitted by default. Such filesystems are typically special-purpose pseudo-filesystems, such as automounter entries. On some systems, filesystems of type ``ignore'' or ``auto'' are also omitted by default and included in the listing by this option.

-i, --inodes

List inode usage information instead of block usage. An inode (short for ``index node'') is a special kind of disk block that contains information about a file, such as its owner, permissions, timestamps, and location on the disk.

-k, --kilobytes

Print sizes in 1K blocks instead of 512-byte blocks. This overrides the environment variable POSIXLY_CORRECT.

-P, --portability

Use the POSIX output format. This is like the default format except that the information about each filesystem is always printed on exactly one line; a mount device is never put on a line by itself. This means that if the mount device name is more than 20 characters long (as for some network mounts), the columns are misaligned.

-T, --print-type

Print a type string for each filesystem. Any such printed filesystem type name may be used as an argument to either of the --type= or --exclude-type= options.

-t, --type=fstype

Limit the listing to filesystems of type fstype. Multiple filesystem types can be shown by giving multiple -t options. By default, all filesystem types are listed.

-x, --exclude-type=fstype

Limit the listing to filesystems not of type fstype. Multiple filesystem types can be eliminated by giving multiple -x options. By default, all filesystem types are listed.

-v

Ignored; for compatibility with System V versions of df.

--help

Print a usage message on standard output and exit successfully.

--version

Print version information on standard output then exit successfully.

 

 


  1. diff

 

NAME

diff - find differences between two files
 

SYNOPSIS

       diff [options] from-file to-file
 
 

DESCRIPTION

       In  the  simplest  case, diff compares the contents of the
       two files from-file and to-file.  A file name of -  stands
       for text read from the standard input.  As a special case,
       diff - - compares a copy of standard input to itself.
 
       If from-file is a directory and to-file is not, diff  com­
       pares the file in from-file whose file name is that of to-
       file, and vice versa.  The non-directory file must not  be
       -.
 
       If  both  from-file and to-file are directories, diff com­
       pares corresponding files in both directories,  in  alpha­
       betical order; this comparison is not recursive unless the
       -r or --recursive option is given.   diff  never  compares
       the  actual  contents of a directory as if it were a file.
       The file that is  fully  specified  may  not  be  standard
       input,  because  standard input is nameless and the notion
       of ``file with the same name'' does not apply.
 
       diff options begin with -, so normally from-file  and  to-
       file  may not begin with -.  However, -- as an argument by
       itself treats the remaining arguments as file  names  even
       if they begin with -.
 
   Options
       Below  is  a  summary  of all of the options that GNU diff
       accepts.  Most options have two equivalent names,  one  of
       which  is  a single letter preceded by -, and the other of
       which is a long name preceded by --.  Multiple single let­
       ter options (unless they take an argument) can be combined
       into a single command line word: -ac is equivalent  to  -a
       -c.   Long  named options can be abbreviated to any unique
       prefix of their name.  Brackets ([ and ]) indicate that an
       option takes an optional argument.
 
       -lines Show  lines  (an  integer)  lines of context.  This
              option does not specify an output format by itself;
              it  has  no effect unless it is combined with -c or
              -u.  This option is obsolete.   For  proper  opera­
              tion,  patch  typically needs at least two lines of
              context.
 
       -a     Treat all files as text and compare  them  line-by-
              line, even if they do not seem to be text.
 
       -b     Ignore changes in amount of white space.
              lines.
 
       --brief
              Report only  whether  the  files  differ,  not  the
              details of the differences.
 
       -c     Use the context output format.
 
       -C lines
       --context[=lines]
              Use  the  context  output format, showing lines (an
              integer) lines of context, or three if lines is not
              given.  For proper operation, patch typically needs
              at least two lines of context.
 
       --changed-group-format=format
              Use format to output a line group  containing  dif­
              fering  lines  from both files in if-then-else for­
              mat.
 
       -d     Change the algorithm to perhaps find a smaller  set
              of changes.  This makes diff slower (sometimes much
              slower).
 
       -D name
              Make merged if-then-else format output, conditional
              on the preprocessor macro name.
 
       -e
       --ed   Make output that is a valid ed script.
 
       --exclude=pattern
              When comparing directories, ignore files and subdi­
              rectories whose basenames match pattern.
 
       --exclude-from=file
              When comparing directories, ignore files and subdi­
              rectories  whose  basenames  match any pattern con­
              tained in file.
 
       --expand-tabs
              Expand tabs to spaces in the  output,  to  preserve
              the alignment of tabs in the input files.
 
       -f     Make  output  that  looks vaguely like an ed script
              but has changes in the order  they  appear  in  the
              file.
 
       -F regexp
              In  context  and  unified  format, for each hunk of
              differences, show some of the last  preceding  line
              that matches regexp.
              Make  output  that  looks vaguely like an ed script
              but has changes in the order  they  appear  in  the
              file.
 
       -h     This  option currently has no effect; it is present
              for Unix compatibility.
 
       -H     Use heuristics to speed  handling  of  large  files
              that have numerous scattered small changes.
 
       --horizon-lines=lines
              Do  not  discard the last lines lines of the common
              prefix and the first lines lines of the common suf­
              fix.
 
       -i     Ignore  changes in case; consider upper- and lower-
              case letters equivalent.
 
       -I regexp
              Ignore changes that just  insert  or  delete  lines
              that match regexp.
 
       --ifdef=name
              Make merged if-then-else format output, conditional
              on the preprocessor macro name.
 
       --ignore-all-space
              Ignore white space when comparing lines.
 
       --ignore-blank-lines
              Ignore changes that just  insert  or  delete  blank
              lines.
 
       --ignore-case
              Ignore  changes in case; consider upper- and lower-
              case to be the same.
 
       --ignore-matching-lines=regexp
              Ignore changes that just  insert  or  delete  lines
              that match regexp.
 
       --ignore-space-change
              Ignore changes in amount of white space.
 
       --initial-tab
              Output a tab rather than a space before the text of
              a line in normal or context  format.   This  causes
              the alignment of tabs in the line to look normal.
 
       -l     Pass the output through pr to paginate it.
 
       -L label
              Use  label  instead of the file name in the context
              format and unified format headers.
 
       --left-column
              Print only the left column of two common  lines  in
              side by side format.
 
       --line-format=format
              Use  format  to  output all input lines in in-then-
              else format.
 
       --minimal
              Change the algorithm to perhaps find a smaller  set
              of changes.  This makes diff slower (sometimes much
              slower).
 
       -n     Output RCS-format diffs; like -f except  that  each
              command specifies the number of lines affected.
 
       -N
       --new-file
              In directory comparison, if a file is found in only
              one directory, treat it as present but empty in the
              other directory.
 
       --new-group-format=format
              Use  format  to  output a group of lines taken from
              just the second file in if-then-else format.
 
       --new-line-format=format
              Use format to output a line  taken  from  just  the
              second file in if-then-else format.
 
       --old-group-format=format
              Use  format  to  output a group of lines taken from
              just the first file in if-then-else format.
 
       --old-line-format=format
              Use format to output a line  taken  from  just  the
              first file in if-then-else format.
 
       -p     Show which C function each change is in.
 
       -P     When  comparing directories, if a file appears only
              in the second directory of the  two,  treat  it  as
              present but empty in the other.
 
       --paginate
              Pass the output through pr to paginate it.
 
       -q     Report  only  whether  the  files  differ,  not the
              details of the differences.
              subdirectories found.
 
       --rcs  Output  RCS-format  diffs; like -f except that each
              command specifies the number of lines affected.
 
       --recursive
              When comparing directories, recursively compare any
              subdirectories found.
 
       --report-identical-files
       -s     Report when two files are the same.
 
       -S file
              When  comparing  directories,  start  with the file
              file.  This is used for resuming an aborted compar­
              ison.
 
       --sdiff-merge-assist
              Print  extra information to help sdiff.  sdiff uses
              this option when it runs diff.  This option is  not
              intended for users to use directly.
 
       --show-c-function
              Show which C function each change is in.
 
       --show-function-line=regexp
              In  context  and  unified  format, for each hunk of
              differences, show some of the last  preceding  line
              that matches regexp.
 
       --side-by-side
              Use the side by side output format.
 
       --speed-large-files
              Use  heuristics  to  speed  handling of large files
              that have numerous scattered small changes.
 
       --starting-file=file
              When comparing directories,  start  with  the  file
              file.  This is used for resuming an aborted compar­
              ison.
 
       --suppress-common-lines
              Do not print common lines in side by side format.
 
       -t     Expand tabs to spaces in the  output,  to  preserve
              the alignment of tabs in the input files.
 
       -T     Output a tab rather than a space before the text of
              a line in normal or context  format.   This  causes
              the alignment of tabs in the line to look normal.
 
 
       -u     Use the unified output format.
 
       --unchanged-group-format=format
              Use format to output a group of common lines  taken
              from both files in if-then-else format.
 
       --unchanged-line-format=format
              Use format to output a line common to both files in
              if-then-else format.
 
       --unidirectional-new-file
              When comparing directories, if a file appears  only
              in  the  second  directory  of the two, treat it as
              present but empty in the other.
 
       -U lines
       --unified[=lines]
              Use the unified output format,  showing  lines  (an
              integer) lines of context, or three if lines is not
              given.  For proper operation, patch typically needs
              at least two lines of context.
 
       -v
       --version
              Output the version number of diff.
 
       -w     Ignore white space when comparing lines.
 
       -W columns
       --width=columns
              Use an output width of columns in side by side for­
              mat.
 
       -x pattern
              When comparing directories, ignore files and subdi­
              rectories whose basenames match pattern.
 
       -X file
              When comparing directories, ignore files and subdi­
              rectories whose basenames match  any  pattern  con­
              tained in file.
 
       -y     Use the side by side output format.

 

 


  1. grep

 

NAME

grep, egrep, fgrep - print lines matching a pattern       

SYNOPSIS

grep [ -[[AB] ] num ] [ -[CEFGVBchilnsvwx] ] [ -e ] pattern | -ffile ] [ files... ]

DESCRIPTION

Grep searches the named input files (or standard input if no files are named, or the file name - is given) for lines containing a match to the given pattern. By default, grep prints the matching lines.

There are three major variants of grep, controlled by the following options.

-G

Interpret pattern as a basic regular expression (see below). This is the default.

-E

Interpret pattern as an extended regular expression (see below).

-F

Interpret pattern as a list of fixed strings, separated by newlines, any of which is to be matched.

In addition, two variant programs egrep and fgrep are available. Egrep is similiar (but not identical) to grep -E, and is compatible with the historical Unix egrep. Fgrep is the same as grep -F.

All variants of grep understand the following options:

}

-num

Matches will be printed with num lines of leading and trailing context. However, grep will never print any given line more than once.

-A num

Print num lines of trailing context after matching lines.

-B num

Print num lines of leading context before matching lines.

-C

Equivalent to -2.

-V

Print the version number of grep to standard error. This version number should be included in all bug reports (see below).

-b

Print the byte offset within the input file before each line of output.

-c

Suppress normal output; instead print a count of matching lines for each input file. With the -v option (see below), count non-matching lines.

-e pattern

Use pattern as the pattern; useful to protect patterns beginning with -.

-f file

Obtain the pattern from file.

-h

Suppress the prefixing of filenames on output when multiple files are searched.

-i

Ignore case distinctions in both the pattern and the input files.

-L

Suppress normal output; instead print the name of each input file from which no output would normally have been printed.

-l

Suppress normal output; instead print the name of each input file from which output would normally have been printed.

-n

Prefix each line of output with the line number within its input file.

-q

Quiet; suppress normal output.

-s

Suppress error messages about nonexistent or unreadable files.

-v

Invert the sense of matching, to select non-matching lines.

-w

Select only those lines containing matches that form whole words. The test is that the matching substring must either be at the beginning of the line, or preceded by a non-word constituent character. Similarly, it must be either at the end of the line or followed by a non-word constituent character. Word-constituent characters are letters, digits, and the underscore.

-x

Select only those matches that exactly match the whole line.

A regular expression is a pattern that describes a set of strings. Regular expressions are constructed analagously to arithmetic expressions, by using various operators to combine smaller expressions.

Grep understands two different versions of regular expression syntax: ``basic'' and ``extended.'' In GNU grep, there is no difference in available functionality using either syntax. In other implementations, basic regular expressions are less powerful. The following description applies to extended regular expressions; differences for basic regular expressions are summarized afterwards.

The fundamental building blocks are the regular expressions that match a single character. Most characters, including all letters and digits, are regular expressions that match themselves. Any metacharacter with special meaning may be quoted by preceding it with a backslash.

A list of characters enclosed by [ and ] matches any single character in that list; if the first character of the list is the caret ^ then it matches any character not in the list. For example, the regular expression [0123456789] matches any single digit. A range of ASCII characters may be specified by giving the first and last characters, separated by a hyphen. Finally, certain named classes of characters are predefined. Their names are self explanatory, and they are [:alnum:], [:alpha:], [:cntrl:], [:digit:], [:graph:], [:lower:], [:print:], [:punct:], [:space:], [:upper:], and [:xdigit:]. For example, [[:alnum:]] means [0-9A-Za-z], except the latter form is dependent upon the ASCII character encoding, whereas the former is portable. (Note that the brackets in these class names are part of the symbolic names, and must be included in addition to the brackets delimiting the bracket list.) Most metacharacters lose their special meaning inside lists. To include a literal ] place it first in the list. Similarly, to include a literal ^ place it anywhere but first. Finally, to include a literal - place it last.

The period . matches any single character. The symbol w is a synonym for [[:alnum:]] and W is a synonym for [^[:alnum]].

The caret ^ and the dollar sign are metacharacters that respectively match the empty string at the beginning and end of a line. The symbols < and > respectively match the empty string at the beginning and end of a word. The symbol b matches the empty string at the edge of a word, and B matches the empty string provided it's not at the edge of a word.

A regular expression matching a single character may be followed by one of several repetition operators:

?

The preceding item is optional and matched at most once.

*

The preceding item will be matched zero or more times.

+

The preceding item will be matched one or more times.

n

The preceding item is matched exactly n times.

n ,

The preceding item is matched n or more times.

, m

The preceding item is optional and is matched at most m times.

n , m

The preceding item is matched at least n times, but not more than m times.

Two regular expressions may be concatenated; the resulting regular expression matches any string formed by concatenating two substrings that respectively match the concatenated subexpressions.

Two regular expressions may be joined by the infix operator |; the resulting regular expression matches any string matching either subexpression.

Repetition takes precedence over concatenation, which in turn takes precedence over alternation. A whole subexpression may be enclosed in parentheses to override these precedence rules.

The backreference n , where n is a single digit, matches the substring previously matched by the nth parenthesized subexpression of the regular expression.

In basic regular expressions the metacharacters |, (, and ) lose their special meaning; instead use the backslashed versions ?, +, {, |, (, and ).

In egrep the metacharacter { loses its special meaning; instead use { .


  1. find

 

NAME

find - search for files in a directory hierarchy     

SYNOPSIS

find [path...] [expression]

DESCRIPTION

This manual page documents the GNU version of find. find searches the directory tree rooted at each given file name by evaluating the given expression from left to right, according to the rules of precedence (see section OPERATORS), until the outcome is known (the left hand side is false for and operations, true for or ), at which point find moves on to the next file name.

The first argument that begins with `-', `(', `)', `,', or `!' is taken to be the beginning of the expression; any arguments before it are paths to search, and any arguments after it are the rest of the expression. If no paths are given, the current directory is used. If no expression is given, the expression `-print' is used.

find exits with status 0 if all files are processed successfully, greater than 0 if errors occur.

EXPRESSIONS

The expression is made up of options (which affect overall operation rather than the processing of a specific file, and always return true), tests (which return a true or false value), and actions (which have side effects and return a true or false value), all separated by operators. -and is assumed where the operator is omitted. If the expression contains no actions other than -prune, -print is performed on all files for which the expression is true.

OPTIONS

All options always return true. They always take effect, rather than being processed only when their place in the expression is reached. Therefore, for clarity, it is best to place them at the beginning of the expression.

-daystart

Measure times (for -amin, -atime, -cmin, -ctime, -mmin, and -mtime) from the beginning of today rather than from 24 hours ago.

-depth

Process each directory's contents before the directory itself.

-follow

Dereference symbolic links. Implies -noleaf.

-help, --help

Print a summary of the command-line usage of find and exit.

-maxdepth levels

Descend at most levels (a non-negative integer) levels of directories below the command line arguments. `-maxdepth 0' means only apply the tests and actions to the command line arguments.

-mindepth levels

Do not apply any tests or actions at levels less than levels (a non-negative integer). `-mindepth 1' means process all files except the command line arguments.

-mount

Don't descend directories on other filesystems. An alternate name for -xdev, for compatibility with some other versions of find.

-noleaf

Do not optimize by assuming that directories contain 2 fewer subdirectories than their hard link count. This option is needed when searching filesystems that do not follow the Unix directory-link convention, such as CD-ROM or MS-DOS filesystems or AFS volume mount points. Each directory on a normal Unix filesystem has at least 2 hard links: its name and its `.' entry. Additionally, its subdirectories (if any) each have a `..' entry linked to that directory. When find is examining a directory, after it has statted 2 fewer subdirectories than the directory's link count, it knows that the rest of the entries in the directory are non-directories (`leaf' files in the directory tree). If only the files' names need to be examined, there is no need to stat them; this gives a significant increase in search speed.

-version, --version

Print the find version number and exit.

-xdev

Don't descend directories on other filesystems.

TESTS

Numeric arguments can be specified as

+n

for greater than n,

-n

for less than n,

n

for exactly n.

-amin n

File was last accessed n minutes ago.

-anewer file

File was last accessed more recently than file was modified. -anewer is affected by -follow only if -follow comes before -anewer on the command line.

-atime n

File was last accessed n *24 hours ago.

-cmin n

File's status was last changed n minutes ago.

-cnewer file

File's status was last changed more recently than file was modified. -cnewer is affected by -follow only if -follow comes before -cnewer on the command line.

-ctime n

File's status was last changed n *24 hours ago.

-empty

File is empty and is either a regular file or a directory.

-false

Always false.

-fstype type

File is on a filesystem of type type . The valid filesystem types vary among different versions of Unix; an incomplete list of filesystem types that are accepted on some version of Unix or another is: ufs, 4.2, 4.3, nfs, tmp, mfs, S51K, S52K. You can use -printf with the %F directive to see the types of your filesystems.

-gid n

File's numeric group ID is n .

-group gname

File belongs to group gname (numeric group ID allowed).

-ilname pattern

Like -lname, but the match is case insensitive.

-iname pattern

Like -name, but the match is case insensitive. For example, the patterns `fo*' and `F??' match the file names `Foo', `FOO', `foo', `fOo', etc.

-inum n

File has inode number n .

-ipath pattern

Like -path, but the match is case insensitive.

-iregex pattern

Like -regex, but the match is case insensitive.

-links n

File has n links.

-lname pattern

File is a symbolic link whose contents match shell pattern pattern . The metacharacters do not treat `/' or `.' specially.

-mmin n

File's data was last modified n minutes ago.

-mtime n

File's data was last modified n *24 hours ago.

-name pattern

Base of file name (the path with the leading directories removed) matches shell pattern pattern . The metacharacters (`*', `?', and `[]') do not match a `.' at the start of the base name. To ignore a directory and the files under it, use -prune; see an example in the description of -path.

-newer file

File was modified more recently than file . -newer is affected by -follow only if -follow comes before -newer on the command line.

-nouser

No user corresponds to file's numeric user ID.

-nogroup

No group corresponds to file's numeric group ID.

-path pattern

File name matches shell pattern pattern . The metacharacters do not treat `/' or `.' specially; so, for example,

find . -path './sr*sc'

will print an entry for a directory called './src/misc' (if one exists). To ignore a whole directory tree, use -prune rather than checking every file in the tree. For example, to skip the directory `src/emacs' and all files and directories under it, and print the names of the other files found, do something like this:

find . -path './src/emacs' -prune -o -print

-perm mode

File's permission bits are exactly mode (octal or symbolic). Symbolic modes use mode 0 as a point of departure.

-perm - mode

All of the permission bits mode are set for the file.

-perm + mode

Any of the permission bits mode are set for the file.

-regex pattern

File name matches regular expression pattern . This is a match on the whole path, not a search. For example, to match a file named `./fubar3', you can use the regular expression `.*bar.' or `.*b.*3', but not `b.*r3'.

-size n [bckw]

File uses n units of space. The units are 512-byte blocks by default or if `b' follows n , bytes if `c' follows n , kilobytes if `k' follows n , or 2-byte words if `w' follows n . The size does not count indirect blocks, but it does count blocks in sparse files that are not actually allocated.

-true

Always true.

-type c

File is of type c :

b

block (buffered) special

c

character (unbuffered) special

d

directory

p

named pipe (FIFO)

f

regular file

l

symbolic link

s

socket

-uid n

File's numeric user ID is n .

-used n

File was last accessed n days after its status was last changed.

-user uname

File is owned by user uname (numeric user ID allowed).

-xtype c

The same as -type unless the file is a symbolic link. For symbolic links: if -follow has not been given, true if the file is a link to a file of type c ; if -follow has been given, true if c is `l'. In other words, for symbolic links, -xtype checks the type of the file that -type does not check.

ACTIONS

-exec command ;

Execute command ; true if 0 status is returned. All following arguments to find are taken to be arguments to the command until an argument consisting of `;' is encountered. The string `{}' is replaced by the current file name being processed everywhere it occurs in the arguments to the command, not just in arguments where it is alone, as in some versions of find. Both of these constructions might need to be escaped (with a ` ') or quoted to protect them from expansion by the shell. The command is executed in the starting directory.

-fls file

True; like -ls but write to file like -fprint.

-fprint file

True; print the full file name into file file . If file does not exist when find is run, it is created; if it does exist, it is truncated. The file names ``/dev/stdout'' and ``/dev/stderr'' are handled specially; they refer to the standard output and standard error output, respectively.

-fprint0 file

True; like -print0 but write to file like -fprint.

-fprintf file format

True; like -printf but write to file like -fprint.

-ok command ;

Like -exec but ask the user first (on the standard input); if the response does not start with `y' or `Y', do not run the command, and return false.

-print

True; print the full file name on the standard output, followed by a newline.

-print0

True; print the full file name on the standard output, followed by a null character. This allows file names that contain newlines to be correctly interpreted by programs that process the find output.

-printf format

True; print format on the standard output, interpreting ` ' escapes and `%' directives. Field widths and precisions can be specified as with the `printf' C function. Unlike -print, -printf does not add a newline at the end of the string. The escapes and directives are:

a

Alarm bell.

b

Backspace.

c

Stop printing from this format immediately and flush the output.

f

Form feed.

n

Newline.

r

Carriage return.

t

Horizontal tab.

v

Vertical tab.

A literal backslash (` ').

A ` ' character followed by any other character is treated as an ordinary character, so they both are printed.

%%

A literal percent sign.

%a

File's last access time in the format returned by the C `ctime' function.

%A k

File's last access time in the format specified by k , which is either `@' or a directive for the C `strftime' function. The possible values for k are listed below; some of them might not be available on all systems, due to differences in `strftime' between systems.

@

seconds since Jan. 1, 1970, 00:00 GMT.

Time fields:

H

hour (00..23)

I

hour (01..12)

k

hour ( 0..23)

l

hour ( 1..12)

M

minute (00..59)

p

locale's AM or PM

r

time, 12-hour (hh:mm:ss [AP]M)

S

second (00..61)

T

time, 24-hour (hh:mm:ss)

X

locale's time representation (H:M:S)

Z

time zone (e.g., EDT), or nothing if no time zone is determinable

Date fields:

a

locale's abbreviated weekday name (Sun..Sat)

A

locale's full weekday name, variable length
(Sunday..Saturday)

b

locale's abbreviated month name (Jan..Dec)

B

locale's full month name, variable length (January..December)

c

locale's date and time (Sat Nov 04 12:02:33 EST 1989)

d

day of month (01..31)

D

date (mm/dd/yy)

h

same as b

j

day of year (001..366)

m

month (01..12)

U

week number of year with Sunday as first day of week (00..53)

w

day of week (0..6)

W

week number of year with Monday as first day of week (00..53)

x

locale's date representation (mm/dd/yy)

y

last two digits of year (00..99)

Y

year (1970...)

%b

File's size in 512-byte blocks (rounded up).

%c

File's last status change time in the format returned by the C `ctime' function.

%C k

File's last status change time in the format specified by k , which is the same as for %A.

%d

File's depth in the directory tree; 0 means the file is a command line argument.

%f

File's name with any leading directories removed (only the last element).

%F

Type of the filesystem the file is on; this value can be used for -fstype.

%g

File's group name, or numeric group ID if the group has no name.

%G

File's numeric group ID.

%h

Leading directories of file's name (all but the last element).

%H

Command line argument under which file was found.

%i

File's inode number (in decimal).

%k

File's size in 1K blocks (rounded up).

%l

Object of symbolic link (empty string if file is not a symbolic link).

%m

File's permission bits (in octal).

%n

Number of hard links to file.

%p

File's name.

%P

File's name with the name of the command line argument under which it was found removed.

%s

File's size in bytes.

%t

File's last modification time in the format returned by the C `ctime' function.

%T k

File's last modification time in the format specified by k , which is the same as for %A.

%u

File's user name, or numeric user ID if the user has no name.

%U

File's numeric user ID.

A `%' character followed by any other character is discarded (but the other character is printed).

-prune

If -depth is not given, true; do not descend the current directory.
If -depth is given, false; no effect.

-ls

True; list current file in `ls -dils' format on standard output. The block counts are of 1K blocks, unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.

OPERATORS

Listed in order of decreasing precedence:

( expr )

Force precedence.

! expr

True if expr is false.

-not expr

Same as ! expr .

expr1 expr2

And (implied); expr2 is not evaluated if expr1 is false.

expr1 -a expr2

Same as expr1 expr2 .

expr1 -and expr2

Same as expr1 expr2 .

expr1 -o expr2

Or; expr2 is not evaluated if expr1 is true.

expr1 -or expr2

Same as expr1 -o expr2 .

expr1 , expr2

List; both expr1 and expr2 are always evaluated. The value of expr1 is discarded; the value of the list is the value of expr2 .

locate (1L), locatedb (5L), updatedb (1L), xargs (1L) Finding Files (on-line in Info, or printed)

 


  1. sort

 

NAME

sort - sort lines of text files     

SYNOPSIS

sort [-cmus] [-t separator] [-o output-file] [-T tempdir] [-bdfiMnr] [+POS1 [-POS2]] [-k POS1[,POS2]] [file...]
sort {--help,--version}

DESCRIPTION

This manual page documents the GNU version of sort. sort sorts, merges, or compares all the lines from the given files, or the standard input if no files are given. A file name of `-' means standard input. By default, sort writes the results to the standard output.

sort has three modes of operation: sort (the default), merge, and check for sortedness. The following options change the operation mode:

-c

Check whether the given files are already sorted: if they are not all sorted, print an error message and exit with a status of 1.

-m

Merge the given files by sorting them as a group. Each input file should already be individually sorted. It always works to sort instead of merge; merging is provided because it is faster, in the case where it works.

A pair of lines is compared as follows: if any key fields have been specified, sort compares each pair of fields, in the order specified on the command line, according to the associated ordering options, until a difference is found or no fields are left.

If any of the global options Mbdfinr are given but no key fields are specified, sort compares the entire lines according to the global options.

Finally, as a last resort when all keys compare equal (or if no ordering options were specified at all), sort compares the lines byte by byte in machine collating sequence. The last resort comparison honors the -r global option. The -s (stable) option disables this last-resort comparison so that lines in which all fields compare equal are left in their original relative order. If no fields or global options are specified, -s has no effect.

GNU sort has no limits on input line length or restrictions on bytes allowed within lines. In addition, if the final byte of an input file is not a newline, GNU sort silently supplies one.

If the environment variable TMPDIR is set, sort uses it as the directory in which to put temporary files instead of the default, /tmp. The -T tempdir option is another way to select the directory for temporary files; it overrides the environment variable.

The following options affect the ordering of output lines. They may be specified globally or as part of a specific key field. If no key fields are specified, global options apply to comparison of entire lines; otherwise the global options are inherited by key fields that do not specify any special options of their own.

-b

Ignore leading blanks when finding sort keys in each line.

-d

Sort in `phone directory' order: ignore all characters except letters, digits and blanks when sorting.

-f

Fold lower case characters into the equivalent upper case characters when sorting so that, for example, `b' is sorted the same way `B' is.

-i

Ignore characters outside the ASCII range 040-0176 octal (inclusive) when sorting.

-M

An initial string, consisting of any amount of white space, followed by three letters abbreviating a month name, is folded to UPPER case and compared in the order `JAN' < `FEB' < ... < `DEC.' Invalid names compare low to valid names.

-n

Compare according to arithmetic value an initial numeric string consisting of optional white space, an optional - sign, and zero or more digits, optionally followed by a decimal point and zero or more digits.

-r

Reverse the result of comparison, so that lines with greater key values appear earlier in the output instead of later.

Other options are:

-o output-file

Write output to output-file instead of to the standard output. If output-file is one of the input files, sort copies it to a temporary file before sorting and writing the output to output-file.

-t separator

Use character separator as the field separator when finding the sort keys in each line. By default, fields are separated by the empty string between a non-whitespace character and a whitespace character. That is to say, given the input line ` foo bar', sort breaks it into fields ` foo' and ` bar'. The field separator is not considered to be part of either the field preceding or the field following it.

-u

For the default case or the -m option, only output the first of a sequence of lines that compare equal. For the -c option, check that no pair of consecutive lines compares equal.

+POS1 [-POS2]

Specify a field within each line to use as a sorting key. The field consists of the portion of the line starting at POS1 and up to (but not including) POS2 (or to the end of the line if POS2 is not given). The fields and character positions are numbered starting with 0.

-k POS1[,POS2]

An alternate syntax for specifying sorting keys. The fields and character positions are numbered starting with 1.

A position has the form f . c , where f is the number of the field to use and c is the number of the first character from the beginning of the field (for +pos ) or from the end of the previous field (for -pos ). The . c part of a position may be omitted in which case it is taken to be the first character in the field. If the -b option has been given, the . c part of a field specification is counted from the first nonblank character of the field (for +pos ) or from the first nonblank character following the previous field (for -pos ).

A +pos or -pos argument may also have any of the option letters Mbdfinr appended to it, in which case the global ordering options are not used for that particular field. The -b option may be independently attached to either or both of the +pos and -pos parts of a field specification, and if it is inherited from the global options it will be attached to both. If a -n or -M option is used, thus implying a -b option, the -b option is taken to apply to both the +pos and the -pos parts of a key specification. Keys may span multiple fields.

In addition, when GNU join is invoked with exactly one argument, the following options are recognized:

--help

Print a usage message on standard output and exit successfully.

--version

Print version information on standard output then exit successfully.

Historical (BSD and System V) implementations of sort have differed in their interpretation of some options, particularly -b, -f, and -n. GNU sort follows the POSIX behavior, which is usually (but not always!) like the System V behavior. According to POSIX -n no longer implies -b. For consistency, -M has been changed in the same way. This may affect the meaning of character positions in field specifications in obscure cases. If this bites you the fix is to add an explicit -b.

 

 


  1. clear

 

NAME

clear - clear terminal screen   

SYNOPSIS

clear

DESCRIPTION

clear calls tput(1) with the clear argument. This causes tput to attempt to clear the screen checking the data in /etc/termcap (for the GNU or BSD tput) or in the terminfo database (for the ncurses tput) and sending the appropriate sequence to the terminal. This command can be redirected to clear the screen of some other terminal.

SEE ALSO

reset(1), stty(1), tput(1)

 


  1. lp
 

NAME

 
lp - line printer devices
 

SYNOPSIS

       #include <linux/lp.h>
 
 

CONFIGURATION

       lp[0-2] are character devices for the parallel line print­
       ers; they have major number 6 and minor number  0-2.   The
       minor   numbers   correspond  to  the  printer  port  base
       addresses 0x03bc, 0x0378 and 0x0278.   Usually  they  have
       mode  220 and are owned by root and group lp.  You can use
       printer ports either  with  polling  or  with  interrupts.
       Interrupts  are recommended when high traffic is expected,
       e.g. for laser printers.  For usual  dot  matrix  printers
       polling will usually be enough.  The default is polling.
 
 

DESCRIPTION

       The following ioctl(2) calls are supported:
 
       int ioctl(int fd, LPTIME, int arg)</EM)
              Sets  the  amount  of  time  that the driver sleeps
              before rechecking the printer  when  the  printer's
              buffer  appears to be filled to arg.  If you have a
              fast printer, decrease this number; if you  have  a
              slow  printer  then  increase  it.  This is in hun­
              dredths of a second, the default 2 being 0.02  sec­
              onds.  It only influences the polling driver.
 
       int ioctl(int fd, LPCHAR, int arg)</EM)
              Sets  the  maximum  number  of busy-wait iterations
              which the polling driver does while waiting for the
              printer  to  get ready for receiving a character to
              arg.  If printing is too slow, increase  this  num­
              ber;  if  the  system  gets too slow, decrease this
              number.  The default is 1000.  It  only  influences
              the polling driver.
 
       int ioctl(int fd, LPABORT, int arg)</EM)
              If  arg  is  0,  the  printer  driver will retry on
              errors, otherwise it will abort.  The default is 0.
 
       int ioctl(int fd, LPABORTOPEN, int arg)</EM)
              If arg is 0, open(2) will be aborted on error, oth­
              erwise error will be ignored.  The  default  is  to
              ignore it.
 
       int ioctl(int fd, LPCAREFUL, int arg)</EM)
              If  arg  is  0,  then the out-of-paper, offline and
              error signals are  required  to  be  false  on  all
              writes, otherwise they are ignored.  The default is
              to ignore them.
 
              Sets the number of busy waiting iterations to  wait
              before  strobing the printer to accept a just-writ­
              ten character, and the number of iterations to wait
              before  turning  the strobe off again, to arg.  The
              specification  says  this  time   should   be   0.5
              microseconds,  but  experience  has shown the delay
              caused by the code is  already  enough.   For  that
              reason,  the  default value is 0.  This is used for
              both the polling and the interrupt driver.
 
       int ioctl(int fd, LPSETIRQ, int arg)</EM)
              This ioctl()  requires  superuser  privileges.   It
              takes  an  int  containing the new IRQ as argument.
              As a side effect, the printer will be reset.   When
              arg is 0, the polling driver will be used, which is
              also default.
 
       int ioctl(int fd, LPGETIRQ, int *arg)</EM)
              Stores the currently used IRQ in arg.
 
       int ioctl(int fd, LPGETSTATUS, int *arg)</EM)
              Stores the value of the status port  in  arg.   The
              bits have the following meaning:
 
              LP_PBUSY     inverted busy input, active high
              LP_PACK      unchanged acknowledge input, active low
              LP_POUTPA    unchanged out-of-paper input, active high
              LP_PSELECD   unchanged selected input, active high
              LP_PERRORP   unchanged error input, active low
 
              Refer to your printer manual for the meaning of the
              signals.  Note that undocumented bits may  also  be
              set, depending on your printer.
 
       int ioctl(int fd, LPRESET)
              Resets the printer.  No argument is used.
 
 

FILES

       /dev/lp*

 

 


  1. kill

 

NAME

 

kill - terminate a process
 

SYNOPSIS

       kill [ -s signal | -p ]  [ -a ] pid ...
       kill -l [ signal ]
 

DESCRIPTION

       kill  sends the specified signal to the specified process.
       If no signal is specified, the TERM signal is  sent.   The
       TERM  signal  will  kill processes which do not catch this
       signal.  For other processes, if may be necessary  to  use
       the KILL (9) signal, since this signal cannot be caught.
 
       Most modern shells have a builtin kill function.
 
 

OPTIONS

       pid ...
              Specify the list of processes that kill should sig­
              nal.  Each pid can be one of four things.   A  pro­
              cess  name in which case processes called that will
              be signaled.  n where n is larger than 0.  The pro­
              cess with pid n will be signaled.  -1 in which case
              all processes from MAX_INT to 2 will  be  signaled,
              as  allowed  by  the  issuing  user.  -n where n is
              larger than 1, in which case processes  in  process
              group  n  are signaled.  IFF a negative argument is
              given the signal must be specified first, otherwise
              it will be taken as the signal to send.
 
       -s     Specify  the  signal  to  send.   The signal may be
              given as a signal name or number.
 
       -p     Specify that kill should only print the process  id
              (pid)  of the named process, and should not send it
              a signal.
 
       -l     Print a list of signal names.  These are  found  in
              /usr/include/linux/signal.h

 

 


  1. rm (-i, -r)

 

NAME

rm - remove files     

SYNOPSIS

rm [-dfirvR] [--directory] [--force] [--interactive] [--recursive] [--help] [--version] [--verbose] name...

DESCRIPTION

This manual page documents the GNU version of rm. rm removes each specified file. By default, it does not remove directories. If a file is unwritable, the standard input is a tty, and the -f or --force option is not given, rm prompts the user for whether to remove the file. If the response does not begin with `y' or `Y', the file is skipped.

GNU rm, like every program that uses the getopt function to parse its arguments, lets you use the -- option to indicate that all following arguments are non-options. To remove a file called `-f' in the current directory, you could type either

rm -- -f

or

rm ./-f

The Unix rm program's use of a single `-' for this purpose predates the development of the getopt standard syntax.

OPTIONS

-d, --directory

Remove directories with `unlink' instead of `rmdir', and don't require a directory to be empty before trying to unlink it. Only works for the super-user. Because unlinking a directory causes any files in the deleted directory to become unreferenced, it is wise to fsck the filesystem after doing this.

-f, --force

Ignore nonexistent files and never prompt the user.

-i, --interactive

Prompt whether to remove each file. If the response does not begin with `y' or `Y', the file is skipped.

-r, -R, --recursive

Remove the contents of directories recursively.

-v, --verbose

Print the name of each file before removing it.

--help

Print a usage message on standard output and exit successfully.

--version

Print version information on standard output then exit successfully.

 

 


Chapter 4

Please read chapter 25 of Red Hat Linux unleashed

 

 

Why didn’t the Class program work??

 

 

The syntax for the if statement is

 

If [condition]; then

                   Statement

          elif [expression]; then

                   Statement

          else

                   Statement

fi

 

The program we wrote in class was

 

For filename in `ls`

          do

                   cp $filename backup/$filenam

                   if [ $? –ne 0 ] then

                             echo “Copy of file $filename failed”

                   fi

          done

 

The program should read

 

 

For filename in `ls`

          do

                   cp $filename backup/$filenam

                   if [ $? –ne 0 ]; then

                             echo “Copy of file $filename failed”

                   fi

          done

 

The only difference is the semicolon after the expression for if.