START-INFO-DIR-ENTRY
* File utilities: (fileutils).  GNU file utilities.
* chgrp: (fileutils)chgrp invocation.	        Change file groups.
* chown: (fileutils)chown invocation.	        Change file owners/groups.
* chmod: (fileutils)chmod invocation.	        Change file permissions.
* cp: (fileutils)cp invocation.	                Copy files.
* dd: (fileutils)dd invocation.	                Copy and convert a file.
* df: (fileutils)df invocation.	                Report filesystem disk usage.
* dir: (fileutils)dir invocation.	List directories briefly.
* du: (fileutils)du invocation.	                Report on disk usage.
* install: (fileutils)install invocation.	Copy and change attributes.
* ln: (fileutils)ln invocation.	                Make links between files.
* ls: (fileutils)ls invocation.	List directory contents.
* mkdir: (fileutils)mkdir invocation.	        Create directories.
* mkfifo: (fileutils)mkfifo invocation.	        Create FIFOs: (named pipes).
* mknod: (fileutils)mknod invocation.	        Create special files.
* mv: (fileutils)mv invocation.	                Rename files.
* rm: (fileutils)rm invocation.	                Remove files.
* rmdir: (fileutils)rmdir invocation.	        Remove empty directories.
* sync: (fileutils)sync invocation.	        Synchronize memory and disk.
* touch: (fileutils)touch invocation.	        Change file timestamps.
* vdir: (fileutils)vdir invocation.	List directories verbosely.
END-INFO-DIR-ENTRY

This file documents the GNU set of file utilities.

Copyright (C) 1994 Free Software Foundation, Inc.

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation.


GNU file utilities
Node: Top, Next: Introduction, Prev: , Up: (dir)

GNU file utilities

This manual minimally documents version GNU fileutils 3.12 of the GNU file utilities.

* Menu:

Introduction	Caveats, overview, and authors.

Common options	Common options.

File permissions	Access modes.

Directory listing	ls dir vdir d v

Basic operations	cp dd install mv rm

Special file types	ln mkdir rmdir mkfifo mknod

Changing file attributes	chgrp chmod chown touch

Disk usage	df du sync

Index	General index.


Introduction
Node: Introduction, Next: Common options, Prev: Top, Up: Top

Introduction

This manual is incomplete: No attempt is made to explain basic file concepts in a way suitable for novices.  Thus, if you are interested, please get involved in improving this manual.  The entire GNU community will benefit.

The GNU file utilities are mostly compatible with the POSIX.2 standard.

Please report bugs to 'bug-gnu-utils@prep.ai.mit.edu'.  Remember to include the version number, machine architecture, input files, and any other information needed to reproduce the bug.  See Bugs.

This manual is based on the Unix man pages in the distribution, which were originally written by David MacKenzie and updated by Jim Meyering.   Franc,ois Pinard did the initial conversion to Texinfo format.  Karl Berry did the indexing, some reorganization, and editing of the results.  Richard Stallman contributed his usual invaluable insights to the overall process.


Common options
Node: Common options, Next: File permissions, Prev: Introduction, Up: Top

Common options

Certain options are available in all these programs.  Rather than writing identical descriptions for each of the programs, they are described here.  (In fact, every GNU program accepts (or should accept) these options.)

'--help'

Print a usage message listing all available options, then exit successfully.

'--version'

Print the version number, then exit successfully.

* Menu:

Backup options	-b -S -V, in some programs.


Backup options
Node: Backup options, Next: , Prev: , Up: Common options

Backup options

Some GNU programs (at least cp, mv, and ln) optionally make backups of files before writing new versions.  These options control the details of these backups.  The options are also briefly mentioned in the descriptions of the particular programs.

'-b'

'--backup'

Make backups of files that are about to be overwritten or removed.  Without this option, the original versions are destroyed.

'-S suffix'

'--suffix=suffix'

Append suffix to each backup file made with '-b'.  If this option is not specified, the value of the SIMPLE_BACKUP_SUFFIX environment variable is used.  And if SIMPLE_BACKUP_SUFFIX is not set, the default is '~', just as in Emacs.

'-V method'

'--version-control=method'

Use method to determine the type of backups made with '-b'.  If this option is not specified, the value of the VERSION_CONTROL environment variable is used.  And if VERSION_CONTROL is not set, the default backup type is 'existing'.

This option corresponds to the Emacs variable 'version-control'; the same values for method are accepted as in Emacs.  This options also more descriptive name.  The valid methods (unique abbreviations are accepted):

't'

'numbered'

Always make numbered backups.

'nil'

'existing'

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

'never'

'simple'

Always make simple backups.


File permissions
Node: File permissions, Next: Directory listing, Prev: Common options, Up: Top

File permissions

Each file has a set of "permissions" that control the kinds of access that users have to that file.  The permissions for a file are also called its "access mode".  They can be represented either in symbolic form or as an octal number.

* Menu:

Mode Structure	Structure of file permissions.

Symbolic Modes	Mnemonic permissions representation.

Numeric Modes	Permissions as octal numbers.


Structure of File Permissions
Node: Mode Structure, Next: Symbolic Modes, Prev: , Up: File permissions

Structure of File Permissions

There are three kinds of permissions that a user can have for a file:

1. 	permission to read the file.  For directories, this means permission to list the contents of the directory.

2. 	permission to write to (change) the file.  For directories, this means permission to create and remove files in the directory.

3. 	permission to execute the file (run it as a program).  For directories, this means permission to access files in the directory.

There are three categories of users who may have different permissions to perform any of the above operations on a file:

1. 	the file's owner;

2. 	other users who are in the file's group;

3. 	everyone else.

Files are given an owner and group when they are created.  Usually the owner is the current user and the group is the group of the directory the file is in, but this varies with the operating system, the filesystem the file is created on, and the way the file is created.  You can change the owner and group of a file by using the chown and chgrp commands.

In addition to the three sets of three permissions listed above, a file's permissions have three special components, which affect only executable files (programs) and, on some systems, directories:

1. 	set the process's effective user ID to that of the file upon execution (called the "setuid bit").  No effect on directories.

2. 	set the process's effective group ID to that of the file upon execution (called the "setgid bit").  For directories on some systems, put files created in the directory into the same group as the directory, no matter what group the user who creates them is in.

3. 	save the program's text image on the swap device so it will load more quickly when run (called the "sticky bit").  For directories on some systems, prevent users from removing files that they do not own in the directory; this is called making the directory "append-only".


Symbolic Modes
Node: Symbolic Modes, Next: Numeric Modes, Prev: Mode Structure, Up: File permissions

Symbolic Modes

"Symbolic modes" represent changes to files' permissions as operations on single-character symbols.  They allow you to modify either all or selected parts of files' permissions, optionally based on their previous values, and perhaps on the current umask as well (see Umask and Protection).

The format of symbolic modes is:

[ugoa...][[+-=][rwxXstugo...]...][,...]

The following sections describe the operators and other details of symbolic modes.

* Menu:

Setting Permissions	Basic operations on permissions.

Copying Permissions	Copying existing permissions.

Changing Special Permissions	Special permissions.

Conditional Executability	Conditionally affecting executability.

Multiple Changes	Making multiple changes.

Umask and Protection	The effect of the umask.


Setting Permissions
Node: Setting Permissions, Next: Copying Permissions, Prev: , Up: Symbolic Modes

Setting Permissions

The basic symbolic operations on a file's permissions are adding, removing, and setting the permission that certain users have to read, write, and execute the file.  These operations have the following format:

users operation permissions

The spaces between the three parts above are shown for readability only; symbolic modes can not contain spaces.

The users part tells which users' access to the file is changed.  It consists of one or more of the following letters (or it can be empty; see Umask and Protection, for a description of what happens then).  When more than one of these letters is given, the order that they are in does not matter.

u

the user who owns the file;

g

other users who are in the file's group;

o

all other users;

a

all users; the same as 'ugo'.

The operation part tells how to change the affected users' access to the file, and is one of the following symbols:

+

to add the permissions to whatever permissions the users already have for the file;

-

to remove the permissions from whatever permissions the users already have for the file;

=

to make the permissions the only permissions that the users have for the file.

The permissions part tells what kind of access to the file should be changed; it is zero or more of the following letters.  As with the users part, the order does not matter when more than one letter is given.  Omitting the permissions part is useful only with the '=' operation, where it gives the specified users no access at all to the file.

r

the permission the users have to read the file;

w

the permission the users have to write to the file;

x

the permission the users have to execute the file.

For example, to give everyone permission to read and write a file, but not to execute it, use:

a=rw

To remove write permission for from all users other than the file's owner, use:

go-w

The above command does not affect the access that the owner of the file has to it, nor does it affect whether other users can read or execute the file.

To give everyone except a file's owner no permission to do anything with that file, use the mode below.  Other users could still remove the file, if they have write permission on the directory it is in.

go=

Another way to specify the same thing is:

og-rxw


Copying Existing Permissions
Node: Copying Permissions, Next: Changing Special Permissions, Prev: Setting Permissions, Up: Symbolic Modes

Copying Existing Permissions

You can base part of a file's permissions on part of its existing permissions.  To do this, instead of using 'r', 'w', or 'x' after the operator, you use the letter 'u', 'g', or 'o'.  For example, the mode

o+g

adds the permissions for users who are in a file's group to the permissions that other users have for the file.  Thus, if the file started out as mode 664 ('rw-rw-r--'), the above mode would change it to mode 666 ('rw-rw-rw-').  If the file had started out as mode 741 ('rwxr----x'), the above mode would change it to mode 745 ('rwxr--r-x').  The '-' and '=' operations work analogously.


Changing Special Permissions
Node: Changing Special Permissions, Next: Conditional Executability, Prev: Copying Permissions, Up: Symbolic Modes

Changing Special Permissions

In addition to changing a file's read, write, and execute permissions, you can change its special permissions.  See Mode Structure, for a summary of these permissions.

To change a file's permission to set the user ID on execution, use 'u' in the users part of the symbolic mode and 's' in the permissions part.

To change a file's permission to set the group ID on execution, use 'g' in the users part of the symbolic mode and 's' in the permissions part.

To change a file's permission to stay permanently on the swap device, use 'o' in the users part of the symbolic mode and 't' in the permissions part.

For example, to add set user ID permission to a program, you can use the mode:

u+s

To remove both set user ID and set group ID permission from it, you can use the mode:

ug-s

To cause a program to be saved on the swap device, you can use the mode:

o+t

Remember that the special permissions only affect files that are executable, plus, on some systems, directories (on which they have different meanings; see Mode Structure).  Using 'a' in the users part of a symbolic mode does not cause the special permissions to be affected; thus,

a+s

has no effect.  You must use 'u', 'g', and 'o' explicitly to affect the special permissions.  Also, the combinations 'u+t', 'g+t', and 'o+s' have no effect.

The '=' operator is not very useful with special permissions; for example, the mode:

o=t

does cause the file to be saved on the swap device, but it also removes all read, write, and execute permissions that users not in the file's group might have had for it.


Conditional Executability
Node: Conditional Executability, Next: Multiple Changes, Prev: Changing Special Permissions, Up: Symbolic Modes

Conditional Executability

There is one more special type of symbolic permission: if you use 'X' instead of 'x', execute permission is affected only if the file already had execute permission or is a directory.  It affects directories' execute permission even if they did not initially have any execute permissions set.

For example, this mode:

a+X

gives all users permission to execute files (or search directories) if anyone could before.


Making Multiple Changes
Node: Multiple Changes, Next: Umask and Protection, Prev: Conditional Executability, Up: Symbolic Modes

Making Multiple Changes

The format of symbolic modes is actually more complex than described above (see Setting Permissions).  It provides two ways to make multiple changes to files' permissions.

The first way is to specify multiple operation and permissions parts after a users part in the symbolic mode.

For example, the mode:

og+rX-w

gives users other than the owner of the file read permission and, if it is a directory or if someone already had execute permission to it, gives them execute permission; and it also denies them write permission to it file.  It does not affect the permission that the owner of the file has for it.  The above mode is equivalent to the two modes:

og+rX
og-w

The second way to make multiple changes is to specify more than one simple symbolic mode, separated by commas.  For example, the mode:

a+r,go-w

gives everyone permission to read the file and removes write permission on it for all users except its owner.  Another example:

u=rwx,g=rx,o=

sets all of the non-special permissions for the file explicitly.  (It gives users who are not in the file's group no permission at all for it.)

The two methods can be combined.  The mode:

a+r,g+x-w

gives all users permission to read the file, and gives users who are in the file's group permission to execute it, as well, but not permission to write to it.  The above mode could be written in several different ways; another is:

u+r,g+rx,o+r,g-w


The Umask and Protection
Node: Umask and Protection, Next: , Prev: Multiple Changes, Up: Symbolic Modes

The Umask and Protection

If the users part of a symbolic mode is omitted, it defaults to 'a' (affect all users), except that any permissions that are set in the system variable umask are not affected.  The value of umask can be set using the umask command.  Its default value varies from system to system.

Omitting the users part of a symbolic mode is generally not useful with operations other than '+'.  It is useful with '+' because it allows you to use umask as an easily customizable protection against giving away more permission to files than you intended to.

As an example, if umask has the value 2, which removes write permission for users who are not in the file's group, then the mode:

+w

adds permission to write to the file to its owner and to other users who are in the file's group, but not to other users.  In contrast, the mode:

a+w

ignores umask, and does give write permission for the file to all users.


Numeric Modes
Node: Numeric Modes, Next: , Prev: Symbolic Modes, Up: File permissions

Numeric Modes

File permissions are stored internally as 16 bit integers.  As an alternative to giving a symbolic mode, you can give an octal (base 8) number that corresponds to the internal representation of the new mode.  This number is always interpreted in octal; you do not have to add a leading 0, as you do in C.  Mode 0055 is the same as mode 55.

A numeric mode is usually shorter than the corresponding symbolic mode, but it is limited in that it can not take into account a file's previous permissions; it can only set them absolutely.

The permissions granted to the user, to other users in the file's group, and to other users not in the file's group are each stored as three bits, which are represented as one octal digit.  The three special permissions are also each stored as one bit, and they are as a group represented as another octal digit.  Here is how the bits are arranged in the 16 bit integer, starting with the lowest valued bit:

Value in  Corresponding
Mode      Permission

          Other users not in the file's group:
   1      Execute
   2      Write
   4      Read

          Other users in the file's group:
  10      Execute
  20      Write
  40      Read

          The file's owner:
 100      Execute
 200      Write
 400      Read

          Special permissions:
1000      Save text image on swap device
2000      Set group ID on execution
4000      Set user ID on execution

For example, numeric mode 4755 corresponds to symbolic mode 'u=rwxs,go=rx', and numeric mode 664 corresponds to symbolic mode 'ug=rw,o=r'.  Numeric mode 0 corresponds to symbolic mode 'ugo='.


Directory listing
Node: Directory listing, Next: Basic operations, Prev: File permissions, Up: Top

Directory listing

This chapter describes the ls command and its variants dir and vdir, which list information about files.

* Menu:

ls invocation	List directory contents.

dir invocation	Briefly ls.

vdir invocation	Verbosely ls.


ls: List directory contents
Node: ls invocation, Next: dir invocation, Prev: , Up: Directory listing

ls: List directory contents

The ls program lists information about files (of any type, including directories).  Options and file arguments can be intermixed arbitrarily, as usual.

For non-option command-line arguments that are directories, by default ls lists the contents of directories, not recursively, and omitting files with names beginning with ..  For other non-option arguments, by default ls lists just the filename.  If no non-option arguments are specified, ls lists the contents of the current directory.

By default, the output is sorted alphabetically.  If standard output is a terminal, the output is in columns (sorted vertically); otherwise, they are listed one per line.

Because ls is such a fundamental program, it has accumulated many options over the years.  They are described in the subsections below; within each section, options are listed alphabetically (ignoring case).  The division of options into the subsections is not absolute, since some options affect more than one aspect of ls's operation.

Also, the '-g' option is accepted but ignored, for compatibility with Unix.  Also see See Common options.

* Menu:

Which files are listed

What information is listed

Sorting the output

General output formatting

Formatting the filenames


Which files are listed
Node: Which files are listed, Next: What information is listed, Prev: , Up: ls invocation

Which files are listed

These options determine which files ls lists information for.  By default, any files and the contents of any directories on the command line are shown.

'-a'

'--all'

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

'-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.

'-d'

'--directory'

List just the names of directories, as with other types of files, rather than listing their contents.

'-I'

'--ignore'

Do not list files whose names match the shell pattern (not regular expression) 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.

'-L'

'--dereference'

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

'-R'

'--recursive'

List the contents of all directories recursively.


What information is listed
Node: What information is listed, Next: Sorting the output, Prev: Which files are listed, Up: ls invocation

What information is listed

These options affect the information that ls displays.  By default, only filenames are shown.

'-D'

'--dired'

With the long listing ('-l') format, print an additional line after the main output:

//DIRED// beg1 end1 beg2 end2 ...

The begN and endN are unsigned integers which record the byte position of the beginning and end of each filename in the output.  This makes it easy for Emacs to find the names, even when they contain unusual characters such as space or newline, without fancy searching.

If directories are being listed recursively (-R), output a similar line after each subdirectory:

//SUBDIRED// beg1 end1 ...

'-G'

'--no-group'

Inhibit display of group information in a long format directory listing.  (This is the default in some non-GNU versions of ls, so we provide this option for compatibility.)

'-i'

'--inode'

Print the inode number (also called the file serial number and index number) of each file to the left of the filename.  (This number uniquely identifies each file within a particular filesystem.)

'-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 (by default, the modification time).  For files with a time more than 6 months old or more than 1 hour into the future, the timestamp contains the year instead of the time of day.

For each directory that is listed, preface the files with a line total blocks, where blocks is the total disk space used by all files in that directory.  By default, 1024-byte blocks are used; if the environment variable POSIXLY_CORRECT is set, 512-byte blocks are used (unless the '-k' option is given).  The blocks computed counts each hard link separately; this is arguably a bug.

This output format is the default for the GNU v and vdir programs.

'-s'

'--size'

Print the size of each file in 1024-byte blocks to the left of the filename.  If the environment variable POSIXLY_CORRECT is set, 512-byte blocks are used instead, unless the '-k' option is given (see General output formatting).

For files that are NFS-mounted from an HP-UX system to a BSD system, this option reports sizes that are half the correct values.  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.


Sorting the output
Node: Sorting the output, Next: General output formatting, Prev: What information is listed, Up: ls invocation

Sorting the output

These options change the order in which ls sorts the information it outputs.  By default, sorting is done by character code (e.g., ASCII order).

'-c'

'--time=ctime'

'--time=status'

Sort according to the status change time (the 'ctime' in the inode).  If the long listing format ('-l') is being used, print the status change time instead of the modification time.

'-f'

Primarily, like '-U'--do not sort; list the files in whatever order they are stored in the directory.  But also enable '-a' (list all files) and disable '-l' and '-s' (if they were specified before the '-f').

'-r'

'--reverse'

Reverse whatever the sorting method is--e.g., list files in reverse alphabetical order, youngest first, smallest first, or whatever.

'-S'

'--sort=size'

Sort by file size, largest first.

'-t'

'--sort=time'

Sort by modification time (the 'mtime' in the inode), newest first.

'-u'

'--time=atime'

'--time=access'

'--time=use'

Sort by access time (the 'atime' in the inode).  If the long listing format is being used, print the last access time.

'-U'

'--sort=none'

Do not sort; list the files in whatever order they are stored in the directory.  (Do not do any of the other unrelated things that '-f' does.)  This is especially useful when listing very large directories, since not doing any sorting can be noticeably faster.

'-X'

'--sort=extension'

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


General output formatting
Node: General output formatting, Next: Formatting the filenames, Prev: Sorting the output, Up: ls invocation

General output formatting

These options affect the appearance of the overall output.

'-1'

'--format=single-column'

List one file per line.  This is the default for ls when standard output is not a terminal.

'-C'

'--format=vertical'

List files in columns, sorted vertically.  This is the default for ls if standard output is a terminal.  It is always the default for the dir and d programs.

'-F'

'--classify'

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

'--full-time'

List times in full, rather than using the standard abbreviation heuristics.  The format is the same as date's default; it's not possible to change this, but you can extract out the date string with cut and then pass the result to date -d.  See date invocation.

This is most useful because the time output includes the seconds.  (Unix filesystems store file timestamps only to the nearest second, so this option shows all the information there is.)  For example, this can help when you have a Makefile that is not regenerating files properly.

'-k'

'--kilobytes'

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

'-m'

'--format=commas'

List files horizontally, with as many as will fit on each line, separated by ', ' (a comma and a space).

'-n'

'--numeric-uid-gid'

List the numeric UID and GID instead of the names.

'-p'

Append a character to each filename indicating the file type. This is like '-F', except that executables are not marked.

'-x'

'--format=across'

'--format=horizontal'

List the files in columns, sorted horizontally.

'-T'

'--tabsize=cols'

Assume that each tabstop is cols columns wide.  The default is 8.  ls uses tabs where possible in the output, for efficiency.

'-w'

'--width=cols'

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


Formatting the filenames
Node: Formatting the filenames, Next: , Prev: General output formatting, Up: ls invocation

Formatting the filenames

These options change how filenames themselves are printed.

'-b'

'--escape'

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

'-N'

'--literal'

Do not quote filenames.

'-q'

'--hide-control-chars'

Print question marks instead of nongraphic characters in filenames.  This is the default.

'-Q'

'--quote-name'

Enclose filenames in double quotes and quote nongraphic characters as in C.


dir: Briefly list directory contents
Node: dir invocation, Next: vdir invocation, Prev: ls invocation, Up: Directory listing

dir: Briefly list directory contents

The dir program (also installed as d) is equivalent to ls -C; that is, files are by default always listed in columns, sorted vertically.

See ls.


vdir: Verbosely list directory contents
Node: vdir invocation, Next: , Prev: dir invocation, Up: Directory listing

vdir: Verbosely list directory contents

The vdir program (also installed v)is equivalent to ls -l; that is, files are by default listed in long format.


Basic operations
Node: Basic operations, Next: Special file types, Prev: Directory listing, Up: Top

Basic operations

This chapter describes the commands for basic file manipulation: copying, moving (renaming), and deleting (removing).

* Menu:

cp invocation	Copy files.

dd invocation	Convert and copy a file.

install invocation	Copy files and set attributes.

mv invocation	Move (rename) files.

rm invocation	Remove files or directories.


cp: Copy files and directories
Node: cp invocation, Next: dd invocation, Prev: , Up: Basic operations

cp: Copy files and directories

cp copies files (or, optionally, directories).  The copy is completely independent of the original.  You can either copy one file to another, or copy arbitrarily many files to a destination directory.  Synopsis:

cp [option]... source dest
cp [option]... source... directory

If the last argument names an existing directory, cp copies each source file into that directory (retaining the same name).  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 non-option arguments are given.

If the source file contains holes, cp copies them and other blocks of zero bytes as holes.  Otherwise, files are written just as they are read.  (A "hole" is a sequence of zero bytes that does not occupy any physical disk blocks; the 'read' system call reads these as zeroes.)

By default, cp does not copy directories.  It also refuses to copy a file onto itself.

The program accepts the following options.  Also see See Common options.

'-a'

'--archive'

Preserve as much as possible of the structure and attributes of the original files in the copy.  Equivalent to '-dpR'.

'-b'

'--backup'

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

'-d'

'--no-dereference'

Copy symbolic links as symbolic links rather than copying the files that they point to, and preserve hard links 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'

'--preserve'

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

'-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.

'-r'

Copy directories recursively, copying any non-directories and non-symbolic links (that is, FIFOs and special files) as if they were regular files.  This means trying to read the data in each source file and writing it to the destination.  Thus, with this option, cp may well hang indefinitely reading a FIFO, unless something else happens to be writing it.

'-R'

'--recursive'

Copy directories recursively, preserving non-directories (see '-r' just above).

'-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 merely results in an error message on systems that do not support symbolic links.

'-S suffix'

'--suffix=suffix'

Append suffix to each backup file made with '-b'.  See Backup options.

'-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.

'-V method'

'--version-control=method'

Change the type of backups made with '-b'.  The method argument can be 'numbered' (or 't'), 'existing' (or 'nil'), or 'never' (or 'simple').  See Backup options.

'-x'

'--one-file-system'

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


dd: Convert and copy a file
Node: dd invocation, Next: install invocation, Prev: cp invocation, Up: Basic operations

dd: Convert and copy a file

dd copies a file (from standard input to standard output, by default) with a changeable I/O blocksize, while optionally performing conversions on it.  Synopsis:

dd [option]...

The program accepts the following options.  Also see See Common options.

The numeric-valued options below (bytes and blocks) can be followed by a multiplier: 'b'=512, 'c'=1, 'k'=1024, 'w'=2, 'xm'=m.

'if=file'

Read from file instead of standard input.

'of=file'

Write to file instead of standard output.  Unless 'conv=notrunc' is given, dd truncates file to zero bytes (or the size specified with 'seek=').

'ibs=bytes'

Read bytes bytes at a time.

'obs=bytes'

Write bytes bytes at a time.

'bs=bytes'

Both read and write bytes bytes at a time.  This overrides 'ibs' and 'obs'.

'cbs=bytes'

Convert bytes bytes at a time.

'skip=blocks'

Skip blocks 'ibs'-byte blocks in the input file before copying.

'seek=blocks'

Skip blocks 'obs'-byte blocks in the output file before copying.

'count=blocks'

Copy blocks 'obs'-byte blocks from the input file, instead of everything until the end of the file.

'conv=conversion[,conversion]...'

Convert the file as specified by the conversion argument(s).  (No spaces around any comma(s).)

Conversions:

'ascii'

Convert EBCDIC to ASCII.

'ebcdic'

Convert ASCII to EBCDIC.

'ibm'

Convert ASCII to alternate EBCDIC.

'block'

For each line in the input, output 'cbs' bytes, replacing the input newline with a space and padding with spaces as necessary.

'unblock'

Replace trailing spaces in each 'cbs'-sized input block with a newline.

'lcase'

Change uppercase letters to lowercase.

'ucase'

Change lowercase letters to uppercase.

'swab'

Swap every pair of input bytes.  GNU dd, unlike others, works when an odd number of bytes are read--the last byte is simply copied (since there is nothing to swap it with).

'noerror'

Continue after read errors.

'notrunc'

Do not truncate the output file.

'sync'

Pad every input block to size of 'ibs' with trailing zero bytes.


install: Copy files and set attributes
Node: install invocation, Next: mv invocation, Prev: dd invocation, Up: Basic operations

install: Copy files and set attributes

install copies files while setting their permission modes and, if possible, their owner and group.  Synopses:

install [option]... source dest
install [option]... source... directory
install -d [option]... directory...

In the first of these, the source file is copied to the dest target file.  In the second, each of the source files are copied to the destination directory.  In the last, each directory (and any missing parent directories) is created.

install is similar to cp, but allows you to control the attributes of destination files.  It is typically used in Makefiles to copy programs into their destination directories.  It refuses to copy files onto themselves.

The program accepts the following options.  Also see See Common options.

'-c'

Ignored; for compatibility with old Unix versions of install.

'-d'

'--directory'

Create each given directory and any missing parent directories, setting the owner, group and mode as given on the command line or to the defaults.  It also gives any parent directories it creates those attributes.  (This is different from the SunOS 4.x install, which gives directories that it creates the default attributes.)

'-g group'

'--group=group'

Set the group ownership of installed files or directories to group. The default is the process's current group.  group may be either a group name or a numeric group id.

'-m mode'

'--mode=mode'

Set the permissions for the installed file or directory to mode, which can be either an octal number, or a symbolic mode as in chmod, with 0 as the point of departure (see File permissions).  The default mode is 0755--read, write, and execute for the owner, and read and execute for group and other.

'-o owner'

'--owner=owner'

If install has appropriate privileges (is run as root), set the ownership of installed files or directories to owner. The default is root.  owner may be either a user name or a numeric user ID.

'-s'

'--strip'

Strip the symbol tables from installed binary executables.


mv: Move (rename) files
Node: mv invocation, Next: rm invocation, Prev: install invocation, Up: Basic operations

mv: Move (rename) files

mv moves or renames files (or directories).  Synopsis:

mv [option]... source dest
mv [option]... source... directory

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 renames the first as the second.  It is an error if the last argument is not a directory and more than two files are given.

mv can move only regular files across filesystems.

If a destination file exists but is normally unwritable, standard input is a terminal, and the '-f' or '--force' option is not given, mv prompts the user for whether to replace the file.  (You might own the file, or have write permission on its directory.)  If the response does not begin with 'y' or 'Y', the file is skipped.

The program accepts the following options.  Also see See Common options.

'-b'

'--backup'

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

'-f'

'--force'

Remove existing destination files and never prompt the user.

'-i'

'--interactive'

Prompt whether to overwrite each existing destination file, regardless of its permissions.  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.

'-S suffix'

'--suffix=suffix'

Append suffix to each backup file made with '-b'.  See Backup options.

'-V method'

'--version-control=method'

Change the type of backups made with '-b'.  The method argument can be 'numbered' (or 't'), 'existing' (or 'nil'), or 'never' (or 'simple').  See Backup options.


rm: Remove files or directories
Node: rm invocation, Next: , Prev: mv invocation, Up: Basic operations

rm: Remove files or directories

rm removes each given file.  By default, it does not remove directories.  Synopsis:

rm [option]... [file]...

If a file is unwritable, standard input is a terminal, and the '-f' or '--force' option is not given, or the '-i' or '--interactive' option is 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.

The program accepts the following options.  Also see See Common 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 if you have appropriate privileges.  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.

One common question is how to remove files whose names being with a '-'.  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.


Special file types
Node: Special file types, Next: Changing file attributes, Prev: Basic operations, Up: Top

Special file types

This chapter describes commands which create special types of files (and rmdir, which removes directories, one special file type).

Although Unix-like operating systems have markedly fewer special file types than others, not everything can be treated only as the undifferentiated byte stream of "normal files".  For example, when a file is created or removed, the system must record this information, which it does in a "directory"--a special type of file.  Although you can read directories as normal files, if you're curious, in order for the system to do its job it must impose a structure, a certain order, on the bytes of the file.  Thus it is a "special" type of file.

Besides directories, other special file types include named pipes (FIFOs), symbolic links, sockets, and so-called "special files".

* Menu:

ln invocation	Make links between files.

mkdir invocation	Make directories.

mkfifo invocation	Make FIFOs (named pipes).

mknod invocation	Make block or character special files.

rmdir invocation	Remove empty directories.


ln: Make links between files
Node: ln invocation, Next: mkdir invocation, Prev: , Up: Special file types

ln: Make links between files

ln makes links between files.  By default, it makes hard links; with the '-s' option, it makes symbolic (or "soft") links.  Synopses:

ln [option]... source [dest]
ln [option]... source... directory

If the last argument names an existing directory, ln links each source file into a file with the same name in that directory.  (But see the description of the '--no-dereference' option below.) If only one file is given, it links that file into the current directory.  Otherwise, if only two files are given, it links 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 remove existing files.

A "hard link" is another name for an existing file; the link and the original are indistinguishable.  (Technically speaking, they share the same inode, and the inode contains all the information about a file--indeed, it is not incorrect to say that the inode is the file.)  On all existing implementations, you cannot make a hard links to directories, and hard links cannot cross filesystem boundaries.  (These restrictions are not mandated by POSIX, however.)

"Symbolic links" ("symlinks" for short), on the other hand, are a special file type (which not all kernels support; in particular, system V release 3 (and older) systems lack symlinks) in which the link file actually refers to a different file, by name.  When most operations (opening, reading, writing, and so on) are passed the symbolic link file, the kernel automatically "dereferences" the link and operates on the target of the link.  But some operations (e.g., removing) work on the link file itself, rather than on its target.  See Symbolic Links.

The program accepts the following options.  Also see See Common options.

'-b'

'--backup'

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

'-d'

'-F'

'--directory'

Allow the super-user to make hard links to directories.

'-f'

'--force'

Remove existing destination files.

'-i'

'--interactive'

Prompt whether to remove existing destination files.

'-n'

'--no-dereference'

When used with '--force' and an explicit destination that is a symlink to a directory, remove (or move it with '--backup') that symlink before making any link.

When the destination is an actual directory (not a symlink to one), there is no ambiguity.  The link is created in that directory.  But when the specified destination is a symlink to a directory, there are two ways to treat the user's request.  ln can treat the destination just as it would a normal directory and create the link in it.  On the other hand, the destination can be viewed as a non-directory--as the symlink itself.  In that case, ln must delete or backup that symlink before creating the new link.  The default is to treat a destination that is a symlink to a directory just like a directory.

'-s'

'--symbolic'

Make symbolic links instead of hard links.  This option merely produces an error message on systems that do not support symbolic links.

'-v'

'--verbose'

Print the name of each file before linking it.

'-S suffix'

'--suffix=suffix'

Append suffix to each backup file made with '-b'.  See Backup options.

'-V method'

'--version-control=method'

Change the type of backups made with '-b'.  The method argument can be 'numbered' (or 't'), 'existing' (or 'nil'), or 'never' (or 'simple').  See Backup options.


mkdir: Make directories
Node: mkdir invocation, Next: mkfifo invocation, Prev: ln invocation, Up: Special file types

mkdir: Make directories

mkdir creates directories with the specified names.  Synopsis:

mkdir [option]... name...

It is not an error if a name is already a directory; mkdir simply proceeds.  But if a name is an existing file and is anything but a directory, mkdir complains.

The program accepts the following options.  Also see See Common options.

'-m mode'

'--mode=mode'

Set the mode of created directories to mode, which is symbolic as in chmod and uses 0777 (read, write and execute allowed for everyone) minus the bits set in the umask for the point of the departure.  See File permissions.

'-p'

'--parents'

Make any missing parent directories for each argument.  The mode for parent directories is set to the umask modified by 'u+wx'.  Ignore arguments corresponding to existing directories.


mkfifo: Make FIFOs (named pipes)
Node: mkfifo invocation, Next: mknod invocation, Prev: mkdir invocation, Up: Special file types

mkfifo: Make FIFOs (named pipes)

mkfifo creates FIFOs (also called "named pipes") with the specified names.  Synopsis:

mkfifo [option] name...

A "FIFO" is a special file type that permits independent processes to communicate.  One process opens the FIFO file for writing, and another for reading, after which data can flow as with the usual anonymous pipe in shells or elsewhere.

The program accepts the following option.  Also see See Common options.

'-m mode'

'--mode=mode'

Set the mode of created FIFOs to mode, which is symbolic as in chmod and uses 0666 (read and write allowed for everyone) minus the bits set in the umask for the point of departure.  See File permissions.


mknod: Make block or character special files
Node: mknod invocation, Next: rmdir invocation, Prev: mkfifo invocation, Up: Special file types

mknod: Make block or character special files

mknod creates a FIFO, character special file, or block special file with the specified name.  Synopsis:

mknod [option]... name type [major minor]

Unlike the phrase "special file type" above, the term "special file" has a technical meaning on Unix: something that can generate or receive data.  Usually this corresponds to a physical piece of hardware, e.g., a printer or a disk.  (These files are typically created at system-configuration time.)  The mknod command is what creates files of this type.  Such devices can be read either a character at a time or a "block" (many characters) at a time, hence we say there are "block special" files and "character special" files.

The arguments after name specify the type of file to make:

'p'

for a FIFO

'b'

for a block (buffered) special file

'c'

for a character (buffered) special file

'u'

for a character (unbuffered) special file

When making a block or character special file, the major and minor device numbers must be given after the file type.

The program accepts the following option.  Also see See Common options.

'-m mode'

'--mode=mode'

Set the mode of created files to mode, which is symbolic as in chmod and uses 0666 minus the bits set in the umask as the point of departure.  See File permissions.


rmdir: Remove empty directories
Node: rmdir invocation, Next: , Prev: mknod invocation, Up: Special file types

rmdir: Remove empty directories

rmdir removes empty directories.  Synopsis:

rmdir [option]... directory...

If any directory argument does not refer to an existing empty directory, it is an error.

The program accepts the following option.  Also see See Common options.

'-p'

'--parents'

Remove any parent directories that become empty after an argument directory is removed.

See rm invocation, for how to remove non-empty directories (recursively).


Changing file attributes
Node: Changing file attributes, Next: Disk usage, Prev: Special file types, Up: Top

Changing file attributes

Files are not merely contents, a name, and a file type (see Special file types).  They also have an owner (a userid), a group (a group id), permissions (what the owner can do with the file, what people in the group can do, and what everyone else can do), various timestamps, and other information.  Collectively, we call all this a file's "attributes".

These commands change file attributes.

* Menu:

chown invocation	Change file owners and groups.

chgrp invocation	Change file groups.

chmod invocation	Change access permissions.

touch invocation	Change file timestamps.


chown: Change file owner and group
Node: chown invocation, Next: chgrp invocation, Prev: , Up: Changing file attributes

chown: Change file owner and group

chown changes the user and/or group ownership of each given file.  Synopsis:

chown [option]... new-owner file...

The first non-option argument, new-owner, specifies the new owner and/or group, as follows (with no embedded white space):

[owner] [ [:.] [group] ]

Specifically:

owner

If only an owner (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.

owner'.'group

owner':'group

If the owner is followed by a colon or dot and a group (a group name or numeric group id), with no spaces between them, the group ownership of the files is changed as well (to group).

owner'.'

owner':'

If a colon or dot but no group name follows owner, that user is made the owner of the files and the group of the files is changed to owner's login group.

'.'group

':'group

If the colon or dot and following group are given, but the owner is omitted, only the group of the files is changed; in this case, chown performs the same function as chgrp.

The program accepts the following options.  Also see See Common options.

'-c'

'--changes'

Verbosely describe the action for each file whose ownership actually changes.

'-f'

'--silent'

'--quiet'

Do not print error messages about files whose ownership cannot be changed.

'-v'

'--verbose'

Verbosely describe the action (or non-action) taken for every file.

'-R'

'--recursive'

Recursively change ownership of directories and their contents.


chgrp: Change group ownership
Node: chgrp invocation, Next: chmod invocation, Prev: chown invocation, Up: Changing file attributes

chgrp: Change group ownership

chgrp changes the group ownership of each given file to group, which can be either a group name or a numeric group id.  Synopsis:

chgrp [option]... group file...

The program accepts the following options.  Also see See Common options.

'-c'

'--changes'

Verbosely describe the action for each file whose group actually changes.

'-f'

'--silent'

'--quiet'

Do not print error messages about files whose group cannot be changed.

'-v'

'--verbose'

Verbosely describe the action or non-action taken for every file.

'-R'

'--recursive'

Recursively change the group ownership of directories and their contents.


chmod: Change access permissions
Node: chmod invocation, Next: touch invocation, Prev: chgrp invocation, Up: Changing file attributes

chmod: Change access permissions

chmod changes the access permissions of the named files.  Synopsis:

chmod [option]... mode file...

chmod never changes the permissions of symbolic links, since the chmod system call cannot change their permissions.  This 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.

The first non-option argument, mode, specifies the new permissions.  See the section below for details.

The program accepts the following options.  Also see See Common options.

'-c'

'--changes'

Verbosely describe the action for each file whose permissions actually changes.

'-f'

'--silent'

'--quiet'

Do not print error messages about files whose permissions cannot be changed.

'-v'

'--verbose'

Verbosely describe the action or non-action taken for every file.

'-R'

'--recursive'

Recursively change permissions of directories and their contents.


touch: Change file timestamps
Node: touch invocation, Next: , Prev: chmod invocation, Up: Changing file attributes

touch: Change file timestamps

touch changes the access and/or modification times of the specified files.  Synopsis:

touch [option]... file...

If the first file would be a valid argument to the '-t' option and no timestamp is given with any of the '-d', '-r', or '-t' options and the '--' argument is not given, that argument is interpreted as the time for the other files instead of as a filename.

Any file that does not exist is created empty.

If changing both the access and modification times to the current time, touch can change the timestamps for files that the user running it does not own but has write permission for.  Otherwise, the user must own the files.

The program accepts the following options.  Also see See Common options.

'-a'

'--time=atime'

'--time=access'

'--time=use'

Change the access time only.

'-c'

'--no-create'

Do not create files that do not exist.

'-d'

'--date=time'

Use time instead of the current time.  It can contain month names, timezones, 'am' and 'pm', etc.  See date invocation.

'-f'

Ignored; for compatibility with BSD versions of touch.

'-m'

'--time=mtime'

'--time=modify'

Change the modification time only.

'-r reference-file'

'--file=reference-file'

Use the times of reference-file instead of the current time.

'-t MMDDhhmm[[CC]YY][.ss]'

Use the argument (months, days, hours, minutes, optional century and years, optional seconds) instead of the current time.


Disk usage
Node: Disk usage, Next: Index, Prev: Changing file attributes, Up: Top

Disk usage

No disk can hold an infinite amount of data.  These commands report on how much disk storage is in use or available.  (This has nothing much to do with how much main memory, i.e., RAM, a program is using when it runs; for that, you want ps or pstat or swap or some such command.)

* Menu:

df invocation	Report filesystem disk space usage.

du invocation	Estimate file space usage.

sync invocation	Synchronize memory and disk.


df: Report filesystem disk space usage
Node: df invocation, Next: du invocation, Prev: , Up: Disk usage

df: Report filesystem disk space usage

df reports the amount of disk space used and available on filesystems.  Synopsis:

df [option]... [file]...

With no arguments, df reports the space used and available on all currently mounted filesystems (of all types).  Otherwise, df reports on the filesystem containing each argument file.

Disk space is shown in 1024-byte blocks by default, unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used (unless the '-k' option is given).

If an argument file is a disk device file containing a mounted filesystem, df shows the space available on that filesystem rather than on the filesystem containing the device node (i.e., the root filesystem).  GNU df does not attempt to determine the disk usage on unmounted filesystems, because on most kinds of systems doing so requires extremely nonportable intimate knowledge of filesystem structures.

The program accepts the following options.  Also see See Common 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.  Filesystems of type "ignore" or "auto", supported by some operating systems, are only included in the listing if this option is specified.

'-i'

'--inodes'

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

'-k'

'--kilobytes'

Print sizes in 1024-byte blocks.  This overrides the environment variable POSIXLY_CORRECT.

'--no-sync'

Do not invoke the sync system call before getting any usage data.  This may make df run significantly faster on systems with many disks, but on some systems the results may be slightly out of date.

'-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 (e.g., for some network mounts), the columns are misaligned.

'--sync'

Invoke the sync system call before getting any usage data.  On some systems, doing this yields more up to date results, but in general this option makes df much slower, especially when there are many or very busy filesystems.

'-t fstype'

'--type=fstype'

Limit the listing to filesystems of type fstype.  Multiple filesystem types can be specified by giving multiple '-t' options.  By default, nothing is omitted.

'-T'

'--print-type'

Print each filesystem's type.  The types printed here are the same ones you can include or exclude with '-t' and '-x'.  The particular types printed are whatever is supported by the system.  Here are some of the common names (this list is certainly not exhaustive):

'nfs'

An NFS filesystem, i.e., one mounted over a network from another machine.  This is the one type name which seems to be used uniformly by all systems.

'4.2, ufs, efs...'

A filesystem on a locally-mounted hard disk.  (The system might even support more than one type here; Linux does.)

'hsfs, cdfs'

A filesystem on a CD-ROM drive.  HP-UX uses 'cdfs', most other systems use 'hsfs' ('hs' for `High Sierra').

'pcfs'

An MS-DOS filesystem, usually on a diskette.

'-x fstype'

'--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, no filesystem types are omitted.

'-v'

Ignored; for compatibility with System V versions of df.


du: Estimate file space usage
Node: du invocation, Next: sync invocation, Prev: df invocation, Up: Disk usage

du: Estimate file space usage

du reports the amount of disk space used by the specified files and for each subdirectory (of directory arguments).  Synopsis:

du [option]... [file]...

With no arguments, du reports the disk space for the current directory.  The output is in 1024-byte units by default, unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used (unless '-k' is specified).

The program accepts the following options.  Also see See Common options.

'-a'

'--all'

Show counts for all files, not just directories.

'-b'

'--bytes'

Print sizes in bytes, instead of kilobytes.

'-c'

'--total'

Print a grand total of all arguments after all arguments have been processed.  This can be used to find out the total disk usage of a given set of files or directories.

'-D'

'--dereference-args'

Dereference symbolic links that are command line arguments.  Does not affect other symbolic links.  This is helpful for finding out the disk usage of directories, such as '/usr/tmp', which are often symbolic links.

'-k'

'--kilobytes'

Print sizes in kilobytes.  This overrides the environment variable POSIXLY_CORRECT.

'-l'

'--count-links'

Count the size of all files, even if they have appeared already (as a hard link).

'-L'

'--dereference'

Dereference symbolic links (show the disk space used by the file or directory that the link points to instead of the space used by the link).

'-s'

'--summarize'

Display only a total for each argument.

'-S'

'--separate-dirs'

Report the size of each directory separately, not including the sizes of subdirectories.

'-x'

'--one-file-system'

Skip directories that are on different filesystems from the one that the argument being processed is on.

On BSD systems, du 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 du program.


sync: Synchronize data on disk with memory
Node: sync invocation, Next: , Prev: du invocation, Up: Disk usage

sync: Synchronize data on disk with memory

sync writes any data buffered in memory out to disk.  This can include (but is not limited to) modified superblocks, modified inodes, and delayed reads and writes.  This must be implemented by the kernel; The sync program does nothing but exercise the sync system call.

The kernel keeps data in memory to avoid doing (relatively slow) disk reads and writes.  This improves performance, but if the computer crashes, data may be lost or the filesystem corrupted as a result. sync ensures everything in memory is written to disk.

Any arguments are ignored, except for a lone '--help' or '--version' (see Common options).


Index
Node: Index, Next: , Prev: Disk usage, Up: Top

Index

- and Unix rm:	See rm invocation.

-all <1>:	See df invocation.

-all <1>:	See Which files are listed.

-all:	See du invocation.

-almost-all:	See Which files are listed.

-archive:	See cp invocation.

-backup <1>:	See cp invocation.

-backup <1>:	See Backup options.

-backup <1>:	See mv invocation.

-backup:	See ln invocation.

-bytes:	See du invocation.

-changes <1>:	See chgrp invocation.

-changes <1>:	See chown invocation.

-changes:	See chmod invocation.

-classify:	See General output formatting.

-count-links:	See du invocation.

-date:	See touch invocation.

-dereference <1>:	See du invocation.

-dereference:	See Which files are listed.

-dereference-args:	See du invocation.

-directory <1>:	See install invocation.

-directory <1>:	See Which files are listed.

-directory <1>:	See rm invocation.

-directory:	See ln invocation.

-dired:	See What information is listed.

-escape:	See Formatting the filenames.

-exclude-type:	See df invocation.

-file:	See touch invocation.

-force <1>:	See ln invocation.

-force <1>:	See rm invocation.

-force <1>:	See mv invocation.

-force:	See cp invocation.

-format <1>:	See General output formatting.

-format <1>:	See What information is listed.

-format:	See General output formatting.

-full-time:	See General output formatting.

-group:	See install invocation.

-help:	See Common options.

-hide-control-chars:	See Formatting the filenames.

-ignore-backups:	See Which files are listed.

-ignore=pattern:	See Which files are listed.

-inode:	See What information is listed.

-inodes:	See df invocation.

-interactive <1>:	See cp invocation.

-interactive <1>:	See ln invocation.

-interactive <1>:	See rm invocation.

-interactive:	See mv invocation.

-kilobytes <1>:	See df invocation.

-kilobytes <1>:	See du invocation.

-kilobytes:	See General output formatting.

-link:	See cp invocation.

-literal:	See Formatting the filenames.

-mode <1>:	See mkdir invocation.

-mode <1>:	See mknod invocation.

-mode <1>:	See install invocation.

-mode:	See mkfifo invocation.

-no-create:	See touch invocation.

-no-dereference <1>:	See cp invocation.

-no-dereference:	See ln invocation.

-no-group:	See What information is listed.

-no-sync:	See df invocation.

-numeric-uid-gid:	See General output formatting.

-one-file-system <1>:	See du invocation.

-one-file-system:	See cp invocation.

-owner:	See install invocation.

-parents <1>:	See cp invocation.

-parents <1>:	See rmdir invocation.

-parents:	See mkdir invocation.

-portability:	See df invocation.

-preserve:	See cp invocation.

-print-type:	See df invocation.

-quiet <1>:	See chgrp invocation.

-quiet <1>:	See chown invocation.

-quiet:	See chmod invocation.

-quote-name:	See Formatting the filenames.

-recursive <1>:	See Which files are listed.

-recursive <1>:	See rm invocation.

-recursive <1>:	See chmod invocation.

-recursive <1>:	See chgrp invocation.

-recursive <1>:	See cp invocation.

-recursive:	See chown invocation.

-reverse:	See Sorting the output.

-separate-dirs:	See du invocation.

-silent <1>:	See chown invocation.

-silent <1>:	See chgrp invocation.

-silent:	See chmod invocation.

-size:	See What information is listed.

-sort:	See Sorting the output.

-strip:	See install invocation.

-suffix <1>:	See ln invocation.

-suffix <1>:	See cp invocation.

-suffix <1>:	See Backup options.

-suffix:	See mv invocation.

-summarize:	See du invocation.

-symbolic:	See ln invocation.

-symbolic-link:	See cp invocation.

-sync:	See df invocation.

-tabsize:	See General output formatting.

-time <1>:	See Sorting the output.

-time:	See touch invocation.

-total:	See du invocation.

-type:	See df invocation.

-update <1>:	See cp invocation.

-update:	See mv invocation.

-verbose <1>:	See mv invocation.

-verbose <1>:	See chown invocation.

-verbose <1>:	See chmod invocation.

-verbose <1>:	See rm invocation.

-verbose <1>:	See chgrp invocation.

-verbose <1>:	See ln invocation.

-verbose:	See cp invocation.

-version:	See Common options.

-version-control <1>:	See cp invocation.

-version-control <1>:	See Backup options.

-version-control <1>:	See ln invocation.

-version-control:	See mv invocation.

-width:	See General output formatting.

-1:	See General output formatting.

-a <1>:	See Which files are listed.

-a <1>:	See touch invocation.

-a <1>:	See du invocation.

-a <1>:	See cp invocation.

-a:	See df invocation.

-B:	See Which files are listed.

-b <1>:	See Formatting the filenames.

-b <1>:	See ln invocation.

-b <1>:	See Backup options.

-b <1>:	See cp invocation.

-b <1>:	See du invocation.

-b:	See mv invocation.

-c <1>:	See chgrp invocation.

-c <1>:	See du invocation.

-c <1>:	See touch invocation.

-c <1>:	See install invocation.

-c <1>:	See chmod invocation.

-c <1>:	See chown invocation.

-c:	See Sorting the output.

-C:	See General output formatting.

-d <1>:	See ln invocation.

-d:	See touch invocation.

-D:	See du invocation.

-d <1>:	See Which files are listed.

-d:	See cp invocation.

-D:	See What information is listed.

-d <1>:	See install invocation.

-d:	See rm invocation.

-f <1>:	See chgrp invocation.

-f <1>:	See ln invocation.

-f <1>:	See cp invocation.

-f <1>:	See mv invocation.

-f <1>:	See chmod invocation.

-f <1>:	See rm invocation.

-f:	See Sorting the output.

-F:	See ln invocation.

-f:	See chown invocation.

-F:	See General output formatting.

-g:	See install invocation.

-G:	See What information is listed.

-g:	See ls invocation.

-i:	See cp invocation.

-I:	See Which files are listed.

-i <1>:	See mv invocation.

-i <1>:	See rm invocation.

-i <1>:	See ln invocation.

-i <1>:	See What information is listed.

-i:	See df invocation.

-k <1>:	See General output formatting.

-k <1>:	See du invocation.

-k:	See df invocation.

-L <1>:	See Which files are listed.

-L:	See du invocation.

-l <1>:	See cp invocation.

-l <1>:	See du invocation.

-l:	See What information is listed.

-m <1>:	See mkfifo invocation.

-m <1>:	See General output formatting.

-m <1>:	See touch invocation.

-m <1>:	See mkdir invocation.

-m <1>:	See mknod invocation.

-m:	See install invocation.

-n:	See General output formatting.

-N:	See Formatting the filenames.

-n:	See ln invocation.

-o:	See install invocation.

-p <1>:	See mkdir invocation.

-p:	See rmdir invocation.

-P:	See df invocation.

-p:	See cp invocation.

-Q:	See Formatting the filenames.

-r <1>:	See Sorting the output.

-r <1>:	See touch invocation.

-r:	See rm invocation.

-R <1>:	See cp invocation.

-R <1>:	See chgrp invocation.

-R <1>:	See rm invocation.

-R <1>:	See Which files are listed.

-R <1>:	See chown invocation.

-R:	See chmod invocation.

-s:	See cp invocation.

-S <1>:	See ln invocation.

-S <1>:	See Sorting the output.

-S:	See Backup options.

-s <1>:	See What information is listed.

-s:	See du invocation.

-S <1>:	See cp invocation.

-S <1>:	See du invocation.

-S:	See mv invocation.

-s <1>:	See ln invocation.

-s:	See install invocation.

-T <1>:	See General output formatting.

-T:	See df invocation.

-t:	See Sorting the output.

-u:	See cp invocation.

-U:	See Sorting the output.

-u <1>:	See mv invocation.

-u:	See Sorting the output.

-v:	See rm invocation.

-V <1>:	See cp invocation.

-V:	See ln invocation.

-v:	See cp invocation.

-V:	See Backup options.

-v <1>:	See chgrp invocation.

-v <1>:	See ln invocation.

-v <1>:	See chown invocation.

-v:	See chmod invocation.

-V:	See mv invocation.

-w:	See General output formatting.

-x <1>:	See df invocation.

-x <1>:	See du invocation.

-x <1>:	See General output formatting.

-x:	See cp invocation.

-X:	See Sorting the output.

.2 filesystem type:	See df invocation.

-, removing files beginning with:	See rm invocation.

access time, changing:	See touch invocation.

access permissions, changing:	See chmod invocation.

access time, sorting files by:	See Sorting the output.

across, listing files:	See General output formatting.

adding permissions:	See Setting Permissions.

alternate ebcdic, converting to:	See dd invocation.

append-only directories:	See Mode Structure.

appropriate privileges:	See install invocation.

ascii, converting to:	See dd invocation.

atime, changing:	See touch invocation.

atime, sorting files by:	See Sorting the output.

attributes, file:	See Changing file attributes.

automounter filesystems:	See df invocation.

b for block special file:	See mknod invocation.

backslash sequences for filenames:	See Formatting the filenames.

backup files, ignoring:	See Which files are listed.

backup files, type made:	See Backup options.

backup options:	See Backup options.

backup suffix:	See Backup options.

backups, making <1>:	See Backup options.

backups, making <1>:	See mv invocation.

backups, making <1>:	See ln invocation.

backups, making:	See cp invocation.

block (space-padding):	See dd invocation.

block size:	See dd invocation.

block size of conversion:	See dd invocation.

block size of input:	See dd invocation.

block size of output:	See dd invocation.

block special files:	See mknod invocation.

block special files, creating:	See mknod invocation.

bs:	See dd invocation.

buffered character file:	See mknod invocation.

bugs, reporting:	See Introduction.

byte-swapping:	See dd invocation.

c for character special file:	See mknod invocation.

cbs:	See dd invocation.

CD-ROM filesystem type:	See df invocation.

cdfs filesystem type:	See df invocation.

changed files, verbosely describing:	See chgrp invocation.

changed owners, verbosely describing:	See chown invocation.

changing access permissions:	See chmod invocation.

changing file attributes:	See Changing file attributes.

changing file ownership:	See chown invocation.

changing file timestamps:	See touch invocation.

changing group ownership <1>:	See chown invocation.

changing group ownership:	See chgrp invocation.

changing special permissions:	See Changing Special Permissions.

character special files:	See mknod invocation.

character special files, creating:	See mknod invocation.

chgrp:	See chgrp invocation.

chmod:	See chmod invocation.

chown:	See chown invocation.

COLUMNS:	See General output formatting.

commas, outputting between files:	See General output formatting.

common options:	See Common options.

conditional executability:	See Conditional Executability.

conv:	See dd invocation.

converstion block size:	See dd invocation.

converting while copying a file:	See dd invocation.

copying directories recursively:	See cp invocation.

copying existing permissions:	See Copying Permissions.

copying files and directories:	See cp invocation.

copying files and setting attributes:	See install invocation.

count:	See dd invocation.

cp:	See cp invocation.

crashes and corruption:	See sync invocation.

creating directories:	See mkdir invocation.

creating FIFOs (named pipes):	See mkfifo invocation.

creating links (hard or soft):	See ln invocation.

ctime, sorting by:	See Sorting the output.

dd:	See dd invocation.

dereferencing symbolic links:	See ln invocation.

device file, disk:	See df invocation.

df:	See df invocation.

dir:	See dir invocation.

directories, copying:	See cp invocation.

directories, copying recursively:	See cp invocation.

directories, creating:	See mkdir invocation.

directories, creating with given attributes:	See install invocation.

directories, removing (recursively):	See rm invocation.

directories, removing empty:	See rmdir invocation.

directories, removing with unlink:	See rm invocation.

directory listing:	See ls invocation.

directory listing, brief:	See dir invocation.

directory listing, recursive:	See Which files are listed.

directory listing, verbose:	See vdir invocation.

dired Emacs mode support:	See What information is listed.

disk device file:	See df invocation.

disk usage:	See Disk usage.

disk usage by filesystem:	See df invocation.

disk usage for files:	See du invocation.

diskette filesystem:	See df invocation.

DOS filesystem:	See df invocation.

du:	See du invocation.

ebcdic, converting to:	See dd invocation.

efs filesystem type:	See df invocation.

empty files, creating:	See touch invocation.

error messages, omitting <1>:	See chgrp invocation.

error messages, omitting <1>:	See chown invocation.

error messages, omitting:	See chmod invocation.

executables and file type, marking:	See General output formatting.

execute permission:	See Mode Structure.

execute permission, symbolic:	See Setting Permissions.

existing backup method:	See Backup options.

extension, sorting files by:	See Sorting the output.

FIFOs, creating:	See mkfifo invocation.

file attributes, changing:	See Changing file attributes.

file information, preserving:	See cp invocation.

file ownership, changing:	See chown invocation.

file permissions:	See File permissions.

file permissions, numeric:	See Numeric Modes.

file space usage:	See du invocation.

file timestamps, changing:	See touch invocation.

file type and executables, marking:	See General output formatting.

file type, marking:	See General output formatting.

file types:	See Special file types.

file types, special:	See Special file types.

file utilities:	See Top.

files beginning with -, removing:	See rm invocation.

files, copying:	See cp invocation.

filesystem disk usage:	See df invocation.

filesystem space, retrieving current data more slowly:	See df invocation.

filesystem space, retrieving old data more quickly:	See df invocation.

filesystem types, limiting output to certain:	See df invocation.

filesystem types, printing:	See df invocation.

filesystems and hard links:	See ln invocation.

filesystems, omitting copying to different:	See cp invocation.

fsck:	See rm invocation.

giving away permissions:	See Umask and Protection.

grand total of disk space:	See du invocation.

group owner, default:	See Mode Structure.

group ownership of installed files, setting:	See install invocation.

group ownership, changing:	See chgrp invocation.

group ownerships, changing:	See chown invocation.

group, permissions for:	See Setting Permissions.

hard links to directories:	See ln invocation.

hard links, creating:	See ln invocation.

hard links, preserving:	See cp invocation.

help, online:	See Common options.

High Sierra filesystem:	See df invocation.

history:	See Introduction.

holes, copying:	See cp invocation.

horizontal, listing files:	See General output formatting.

hsfs filesystem type:	See df invocation.

ibs:	See dd invocation.

if:	See dd invocation.

ignore filesystems:	See df invocation.

inode number, printing:	See What information is listed.

inode usage:	See df invocation.

inodes, written buffered:	See sync invocation.

input block size:	See dd invocation.

install:	See install invocation.

introduction:	See Introduction.

lcase, converting to:	See dd invocation.

leading directories, creating missing:	See install invocation.

links, creating:	See ln invocation.

Linux filesystem types:	See df invocation.

ln:	See ln invocation.

local filesystem types:	See df invocation.

long ls format:	See What information is listed.

ls:	See ls invocation.

Makefiles, installing programs in:	See install invocation.

manipulating files:	See Basic operations.

mkdir:	See mkdir invocation.

mkfifo:	See mkfifo invocation.

mknod:	See mknod invocation.

modes and umask:	See Umask and Protection.

modes of created directories, setting:	See mkdir invocation.

modes of created FIFOs, setting:	See mkfifo invocation.

modification time, sorting files by:	See Sorting the output.

modify time, changing:	See touch invocation.

MS-DOS filesystem:	See df invocation.

mtime, changing:	See touch invocation.

multiple changes to permissions:	See Multiple Changes.

multipliers after numbers:	See dd invocation.

mv:	See mv invocation.

named pipes, creating:	See mkfifo invocation.

newer files, copying only:	See cp invocation.

newer files, moving only:	See mv invocation.

NFS filesystem type:	See df invocation.

NFS mounts from BSD to HP-UX <1>:	See What information is listed.

NFS mounts from BSD to HP-UX:	See du invocation.

noerror:	See dd invocation.

non-directories, copying as special files:	See cp invocation.

none, sorting option for ls:	See Sorting the output.

notrunc:	See dd invocation.

numbered backup method:	See Backup options.

numeric modes:	See Numeric Modes.

numeric uid and gid:	See General output formatting.

obs:	See dd invocation.

octal numbers for file modes:	See Numeric Modes.

of:	See dd invocation.

one filesystem, restricting du to:	See du invocation.

one-line output format:	See df invocation.

other permissions:	See Setting Permissions.

output block size:	See dd invocation.

output format, portable:	See df invocation.

owner of file, permissions for:	See Setting Permissions.

owner, default:	See Mode Structure.

ownership of installed files, setting:	See install invocation.

p for FIFO file:	See mknod invocation.

parent directories and cp:	See cp invocation.

parent directories, creating:	See mkdir invocation.

parent directories, creating missing:	See install invocation.

parent directories, removing:	See rmdir invocation.

PC filesystem:	See df invocation.

pcfs:	See df invocation.

permissions of files:	See File permissions.

permissions of installed files, setting:	See install invocation.

permissions, changing access:	See chmod invocation.

permissions, copying existing:	See Copying Permissions.

permissions, for changing file timestamps:	See touch invocation.

portable output format:	See df invocation.

POSIX output format:	See df invocation.

POSIX.2:	See Introduction.

POSIXLY_CORRECT:	See df invocation.

POSIXLY_CORRECT, overridden by df -k:	See df invocation.

POSIXLY_CORRECT, overridden by du -k:	See du invocation.

POSIXLY_CORRECT, overridden by ls -k:	See General output formatting.

POSIXLY_CORRECT, overrides ls -s:	See What information is listed.

prompting, and ln:	See ln invocation.

prompting, and mv:	See mv invocation.

prompting, and rm:	See rm invocation.

prompts, forcing:	See mv invocation.

prompts, omitting:	See mv invocation.

read system call, and holes:	See cp invocation.

read errors, ignoring:	See dd invocation.

read permission:	See Mode Structure.

read permission, symbolic:	See Setting Permissions.

recursive directory listing:	See Which files are listed.

recursively changing access permissions:	See chmod invocation.

recursively changing file ownership:	See chown invocation.

recursively changing group ownership:	See chgrp invocation.

recursively copying directories:	See cp invocation.

removing empty directories:	See rmdir invocation.

removing files or directories:	See rm invocation.

removing permissions:	See Setting Permissions.

reverse sorting:	See Sorting the output.

rm:	See rm invocation.

rmdir:	See rmdir invocation.

root as default owner:	See install invocation.

seek:	See dd invocation.

setgid:	See Mode Structure.

setting permissions:	See Setting Permissions.

setuid:	See Mode Structure.

simple backup method:	See Backup options.

SIMPLE_BACKUP_SUFFIX:	See Backup options.

single-column output of files:	See General output formatting.

size of files, reporting:	See What information is listed.

size of files, sorting files by:	See Sorting the output.

skip:	See dd invocation.

sorting ls output:	See Sorting the output.

special file types:	See Special file types.

special files:	See mknod invocation.

status time, sorting by:	See Sorting the output.

sticky:	See Mode Structure.

stripping symbol table information:	See install invocation.

subtracting permissions:	See Setting Permissions.

superblock, writing:	See sync invocation.

swab (byte-swapping):	See dd invocation.

swap space, saving text image in:	See Mode Structure.

symbol table information, stripping:	See install invocation.

symbolic (soft) links, creating:	See ln invocation.

symbolic links, copying:	See cp invocation.

symbolic links, copying with:	See cp invocation.

symbolic links, dereferencing:	See Which files are listed.

symbolic links, permissions of:	See chmod invocation.

symbolic modes:	See Symbolic Modes.

sync:	See sync invocation.

sync (padding with nulls):	See dd invocation.

synchronize disk and memory:	See sync invocation.

text image, saving in swap space:	See Mode Structure.

time:	See touch invocation.

timestamps, changing file:	See touch invocation.

touch:	See touch invocation.

truncating output file, avoiding:	See dd invocation.

u for unbuffered character special file:	See mknod invocation.

ucase, converting to:	See dd invocation.

ufs filesystem type:	See df invocation.

umask and modes:	See Umask and Protection.

unblock:	See dd invocation.

unbuffered character special file:	See mknod invocation.

unlink:	See rm invocation.

use time, changing:	See touch invocation.

use time, sorting files by:	See Sorting the output.

utilities for file handling:	See Top.

vdir:	See vdir invocation.

verbose ls format:	See What information is listed.

version number, finding:	See Common options.

version-control Emacs variable:	See Backup options.

VERSION_CONTROL:	See Backup options.

vertical sorted files in columns:	See General output formatting.

write permission:	See Mode Structure.

write permission, symbolic:	See Setting Permissions.