-->
Previous Table of Contents Next


EXAMPLE USING NUMERIC FORM


$ chmod 764 pat.memo

This command line combines chmod with a mode of 744, applied to the file pat.memo. This means that the owner can read, write, and execute the file (that’s what the 7 designates), the group can read the file and write to it, but not execute it, and the world can read the file but not execute it or write to it.

How do we arrive at 764? Because we add up the numerical value of modes, which we’ll cover in the next sections. A mode number can range between 000 and 777; 000 means that no one has any access to a file, while 777 means that everyone has full access to a file. Here’s the exact math used to arrive at 764:

400 Owner has read permission.
200 Owner has write permission.
100 Owner has execute permission.
040 Group has read permission.
020 Group has write permission.
004 World has read permission.
764 (Total)

Using the ls command on the file in question, you’d see that it has the following permissions:


     rwxrw-r--

MODES

The mode is a combination of the following:

400 Owner has read permission.
200 Owner has write permission.
100 Owner has execute permission.
040 Group has read permission.
020 Group has write permission.
010 Group has execute permission.
004 World has read permission.
002 World has write permission.
001 World has execute permission.

OPTIONS

-c Prints information about the changes made.
-f Ignores information about files that can’t be changed.
-v Verbose mode, where changes and failed changes are listed.
-R Recursive mode, which means that subdirectories are also changed.

FOUR-DIGIT MODES

Occasionally there will be four-digit modes. In these cases, the extra digit is actually at the beginning of the mode and adds the following permissions:

4 Sets user ID upon execution.
2 Sets group ID upon execution.
1 Sets the sticky bit.

RELATED COMMANDS

chgrp
chown

chown......Change Owner

chown option(s) newowner file(s)

PURPOSE

The chown command changes the ownership of a file or directory. The new owner is either a username (one of which stored in /etc/passwd) or a user ID number. You must be the owner of this file or a privileged user (i.e., root user) to change the ownership.

OPTIONS

-c Prints information about the changes made.
-f Ignores information about files that can’t be changed.
-v Verbose mode, where changes and failed changes are listed.
-R Recursive mode, which means that subdirectories are also changed.

EXAMPLE


$ chown kevin report

This changes the ownership of report to the user kevin.

RELATED COMMANDS

chmod
chgrp

chroot......Change Root Directory

chroot path

PURPOSE

The chroot directory changes the root directory of a Linux system to that specified in path. Only the root user may change the root directory.

cp......Copy Files

cp option(s) file1 file2

cp option(s) file1 directory

cp option(s) directory1 directory2

PURPOSE

The cp command copies files—the contents of one file into another file, the contents of a file into a new directory, or from one directory to another. The existing file isn’t changed.

OPTIONS

-a Retains archival attributes.
-b Creates a backup instead of overwriting an existing file.
-d Maintains symbolic links between files.
-f Forces copying.
-i Turns on interactive mode, where you are prompted before existing files are overwritten.
-l Creates hard links between files copied to directories, instead of actually copying the files.
-p Preserves existing permissions, including the ownership and time stamp.
-r Copies entire directory and any subdirectories.
-R Copies entire directory and any subdirectories.
-s Creates symbolic links between files copied to directories, instead of actually copying the files.
-S Sets a suffix to all new files; the default is ~ and stored in the SIMPLE_BACKUP_SUFFIX environment variable. Don’t change this variable, since other applications (notably emacs) also use it.
-u Doesn’t copy to new files that are newer than the existing file.
-v Turns on verbose mode, where all transactions are printed to screen.
-V Uses the version-control numbering set with the VERSION_CONTROL environment variable.
-x Ignores subdirectories on remote filesystems when copying.

EXAMPLES


$ cp pat.letter pat.old

This copies the file pat.letter into a new file called pat.old.


$ cp kevin.letter /home/Kevin/kevin.letter

This copies the file kevin.letter, contained in the current directory, to the file kevin.letter, stored in the /home/Kevin directory.


$ cp -r /home/Kevin /home/Kevin/letters

This copies the entire contents of /home/Kevin into the directory /home/Kevin/letters.


Previous Table of Contents Next