UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 22.3 Who Will Own a New File? Chapter 22
File Security, Ownership, and Sharing
Next: 22.5 Group Permissions in a Directory with the setgid Bit
 

22.4 Setting an Exact umask

You can use the umask command to set the default mode for newly created files. Its argument is a three-digit numeric mode that represents the access to be inhibited - masked out - when a file is created. Thus, the value it wants is the octal complement of the numeric file mode you want. To determine this, you simply figure out the numeric equivalent (1.23) for the file mode you want and then subtract it from 777. For example, to get the mode 751 by default, compute 777-751 = 026; this is the value you give to umask:

% umask 026

Once this command is executed, all future files created will be given this protection automatically. System administrators can put a umask command in the system initialization file to set a default for all users. You can set your own umask in your shell setup files (2.1). Article 22.2 has more information about the umask and two aliases for changing yours.

- AF from O'Reilly & Associates' Essential System Administration, Chapter 2


Previous: 22.3 Who Will Own a New File? UNIX Power ToolsNext: 22.5 Group Permissions in a Directory with the setgid Bit
22.3 Who Will Own a New File? Book Index22.5 Group Permissions in a Directory with the setgid Bit

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System