Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at the umask command. You can use it to set the default permissions for files that you create.
One of the most important things to keep in mind is that umask is a mask. That word implies that the settings are in some ways the opposite of what they might seem. Set your umask to 777, for example, and newly created files will be given 000 -- in other words, no read, write or execute permissions for anyone.
The other thing to remember is that execute permissions are never set by default, no matter what umask settings are in force. Set your umask to 000 and your files will be set up with 666. Not 777.
If you want files to be executable, you have to use the chmod command to make them so.
Changes to umask will not affect existing files and a umask setting will be in effect even if you never use the command. If you simply log into your account and type umask, you’ll see the current setting.
The first digit shown has no effect and is probably displayed only because of the relationship between umask and the chmod command which uses that position to set something referred to as the “sticky bit”.
That’s your Linux tip for umask.
If you have questions or would like to suggest a topic, please add a comment below. And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.