Home Page The Club Computers News Links Glossary EYAWTK
Before Amiga Background ICS OCS ECS AGA ??? PPC
U-Boot SLB Linux Amiga OS Dual Boot Motherboards Peripherals Other
Initialisation Installation OS4 Updates About OS4 File Systems Networking Printing Other
Introduction File System Workbench Preferences Commands Error Msgs Miscellaneous

AmigaOS 4.0 - About OS4 - Commands

PROTECT AmigaDOS
Purpose: Changes the protection bit of files and directories.
Format: PROTECT [FILE] <name | pattern> [FLAGS] [+ | -] [<flags>] [ADD | SUB] [ALL] [QUIET] [USER] [GROUP] [OTHER] [CLONE] [CLEAR] [FILES] [DIRS]
Template: FILE/A, FLAGS, ADD/S, SUB/S, ALL/S, QUIET/S, USER/S, GROUP/S, OTHER/S, CLONE/S, CLEAR/S, FILES/S, DIRS/S
Path: C:PROTECT
All files and directories have a series of protection bits (attributes) stored with them that control their properties. These bits can be altered to indicate the type of file and the operations permitted. PROTECT is used to set or clear the protection bits. For directories, only the 'd' bit is significant.

The protection bits are represented by letters:

r The file can be read.
w The file can be written to (altered).
e Turns off burst mode for both data and instructions.
d The file or directory can be deleted.
(Files within a delete-protected directory can still be deleted.)
s The file is a script.
p The file is a pure command and can be made resident.
a The file has been archived.
h The command file should be held resident in memory after it has been used (requires that the 'p' bit is set, too).
And just to add to the confusion, there are actually 3 sets of these bits; one set for the 'user' (or owner) of the file, one set for 'group' rights, and another set for 'other' rights. This means that if a user is the owner of a file, the 'user' set applies, and if you are not the owner but a member of the specified group the 'group' set applies, while the 'other' set applies if you fail the other criteria.

Use the LIST command to see the protection bits associated with a file. The protection field is displayed with set (on) bits shown by their letters and clear (off) bits shown by hyphens. For example, a file that is readable, writable and deletable has '– – – – r w – d' in the protection field.

To specify the entire protection field at the same time, enter the letters of the bits you want set as the FLAGS argument without any other keywords. The named bits will be set and all others will be cleared.

The symbols + and (or the eqivalent keywords ADD and SUB are used to control specific bits without affecting the state of the unspecified bits. Follow + or with the letter(s) of the bit(s) to set or clear, respectively, and only those bits are changed. There is no space after the symbol or between the letters. The order of the letters does not matter. ADD and SUB work similarly, but there must be a space between the keyword and the letter(s). You cannot both set and clear bits in the same command. If you unset the readable bit, it will automatically unset the execution bit if it is set, and a warning message is displayed.

The ALL option adds or removes the specified protection bits from all the files and subdirectories matching the pattern entered.

The QUIET option suppresses the screen output. The local shell variable _Verbosity with a negative value has the same effect.

The USER option causes only the 'user' protection bits to be modified. This is the default.

The GROUP option causes only the 'group' protection bits to be modified.

The OTHER option causes only the 'other' protection bits to be modified.

The CLONE option is used when you want to change the 'group' and/or 'other' protection bits to the same value as the 'user' protection bits. Requires at least one of the USER and GROUP options, and no protection bits specified.

The CLEAR option clears all protection bits for the file.

The FILES options says to only change the protection bits of the files found, NOT directories.

The DIRS options says to only change the protection bits of the directories found, NOT files.

Example 1:

3.OS4:> PROTECT Work:Memo +rw sets only the protection bits r (readable) and w (writable) of the file Memo on drive Work:. No other protection bits are changed.

Example 2:

3.OS4:> PROTECT L:#? e SUB clears the e (executable) protection bit from all files in the L: directory.

Example 3:

3.OS4:> PROTECT Work:Paint rwed sets the protection bits of file Paint on drive Work: to '– – – – r w e d'.

Example 4:

3.OS4:> PROTECT Work:Write CLONE GROUP OTHER the 'group' and 'other' protection bits of file Write are made the same as the 'user' protection bits.

Example 5:

3.OS4:> PROTECT Work:Save CLEAR clears all the protection bits of file Save.

See Also: LIST


Return to Commands Selection

Disclaimer: Amiga Auckland have prepared the above information for the use of its members based on our experiences and as such is subject to revision at any time. Amiga Auckland cannot guarantee any of the information and cannot be held accountable for any issues that may result from using it.


Copyright 2006 Amiga Auckland Inc. All rights reserved.
Revised: February 9, 2006.