LiveFire Labs - Online UNIX Training - Company Logo


Online UNIX Training with Hands-on Internet Lab


"Eliminate the expense and inconvenience of classroom training without eliminating the classroom experience."

 


Home
Internet Lab
Console Access
Sample Course

Student Login


LiveFire Labs' UNIX Tip, Trick, or Shell Script of the Week - View


Questions? Call
1.888.843.1637 or send us email





August 18, 2003 - File Access Modes (Permissions) and umask

The umask command is used to set the file creation mask.  To put it another way, it controls what permissions will be granted to a newly created file or directory.

The syntax for the command is:

#umask mask
where mask is a three digit octal number, similar to the one used with the chmod command to set file permissions.  The first digit sets the mask for user, the second for group, and the third for other users.  Using umask without specifying a mask will display the current setting.

The value of mask represents what permissions will be revoked from the default file and directory permissions.  The default permissions for a file are rw-rw-rw- (or 666), and rwxrwxrwx (or 777) for a directory.

If the mask is set to 022, the write permission for group and other users will be revoked from the default permission settings:

# touch unixfile1
# ls -l unixfile1
-rw-rw-rw-   1   root   other      0   Aug 16 15:14 unixfile1
# umask 022
# touch unixfile2
# ls -l unixfile2
-rw-r--r--   1   root   other      0   Aug 16 15:15 unixfile2

Notice that the write permission for user was not changed because the first digit of the mask is 0.

The setting for umask is typically defined in the system startup file, but can be set to the value you desire by adding the umask command to your .profile.



Learn more...
  

If you are new to the UNIX or Linux operating system and would like to learn more, you may want to consider registering for LiveFire Labs' UNIX and Linux Operating System Fundamentals online training course.

If you already have a solid grasp of the fundamentals but would like to learn more about the Korn shell and basic and advanced shell scripting, taking our Korn Shell Scripting course will be beneficial to you.

Our innovative hands-on training model allows you to learn UNIX by completing hands-on exercises on real servers in our Internet Lab.


More Tips...

· 
Popular UNIX Tips from the Past

spacer Box Border
 

Receive the UNIX Tip, Trick, or Shell Script of the Week by Email


First Name:


Email Address:






   1.888.843.1637

Home - Contact us - Company info - Privacy Statement   

 
©2002-2003 LiveFire Labs.  All rights reserved.
Linux® is a registered trademark of Linus Torvalds, author and developer of this public domain operating system.
UNIX® is a registered trademark of The Open Group in the United States and other countries.