[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A file is not merely its contents, a name, and a file type (see section 12. Special file types). A file also has 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 these a file's attributes.
These commands change file attributes.
13.2 chgrp
: Change group ownershipChange file groups. 13.3 chmod
: Change access permissionsChange access permissions. 13.1 chown
: Change file owner and groupChange file owners and groups. 13.4 touch
: Change file timestampsChange file timestamps.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
chown
: Change file owner and group
chown
changes the user and/or group ownership of each given file
to new-owner or to the user and group of an existing reference file.
Synopsis:
chown [option]... {new-owner | --reference=ref_file} file... |
If used, new-owner specifies the new owner and/or group as follows (with no embedded white space):
[owner] [ [:] [group] ] |
Specifically:
chown
performs the same function as chgrp
.
You may use `.' in place of the `:' separator. This is a
GNU extension for compatibility with older scripts.
New scripts should avoid the use of `.' because GNU chown
may fail if owner contains `.' characters.
The program accepts the following options. Also see 2. Common options.
root
might run
find / -owner OLDUSER -print0 | xargs -0 chown NEWUSER |
But that is dangerous because the interval between when the find
tests the existing file's owner and when the chown
is actually run
may be quite large.
One way to narrow the gap would be to invoke chown for each file
as it is found:
find / -owner OLDUSER -exec chown NEWUSER {} \; |
But that is very slow if there are many affected files. With this option, it is safer (the gap is narrower still) though still not perfect:
chown -R --from=OLDUSER NEWUSER / |
lchown
system call.
On systems that do not provide the lchown
system call,
chown
fails when a file specified on the command line
is a symbolic link.
By default, no diagnostic is issued for symbolic links encountered
during a recursive traversal, but see `--verbose'.
lchown
system call, and `--no-dereference'
is in effect, then issue a diagnostic saying neither the symbolic link nor
its referent is being changed.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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)
or to the group of an existing reference file. Synopsis:
chgrp [option]... {group | --reference=ref_file} file... |
The program accepts the following options. Also see 2. Common options.
lchown
system call.
On systems that do not provide the lchown
system call,
chgrp
fails when a file specified on the command line
is a symbolic link.
By default, no diagnostic is issued for symbolic links encountered
during a recursive traversal, but see `--verbose'.
lchown
system call, and `--no-dereference'
is in effect, then issue a diagnostic saying neither the symbolic link nor
its referent is being changed.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
chmod
: Change access permissions
chmod
changes the access permissions of the named files. Synopsis:
chmod [option]... {mode | --reference=ref_file} 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.
If used, mode specifies the new permissions. For details, see the section on 26. File permissions.
The program accepts the following options. Also see 2. Common options.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
touch
: Change file timestamps
touch
changes the access and/or modification times of the
specified files. Synopsis:
touch [option]... file... |
On older systems, touch
supports an obsolete syntax, as follows.
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 file name. POSIX 1003.1-2001 (see section 2.5 Standards conformance)
does not allow this; use `-t' instead.
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.
Although touch
provides options for changing two of the times --
the times of last access and modification -- of a file, there is actually
a third one as well: the inode change time. This is often referred to
as a file's ctime
.
The inode change time represents the time when the file's meta-information
last changed. One common example of this is when the permissions of a
file change. Changing the permissions doesn't access the file, so
the atime doesn't change, nor does it modify the file, so the mtime
doesn't change. Yet, something about the file itself has changed,
and this must be noted somewhere. This is the job of the ctime field.
This is necessary, so that, for example, a backup program can make a
fresh copy of the file, including the new permissions value.
Another operation that modifies a file's ctime without affecting
the others is renaming. In any case, it is not possible, in normal
operations, for a user to change the ctime field to a user-specified value.
The program accepts the following options. Also see 2. Common options.
touch
.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |